Read image to trained neural network
3 views (last 30 days)
Show older comments
Hello,
I have trained neural network. I want to put there picture to see results. I have saved my trained neural network. I load it but I don't know how to pu there image to get results. My first layer is
imageInputLayer([65 100 1]) %first input layer
net = network; %how I create network
save network %how I save network
load ('network.mat'); %how I load network
I put there image but I get always this error. Images are same processed as trained images. They have same sizes. They are all in grayscale.
%Import input and put it into network
input = imread('image.png');
output = network(image(input));
%error
Error using false
Size inputs must be numeric.
Error in network>new_network (line 81)
if nargin < 4, inputConnect = false(numLayers,numInputs); end
Error in network (line 68)
net = new_network(in1);
Or if I put there it like numbers.
%Import input and put it into network
input = im2double(imread('image.png'));
output = network(input);
%error
Error using false
Size inputs must be scalar.
Error in network>new_network (line 81)
if nargin < 4, inputConnect = false(numLayers,numInputs); end
Error in network (line 68)
net = new_network(in1);
Please help I tried to put it there like array but nothing helps me.
0 Comments
Answers (1)
Nagasai Bharat
on 8 Mar 2021
Hi,
From my understanding you are trying to input an image into a trained network. The problem I think is due to the dimensions of the test images you are inputting. As you do not mention it is a Convolutional Neural Network then I suppose you need to flatten the image(row or column matrix) before passing in into the trained network.
Or something like this should also help.
I = imread("peppers.png");
inputSize = net.Layers(1).InputSize;
I = imresize(I,inputSize(1:2));
0 Comments
See Also
Categories
Find more on Deep Learning Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!