Borrar filtros
Borrar filtros

How to load and predict using my trained deep neural network in MATLAB GUI window?

11 visualizaciones (últimos 30 días)
hi!
I have a trained deep neural network using my own dataset. How do i load my trained network in the GUI and predict the output using any random image. I have developed GUI using App Desinger. Please help
Tried to load network using different ways:
One way-
trained_net_vars = load('E:\Subject\newtrain_05_12.mat');
handles.neural_net = trained_net_vars.net;
guidata(hObject, handles)
Second way -
% [f, p, i]=uigetfile('*.mat');
% f_name=fullfile(p,f);
% a=load(f_name);
% A_cell = struct2cell(a);

Respuestas (1)

Sanjana
Sanjana el 27 de Mzo. de 2023
Hi,
I understand that you're facing difficulties in creating a GUI window to load a pretrained model and perform predictions on random images, and then display the prediction. Here is a possible solution:
Firstly, you can add a “button” and an “Image” component to the canvas in the App Designer. Then, write a “callback” function for the “button” component as follows:
function LoadImageButtonPushed(app, event)
net = load('modelName.mat');
[filename, pathname] = uigetfile({'*.jpg;*.png;*.bmp', 'Image files'}, 'Select an image');
filepath = fullfile(pathname, filename);
app.Image.ImageSource = filepath;
img = imread(filepath);
prediction = predict(net,img);
app.OutputLabel.Text = prediction;
end
Hope this helps!
  1 comentario
shazia
shazia el 11 de Sept. de 2023
hello , if i want to pass my test data (not image) and the genrated trained net to GUI for prediction, how i would do that could you plz elobrate.
thank you

Iniciar sesión para comentar.

Categorías

Más información sobre Image Data Workflows en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by