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

相关推荐
动物园猫10 小时前
睡岗检测数据集分享(适用于YOLO系列深度学习分类检测任务)
深度学习·yolo·分类
筱筱木1 天前
从标注优化到全流程落地:Python+YOLOv8 打造 YOLO模型训练 一体化平台
yolo
AI街潜水的八角1 天前
基于YOLO26电池顶盖焊接缺陷检测系统1:电池顶盖焊接缺陷检测数据集说明(含下载链接)
人工智能·深度学习·yolo·目标跟踪
Ricky05531 天前
搭载实时 FPGA 处理系统的航天器上用于海上监视的超分辨率YOLO目标检测技术(意大利2026年研究)
yolo·目标检测·fpga开发
YOLO数据集集合1 天前
智慧农业|农田作物杂草识别数据集|航拍巡检|YOLO实例分割|深度学习训练集|智能除草视觉数据集
人工智能·深度学习·yolo·目标检测·无人机
星越华夏1 天前
YOLO v11蚊子数据集训练
人工智能·python·深度学习·yolo
你是个什么橙1 天前
缺陷检测数据集选择:NEU-DET、GC10-DET、MVTec_AD,将其转换成YOLO数据集适用的txt格式
yolo
前网易架构师-高司机1 天前
带标注的交警识别数据集,可识别交警和非交警,5587张图,支持yolo,coco json,voc xml,文末有模型训练代码
xml·yolo·json·数据集·交警
Ricky05531 天前
YOLO-FCE:一种基于特征与聚类增强的物种分类目标检测模型(澳大利亚2026年研究)
图像处理·人工智能·yolo·目标检测·分类
不懒不懒1 天前
基于 YOLOv10 的汽车机油滤芯缺陷检测系统(训练 + 测试 + 可视化 + 避坑)
yolo·汽车