필터 지우기
필터 지우기

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

조회 수: 11 (최근 30일)
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);

답변 (1개)

Sanjana
Sanjana 2023년 3월 27일
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
shazia
shazia 2023년 9월 11일
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

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Image Data Workflows에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by