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

1 visualización (últimos 30 días)
Sanusi Abu Darma
Sanusi Abu Darma el 9 de Mayo de 2021
Respondida: Tejas el 9 de Jul. de 2025
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.

Respuestas (1)

Tejas
Tejas el 9 de Jul. de 2025
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 .

Etiquetas

Productos


Versión

R12.1

Community Treasure Hunt

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

Start Hunting!

Translated by