Filter löschen
Filter löschen

Yolov3 CUDA code generation for NVIDIA Jetson using GPU Coder throws Class 'coder.dlnetwork' does not have a method or property with name 'detect'

2 Ansichten (letzte 30 Tage)
Hi all,
As mentioned on the title I am trying to generate CUDA code from a trained YOLO_v3 neural network.
I saved my network using
persondetector=load('yolov3Detector.mat');
net = persondetector.yolov3Detector.Network
matFile = 'YOLOv3Detector12K.mat';
save(matFile,'net');
This the function I have used:
function detectpedestrian5()
persistent mynet
hwobj = jetson;
w = camera(hwobj,"vi-output, imx219 7-0010",[1280 720]);
d = imageDisplay(hwobj);
if isempty(mynet)
mynet = coder.loadDeepLearningNetwork('YOLOv3Detector12K_2.mat');
end
while true
img = snapshot(w);
img = imresize(img,[608 608]);
%[bboxes,scores,labels] = detect(mynet,img,'Threshold',0.6);
[bboxes,scores,labels] = mynet.detect(img,'Threshold',0.6);
[~,idx] = max(scores);
% Annotate detections in the image.
if ~isempty(bboxes)
outImg = insertObjectAnnotation(img,'Rectangle',bboxes(idx,:),labels);
else
outImg = img;
end
image(d,outImg);
end
end
This is the configuration I have used:
cfg = coder.gpuConfig('exe');
cfg.Hardware = coder.hardware('NVIDIA Jetson');
cfg.Hardware.BuildDir = '~/Desktop/GPUcodeGeneration/test9';
cfg.GenerateExampleMain = 'GenerateCodeAndCompile'
cfg.DeepLearningConfig = coder.DeepLearningConfig('tensorrt');
cfg.DeepLearningConfig.DataType = 'fp32';
For code generation, I used
codegen('-config ', cfg,' detectpedestrian5', '-report');
When executing this code I get this error
??? Class 'coder.dlnetwork' does not have a method or property with name
'detect'.
Can someone help me resolve this error, or the yolov3 is not supported for GPU generation?
Thanks in advance

Antworten (1)

Sayan Saha
Sayan Saha am 12 Mai 2022
Hi,
The error thrown is correct. dlnetwork has no method "detect" defined on it. "detect" methods are only defined on object detector objects. To generate code for yolov3 you can load the MATFile with "coder.loadDeepLearningNetwork" as you are doing now and use the loaded "yolov3ObjectDetector" object directly to peform detections. Below is a code snippet for reference:
persistent mynet;
if isempty(mynet)
mynet = coder.loadDeepLearningNetwork('yolov3Detector.mat'); % load the detector itself
end
mynet.detect(img,'Threshold',0.6)
There is no need to extract the network stored in the detector and use it. You can certainly do so but you will only be able to invoke predict method on the network in that case.
I am assuming you followed the steps in https://www.mathworks.com/help/gpucoder/ug/yolov3-object-detection-using-gpucoder.html which asks to save the network in a MATFile. I'll reach out to our documentation team to correct it. Thank you for reporting this issue.
~Sayan

Kategorien

Mehr zu Get Started with GPU Coder finden Sie in Help Center und File Exchange

Produkte


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by