The input images for activations must be of size equal to or greater than [224 224 3].

my code is:
augmentedTrainset=augmentedImageDatastore(imagesize,...
trainset,'ColorPreprocessing','rgb2gray');
augmentedTestset=augmentedImageDatastore(imagesize,...
testset,'ColorPreprocessing','rgb2gray');
featureLayer = 'fc1000';
trainingFeatures = activations(net, augmentedTrainset, featureLayer, ...
'MiniBatchSize', 39, 'OutputAs', 'columns');
[224 224 3] image size
And I take an error as "The input images for activations must be of size equal to or greater than [224 224 3]."
Why I'm taking this error, how can I fix it?

2 Comments

aitali - does your test set contain any images that are smaller than 224x224x3?
yes the size of all images i test is 224x224x3

Sign in to comment.

 Accepted Answer

Hi,
Is your image [224 224 3] or of different order?
And try the below code once
augmentedTrainset=augmentedImageDatastore(imagesize,...
trainset);
augmentedTestset=augmentedImageDatastore(imagesize,...
testset);
featureLayer = 'fc1000';
trainingFeatures = activations(net, augmentedTrainset, featureLayer, ...
'MiniBatchSize', 39, 'OutputAs', 'columns');

6 Comments

Yes the size of my image is [224 224 3]
thanks for your answer , doesn't work for me
can you try by removing the 'ColorPreprocessing' name value argument.
The ColorPreprocessing in this case is reducing the channnels from 3 to 1. If all all the images have the same number of channels(i.e 3 in your case) then no processing is required. It is generally used when you have a mix of gray scale and color images(specifically RGB) and to make sure that all output images have the same number of channels . I have updated the above answer accordingly.
Hope that helps!
Thanks sir!
that works for me
augmentedTrainset=augmentedImageDatastore(imagesize,...
trainset,'ColorPreprocessing','gray2rgb');
augmentedTestset=augmentedImageDatastore(imagesize,...
testset,'ColorPreprocessing','gray2rgb');
featureLayer = 'fc1000';
trainingFeatures = activations(net, augmentedTrainset, featureLayer, ...
'MiniBatchSize', 39, 'OutputAs', 'columns');
augmentedTrainset=augmentedImageDatastore(imagesize,...
trainset,'ColorPreprocessing','gray2rgb');
augmentedTestset=augmentedImageDatastore(imagesize,...
testset,'ColorPreprocessing','gray2rgb');
featureLayer = 'fc1000';
trainingFeatures = activations(net, augmentedTrainset, featureLayer, ...
'MiniBatchSize', 39, 'OutputAs', 'columns');
The ColorPreprocessing name value can be removed. As all the images already has 3 channels no processing occurs.
yes exactly sir that work for me soo but i didn't py attention that i have some image has 1 channel so the fault that i make 'rgb2gray' in place of 'gray2rgb'
thanks sir
for your help

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!