problems of using deploy fuction to create yolov2 c++ code for raspberry pi

1 Ansicht (letzte 30 Tage)
hi,
here i use the matlab code deploy function to create the yolov2 c++ code in raspberry pi, but some problems occured after the code compliation.
when i use the armcompute version v19.02 with debug=1 to complie and build the code, there is an error when i deploy the code in matlab:
'terminate called after throwing an instance of 'std::runtime_error'terminate called after throwing an instance of 'std::runtime_error'
what(): in validate_arguments src/core/NEON/kernels/NEDepthwiseWeightsReshapeKernel.cpp:92: biases->dimension(0) != input->dimension(2)
if i set the debug=0, this erro will disappear and the code can be successfully generated. but when i use the generated code to run on the raspberry pi, the elf progamme can be started but there is nothing response from the device. i also try deploy sample in this link in my environment, it can successfully work.
i setup my environment follow the process below:
1. install arm-software computelibrary
git config --global http.sslverify false
git clone https://github.com/Arm-software/ComputeLibrary.git
cd ComputeLibrary
git tag -l
git checkout v19.02
-(to build the arm_compute library and make the libarm_compute.so, libarm_compute_core.so in 'lib folder')
sudo apt-get install scons
scons debug=0 neon=1 opencl=0 arch=armv7a
mkdir lib
mv /build/*.so /lib/
2.install userland
download userland on 'https://github.com/raspberrypi/userland' and unzip it to opt folder
(or git clone https://github.com/raspberrypi/userland)
cd /opt/userland;
sudo ./buildme
sudo ldconfig
3.install nanomsg-1.0.0
wget https://github.com/nanomsg/nanomsg/archive/1.0.0.zip
sudo unzip 1.0.0.zip -d /tmp
cd /tmp/nanomsg-1.0.0 ;
mkdir build ;
cd build
sudo cmake .. ;
sudo cmake --build .
sudo cmake --build . --target install
sudo ldconfig
4. sudo apt-get install libasound2-dev
sudo apt-get install libsdl1.2-dev
5. edit arm computelibrary in /.bashrc
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively
case $- in
*i*) ;;
*) export ARM_COMPUTELIB=~/ComputeLibrary
export PATH=${PATH}:~/ComputeLibrary
return;;
esac
the fuction code and deploy.m i use is below here:
function yolov2_detect_arm_vid()
persistent yolov2obj;
%for raspberry pi opencv library build
opencv_linkflags = '`pkg-config --cflags --libs opencv`';
coder.updateBuildInfo('addLinkFlags',opencv_linkflags);
if isempty(yolov2obj)
yolov2obj = coder.loadDeepLearningNetwork('yolov2.mat','yolov2');
end
host = raspi();
cam = webcam(host,1);
imgsize = [416,416,3];
fps = 0;
for k = 1:1800
img = snapshot(cam);
img = imresize(img,imgsize(1:2));
tic;
[bboxes,~,labels] = detect(yolov2obj,img);
elapsedtime = toc;
fps = 0.9*fps + 0.1*(1/elapsedtime);
fprintf('fps: %f\n',fps);
if isempty(bboxes) || isempty(labels)
img = insertText(img, [5,5],fps);
%imshow(img);
displayImage(host,img);
else
img = insertObjectAnnotation(img,'rectangle',bboxes,labels);
img = insertText(img,[5,5],fps);
%imshow(img);
displayImage(host,img);
end
end
end
deploy.m
board = targetHardware('Raspberry Pi');
board.DeviceAddress = 'xxx';
board.Username = 'xx';
board.Password = 'xx';
board.BuildDir = '/home/pi/matlab_arm_codegen/';
board.CoderConfig.TargetLang = 'C++';
dlcfg = coder.DeepLearningConfig('arm-compute');
dlcfg.ArmArchitecture = 'armv7';
dlcfg.ArmComputeVersion = '19.02';
board.CoderConfig.DeepLearningConfig = dlcfg;
deploy(board,'yolov2_detect_arm_vid');
is anyone can help with this problem?
best regards
  2 Kommentare
Reeno Joseph
Reeno Joseph am 21 Aug. 2020
Hi liheng mo,
Can you please clarify the below items.
  1. OpenCV based APIs are not used in “yolov2_detect_arm_vid”. Do you really need those openCV linkage flags?
  2. There is an example that does classification with resnet-50. (Link). Is it working fine?
  3. Raspberry Pi support package comes with a customized Raspbian image (ARM compute 19.05 included). You can try that if you don’t have any version-specific dependency. Just follow the hardware setup screens.
I’ll check the issue related to debug flag and will get back to you.
Meruzhan Hovhannisyan
Meruzhan Hovhannisyan am 21 Apr. 2022
I also tried this technique, nothing good came out. When compiling, it returns the error "Calling the code generation implementation function 'code.internal.const' from the user function 'insertObjectAnnotation/validateAndParseOptInputs_cg' is not supported. Please contact technical support for help."

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu MATLAB Support Package for Raspberry Pi Hardware finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by