How to split dataset of 3300 image into Training and Testing Datasets?

1 次查看(过去 30 天)
I am workin on face Recognition system using CNN, I have 3300 human face images how can I split them in to Training and testing dataset using this deep leaning function [TrainData,TestData] = SplitEachLabel. I want to have 1843 traing data and 1457 testing data. I need your Assistance.

回答(1 个)

Tejas
Tejas 2025-7-9
Hello Sanusi,
To split the image dataset, the recommend approach is to store the images using the "imageDatastore" function and use the "splitEachLabel" function to split the images.
Here are steps to acheive the desired worflow:
  • Load the images using the "imageDatastore" function.
imds = imageDatastore(rootFolder, 'IncludeSubfolders', true, 'LabelSource', 'foldernames');
  • Find the percentage of images to be split into training dataset.
totalImages = numel(imds.Files);
numTrain = 1843;
numTest = 1457;
trainFraction = numTrain / totalImages;
  • Use the "splitEachLabel" function to split the image dataset.
[TrainData, TestData] = splitEachLabel(imds, trainFraction, 'randomized');
For more examples on how the image dataset can be split, refer to this documentation: https://www.mathworks.com/help/matlab/ref/matlab.io.datastore.imagedatastore.spliteachlabel.html#bu48dhj-1-p .

标签

产品


版本

R12.1

Community Treasure Hunt

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

Start Hunting!

Translated by