How do I import yolov3 onnx model into MATLAB?

16 ビュー (過去 30 日間)
Alexander Zimmerer
Alexander Zimmerer 2021 年 8 月 24 日
コメント済み: Alexander Zimmerer 2021 年 9 月 21 日
Dear Community,
I am currently trying to import a pretrained yolo image segmentation model into Matlab (R2021a, all Addons and Toolboxes installed). When I was doing it with a yolov2-network as described here, I am able to do so.
However when I try to the the same with a newer version of the classifier, provided by the ONNX Model Zoo, I receive the following error message:
modelname='yolov3-10.onnx' %downloaded and stored in current dir
lgraph = importONNXLayers(modelname,'ImportWeights',true);
Error using nnet.internal.cnn.onnx.translateONNX>getONNXImageInputSize (line 482)
Unspecified input dimensions are supported only for sequence or batch dimensions.
Error in nnet.internal.cnn.onnx.translateONNX>createInputLayer (line 464)
ONNXInputShape = getONNXImageInputSize(ONNXInputDims); % Returns [C H W]
Error in nnet.internal.cnn.onnx.translateONNX (line 59)
inputLayer = createInputLayer(thisGraph, inputsWithoutInitializers{i}, UserImageInputSize);
Error in nnet.internal.cnn.onnx.importONNXLayers (line 10)
[LayersOrGraph, translationIssues] = nnet.internal.cnn.onnx.translateONNX(modelProto, OutputLayerType, UserImageInputSize, ImportWeights);
Error in importONNXLayers (line 48)
Layers = nnet.internal.cnn.onnx.importONNXLayers(modelfile, varargin{:});
Any I idea what I could do instead?
Many thanks in advance :)
Alex

回答 (2 件)

Anshika Chaurasia
Anshika Chaurasia 2021 年 9 月 17 日
Hi Alexander,
The reason for error is that your model has variable input dimensions (i.e. input dimensions are not fix).
The possible workaround to import such model is to use importONNXFunction.
Hope it helps!
  1 件のコメント
Alexander Zimmerer
Alexander Zimmerer 2021 年 9 月 20 日
Hi Anshika,
thank you very much for your answer.
When I use importONNXFunction as recommended is it possible from there to change the input layer to fixed dimensions and create a layer graph out of it?
Thanks again and best regards
Alex

サインインしてコメントする。


David Willingham
David Willingham 2021 年 9 月 20 日
Hi Alex,
Have you seen that there is access to yolov3 in matlab?
David
  1 件のコメント
Alexander Zimmerer
Alexander Zimmerer 2021 年 9 月 21 日
Hey David,
many thanks also for your answer. In fact this was exactly what I was doing meanwhile. However I still wanted to understand a kind of "generic" procedure of importing any open source model into matlab, train the model and ideally import it into Simulink to test it and generate code out of it.
So that's the basic idea behind my question ;)
Alex

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeImage Data Workflows についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by