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

1 visualización (últimos 30 días)
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

Respuestas (1)

Sayan Saha
Sayan Saha el 12 de Mayo de 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

Categorías

Más información sobre Get Started with GPU Coder en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by