基于Ascend910+PyTorch1.11.0+CANN6.3.RC2的YoloV5训练推理一体化解决方案

昇腾Pytorch镜像:https://ascendhub.huawei.com/#/detail/ascend-pytorch

代码仓:git clone https://gitee.com/ascend/modelzoo-GPL.git

coco测试验证集:wget https://bj-aicc.obs.cn-north-309.mtgascendic.cn/dataset/coco2017/coco.zip

coco训练集(放images下):wget https://bj-aicc.obs.cn-north-309.mtgascendic.cn/dataset/coco2017/train2017.zip

部分代码

python 复制代码
# import StreamManagerApi.py
from StreamManagerApi import *

if __name__ == '__main__':
    # init stream manager
    streamManagerApi = StreamManagerApi()
    ret = streamManagerApi.InitManager()
    if ret != 0:
        print("Failed to init Stream manager, ret=%s" % str(ret))
        exit()

    # create streams by pipeline config file
    with open("data/pipeline/Sample.pipeline", 'rb') as f:
        pipelineStr = f.read()
    ret = streamManagerApi.CreateMultipleStreams(pipelineStr)
    if ret != 0:
        print("Failed to create Stream, ret=%s" % str(ret))
        exit()

    # Construct the input of the stream
    dataInput = MxDataInput()
    with open("data/test.jpg", 'rb') as f:
        dataInput.data = f.read()

    # The following is how to set the dataInput.roiBoxs
    """
    roiVector = RoiBoxVector()
    roi = RoiBox()
    roi.x0 = 100
    roi.y0 = 100
    roi.x1 = 200
    roi.y1 = 200
    roiVector.push_back(roi)
    dataInput.roiBoxs = roiVector
    """

    # Inputs data to a specified stream based on streamName.
    streamName = b'classification'
    inPluginId = 0
    uniqueId = streamManagerApi.SendDataWithUniqueId(streamName, inPluginId, dataInput)
    if uniqueId < 0:
        print("Failed to send data to stream.")
        exit()

    # Obtain the inference result by specifying streamName and uniqueId.
    inferResult = streamManagerApi.GetResultWithUniqueId(streamName, uniqueId, 3000)
    if inferResult.errorCode != 0:
        print("GetResultWithUniqueId error. errorCode=%d, errorMsg=%s" % (
            inferResult.errorCode, inferResult.data.decode()))
        exit()

    # print the infer result
    print(inferResult.data.decode())

    # destroy streams
    streamManagerApi.DestroyAllStreams()

本来想一次性写完的,奈何装CANN的驱动装了一个礼拜,各种内核版本不匹配,国产AI硬件任重道远...

相关推荐
guo_xiao_xiao_7 小时前
YOLOv11室内果蔬展示苹果目标检测数据集-37张-apple-1_3
人工智能·yolo·目标检测
动物园猫11 小时前
河道塑料瓶识别标准数据集分享(适用于YOLO系列深度学习分类检测任务)
深度学习·yolo·分类
AI棒棒牛11 小时前
YOLO26:面向实时目标检测的核心架构改进与性能基准测试
人工智能·深度学习·yolo·目标检测·架构
guo_xiao_xiao_12 小时前
YOLOv11室内与自然环境鸟类目标检测数据集-120张-bird-1_2
人工智能·yolo·目标检测
钓了猫的鱼儿13 小时前
【数据集】红外建筑生活垃圾目标检测数据集VOC+YOLO格式1341张8类别
yolo·目标检测·无人机
guo_xiao_xiao_1 天前
YOLOv11室内地面塑料袋目标检测数据集-30张-Plastic-Bag-1
yolo·目标检测·目标跟踪
探物 AI1 天前
【感知·yolov11】YOLOv11 部署踩坑录:为什么 INT8 量化后精度往往被直接“腰斩”??
yolo
guo_xiao_xiao_1 天前
YOLOv11室内果蔬摆放香蕉目标检测数据集-4187张-banana-1_4
yolo·目标检测·目标跟踪
guo_xiao_xiao_1 天前
YOLOv11室内办公环境包目标检测数据集-1832张-bag-1_2
yolo·目标检测·目标跟踪
AIDF20262 天前
手把手教你分析深度学习目标检测模型——以YOLOv5为例
深度学习·yolo·目标检测