- Organize the images in separate folders according to classes or categories.
- 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.
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
0 个评论
回答(1 个)
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:
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!
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Deep Learning Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!