Compiled app from App Designer can't recognize 'DAGNetwork'.

18 views (last 30 days)
I trained a U-Net model using 'unetLayers.m' and tried to read this model from an Matlab App.
It works fine with Matlab App but failed to read this model from the compiled standalone App.
I got this error message:
Warning: Variable 'net' originally saved as a DAGNetwork cannot be instantiated as an object and will be read in as a uint32.
I found this thread related to my question:
but the solution provided in this thread didn't work with my issue.
Any clue is appreciated!
Thanks!

Accepted Answer

Pratik
Pratik on 16 Apr 2024 at 8:20
Edited: Pratik on 16 Apr 2024 at 8:21
Hi Wei-Rong Chen,
As per my understanding, issue you're encountering involves the behavior of MATLAB's App Designer and its compiled standalone applications when dealing with 'DAGNetwork' objects, specifically a U-Net model created with unetLayers.m. While your application functions as expected within MATLAB, the compiled version fails to properly load the 'DAGNetwork' object from a .mat file, instead loading it as a uint32 data type.
The current issue appears to be caused by the fact that DAGNetwork is not recognised as an object, because Deep Learning Toolbox is not included when compiling the standalone application. Additionally, code requires elements from the Computer Vision Toolbox, since this model is for image processing. Since model is in a .mat file the dependency analysis ran by MATLAB when compiling your application does not see that these toolboxes are required.   
To resolve this issue, function pragma that refers to the Deep Learning Toolbox and the Computer Vision Toolbox can be added to the code. This will tell MATLAB to include the necessary toolboxes when compiling the application. Please refer to the following snippet:
%#function nnet.cnn.layer.PixelClassificationLayer  
After recompiling the application, the compiler will see the pragma and should include the Deep Learning and Computer Vision Toolboxes. This should allow the program to recognize the DAGNetwork object and resolve the error.
Please refer to the documentation of Function Pragmas for more information:
I hope this helps!

More Answers (0)

Categories

Find more on MATLAB Web App Server in Help Center and File Exchange

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!