필터 지우기
필터 지우기

incorrect input size of image

조회 수: 14 (최근 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 CenterFile Exchange에서 Image Data Workflows에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by