How to load image sequence dataset which contain multiple subfolder then feed into RNN/LSTM model
조회 수: 2 (최근 30일)
이전 댓글 표시
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
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Image Data Workflows에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!