フィルターのクリア

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 Center および File ExchangeConvert Image Type についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by