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

24 vues (au cours des 30 derniers jours)
Ilan
Ilan le 18 Déc 2025 à 13:39
Commenté : Ram Kokku le 18 Déc 2025 à 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 commentaire
Ram Kokku
Ram Kokku il y a environ 2 heures
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.

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Image Data Workflows dans Help Center et File Exchange

Produits


Version

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by