Deploying YoloV3 to Jetson Nano
조회 수: 3 (최근 30일)
이전 댓글 표시
function outImg = YoloOnJetson(cameraName,resolution)
% Copyright 2021-2022 The MathWorks, Inc.
hwobj = jetson;
camObj = camera(hwobj,cameraName,resolution);
dispObj = imageDisplay(hwobj);
configFilePath = "E:\JetsonWork\George Camer Object Detection\ssd_mobilenet_v2_coco.config";
persistent yolov3Obj;
if isempty(yolov3Obj)
yolov3Obj = coder.loadDeepLearningNetwork('darknet53-coco.mat');
end
% Read the contents of the configuration file as text
fid = fopen(configFilePath, 'r');
configText = fscanf(fid, '%c', inf);
fclose(fid);
% Load the pre-trained YOLOv3 object detector
detector = yolov3ObjectDetector('darknet53-coco');
while ishandle(1)
% Capture the image from the camera on hardware.
img = snapshot(camObj);
% Detect objects in the frame
[bboxes, scores, labels] = yolov3Obj.detect(detector, img);
% Annotate the image with bounding boxes and labels
img = insertObjectAnnotation(img, 'rectangle', bboxes, cellstr(labels));
% Display the annotated image
% Display the annotated image
image(dispObj,img);
end
I am trying to run this code in order to generate an .exe of this code to my Jetson Nano Developer Kit
>> inputArgs = {coder.Constant(camName),coder.Constant(camResolution)};
codegen('-config ',cfg,'-args',inputArgs,'YoloOnJetson','-report');
The 'yolov3ObjectDetector' class does not support code generation.
Error in ==> YoloOnJetson Line: 20 Column: 12
Code generation failed: View Error Report
Error using codegen
I usually get this error, I do have the darknet53-coco.mat file in my file directory, I did generate it somehow playing around.
It's werid because yolov3ObjectDetector shall be compatible with code generation, what can I do?
댓글 수: 0
채택된 답변
추가 답변 (1개)
Walter Roberson
2023년 11월 22일
if isempty(yolov3Obj)
yolov3Obj = coder.loadDeepLearningNetwork('darknet53-coco.mat');
end
That step looks good: you are loading a pre-trained detector that should be of the right class.
detector = yolov3ObjectDetector('darknet53-coco');
But there you are trying to create a new object of that class. Creating a new object of the class is not supported in deployed code: all you can do in deployed code is load an already-trained detector and use the detect() method of that pre-trained detector.
참고 항목
카테고리
Help Center 및 File Exchange에서 Get Started with GPU Coder에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!