How to load and predict using my trained deep neural network in MATLAB GUI window?
8 次查看(过去 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);
0 个评论
回答(1 个)
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
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 Center 和 File Exchange 中查找有关 Image Data Workflows 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!