MATLAB Answers

Using a trained neural network in app designer for image classification

44 views (last 30 days)
Malina Balint
Malina Balint on 1 Apr 2021
Edited: Yogini Prabhu on 25 May 2021 at 13:37
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
properties (Access = private)
net % neural network
methods (Access = private)
function startupfunc(app) = load('mini_date2.mat'); =;
app.filepath = 'E:/LICENTA/BD_Skin_Cancer_Screening/';
app.filepath = app.filepath.filepath;
% Callbacks that handle component events
methods (Access = private)
% Button pushed function: AnalyzeImageButtonPushed_2
function AnalyzeImageButtonPushed_2Pushed(app, event)
imds = imageDatastore(app.filepath);
[labels]= classify(,imds);
imshow([labels, imd],'Parent', app.UIAxes4);
% 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);
% 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';
% App creation and deletion
methods (Access = public)
% Construct app
function app = app3
% Create UIFigure and components
% Register the app with App Designer
registerApp(app, app.UIFigure)
if nargout == 0
clear app
% Code that executes before app deletion
function delete(app)
% Delete UIFigure when app is deleted

Accepted Answer

Anshika Chaurasia
Anshika Chaurasia on 19 Apr 2021
Yogini Prabhu
Yogini Prabhu on 24 May 2021 at 23:56
Hi Anshika
I am aware that this comment is to a specific question by another Matlab client ,
however I wanted to reach to u.
I had posted question about NN, and expected Mr. Greg Heath to answer it, but since I dint get any answers, and here was the only place to find you. please oblige
this is the question: "Please let know how is Cross -validation implemented in the the nprtool (Deep Learning Toolbox)?"
"Please let know how is Cross -validation implemented in the the code of classification of patterns at nprtool (Deep Learning Toolbox)?"
Please respond as soon as possible!
thanking you in advance

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!