why my YOLO v2 detector produces no results?
Show older comments
i use a YOLO v2 detector to detect cells in images like this one (i used this specific one to train the detector) of two different types to train the detector.
i give the detector the boxes as in figure.

i use the following lines to train the detector:
T=table(names2',roi1',roi2');
%names2' contains the image file path
%roi1' and roi2' are the matrices M*4 with the [x,y,width,height] of %boxes containing the cells
numClasses=width(T)-1;
anchorBoxes = [
40 40
60 60
80 80
100 100
];
baseNetwork = resnet50;
featureLayer = 'activation_40_relu';
imageSize = [1080 1920 3];
options = trainingOptions('sgdm', ...
'MiniBatchSize', 16, ....
'InitialLearnRate',1e-3, ...
'MaxEpochs',10,...
'CheckpointPath', tempdir, ...
'Shuffle','every-epoch');
lgraph = yolov2Layers(imageSize,numClasses,anchorBoxes,baseNetwork,featureLayer);
[detector,info] = trainYOLOv2ObjectDetector(T,lgraph,options)
----------------------------------------------------------------------------------------------------------------
i get the following outputs:
Training on single CPU.
|========================================================================================|
| Epoch | Iteration | Time Elapsed | Mini-batch | Mini-batch | Base Learning |
| | | (hh:mm:ss) | RMSE | Loss | Rate |
|========================================================================================|
| 1 | 1 | 00:00:43 | 3.32 | 11.0 | 0.0010 |
| 10 | 10 | 00:07:02 | 1.16 | 1.4 | 0.0010 |
|========================================================================================|
detector =
yolov2ObjectDetector with properties:
ModelName: 'Var2'
Network: [1×1 DAGNetwork]
ClassNames: {'Var2' 'Var3'}
AnchorBoxes: [4×2 double]
TrainingImageSize: [1080 1920]
info =
struct with fields:
TrainingLoss: [11.0190 5.5807 4.0740 3.1020 2.1962 1.3285 1.3990 1.5349 1.6414 1.3550]
TrainingRMSE: [3.3195 2.3623 2.0184 1.7613 1.4820 1.1526 1.1828 1.2389 1.2812 1.1641]
BaseLearnRate: [0.0010 0.0010 0.0010 0.0010 0.0010 0.0010 0.0010 0.0010 0.0010 0.0010]
a =
yolov2ObjectDetector with properties:
ModelName: 'Var2'
Network: [1×1 DAGNetwork]
ClassNames: {'Var2' 'Var3'}
AnchorBoxes: [4×2 double]
TrainingImageSize: [1080 1920]
----------------------------------------------------------------------------------------------------------------
when i use the detector to a similar image i get no results. The [bboxes, scores] matrix is empty.
what is my error?
Accepted Answer
More Answers (2)
Srivardhan Gadila
on 14 Aug 2019
Edited: Srivardhan Gadila
on 14 Aug 2019
0 votes
The bboxes from [bboxes,scores] = detect(detector,img); would be empty when no object is detected by your network. You may also refer to trainyolov2objectdetector.
2 Comments
xingxingcui
on 14 Aug 2019
Excuse me,@SriVardhan Gadila , I did it according to the official tutorial,but how can I solve this problem?
Filippo profumo
on 19 Aug 2019
Song Decn
on 14 Mar 2020
0 votes
I have the same issue, after training with my labeled data, detector gives no bounding boxes. What is the general solution steps for this?
1 Comment
Enda O Shea
on 20 May 2022
[bboxes,scores, labels] = detect(detector , I, 'Threshold', 0.5);
For those who need an answer in the future, above is it. You need to specify the threshold (here it is 0.5) so everything with a score above it is shown, if you dont specify it takes the threshold as 1 so unless you get a perfect score nothing will show.
Categories
Find more on Object Detection in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!