metarknn
metarknn部署通用框架
1、安装最新版 meta-cv
pip install meta-cv
2、安装最新版 meta-rknn
pip install meta-rknn
3、图像分类示例(参考classification_demo.py代码)
import cv2, platform
import metarknn as m
Classification = m.Classification
y = Classification(model_path='models/mixnet_xl_bs24_2.rknn',
input_width=224,
input_height=224,
use_preprocess=True,
class_names=classnames,
device_id=0)
batch_size = 24
img = cv2.imread('models/bottle.jpg')
img_list = [img[:, :, ::-1]] * batch_size if batch_size > 1 else img[:, :, ::-1]
_dets, _scores, _labels = y.predict(img_list)
# 显示
y.show(img, _dets, _scores, _labels)
cv2.imwrite("models/bottle.png", img)
4、目标检测示例(参考detection_demo.py代码)
import cv2, platform
import metarknn as m
Detection = m.Detection
y = Detection(model_path='models/yolov8m.rknn',
input_width=640,
input_height=480,
use_preprocess=True,
pad=True,
confidence_thresh=0.5,
nms_thresh=0.3,
class_names=classnames,
device_id=0)
batch_size = 1
img = cv2.imread('models/bus.jpg')
img_list = [img[:, :, ::-1]] * batch_size if batch_size > 1 else img[:, :, ::-1]
_dets, _scores, _labels = y.predict(img_list)
# 显示
y.show(img, _dets[-1], _scores[-1], _labels[-1])
cv2.imwrite("models/bus.png", img)
5、实例分割示例(参考segment_demo.py代码)
import platform, cv2
import metarknn as m
Segment = m.Segment
y = Segment(model_path='models/yolov8m-seg.rknn',
input_width=640,
input_height=480,
use_preprocess=True,
pad=True,
confidence_thresh=0.5,
nms_thresh=0.3,
class_names=classnames,
device_id=0)
batch_size = 1
img = cv2.imread('models/bus.jpg')
img_list = [img[:, :, ::-1]] * batch_size if batch_size > 1 else img[:, :, ::-1]
_dets, _scores, _labels = y.predict(img_list)
# 显示
y.show(img, _dets[-1], _scores[-1], _labels[-1])
cv2.imwrite("models/bus.png", img)
6、模型转换与量化(本地运行)
import metarknn as m
Quantization = m.Quantization
q = Quantization(model_path, # onnx模型路径
dataset, # dataset文件路径
mean=[[0, 0, 0]],
std=[[255, 255, 255]],
batch_size=1) # 定义模型输出层
if is_hybrid: # 是否混合量化
self.model = q.hybrid_convert()
else: # 非混合量化(是否int8量化)
self.model = q.convert(quantize)
Metadata
Release files for meta-rknn 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| meta-rknn-0.1.2.tar.gz | 5.0 kB | Without provenance | Details for meta-rknn-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| meta_rknn-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for meta_rknn-0.1.2-py3-none-any.whl |
Total release size: 17.4 kB
Release files / meta-rknn-0.1.2.tar.gz
| Download URL | meta-rknn-0.1.2.tar.gz |
|---|---|
| Size | 5.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a6faa35db68aa03ca6ccf54d92acdcdd15d617da3d30156a5c9e88471619eedf
|
|
BLAKE2b-256 checksum How to use checksums |
dded4e90edf558769ea2508f0796b3ad245f3230f4128ce372373e45c8b896d0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.9.6 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/1.0.0 urllib3/1.26.15 tqdm/4.64.0 importlib-metadata/4.2.0 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.5 CPython/3.6.13
|
Release files / meta_rknn-0.1.2-py3-none-any.whl
| Download URL | meta_rknn-0.1.2-py3-none-any.whl |
|---|---|
| Size | 12.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6b193671d151aa52f88b468cc7afcacd3d743ee88144a63a350d708f4ec0c0d2
|
|
BLAKE2b-256 checksum How to use checksums |
4e4ff8fb0787ad05466c0580929a3e5953dd70eec014d66dda4caa091c939146
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.9.6 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/1.0.0 urllib3/1.26.15 tqdm/4.64.0 importlib-metadata/4.2.0 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.5 CPython/3.6.13
|
Security for meta-rknn 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.