MATLAB Answers

DenseNet-201 DAGNetwork compilation problem

7 views (last 30 days)
Will Yu
Will Yu on 16 Jul 2019
Answered: Kyle Peterson on 21 Oct 2019
Hi,I'm new to MATLAB. I'm using MATLAB to perform transfer learning.
After using transfer learning based on densenet201, I get the DAGNetwork I need and I want to compile a recongnition program (.exe) using MATLAB.
Here is my recongnition program code (combinetest.m):
%MAIN PROGRAM
load('demo1');
while(1)
if (exist('00015.jpg','file') ~=0)
try
I=imread('00015.jpg');
catch
delete('00015.jpg');
continue;
end
m=fishrecon(I,net);
delete('00015.jpg');
fileID = fopen('result.txt','w');
fprintf(fileID,'%s',m);
fclose(fileID);
end
pause(0.5);
end
And fishrecon function (fishrecon.m):
function m=fishrecon(imd,net)
if (ischar(imd))
imd=eval(imd);
end
imd=imresize(imd,[224,224]);
[label,scores] = classify(net, imd);
classNames = net.Layers(end).ClassNames;
m=string(label)+ num2str(100*scores(classNames == label),3) + "%";
'demo1' is the DAGNetwork I got from transfer learning on densenet201.
I compile the MATLAB code with the build-in APP --Application Compiler,but after compilation the program keeps jumping out the error message.
It seems the code below went wrong.
m=fishrecon(I,net);
But the code works fine while using MATLAB editor.
Have anybody encountered this problem? Please help.

Answers (1)

Kyle Peterson
Kyle Peterson on 21 Oct 2019
I am getting the same error when trying to run my compiled code that uses DenseNet-201 to classify images. I found a link on the Matlab documentation that may explain? https://www.mathworks.com/help/coder/ug/networks-and-layers-supported-for-c-code-generation.html
Does this mean that DenseNet-201 cannot be used in the matlab compiler?

Community Treasure Hunt

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

Start Hunting!