what is wrong in this code..?
显示 更早的评论
I trained a faster rcnn object detector using the example code. the training process sucessfully finished but i came up with this error.when this code runs,
___________________________________
I = imread('image1.png');
% Run the detector.
[bboxes, scores] = detect(detector, I);
% Annotate detections in the image.
I = insertObjectAnnotation(I, 'rectangle', bboxes, scores);
figure
imshow(I)
....
then this error came
Error using insertObjectAnnotation
Expected LABEL to be nonempty.
Error in insertObjectAnnotation
Error in insertObjectAnnotation
Error in insertObjectAnnotation
Error in t27_trainFasterrcnn (line 139)
I = insertObjectAnnotation(I, 'rectangle', bboxes, scores);
please help me.
5 个评论
Star Strider
2018-3-19
The ‘scores’ variable seems to be empty.
Check that first, and if it is, determine the reason.
sam Boadi
2018-8-28
What type of detector are you using? Are you training your detector on a pre-trained model or you built a model from scratch? If you did build a model from scratch, you would need a lot of data. Otherwise, the model will not converge, hence the empty detection boxes,(it is like the model has not learnt anything). i will advise you to use a pertained model, like the Vgg16 or alexnet, and modify the input and output layers then you can take advantage of the features the middle layer has learnt, or better still, if you decide to build your model, use one of the known big datasets like the Cifar10 and then train your CNN on the dataset, after which you can take advantage of the features the middle layers have learnt and then train your detector, that is either FasterRcnn or Rcnn, using your dataset. I hope this helps otherwise, feel free to ask back.
KALYAN ACHARJYA
2018-8-29
Which Matlab Version you are using?
omar A.alghafoor
2020-5-29
2019a same error
Dave Eccles
2021-11-15
Same issue - was this resolved? Can this be solved by increasing the number of epochs used in the model?
回答(1 个)
Kanika Gupta
2020-6-24
The insertAnnotation function excepts labels to be passed as na arguments.
Try cloading labels using
[bboxes,scores,labels] = detect(detector,I)
Then call insertAnnotation function using
detectedI = insertObjectAnnotation(I,'Rectangle',bboxes,cellstr(labels));
Refer to this link for an example: Object detection using faster R CNN
类别
在 帮助中心 和 File Exchange 中查找有关 Object Detection 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!