how do i change the size of the image

6 visualizaciones (últimos 30 días)
Asha kumar
Asha kumar el 8 de Oct. de 2021
Respondida: Murad Alr el 22 de Abr. de 2022
Hi.
i want to train my data set(X-ray images) using googlenet..when i m tring to do m getting this error.Could you please help me..
Error using trainNetwork (line 184)
The training images are of size 224×224×1 but the input layer expects images of size 224×224×3.
Error in training (line 44)
net = trainNetwork(Resized_Training_Dataset, New_Network, Training_Options);
  5 comentarios
KSSV
KSSV el 8 de Oct. de 2021
Show us the whole code which you have tried.
Asha kumar
Asha kumar el 9 de Oct. de 2021
Dataset = imageDatastore('Dataset', 'IncludeSubfolders', true, 'LabelSource', 'foldernames');
[Training_Dataset, Validation_Dataset, Testing_Dataset] = splitEachLabel(Dataset, 0.7, 0.15, 0.15);
net = googlenet;
analyzeNetwork(net)
Input_Layer_Size = net.Layers(1).InputSize(1:2);
Resized_Training_Dataset = augmentedImageDatastore(Input_Layer_Size ,Training_Dataset);
Resized_Validation_Dataset = augmentedImageDatastore(Input_Layer_Size ,Validation_Dataset);
Resized_Testing_Dataset = augmentedImageDatastore(Input_Layer_Size ,Testing_Dataset);
Feature_Learner = net.Layers(142).Name;
Output_Classifier = net.Layers(144).Name;
Number_of_Classes = numel(categories(Training_Dataset.Labels));
New_Feature_Learner = fullyConnectedLayer(Number_of_Classes, ...
'Name', 'Vehicle Feature Learner', ...
'WeightLearnRateFactor', 10, ...
'BiasLearnRateFactor', 10);
New_Classifier_Layer = classificationLayer('Name', 'Thorax disease Classifier');
Network_Architecture = layerGraph(net);
New_Network = replaceLayer(Network_Architecture, Feature_Learner, New_Feature_Learner);
New_Network = replaceLayer(New_Network, Output_Classifier, New_Classifier_Layer);
analyzeNetwork(New_Network)
Minibatch_Size = 2;
Validation_Frequency = floor(numel(Resized_Training_Dataset.Files)/Minibatch_Size);
Training_Options = trainingOptions('sgdm', ...
'MiniBatchSize', Minibatch_Size, ...
'MaxEpochs', 6, ...
'InitialLearnRate', 3e-4, ...
'Shuffle', 'every-epoch', ...
'ValidationData', Resized_Validation_Dataset, ...
'ValidationFrequency', Validation_Frequency, ...
'Verbose', false, ...
'Plots', 'training-progress');
net = trainNetwork(Resized_Training_Dataset, New_Network, Training_Options);

Iniciar sesión para comentar.

Respuestas (2)

Image Analyst
Image Analyst el 8 de Oct. de 2021
You're passing in a gray scale image when it wants a color image. When you resized them you also needed to convert them to color, like
rgbImage = cat(3, grayImage, grayImage, grayImage);
  3 comentarios
Image Analyst
Image Analyst el 9 de Oct. de 2021
Get code snippets in the FAQ:
Asha kumar
Asha kumar el 9 de Oct. de 2021
okay.thank you

Iniciar sesión para comentar.


Murad Alr
Murad Alr el 22 de Abr. de 2022
Resized_Training_Image=augmentedImageDatastore(Input_Layer_Size,Training_Dataset,'ColorPreprocessing','gray2rgb');
Resized_Validation_Image=augmentedImageDatastore(Input_Layer_Size,Validation_Dataset,'ColorPreprocessing','gray2rgb');

Categorías

Más información sobre Image Data Workflows en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by