在华为ModelArts运行YOLOV3_coco_detection_dynamic_AIPP样例

2023-11-05 16:50

本文主要是介绍在华为ModelArts运行YOLOV3_coco_detection_dynamic_AIPP样例,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

一、参考资料

YOLOV3_coco_detection_dynamic_AIPP样例

ATC_yolov3_caffe_AE

在Atlas 200DK上体验DVPP(2)DVPP、AIPP和OM推理

二、关键步骤

2.1 下载源代码

官方:samples
博主:samples

2.2 下载预训练模型

wget https://modelzoo-train-atc.obs.cn-north-4.myhuaweicloud.com/003_Atc_Models/AE/ATC%20Model/Yolov3/yolov3.caffemodelwget https://modelzoo-train-atc.obs.cn-north-4.myhuaweicloud.com/003_Atc_Models/AE/ATC%20Model/Yolov3/yolov3.prototxt

项目目录

samples/cplusplus/level2_simple_inference/2_object_detection/YOLOV3_coco_detection_dynamic_AIPP

2.3 下载AIPP配置文件

wget https://c7xcode.obs.cn-north-4.myhuaweicloud.com/models/YOLOV3_coco_detection_dynamic_AIPP/aipp_objectdetection.cfg

aipp_objectdetection.cfg文件

aipp_op { 
aipp_mode : dynamic
related_input_rank : 0
max_src_image_size: 700000
support_rotation: false
}

2.4 设置环境变量

source ~/Ascend/ascend-toolkit/set_env.shexport INSTALL_DIR=/home/ma-user/Ascend/ascend-toolkit/latest/arm64-linuxexport THIRDPART_PATH=/home/ma-user/work/samplesexport CPU_ARCH=aarch64

2.5 atc模型转换

[ma-user@notebook-87136e07-6a9a-4138-beec-742972f7b62f model]$ atc --model=./yolov3.prototxt --weight=./yolov3.caffemodel --framework=0 --output=./yolov3 --soc_version=Ascend910 --insert_op_conf=./aipp_objectdetection.cfg
ATC start working now, please wait for a moment.
ATC run success, welcome to the next use.

2.6 修改CMakeLists.txt

添加opencv静态链接库,cmake build编译可链接到opencv。

# OpenCV_DIR目录包含OpenCVConfig.cmake
set(OpenCV_DIR /home/ma-user/work/opencv-4.5.1/lib/cmake/opencv4)
# 找到opencv库
find_package(OpenCV REQUIRED)# If the package has been found, several variables will
# be set, you can find the full list with descriptions
# in the OpenCVConfig.cmake file.
# Print some message showing some of them
if(${OPENCV_FOUND})message(STATUS "OpenCV version: ${OpenCV_VERSION}")message(STATUS "OpenCV include path: ${OpenCV_INCLUDE_DIRS}")message(STATUS "OpenCV libraries: ${OpenCV_LIBS}")
endif()# Add OpenCV headers location to your include paths
include_directories(${OpenCV_INCLUDE_DIRS})

2.7 sample_build.sh

