How to load image sequence dataset which contain multiple subfolder then feed into RNN/LSTM model
2 views (last 30 days)
Show older comments
Datasets
The dataset contain 3 class (Gesture_1, Gesture_2, Gesture_3). Each class has 10 samples which are stored in a sub folder of the class. All the samples are in jpg format. (frame1.jpg,frame2.jpg) .
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1087870/image.jpeg)
Code
inputSize = [227 227 3];
numHiddenUnits = 128;
numClasses = 3;
%Load Dataset
imdsTrain = imageDatastore("D:\Database\GestureDataset","IncludeSubfolders",true,"LabelSource","foldernames");
[imdsTrain, imdsValidation] = splitEachLabel(imdsTrain,0.7);
augimdsTrain = augmentedImageDatastore(inputSize,imdsTrain);
augimdsValidation = augmentedImageDatastore(inputSize,imdsValidation);
layers = [
sequenceInputLayer(inputSize,'Name','input')
flattenLayer('Name','flatten')
lstmLayer(numHiddenUnits,'OutputMode','last','Name','bi-lstm')
fullyConnectedLayer(numClasses, 'Name','fc')
softmaxLayer('Name','softmax')
classificationLayer('Name','classification')];
lgraph = layerGraph(layers);
opts = trainingOptions('sgdm', ...
'MiniBatchSize',8, ...
'MaxEpochs',16, ...
'InitialLearnRate',0.0001, ...
'Shuffle','every-epoch', ...
'ValidationData',augimdsValidation, ...
'ValidationFrequency',valFrequency, ...
'Verbose',false, ...
'Plots','training-progress');
net = trainNetwork(augimdsTrain,lgraph,opts);
Problem
I'm able to load the dataset and train the model using the imageDatastore function, but the subfolder of each class will also consider as class using this method to load dataset.
How load the dataset which have multiple subfolder for each class, then feed into the model. (3 class, 10 samples each class)
0 Comments
Answers (0)
See Also
Categories
Find more on Image Data Workflows in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!