Read image to trained neural network

3 ビュー (過去 30 日間)
Martin Hájek
Martin Hájek 2021 年 3 月 3 日
回答済み: Nagasai Bharat 2021 年 3 月 8 日
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.

回答 (1 件)

Nagasai Bharat
Nagasai Bharat 2021 年 3 月 8 日
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));

カテゴリ

Help Center および File ExchangeDeep Learning Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by