meta-onnx 0.1.2
Meta Onnx Toolkit
License: Apache-2.0

# metaonnx

metaonnx部署通用框架

## 1、安装最新版 meta-cv

    pip install meta-cv

## 2、安装最新版 meta-onnx

    pip install meta-onnx

## 3、图像分类示例（参考[classification_demo.py](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](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](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](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)