Resizing images to 224*224 for training VGG16 Model
조회 수: 16 (최근 30일)
이전 댓글 표시
Hi I'm training a VGG16 Model in the latest version of MATLAB R2023-a and I keep getting the same resizing error. I'm wondering if there is a new way to resize the images in a datastore in MATLAB or if the error is really on my improper execution of resizing in my code.
I have a folder of dataset with two sub folders which are my classes. This is the first part of my code with resizing:
% Load the dataset
imds = imageDatastore('DataSetFolder', 'IncludeSubfolders', true, 'LabelSource', 'foldernames');
% Define the desired input size
inputSize = [224 224];
% Resize images to 224x224
inputSize = [224 224];
augmentedIMDS = augmentedImageDatastore(inputSize, imds);
% Use the transform function to resize images
augmentedIMDS = transform(imds, @(x)imresize(x, inputSize));
% Split the dataset into training, validation, and test sets
[trainingData, validationData, testingData] = splitEachLabel(augmentedIMDS, 0.8, 01, 01);
% Load the pretrained VGG16 model
net = vgg16;
I keep getting error for this part of the code:
% Split the dataset into training, validation, and test sets
[trainingData, validationData, testingData] = splitEachLabel(augmentedIMDS, 0.8, 01, 01);
when i change the directory to imds the error is about resizing "Incorrect input size. the input size must have a size of [224 224 3]" and when i change it to augmentedIMDS the error is "Incorrect number or types of inputs or outputs for function 'splitEachLabel'."
댓글 수: 0
채택된 답변
David Ho
2023년 4월 5일
Hi Lalaine,
The "splitEachLabel" function only accepts ImageDatastores as an input. To make training, validation and test data of size [224 224], first split the imageDatastore, then transform it:
[imdsTrain, imdsValidation, imdsTest] = splitEachLabel(imds, 0.8, 0.1, 0.1);
inputSize = [224 224];
trainingData = augmentedImageDatastore(inputSize, imdsTrain);
validationData = augmentedImageDatastore(inputSize, imdsValidation);
testingData = augmentedImageDatastore(inputSize, imdsTest);
댓글 수: 0
추가 답변 (1개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Image Data Workflows에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!