[ma-user@notebook-87136e07-6a9a-4138-beec-742972f7b62f scripts]$ ./sample_build.sh
ScriptPath: /home/ma-user/work/samples/cplusplus/level2_simple_inference/2_object_detection/YOLOV3_coco_detection_dynamic_AIPP/scripts
ModelPath: /home/ma-user/work/samples/cplusplus/level2_simple_inference/2_object_detection/YOLOV3_coco_detection_dynamic_AIPP/scripts/../model
[INFO] Sample preparation
please input TargetKernel? [arm/x86]:arm
[INFO] input is normal, start preparation.
--2022-07-05 18:00:01--  https://c7xcode.obs.cn-north-4.myhuaweicloud.com/models/YOLOV3_coco_detection_dynamic_AIPP/dog1_1024_683.jpg
Resolving proxy-notebook.modelarts.com (proxy-notebook.modelarts.com)... 192.168.0.62
Connecting to proxy-notebook.modelarts.com (proxy-notebook.modelarts.com)|192.168.0.62|:8083... connected.
Proxy request sent, awaiting response... 200 OK
Length: 35635 (35K) [image/jpeg]
Saving to: '/home/ma-user/work/samples/cplusplus/level2_simple_inference/2_object_detection/YOLOV3_coco_detection_dynamic_AIPP/scripts/../model/../data/dog1_1024_683.jpg'/home/ma-user/work/samples/cplusp 100%[============================================================>]  34.80K  --.-KB/s    in 0.02s2022-07-05 18:00:02 (1.61 MB/s) - '/home/ma-user/work/samples/cplusplus/level2_simple_inference/2_object_detection/YOLOV3_coco_detection_dynamic_AIPP/scripts/../model/../data/dog1_1024_683.jpg' saved [35635/35635][INFO] The yolov3.om already exists.start buiding
-- The C compiler identification is GNU 7.3.0
-- The CXX compiler identification is GNU 7.3.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/g++
-- Check for working CXX compiler: /usr/bin/g++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found OpenCV: /home/ma-user/work/opencv-4.5.1 (found version "4.5.2")
-- OpenCV version: 4.5.2
-- OpenCV include path: /home/ma-user/work/opencv-4.5.1/include/opencv4
-- OpenCV libraries: opencv_calib3d;opencv_core;opencv_dnn;opencv_features2d;opencv_flann;opencv_gapi;opencv_highgui;opencv_imgcodecs;opencv_imgproc;opencv_ml;opencv_objdetect;opencv_photo;opencv_stitching;opencv_video;opencv_videoio
arm architecture detected
target aarch64 300
-- Configuring done
-- Generating done
-- Build files have been written to: /home/ma-user/work/samples/cplusplus/level2_simple_inference/2_object_detection/YOLOV3_coco_detection_dynamic_AIPP/build/intermediates/host
Scanning dependencies of target main
[ 12%] Building CXX object CMakeFiles/main.dir/utils.cpp.o
[ 25%] Building CXX object CMakeFiles/main.dir/model_process.cpp.o
[ 37%] Building CXX object CMakeFiles/main.dir/object_detect.cpp.o
/home/ma-user/work/samples/cplusplus/level2_simple_inference/2_object_detection/YOLOV3_coco_detection_dynamic_AIPP/src/object_detect.cpp: In member function 'void* ObjectDetect::GetInferenceOutputItem(uint32_t&, aclmdlDataset*, uint32_t)':
/home/ma-user/work/samples/cplusplus/level2_simple_inference/2_object_detection/YOLOV3_coco_detection_dynamic_AIPP/src/object_detect.cpp:431:56: warning: 'uint32_t aclGetDataBufferSize(const aclDataBuffer*)' is deprecated: aclGetDataBufferSize is deprecated, use aclGetDataBufferSizeV2 instead [-Wdeprecated-declarations]size_t bufferSize = aclGetDataBufferSize(dataBuffer);^
In file included from /home/ma-user/Ascend/ascend-toolkit/latest/arm64-linux/acllib/include/acl/acl_rt.h:16:0,from /home/ma-user/Ascend/ascend-toolkit/latest/arm64-linux/acllib/include/acl/acl.h:14,from /home/ma-user/work/samples/cplusplus/level2_simple_inference/2_object_detection/YOLOV3_coco_detection_dynamic_AIPP/src/../inc/utils.h:24,from /home/ma-user/work/samples/cplusplus/level2_simple_inference/2_object_detection/YOLOV3_coco_detection_dynamic_AIPP/src/../inc/object_detect.h:20,from /home/ma-user/work/samples/cplusplus/level2_simple_inference/2_object_detection/YOLOV3_coco_detection_dynamic_AIPP/src/object_detect.cpp:19:
/home/ma-user/Ascend/ascend-toolkit/latest/arm64-linux/acllib/include/acl/acl_base.h:276:30: note: declared hereACL_FUNC_VISIBILITY uint32_t aclGetDataBufferSize(const aclDataBuffer *dataBuffer);^~~~~~~~~~~~~~~~~~~~
[ 50%] Building CXX object CMakeFiles/main.dir/dvpp_process.cpp.o
[ 62%] Building CXX object CMakeFiles/main.dir/dvpp_resize.cpp.o
[ 75%] Building CXX object CMakeFiles/main.dir/dvpp_jpegd.cpp.o
[ 87%] Building CXX object CMakeFiles/main.dir/main.cpp.o
[100%] Linking CXX executable /home/ma-user/work/samples/cplusplus/level2_simple_inference/2_object_detection/YOLOV3_coco_detection_dynamic_AIPP/out/main
[100%] Built target main
[INFO] Sample preparation is complete

在这里插入图片描述

2.8 sample_run.sh

[ma-user@notebook-87136e07-6a9a-4138-beec-742972f7b62f scripts]$ ./sample_run.sh
[INFO] The sample starts to run
[INFO]  acl init success
[INFO]  open device 0 success
[INFO]  create context success
[INFO]  create stream success
[INFO]  load model ../model/yolov3.om success
[INFO]  create model description success
[INFO]  create model output success
[INFO]  dvpp init resource ok
[INFO]  convert image success
[WARN]  Input size verify failed input[0] size: 700000, provide size : 259584
[INFO]  model execute success
110 116 929 600 dog99%
[INFO]  Process pic ../data/dog1_1024_683.jpg by dvpp success
[WARN]  Input size verify failed input[0] size: 700000, provide size : 519168
[INFO]  model execute success
120 118 925 596 dog99%
[INFO]  Process pic ../data/dog1_1024_683.jpg by OpenCV success
[INFO]  Execute sample success
[INFO]  unload model success, modelId is 1
[INFO]  end to destroy stream
[INFO]  end to destroy context
[INFO]  end to reset device is 0
[INFO]  end to finalize acl
[INFO] The program runs successfully, please view the result file in the /home/ma-user/work/samples/cplusplus/level2_simple_inference/2_object_detection/YOLOV3_coco_detection_dynamic_AIPP/scripts/../out/output directory!

