I am trying to build an app with the app designer for skin tumor image classification. I already trained my CNN and I saved it. My problem is that I'm not sure how can I integrate the trained network in my app so that I can classify new images.
The code from the app designer is this:
classdef app3 < matlab.apps.AppBase % Properties that correspond to app components
properties (Access = public) UIFigure matlab.ui.Figure UploadImageButtonPushed_2 matlab.ui.control.Button AnalyzeImageButtonPushed_2 matlab.ui.control.Button UIAxes3 matlab.ui.control.UIAxes UIAxes4 matlab.ui.control.UIAxes end properties (Access = private) filepath net % neural network
labels1 end methods (Access = private) function startupfunc(app) app.net = load('mini_date2.mat'); app.net = app.net.net; app.filepath = 'E:/LICENTA/BD_Skin_Cancer_Screening/'; app.filepath = app.filepath.filepath; end end % Callbacks that handle component events
methods (Access = private) % Button pushed function: AnalyzeImageButtonPushed_2
function AnalyzeImageButtonPushed_2Pushed(app, event) imds = imageDatastore(app.filepath); [labels]= classify(app.net,imds); imshow([labels, imd],'Parent', app.UIAxes4); end % Button pushed function: UploadImageButtonPushed_2
function UploadImageButtonPushed_2Pushed(app, event) [filename, app.filepath] = uigetfile({'*.jpg'},'File Selector'); imagefile = fullfile(app.filepath, filename); imd = imread(imagefile); imshow(imd, 'Parent', app.UIAxes3); end end % Component initialization
methods (Access = private) % Create UIFigure and components
function createComponents(app) % Create UIFigure and hide until all components are created
app.UIFigure = uifigure('Visible', 'off'); app.UIFigure.Position = [100 100 640 480]; app.UIFigure.Name = 'MATLAB App'; % Create UploadImageButtonPushed_2
app.UploadImageButtonPushed_2 = uibutton(app.UIFigure, 'push'); app.UploadImageButtonPushed_2.ButtonPushedFcn = createCallbackFcn(app, @UploadImageButtonPushed_2Pushed, true); app.UploadImageButtonPushed_2.Position = [433 322 162 22]; app.UploadImageButtonPushed_2.Text = 'UploadImageButtonPushed'; % Create AnalyzeImageButtonPushed_2
app.AnalyzeImageButtonPushed_2 = uibutton(app.UIFigure, 'push'); app.AnalyzeImageButtonPushed_2.ButtonPushedFcn = createCallbackFcn(app, @AnalyzeImageButtonPushed_2Pushed, true); app.AnalyzeImageButtonPushed_2.Position = [429 220 170 22]; app.AnalyzeImageButtonPushed_2.Text = ' AnalyzeImageButtonPushed'; % Create UIAxes3
app.UIAxes3 = uiaxes(app.UIFigure); title(app.UIAxes3, 'Title') xlabel(app.UIAxes3, 'X') ylabel(app.UIAxes3, 'Y') zlabel(app.UIAxes3, 'Z') app.UIAxes3.PlotBoxAspectRatio = [1.93129770992366 1 1]; app.UIAxes3.ButtonDownFcn = createCallbackFcn(app, @UIAxes3ButtonDown, true); app.UIAxes3.Position = [48 233 300 185]; % Create UIAxes4
app.UIAxes4 = uiaxes(app.UIFigure); title(app.UIAxes4, 'Title') xlabel(app.UIAxes4, 'X') ylabel(app.UIAxes4, 'Y') zlabel(app.UIAxes4, 'Z') app.UIAxes4.PlotBoxAspectRatio = [1.93129770992366 1 1]; app.UIAxes4.Position = [57 36 300 185]; % Show the figure after all components are created
app.UIFigure.Visible = 'on'; end end % App creation and deletion
methods (Access = public) % Construct app
function app = app3 % Create UIFigure and components createComponents(app) % Register the app with App Designer
registerApp(app, app.UIFigure) if nargout == 0 clear app end end % Code that executes before app deletion
function delete(app) % Delete UIFigure when app is deleted
delete(app.UIFigure) end endend
Best Answer