本文主要是简单写了一个yolov5-seg的onnxruntime推理工程,python版本的,分享给大家。验证了预处理和解码过程,并进行了简单地属性和方法封装。
'''
Descripttion:
version:
@Company:
Author:
Date: 2022-09-28 00:07:30
LastEditors:
LastEditTime: 2022-09-29 09:05:01
'''
import onnx
import numpy as np
import onnxruntime as rt
import cv2
import time
import torch
import torchvision
import torch.nn.functional as F
import argparse
import loggingLOGGER = logging.getLogger("v5-seg")class YOLOV5_SEG:def __init__(self,model_path,conf_thres=0.25,iou_thres=0.45,max_det=1000):self.model_path = model_pathself.conf_thres = conf_thresself.iou_thres = iou_thresself.max_det = max_det#初始化模型self.sess = rt.InferenceSession(self.model_path,providers=['CUDAExecution