画像認識(深層学習)​におけるオクルージョ​ン感度について

11 views (last 30 days)
勇輝 岡安 
勇輝 岡安  on 5 Apr 2021
CNNで学習、分類をさせて、その分類時の特徴抽出の様子をオクルージョン感度を用いて表現しようと考えております。
しかし、以下のようなソースコードで実行するとエラーが出ます。readimage内のallTestは、augmentedImageDatastoreにあるものです。
関数readimageは、augmentedImageDatastoreに対応していないのでしょうか?もし、そうであるならば併せて正しいコードをご教示ください。
よろしくお願いいたします。
ct1=0;ct2=0;ct3=0;
for i=1:length(imdsValidation.Labels)
img = readimage(allTest, i);
[classfn, score] = classify(net,img);
if classfn == imdsValidation.Labels(i)
switch classfn
case 'Bengal'
ct1 = ct1 + 1;
if ct1 == 1
scoreMap1 = occlusionSensitivity(net,img,classfn);
else
scoreMap1 = scoreMap1 + occlusionSensitivity(net,img,classfn);
end
case 'Birman'
ct2 = ct2 + 1;
if ct2 == 1
scoreMap2 = occlusionSensitivity(net,img,classfn);
else
scoreMap2 = scoreMap2 + occlusionSensitivity(net,img,classfn);
end
case 'Bombay'
ct3 = ct3 + 1;
if ct3 == 1
scoreMap3 = occlusionSensitivity(net,img,classfn);
else
scoreMap3 = scoreMap3 + occlusionSensitivity(net,img,classfn);
end
end
end
end

Answers (1)

Naoya
Naoya on 8 Apr 2021
augmentedImageDatastore のドキュメント のオブジェクト関数群を確認できますが、同オブジェクトに対する readimage メソッドはありませんので、代わりに read メソッドを使って1枚ずつ読み込んでみてください。
img = read(allTest);
その際、事前に augmentedImageDatastore 側の MiniBatchSize プロパティの値は 1 に設定した方がよいと思います (既定では 128枚の画像を読み込むような設定となっています)。
allTest.MiniBatchSize = 1;
また、 上記 read コマンドで得られる戻り値 img は Table型となりますので、
img = img.input{1};
などで通常の行列として抽出してください。
  1 Comment
勇輝 岡安 
勇輝 岡安  on 9 Apr 2021
無事、特徴抽出することができました。
教えていただき、ありがとうございます。

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!