why my YOLO v2 detector produces no results?
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Filippo profumo
am 11 Aug. 2019
Kommentiert: Enda O Shea
am 20 Mai 2022
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?
0 Kommentare
Akzeptierte Antwort
Thomas van der Werff
am 28 Jan. 2021
This might not really be relevant anymore but I feel like there are several things to notice here. For example, you're only using one image to train you network. Which means each iteration is 1 epoch which means you've quite a limited amount of trainingdata that you supply to your network. It will most likely learn to look for cells in certain locations of your pictures and not how the cells actually look like. For better results you'll most likely have to provide more pictures or create an augmented set for when you've only a few (flip and resize them for example). 100+ pictures sounds like it might be worth a shot.
Secondly, you're use two anchorboxes of the same format which is a bit unusual. I see you've only used squares to annotate your image but it might be more wiser to take a more precise annotation format in which the cells better fit the boxes and then take 2 anchorboxes based on the dimensions of all your annotations. You can use the estimateAnchorBoxes function for this.
Also, your RMSE is still very high, I thiknk. I don't think you should be suprised nothing was detected. If you want to see all the detections regardless of there error then you can set the threshold of your detector to a lower value or even zero. Something like this could come in handy.
detectionResults = detect(detector, preprocessedTestData, "Threshold", 0);
I also notice you've a very large input format. In my experience, you'll not need to use an input for your network that is much larger than 448x448 or 224x224 for example. Which brings me to the next problem, you're supplying none square images to your network which might result in some strange outcomes. So, I'd recommend resizing the image and its boundingboxes to something smaller. Otherwise you will also have quiet a lengthy processing time for each iteration.
I'm not sure which tutorial you've followed and whether it's normal to use these kind of inputs but all the work I've done with YOLO lets me think that these might not be the right inputs for a good functioning network. For other readers, please correct me where needed.
Weitere Antworten (2)
Srivardhan Gadila
am 14 Aug. 2019
Bearbeitet: Srivardhan Gadila
am 14 Aug. 2019
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 Kommentare
cui,xingxing
am 14 Aug. 2019
Excuse me,@SriVardhan Gadila , I did it according to the official tutorial,but how can I solve this problem?
Song Decn
am 14 Mär. 2020
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 Kommentar
Enda O Shea
am 20 Mai 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.
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!