Error: Undefined function 'preprocessData' for input arguments of type 'cell'.
古いコメントを表示
I am implementing MATLAB 2019b examle "Object Detection Using YOLO v2 Deep Learning"(https://www.mathworks.com/help/vision/ug/train-an-object-detector-using-you-only-look-once.html), but when I run the following line of code:
anchorBoxes = estimateAnchorBoxes(preprocessedTrainingData ,numAnchors)
it gives me error as mentioned in title. Thanks for helping out.
A small piece of code from example is mentioned below:
%...............Code..................................%
unzip vehicleDatasetImages.zip
data = load('vehicleDatasetGroundTruth.mat');
vehicleDataset = data.vehicleDataset;
rng(0)
shuffledIdx = randperm(height(vehicleDataset));
idx = floor(0.6 * height(vehicleDataset));
trainingDataTbl = vehicleDataset(shuffledIdx(1:idx),:);
imdsTrain = imageDatastore(trainingDataTbl{:,'imageFilename'});
bldsTrain = boxLabelDatastore(trainingDataTbl(:,'vehicle'));
trainingData = combine(imdsTrain,bldsTrain);
inputSize = [224 224 3];
preprocessedTrainingData = transform(trainingData, @(data)preprocessData(data,inputSize));
numAnchors = 5;
anchorBoxes = estimateAnchorBoxes(preprocessedTrainingData ,numAnchors)
%.................................................................................................................................................%
1 件のコメント
Harshveer Singh
2020 年 5 月 6 日
I am also getting the similar error. Unable to resolve it. I copied all the supporting function into a .m file. I then tried calling the function through its name in the command window but unable to do so. Someone please help how to go ahead with it.
採用された回答
その他の回答 (2 件)
michael scheinfeild
2020 年 3 月 7 日
some fix needed in preprocessing , first round and be sure it is positive top left , i think maybe check box outside image will be good , i didnt did it . also rounding of box cordinates is important !. also see that in image we have several bounding boxes and we check them all !
function data = preprocessData(data,targetSize)
% Resize image and bounding boxes to the targetSize.
scale = targetSize(1:2)./size(data{1},[1 2]);
data{1} = imresize(data{1},targetSize(1:2));
boxEstimate=round(data{2});
boxEstimate(:,1)=max(boxEstimate(:,1),1);
boxEstimate(:,2)=max(boxEstimate(:,2),1);
data{2} = bboxresize(boxEstimate,scale);
end
9 件のコメント
michael scheinfeild
2020 年 3 月 7 日
same fo the next function
function B = augmentData(A)
% Apply random horizontal flipping, and random X/Y scaling. Boxes that get
% scaled outside the bounds are clipped if the overlap is above 0.25. Also,
% jitter image color.
B = cell(size(A));
I = A{1};
sz = size(I);
if numel(sz)==3 && sz(3) == 3
I = jitterColorHSV(I,...
'Contrast',0.2,...
'Hue',0,...
'Saturation',0.1,...
'Brightness',0.2);
end
% Randomly flip and scale image.
tform = randomAffine2d('XReflection',true,'Scale',[1 1.1]);
rout = affineOutputView(sz,tform,'BoundsStyle','CenterOutput');
B{1} = imwarp(I,tform,'OutputView',rout);
% Apply same transform to boxes.
boxEstimate=round(A{2});
boxEstimate(:,1)=max(boxEstimate(:,1),1);
boxEstimate(:,2)=max(boxEstimate(:,2),1);
[B{2},indices] = bboxwarp(boxEstimate,tform,rout,'OverlapThreshold',0.25);
B{3} = A{3}(indices);
% Return original data only when all boxes are removed by warping.
if isempty(indices)
B = A;
end
end
Scot Bishop
2020 年 3 月 15 日
The modified functions were extremely helpful! Thank you Michael!
ahmed shahin
2020 年 3 月 26 日
thanks you it is working now
Jeremy Bulleid
2020 年 7 月 13 日
Thanks Michael, I had a similar problem and your solution works well.
庆 王
2020 年 9 月 3 日
thanks a lot , it works
Gyubin Hwang
2021 年 2 月 4 日
you saved the day. thank you!
泽宇 王
2021 年 3 月 30 日
Thank you, sir.
Vladimir Socha
2021 年 8 月 27 日
cool thx
userlifeline
2021 年 8 月 28 日
THX!!!
Samuel Manickavasagam S
2020 年 1 月 23 日
0 投票
Tejas Phutane i too have this error
1 件のコメント
TEJAS PHUTANE
2020 年 3 月 2 日
I tried verifying 1000 images in batches of 50 images and found errors in total 60 images.This method solved my problem
カテゴリ
ヘルプ センター および File Exchange で Object Detection についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!