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

相关推荐
深蓝电商API21 分钟前
用YOLO训练验证码目标检测模型的全流程
爬虫·yolo·目标检测·目标跟踪
YOLO数据集集合1 小时前
河道环境智能检测系统(YOLO + DeepSeek) | 河道巡检 YOLO DeepSeek 大语言模型 智慧水利 9144期
人工智能·yolo·目标检测·语言模型·河道污染·城市治理
YOLO数据集集合3 小时前
光伏组件热斑与缺陷检测数据集 | 光伏组件 热斑检测 PID识别 红外检测 光伏巡检9148期
人工智能·yolo·目标检测·光伏·红外光伏·红外检测
hhzz3 小时前
【YOLO 入门到精通 08】推理预测完全指南:多数据源、流式推理与性能优化
人工智能·python·yolo·计算机视觉·性能优化
v:PLLucky203 小时前
眼部疾病智能检测系统
算法·yolo·机器学习·百度·facebook
YOLO数据集集合1 天前
大模型融合YOLO铁路要素缺陷分析系统 | 铁路缺陷检测 YOLO DeepSeek 大语言模型 智能巡检 9141期
人工智能·yolo·目标检测·语言模型·铁路缺陷·轨道缺陷
Tingmanyi1 天前
YOLOv13改进策略【Neck篇】| AFPN 渐进式特征金字塔,整体替换 Head 参数反降 82 万
yolo
YOLO_DATA2 天前
YOLO27防震锤缺陷检测数据集 防震锤数据集 1000张 防震锤 带标注 voc yolo 2 类 目标检测
人工智能·深度学习·yolo·目标检测·计算机视觉·数据集·无人机
YOLO数据集集合2 天前
红外多类型无人机检测数据集 | 红外检测 无人机识别 多类型分类 低空安防 反无人机 9139期
yolo·目标检测·分类·数据挖掘·无人机·无人机检测·红外无人机
YOLO数据集集合3 天前
电力设备目标检测数据集 | 电力设备 变电站巡检 部件识别 目标检测 YOLO格式 9127期
人工智能·yolo·目标检测·计算机视觉·目标跟踪·电力设备