how to import images into the rquired type of datasets to "inputs" and "targets" in neural network pattern recognition

1 次查看(过去 30 天)
i need help into how to upload my images around 6000 images into the "inputs" and "targets" i need to know how to convert the images into the required datasets type

回答(1 个)

Milan Bansal
Milan Bansal 2023-9-20
Hi,
As per my understanding, you want to import the image dataset into MATLAB and split the dataset into "inputs" and "targets".
Kindly follow the steps given below in order to import the image dataset:
  1. Organize the images in separate folders according to classes or categories.
  2. Use the "imageDatastore" function in MATLAB to import the Dataset. This will import all the images and set the labels according to the folder names. Refer to the following code.
dataPath = 'pathToTheDataset'; % path to the folder containing your images
% Create an ImageDatastore object
imds = imageDatastore(dataPath, 'LabelSource', 'foldernames', "IncludeSubfolders",true);
3. The images and the corresponding labels can be extracted using the following code:
imageFiles = imds.Files;
Labels = imds.Labels;
4. The dataset may be splitted into "trainSet" and "testSet" using "splitEachLabel" function in MATLAB.
% Specify the training and testing split ratio
trainRatio = 0.9;
testRatio = 0.1;
% Split the dataset
[trainSet, testSet] = splitEachLabel(imds, trainRatio, testRatio, 'randomized');
Refer to the following documentation link to learn more about "imageDatastore" function:
Hope it helps!

类别

Help CenterFile Exchange 中查找有关 Deep Learning Toolbox 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by