基于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硬件任重道远...

相关推荐
Coding茶水间40 分钟前
基于深度学习的花朵识别系统演示与介绍(YOLOv12/v11/v8/v5模型+Pyqt5界面+训练代码+数据集)
开发语言·人工智能·深度学习·yolo·目标检测·机器学习
LeeeX!2 小时前
YOLOv13全面解析与安卓平台NCNN部署实战:超图视觉重塑实时目标检测的精度与效率边界
android·深度学习·yolo·目标检测·边缘计算
2501_941322032 小时前
叉车人员检测识别实战:基于YOLOv8-BiFPN的高精度目标检测方案
python·yolo·目标检测
li三河3 小时前
yolo进行剪枝、蒸馏、量化研究
算法·yolo·剪枝
Faker66363aaa3 小时前
煤矿杂质识别与分类---基于YOLOv5-FasterNet的目标检测系统实现
yolo·目标检测·分类
极智视界3 小时前
无人机场景 - 目标检测数据集 - 垂直视角车辆检测数据集下载
yolo·数据集·无人机·车辆检测·voc·coco·垂直视角
智驱力人工智能3 小时前
无人机目标检测 低空安全治理的工程实践与价值闭环 无人机缺陷识别 农业无人机作物长势分析系统 森林防火无人机火点实时识别
人工智能·opencv·安全·yolo·目标检测·无人机·边缘计算
2501_941652773 小时前
高速公路车辆检测与识别——基于YOLOv8与RFPN网络的智能监控系统_3
网络·yolo
wfeqhfxz25887824 小时前
基于YOLOv10n-CSP-PMSFA的大象检测与识别系统实践与优化
yolo
无人装备硬件开发爱好者4 小时前
RV1126B 边缘端 AI 实战:YOLOv8+DNTR 微小目标跟踪监测全栈实现 2
人工智能·yolo·目标跟踪