Future Support for 'Acceleration','mex' When Running ONNX Networks - RF-DETR
24 views (last 30 days)
Show older comments
I am working with an ONNX model imported into MATLAB using importNetworkFromONNX.
The model is a RF-DETR object detection network exported from Python.
I would like to use MEX acceleration for inference, but it currently does not seem to be supported for this workflow.
oNet = importNetworkFromONNX("rfdetr.onnx");
sizeImg = 384;
% Load an image
tImg = imread("img.png");
tImgSmall = imresize(tImg,[sizeImg sizeImg]);
mImg = single(tImgSmall);
dlImg = dlarray(mImg,"SSC");
mGPUImg = gpuArray(dlImg);
[dlBoxes, dlLabels] = oNet.predict(mGPUImg, 'Acceleration', 'mex');
I get this error message:
error using dlnetwork/predict (line 700)
Option 'Acceleration', 'mex' is not supported for this network. Use option 'Acceleration', 'auto' instead.
Caused by:
Error using nnet.internal.cnn.coder.MexNetworkConfig/mustBeSupportedNetwork
Layer hyper-parameters for custom layer 'ConstantOfShape_To_ReshapeLayer1102' must be numeric scalar, scalar logical, character or string array, or a matrix of type double or single.
in the future it will be possible that you will support this network?
thanks
1 Comment
Ram Kokku
28 minuter ago
Hi Ilan,
MEX acceleration uses code generation internally. It appears that the layer 'ConstantOfShape_To_ReshapeLayer1102' contains unsupported constructs. Use analyzeNetworkForCodegen(dlnet, TargetLibrary = 'cudnn') to find more details about this error and other blocking issues. While replacing these constructs with supported ones could be a workaround, it may not be straightforward. Since your goal is to improve model inference in MATLAB ( based on : https://www.mathworks.com/matlabcentral/answers/2181894-onnx-model-import-and-inference-performance-in-matlab-is-significantly-slower-than-python-cpu-gpu?s_tid=prof_contriblnk), I recommend waiting for a response to that thread before modifying the model.
Answers (0)
See Also
Categories
Find more on Image Data Workflows in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!