필터 지우기
필터 지우기

Read dataset file name only

조회 수: 1 (최근 30일)
Eiman Hakimy
Eiman Hakimy 2022년 1월 9일
댓글: Walter Roberson 2022년 1월 9일
Hello, i want to ask how i want my code can read dataset folder name only like the folder name like 0,1,2,3,4,5
the dataset i choose is from = https://www.kaggle.com/ayuraj/asl-dataset
Right now i can only read image name only. So, i want the system can read and call dataset folder name.
Here my code
SelectFile.m
%N = 'C:\Users\USER\Documents\MATLAB\Project\asl_dataset\asl_dataset';
function d = SelectFile(A,N)
M = 6; % number of class [0 to 5 ]
cnt(1:M)=0; % counter for each class
% get all filenames in the data directory
D = dir(A);
% extract only N file
d =D(1:N);
% see the statistic of each class pattern
for i=1:N
fn = D(i).asl_dataset; %file name
x = fn(38); % extract target from filename
%find the distribution of file being extracted per class
if (x == '0')
cnt(1)=cnt(1)+1;
elseif (x=='1')
cnt(2)=cnt(2)+1;
elseif (x=='2')
cnt(3)=cnt(3)+1;
elseif (x=='3')
cnt(4)=cnt(4)+1;
elseif (x=='4')
cnt(5)=cnt(5)+1;
elseif (x=='5')
cnt(6)=cnt(6)+1;
end
end
cnt
bar([0 1 2 3 4 5],cnt);
title('statistic number of pattern per class');
text(0:5,cnt,num2str(cnt'),'vert','bottom','horiz','center');
end
sample.m
D = 'C:\Users\USER\Documents\MATLAB\Project\asl_dataset\asl_dataset';
d1 = SelectFile(D,360);
[Dat,Trgt] = FExtraction(d1);
net = NNTrain(Dat,Trgt);
%Test NN using Test Patterns
%D = 'C:\RESEARCH\pattern\fingers\test\*.png';
D = 'C:\Users\USER\Documents\MATLAB\Project\asl_dataset\asl_dataset';
d2 = SelectFile(D,60);
[Data,Target] = FExtraction(d2);
O = NNTest(net,Data,Target);
disp('recognition rate is : ');
disp(O);

채택된 답변

Walter Roberson
Walter Roberson 2022년 1월 9일
D = 'C:\Users\USER\Documents\MATLAB\Project\asl_dataset\asl_dataset';
dinfo = dir(D);
dinfo(ismember({dinfo.name}, {'.', '..'})) = []; %remove . and ..
dinfo(~[dinfo.isdir]) = []; %remove any files leaving only directories
foldernames = {dinfo.name};
  댓글 수: 2
Eiman Hakimy
Eiman Hakimy 2022년 1월 9일
hello walter thank you for answering.. so for this code i just need to add or replace it ?
Walter Roberson
Walter Roberson 2022년 1월 9일
"So, i want the system can read and call dataset folder name."
It does that part only. It looked to me as if you only wanted to know the names of the folders that were present.
Perhaps you have a different need. Perhaps you want to know, for each file, which folder it came from? That is possible

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Convert Image Type에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by