incorrect input size of image

15 ビュー (過去 30 日間)
new_user
new_user 2021 年 12 月 21 日
コメント済み: Image Analyst 2021 年 12 月 21 日
images = imageDatastore('call', 'IncludeSubfolders',true, 'LabelSource','foldernames');
[Training_image, Validation_image] = splitEachLabel(images, 0.6); %split images in 75, 25% use 'randomized' also
Input_Layer_Size = net.Layers(1).InputSize(1:2); % (1:2 = 1st 2 elemnts of input size), input layer size stored in this variable (Input_layer_size)
Resized_Training_image = augmentedImageDatastore(Input_Layer_Size, Training_image, 'ColorPreprocessing','gray2rgb');
net = trainNetwork(Resized_Training_image, New_Network, Training_Options) % training the network
trainall=[]
for i=1:2200
i
a=readimage(Resized_Training_image,i);
[m n c]=size(a);m
Error using DAGNetwork/activations (line 262)
The spatial dimension sizes [169 300 3] of the input images to layer 'input_1' must be greater than or equal to the corresponding
minimum input dimension sizes of the layer [224 224 3].
%% what should i do to insert the resized taining image in the for loop operation.

採用された回答

Image Analyst
Image Analyst 2021 年 12 月 21 日
Replace
a=readimage(Resized_Training_image,i);
[m n c]=size(a);m
with
rgbImage = readimage(Resized_Training_image, i);
[rows, columns, numberOfColorChannels] = size(rgbImage);
fprintf('Original image #%d has %d rows, %d columns, and %d color channels.\n', ...
i, rows, columns, numberOfColorChannels)
if rows ~= 224 || columns ~= 224
% Need to resize laterally to 224 by 224.
rgbImage = imresize(rgbImage, [224, 224]);
end
if numberOfColorChannels == 1
% It's gray scale. Need to convert to color.
rgbImage = ind2rgb(rgbImage, gray(256));
end
  3 件のコメント
new_user
new_user 2021 年 12 月 21 日
@Image Analyst kindly sugest it's still showing error
Image Analyst
Image Analyst 2021 年 12 月 21 日
I don't know. It's difficult for me to reproduce without your images and your folder structure. But the error is now in readimage() which comes before any of my resizing code, so the error lies in your code. Maybe try reading the image this way instead
fullFileName = images.Files{i};
a = imread(fullFileName);
and again I ask you to use descriptive filenames. No one like looking at code that is an alphabet soup of single letter variables. It's maybe not so bad with a very short program but once you get dozens of lines, it can get confusing knowing what each letter actually represents without searching back over the code.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeImage Data Workflows についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by