How to load and predict using my trained deep neural network in MATLAB GUI window?
9 ビュー (過去 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!