select folder that also includes subfolders
6 ビュー (過去 30 日間)
David Glendale Ardenaso 2021 年 12 月 10 日
I'd like to ask is it possible for uigetfile to select a folder so that the contents subfolders inside would get selected too
Here's my CNN code so far:
myfolder = 'D:\School Files\2021 - 2022 1st semester\ECE21131\fall dataset';
dataDir = fullfile(myfolder);
imdir = fullfile(dataDir);
imds = imageDatastore(imdir, "IncludeSubfolders",true ,"LabelSource","foldernames");
[imdsTrain,imdsValidation] = splitEachLabel(imds,0.8,'randomized');
imageSize = [240 320 3];
layers = [
valfrequency = floor(numel(imdsTrain.Files)/64);
options = trainingOptions('adam', ...
net = trainNetwork(imdsTrain,layers,options);
YPred = classify(net,imdsValidation);
Yvalidation = imdsValidation.Labels;
accuracy = mean(YPred == Yvalidation);
idx = [1 4 8 12 16 20 24 28 32 36 40 41 42];
for i = 1:numel(idx)
I = readimage(imdsValidation,idx(i));
label = YPred(idx(i));
whereas the first line would be replaced by a uigetfile
the "fall dataset" folder has 6 subfolders which would also be fed into the system for the CNN
so basically, I'd like a way something like uigetfile that takes in all .png files within a folder, and its subfolders
回答 (1 件)
dpb 2021 年 12 月 10 日
There is no builtin gui tool that does more than multi-select on files within a single folder; you have to traverse the directory tree programmatically. There are several submissions on FEX that do it and while I don't have a link to it, I know I've seen a very nice demonstration posted here as well by one of the several other MVPs -- I don't recall which just now.
I've complained for years that the MATLAB builtin dir() function doesn't accept switches such as /s -- it would be so handy for such cases if it did -- instead, most of the time I just build the appropriate dir command string including the wildcard filename expression and pass it to the OS and then iterate through the resulting returned array.
Find more on Get Started with Deep Learning Toolbox 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!