Skip to main content

Meta Onnx Toolkit

Project description

metaonnx

metaonnx部署通用框架

1、安装最新版 meta-cv

pip install meta-cv

2、安装最新版 meta-onnx

pip install meta-onnx

3、图像分类示例(参考classification_demo.py代码)

import cv2, platform
import metaonnx as m

Classification = m.Classification

y = Classification(model_path='models/mixnet_xl_bs24_4.onnx',
                   input_width=224,
                   input_height=224,
                   use_preprocess=True,
                   normal=True,
                   mean=[0.485, 0.456, 0.406],
                   std=[0.229, 0.224, 0.225],
                   swap=(2, 0, 1),
                   class_names=classnames)

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 platform, cv2
import metaonnx as m

Detection = mo.Detection

y = Detection(model_path='models/yolov8m.onnx',
              input_width=640,
              input_height=480,
              use_preprocess=True,
              pad=True,
              normal=True,
              swap=(2, 0, 1),
              confidence_thresh=0.5,
              nms_thresh=0.3,
              class_names=classnames)

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 cv2
import metaonnx as m

Segment = mo.Segment

y = Segment(model_path='models/yolov8m-seg.onnx',
            input_width=640,
            input_height=480,
            use_preprocess=True,
            pad=True,
            normal=True,
            swap=(2, 0, 1),
            confidence_thresh=0.5,
            nms_thresh=0.3,
            class_names=classnames)

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、人脸检测示例(参考face_detection_demo.py代码)

import cv2
import metaonnx as m

FaceDetection = m.FaceDetection

y = FaceDetection(model_path='models/face_detection.onnx',
                  input_width=480,
                  input_height=640,
                  use_preprocess=True,
                  pad=True,
                  normal=True,
                  mean=[0.485, 0.456, 0.406],
                  std=[0.229, 0.224, 0.225],
                  swap=(2, 0, 1),
                  confidence_thresh=0.5,
                  nms_thresh=0.4,
                  class_names=['face'])

batch_size = 1
img = cv2.imread('models/face.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/face.png", img)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

meta-onnx-0.1.2.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

meta_onnx-0.1.2-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

File details

Details for the file meta-onnx-0.1.2.tar.gz.

File metadata

  • Download URL: meta-onnx-0.1.2.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for meta-onnx-0.1.2.tar.gz
Algorithm Hash digest
SHA256 3dfc8a3e80749b987d91d1ec09451b12a50d176081330d45277583451b0f3581
MD5 5c0af4daf2642d1c92d0eee87e5823e0
BLAKE2b-256 05b7fa3c4221707ba5742e521fb59c482a056d47d908ff9199991d26941d580a

See more details on using hashes here.

File details

Details for the file meta_onnx-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: meta_onnx-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 9.0 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for meta_onnx-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 8c926c2625b7e312dcced703f9503c9b223fd6a3b0ff0cbb4e9b66c470ccc344
MD5 55c21937b937f1783b5d7ac2b0453b13
BLAKE2b-256 5f011a54f39fc2f03c6a2e41888885b58ae587554c549903fc0d7b5a36650fd6

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page