在华为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样例的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/351199

相关文章

如何用Docker运行Django项目

本章教程,介绍如何用Docker创建一个Django,并运行能够访问。 一、拉取镜像 这里我们使用python3.11版本的docker镜像 docker pull python:3.11 二、运行容器 这里我们将容器内部的8080端口,映射到宿主机的80端口上。 docker run -itd --name python311 -p

跨系统环境下LabVIEW程序稳定运行

在LabVIEW开发中,不同电脑的配置和操作系统(如Win11与Win7)可能对程序的稳定运行产生影响。为了确保程序在不同平台上都能正常且稳定运行,需要从兼容性、驱动、以及性能优化等多个方面入手。本文将详细介绍如何在不同系统环境下,使LabVIEW开发的程序保持稳定运行的有效策略。 LabVIEW版本兼容性 LabVIEW各版本对不同操作系统的支持存在差异。因此,在开发程序时,尽量使用

如何在运行时修改serialVersionUID

优质博文:IT-BLOG-CN 问题 我正在使用第三方库连接到外部系统,一切运行正常,但突然出现序列化错误 java.io.InvalidClassException: com.essbase.api.base.EssException; local class incompatible: stream classdesc serialVersionUID = 90314637791991

828华为云征文|华为云Flexus X实例docker部署rancher并构建k8s集群

828华为云征文|华为云Flexus X实例docker部署rancher并构建k8s集群 华为云最近正在举办828 B2B企业节,Flexus X实例的促销力度非常大,特别适合那些对算力性能有高要求的小伙伴。如果你有自建MySQL、Redis、Nginx等服务的需求,一定不要错过这个机会。赶紧去看看吧! 什么是华为云Flexus X实例 华为云Flexus X实例云服务是新一代开箱即用、体

华为OD机试真题-学生方阵-2024年OD统一考试(E卷)

题目描述 学校组织活动,将学生排成一个矩形方阵。 请在矩形方阵中找到最大的位置相连的男生数量。这个相连位置在一个直线上,方向可以是水平的,垂直的,成对角线的或者呈反对角线的。 注:学生个数不会超过10000 输入描述 输入的第一行为矩阵的行数和列数, 接下来的 n行为矩阵元素,元素间用""分隔。 输出描述 输出一个整数,表示矩阵中最长的位

win7+ii7+tomcat7运行javaWeb开发的程序

转载请注明出处:陈科肇 1.前提准备: 操作系统:windows 7 旗舰版   x64 JDK:jdk1.7.0_79_x64(安装目录:D:\JAVA\jdk1.7.0_79_x64) tomcat:32-bit64-bit Windows Service Installer(安装目录:D:\0tomcat7SerV) tomcat-connectors:tomcat-connect

php 7之PhpStorm + Nginx + Xdebug运行调试

操作环境: windows PHP 7.1.10 PhpStorm-2017.2.4 Xdebug 2.5.4 Xdebug helper 1.6.1 nginx-1.12.2 注意查看端口占用情况 netstat -ano //查看所以端口netstat -aon|findstr "80" //查看指定端口占用情况 比如80端口查询情况 TCP 0.0.0.0:8

时间序列|change point detection

change point detection 被称为变点检测,其基本定义是在一个序列或过程中,当某个统计特性(分布类型、分布参数)在某时间点受系统性因素而非偶然因素影响发生变化,我们就称该时间点为变点。变点识别即利用统计量或统计方法或机器学习方法将该变点位置估计出来。 Change Point Detection的类型 online 指连续观察某一随机过程,监测到变点时停止检验,不运用到

[轻笔记] ubuntu Shell脚本实现监视指定进程的运行状态,并能在程序崩溃后重启动该程序

根据网上博客实现,发现只能监测进程离线,然后对其进行重启;然而,脚本无法打印程序正常状态的信息。自己通过不断修改测试,发现问题主要在重启程序的命令上(需要让重启的程序在后台运行,不然会影响监视脚本进程,使其无法正常工作)。具体程序如下: #!/bin/bashwhile [ 1 ] ; dosleep 3if [ $(ps -ef|grep exe_name|grep -v grep|

stl的sort和手写快排的运行效率哪个比较高?

STL的sort必然要比你自己写的快排要快,因为你自己手写一个这么复杂的sort,那就太闲了。STL的sort是尽量让复杂度维持在O(N log N)的,因此就有了各种的Hybrid sort algorithm。 题主你提到的先quicksort到一定深度之后就转为heapsort,这种是introsort。 每种STL实现使用的算法各有不同,GNU Standard C++ Lib