在这里插入图片描述

2.9 效果图

在这里插入图片描述
在这里插入图片描述

这篇关于在华为ModelArts运行YOLOV3_coco_detection_dynamic_AIPP样例的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!


原文地址:https://blog.csdn.net/m0_37605642/article/details/125700863
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.chinasem.cn/article/351199

相关文章

eclipse如何运行springboot项目

《eclipse如何运行springboot项目》:本文主要介绍eclipse如何运行springboot项目问题,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目js录当在eclipse启动spring boot项目时出现问题解决办法1.通过cmd命令行2.在ecl

使用nohup和--remove-source-files在后台运行rsync并记录日志方式

《使用nohup和--remove-source-files在后台运行rsync并记录日志方式》:本文主要介绍使用nohup和--remove-source-files在后台运行rsync并记录日... 目录一、什么是 --remove-source-files?二、示例命令三、命令详解1. nohup2.

Spring Boot项目打包和运行的操作方法

《SpringBoot项目打包和运行的操作方法》SpringBoot应用内嵌了Web服务器,所以基于SpringBoot开发的web应用也可以独立运行,无须部署到其他Web服务器中,下面以打包dem... 目录一、打包为JAR包并运行1.打包为可执行的 JAR 包2.运行 JAR 包二、打包为WAR包并运行

Java NoClassDefFoundError运行时错误分析解决

《JavaNoClassDefFoundError运行时错误分析解决》在Java开发中,NoClassDefFoundError是一种常见的运行时错误,它通常表明Java虚拟机在尝试加载一个类时未能... 目录前言一、问题分析二、报错原因三、解决思路检查类路径配置检查依赖库检查类文件调试类加载器问题四、常见

Python如何精准判断某个进程是否在运行

《Python如何精准判断某个进程是否在运行》这篇文章主要为大家详细介绍了Python如何精准判断某个进程是否在运行,本文为大家整理了3种方法并进行了对比,有需要的小伙伴可以跟随小编一起学习一下... 目录一、为什么需要判断进程是否存在二、方法1:用psutil库(推荐)三、方法2:用os.system调用

Python运行中频繁出现Restart提示的解决办法

《Python运行中频繁出现Restart提示的解决办法》在编程的世界里,遇到各种奇怪的问题是家常便饭,但是,当你的Python程序在运行过程中频繁出现“Restart”提示时,这可能不仅仅是令人头疼... 目录问题描述代码示例无限循环递归调用内存泄漏解决方案1. 检查代码逻辑无限循环递归调用内存泄漏2.

售价599元起! 华为路由器X1/Pro发布 配置与区别一览

《售价599元起!华为路由器X1/Pro发布配置与区别一览》华为路由器X1/Pro发布,有朋友留言问华为路由X1和X1Pro怎么选择,关于这个问题,本期图文将对这二款路由器做了期参数对比,大家看... 华为路由 X1 系列已经正式发布并开启预售,将在 4 月 25 日 10:08 正式开售,两款产品分别为华

Java终止正在运行的线程的三种方法

《Java终止正在运行的线程的三种方法》停止一个线程意味着在任务处理完任务之前停掉正在做的操作,也就是放弃当前的操作,停止一个线程可以用Thread.stop()方法,但最好不要用它,本文给大家介绍了... 目录前言1. 停止不了的线程2. 判断线程是否停止状态3. 能停止的线程–异常法4. 在沉睡中停止5

SpringBoot利用dynamic-datasource-spring-boot-starter解决多数据源问题

《SpringBoot利用dynamic-datasource-spring-boot-starter解决多数据源问题》dynamic-datasource-spring-boot-starter是一... 目录概要整体架构构想操作步骤创建数据源切换数据源后续问题小结概要自己闲暇时间想实现一个多租户平台,

在VSCode中本地运行DeepSeek的流程步骤

《在VSCode中本地运行DeepSeek的流程步骤》本文详细介绍了如何在本地VSCode中安装和配置Ollama和CodeGPT,以使用DeepSeek进行AI编码辅助,无需依赖云服务,需要的朋友可... 目录步骤 1:在 VSCode 中安装 Ollama 和 CodeGPT安装Ollama下载Olla