YOLOv2深層学習​を使用したオブジェク​トの検出での質問

21 views (last 30 days)
HY
HY on 6 Jul 2020
Commented: HY on 7 Jul 2020
ニューラルネットワーク初心者です。今回、MATLABにあるYOLOv2深層学習を使用したオブジェクトの検出(https://jp.mathworks.com/help/vision/ug/train-an-object-detector-using-you-only-look-once.html)の例に則って道路標識を検出できるようなYOLOを作成しようと、以下のコードを実装しました。
data=load('H3.mat'); %ラベル付けしたデータ
SignDataset = data.H3;
SignDataset.imageFilename = fullfile(pwd,SignDataset.imageFilename);
rng(0);
shuffledIndices = randperm(height(SignDataset));
idx = floor(0.8 * length(shuffledIndices) );
trainingDataTbl = SignDataset(shuffledIndices(1:idx),:);
testDataTbl = SignDataset(shuffledIndices(idx+1:end),:);
imdsTrain = imageDatastore(trainingDataTbl{:,'imageFilename'});
bldsTrain = boxLabelDatastore(trainingDataTbl(:,2:end-1));%標識の種類が複数あるため(:,2:end-1)
imdsTest = imageDatastore(testDataTbl{:,'imageFilename'});
bldsTest = boxLabelDatastore(testDataTbl(:,2:end-1));
trainingData = combine(imdsTrain,bldsTrain);
testData = combine(imdsTest,bldsTest);
data = read(trainingData);
I = data{1};
bbox = data{2};
annotatedImage = insertShape(I,'Rectangle',bbox);
annotatedImage = imresize(annotatedImage,2);
figure
imshow(annotatedImage)
inputSize = [224 224 3];
numClasses = width(SignDataset)-1;
trainingDataForEstimation = transform(trainingData,@(data)preprocessData(data,inputSize));
numAnchors = 7;%size(anchorBoxes,1);
[anchorBoxes, meanIoU] = estimateAnchorBoxes(trainingDataForEstimation, numAnchors)
imshow(annotatedImage)までは、問題なく実行されるのですが、アンカーボックスの推定におけるコードを実行すると以下のようなエラーが発生してしまいます。原因も書かれていますが、よく分かりませんでした。これはどのように対処したら良いでしょうか。回答していただければ幸いです。
よろしくお願いいたします。
エラー: estimateAnchorBoxes>iCheckBoxesFromDatastore (line 215)
Invalid transform function defined on datastore.
エラー: estimateAnchorBoxes>iParseInputs (line 168)
boxes = iCheckBoxesFromDatastore(datastore);
エラー: estimateAnchorBoxes (line 136)
[boxes, numAnchors, params] = iParseInputs(datastore, numAnchors,
varargin{:});
エラー: mobilev2 (line 43)
[anchorBoxes, meanIoU] = estimateAnchorBoxes(trainingDataForEstimation,
numAnchors)
原因:
関数 'preprocessData' (タイプ'cell' の入力引数) が未定義です。

Accepted Answer

Kenta
Kenta on 6 Jul 2020
おそらく、補助関数のファイルpreprocessData が同じディレクトリに存在しないためと思います。例を開いたときに、preprocessData というファイルが見つかると思うので、それを同じディレクトリにあることを確認して実行しなおしてみてください。
  3 Comments
Kenta
Kenta on 7 Jul 2020
失礼しました。preprocessDataは、補助関数としておなじライブスクリプト上にあるようですね。ctrl+enterで対象のセクションを実行するか、RUNボタンやF5ボタンで全体を実行するとその関数をうまく認識して走ると思います。
HY
HY on 7 Jul 2020
丁寧に回答いただき、ありがとうございました。

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!