Unable to import an ONNX network in complied application / issues loading DAG networks from MAT files / cannot include support package in compiled application

15 次查看(过去 30 天)
I'm having an issue with a deployed application and a DAG/ONNX network:
  • The network was originally trained in pytorch and written to an ONNX file.
  • I subsequently produced a .mat file with the following routine <updateCnnMat>
  • I then run <testCnn> in both deployed mode and in a native environment: it runs successfully in the latter and fails in the former.
  • Variable names and file names have been changed for this copy because of IP reasons
  • I checked <mccExcludedFiles.log>, which does not indicate that anything important is being excluded
  • I confirmed that the file is being included in my path
  • I do not get the support package section in the compiler window as suggested by https://www.mathworks.com/help/compiler/manage-support-packages.html
  • Note that I'm using R2020a - changing this could be a little painful, but I could do it if really needed.
Any ideas? I feel like I've turned over every stone at this point.
$ cat mccExcludedFiles.log
The List of Excluded Files
Excluded files Exclusion Message ID Reason For Exclusion Exclusion Rule
function updateCnnMat(in,out)
model =importONNXNetwork(in,'outputlayertype','regression');
save(out,'model','-v7.3');
Log output:
~
DAGNetwork with no properties.
-
mat fail!
MException with properties:
identifier: 'MATLAB:structRefFromNonStruct'
message: 'Dot indexing is not supported for variables of this type.'
cause: {}
stack: [4x1 struct]
Correction: []
-----------
coder fail!
MException with properties:
identifier: 'MATLAB:undefinedVarOrClass'
message: 'Unable to resolve the name coder.internal.loadDeepLearningNetwork.'
cause: {}
stack: [3x1 struct]
Correction: []
-----------
onnx fail!
MException with properties:
identifier: 'nnet_cnn:supportpackages:InstallRequired'
message: 'importONNXNetwork requires the Deep Learning Toolbox Converter for ONNX Model Format support package. To install this support package, use the <a href="matlab: matlab.addons.supportpackage.internal.explorer.showSupportPackages('ONNXCONVERTER', 'tripwire')">Add-On Explorer</a>.'
cause: {}
stack: [4x1 struct]
Correction: []
-----------
function testCnn(din)
% modelDir is already specified
load cnn.mat model
disp('if you got here, you were able to read the mat file...')
try
load cnn.mat model
dout = predict(model, din);
disp('mat win!')
catch e
disp('mat fail!')
disp(e)
end
% model=model0.model;
try
modelCoder=coder.loadDeepLearningNetwork(fullfile(modelDir, 'cnn.mat'));
dout = predict(modelCoder, din);
disp('coder win!')
catch e
disp('coder fail!')
disp(e)
end
try
modelOnnx=importONNXNetwork(fullfile(modelDir, 'cnn.onnx'),'outputlayertype','regression');
dout = predict(modelOnnx, din);
disp('onnx win!')
catch e
disp('onnx fail!')
disp(e)
end

回答(2 个)

Pierre Harouimi
Pierre Harouimi 2021-5-19
Hi
Could you share the ONNX file, so that I can reproduce it?
It seems there is a dynamic licensing issue...
  7 个评论
Mirko Prezioso
Mirko Prezioso 2022-8-2
编辑:Mirko Prezioso 2022-8-2
Hi Pierre, I am having the same problem. Could you simplify your workaround in English? :)
What does overload means, and how I can add the overloaded functions after?

请先登录,再进行评论。


Federico
Federico 2023-6-27
I have the same problem, anyone solved the problem?

类别

Help CenterFile Exchange 中查找有关 Image Data Workflows 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by