Future Support for 'Acceleration','mex' When Running ONNX Networks - RF-DETR

24 Ansichten (letzte 30 Tage)
Ilan
Ilan am 18 Dez. 2025 um 13:39
Kommentiert: Ram Kokku am 18 Dez. 2025 um 15:37
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 Kommentar
Ram Kokku
Ram Kokku vor etwa 2 Stunden
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.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Image Data Workflows finden Sie in Help Center und File Exchange

Produkte


Version

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by