# ait_transplt_demos **Repository Path**: wangguowei33/ait_transplt_demos ## Basic Information - **Project Name**: ait_transplt_demos - **Description**: 分别使用 OpenCV / MXBase 的 ResNet50 / YOLOV5 推理示例 - **Primary Language**: Python - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2023-07-11 - **Last Updated**: 2023-08-01 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 简介 - 分别使用 OpenCV / MXBase 的 ResNet50 / YOLOV5 推理示例 *** ## 导出 onnx ```py import torchvision, torch mm = torchvision.models.resnet50(pretrained=True) torch.onnx.export(mm, torch.ones([1, 3, 224, 224]), 'resnet50.onnx') ``` 如需要可下载 - [resnet50.onnx](https://gitee.com/wangguowei33/resnet_opencv_cpp/releases/download/onnx/resnet50.onnx) - [yolov5s.onnx](https://gitee.com/wangguowei33/resnet_opencv_cpp/releases/download/onnx/yolov5s.onnx) ## OpenCV ResNet50 推理 - 相关依赖 ```sh sudo apt install libopencv-dev ``` 如安装失败,可使用源码编译 ```sh git clone https://github.com/opencv/opencv.git cd opencv mkdir build && cd build && cmake .. && make cd - ``` - 编译执行 ```sh cd resnet_opencv g++ -O3 resnet_opencv.cpp -o resnet_opencv `pkg-config --cflags --libs opencv4` ./resnet_opencv # Image process time duration: 4.31935ms # Model inference time duration: 230.819ms # index: 285 # class: Egyptian_cat # score: 18.4915 cd ../ ``` ## MXBase ResNet50 推理 + OpenCV 图像处理 - [MindX SDK 社区版](https://www.hiascend.com/zh/software/mindx-sdk/community) 下载安装 `Ascend-mindxsdk-mxvision`. ```sh ./Ascend-mindxsdk-mxvision_5.0.RC2_linux-aarch64.run --install source mxVision/set_env.sh ``` - 输出 om 模型 ```sh cd assets SOC_VERSION=`python3 -c 'import acl; print(acl.get_soc_name())'` # Ascend310 / Ascend310P3 or others atc --model resnet50.onnx --output resnet50 --framework 5 --soc_version $SOC_VERSION cd - ``` - 编译执行 ```sh cd resnet_mxbase mkdir -p build && cd build && cmake .. && cd - cd build/ && make && cd - && ./resnet_mxbase # Image process time duration: 8.45735ms # Model inference time duration: 3.30807ms # index: 285 # class: Egyptian_cat # score: 18.4844 cd ../ ``` ## MXBase ResNet50 推理 + AIPP 数据处理 - [MindX SDK 社区版](https://www.hiascend.com/zh/software/mindx-sdk/community) 下载安装 `Ascend-mindxsdk-mxvision`. ```sh ./Ascend-mindxsdk-mxvision_5.0.RC2_linux-aarch64.run --install source mxVision/set_env.sh ``` - 输出 om 模型 ```sh cd assets SOC_VERSION=`python3 -c 'import acl; print(acl.get_soc_name())'` # Ascend310 / Ascend310P3 or others atc --model resnet50.onnx --output resnet50_aipp --framework 5 --soc_version $SOC_VERSION --insert_op_conf aipp_resnet.config cd - ``` - 编译执行 ```sh cd resnet_mxbase_aipp mkdir -p build && cd build && cmake .. && cd - cd build/ && make && cd - && ./resnet_mxbase_aipp # Image process time duration: 16.2752ms # Model inference time duration: 2.8023ms # index: 285 # class: Egyptian_cat # score: 18.5625 cd ../ ```