- data — 出力データにdata「画像(input)」と「カテゴリカルラベル(response)」が含まれています
- info — 読み取りデータに関する情報に「カテゴリカルラベル(Label)」が含まれています(read関数のみ)
augmentedImageDatastoreに格納した変数にインデックスorプロパティ(変数.label)ができなくて困っています。可能ですか?
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
takmakome
il 1 Lug 2022
Commentato: Atsushi Ueno
il 2 Lug 2022
imds = imageDatastore('機械学習500',"IncludeSubfolders",true,"LabelSource","foldernames");
[xtrain,xval] = splitEachLabel(imds,0.5,"randomized");
xtrainimg = augmentedImageDatastore([128 128 1],xtrain,"ColorPreprocessing","gray2rgb");
xvalimg = augmentedImageDatastore([128 128 1],xval,"ColorPreprocessing","gray2rgb");
whos xval
whos imds
T = imshow(readimage(imds,1))
whos T
Dt= zeros(128,128,1,2500);
Dv = zeros(128,128,1,2500);
for i=1:numel(xtrainimg.Files)
ytraining = xtrainimg.label(i); <ー%質問箇所.labelをつけたい!ができないので他のアイデアをご教授してほ しいです!
yval = xvalimg.label(i)
I = imread (xtrainimg.Files{i});
Dt(:,:,:,i) = I;
II = imread (xvalimg.Files{i});
Dv(:,:,:,i) = II;
end
Dt(:,:,:,3)
[Dt,~,ytraining] = digitTrain4DArrayData;
[Dv,~,yval] = digitTest4DArrayData;
したいことは画像の名前と画像を紐づけしたいということです。
0 Commenti
Risposta accettata
Atsushi Ueno
il 1 Lug 2022
Modificato: Atsushi Ueno
il 2 Lug 2022
imds = imageDatastore(fullfile(matlabroot,"toolbox","matlab"),"IncludeSubfolders",true,"FileExtensions",".tif","LabelSource","foldernames");
xtrainimg = augmentedImageDatastore([128 128],imds,'ColorPreprocessing','rgb2gray'); % サンプルのimageDatastoreデータ
%[data,info] = read(xtrainimg) % 【追加】予めaugmentedImageDatastoreのオブジェクト関数read()を実行し出力を得る【コメントを受けコメントアウト】
data = readall(xtrainimg) % 【コメント受け追記】予めaugmentedImageDatastoreのオブジェクト関数readall()を実行し出力を得る
for i=1:numel(xtrainimg.Files)
ytraining = data.response(i) % <ー%質問箇所.labelをつけたい!ができないので他のアイデアをご教授してほしいです!
% ytraining = info.Label(i) % 【コメントを受けコメントアウト】
end % data.responseもinfo.Labelも同じデータの様です
4 Commenti
Atsushi Ueno
il 2 Lug 2022
- readall関数:augmentedImageDatastore から全てのデータを読み取る
- read関数:augmentedImageDatastore からMiniBatchSize分のデータを読み取る
MiniBatchSize をNumObservationsと同じ数にしてread関数を使うのはreadall関数を使うのと同じ事で、データ数が膨大な場合エラーになる事が想定されます。その為のread関数で分割するんですね。その際、読み込んだブロック数を管理するhasdata関数を使います。
imds = imageDatastore(fullfile(matlabroot,"toolbox","matlab"),"IncludeSubfolders",true,"FileExtensions",".tif","LabelSource","foldernames");
xtrainimg = augmentedImageDatastore([128 128],imds,'ColorPreprocessing','rgb2gray'); % サンプルのimageDatastoreデータ
ytraining = [];
while hasdata(xtrainimg)
data = read(xtrainimg);
ytraining = [ytraining; data.response];
end
ytraining
Atsushi Ueno
il 2 Lug 2022
>ミニバッチサイズを変更したら解決しますか?
NOの方が適する回答だと思います。ミニバッチサイズを十分に大きくすればread関数でも全てのデータを読み取る事が出来ますが、readall関数があるのでその必要はありません。それに、全ての情報を一度に読み込むとメモリ不足でエラーになる事が想定されます。その為のデータストアなのですから。
>正しいミニバッチサイズの変更の仕方をご教授してほしいです。
単にxtrainimg.MiniBatchSize = ***とすれば変更可能です。MiniBatchSize に記載があるように「学習、予測、および分類では、trainingOptions で定義された MiniBatchSize に設定なる」様です。
imds = imageDatastore(fullfile(matlabroot,"toolbox","matlab"),"IncludeSubfolders",true,"FileExtensions",".tif","LabelSource","foldernames");
xtrainimg = augmentedImageDatastore([128 128],imds,'ColorPreprocessing','rgb2gray'); % サンプルのimageDatastoreデータ
xtrainimg.MiniBatchSize = 1
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Deep Learning Toolbox in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!