Issues with yolo v2 network

29 views (last 30 days)
Felix Chen
Felix Chen on 4 May 2019
Commented: syahir afiq on 2 Jul 2021
Hey, gus I just working on a traffic sign detection projec. My input image is 1200X1600. And I set the input layer of the yolov2 488X488. Use EstimateAnchorBoxes.m to etimate 5 anchor boxes size for my dataset. But after training the network predict nothing. Should I resize the input image to 488X488 then do the estimation(currently the anchor boxes were estimated with 1200X1600 input and label)? Or any recommended anchhor boxes for 488X488 for yolov2 network?
And another question is does anyone know how to use 'detector = trainYOLOv2ObjectDetector(___,'MultiScaleTrainingSizes',trainingSizes)' this syntax? I tried it, and the matlab told me is not a vaild parameter. An example of this syntax would help me a lot.
Thanks very much.

Answers (6)

Hakan Hekimgil
Hakan Hekimgil on 20 Jun 2019
It seems like the YOLO trainer in MATLAB is published before it is actually finalized and the information given in the documentation is not entirely correct.
For the 'MultiScaleTrainingSizes' parameter, I managed to have it work by replacing it with 'TrainingImageSize'...
  1 Comment
Felix Chen
Felix Chen on 25 Aug 2019
Okay, will try go with this, thanks for sharing.

Sign in to comment.

cui on 2 Aug 2019
I have tried to use 1280*1024 size image as the input of the network. The training is very time consuming, about the square of the small image size. After waiting for a long time of training, the result is bad. Nothing can be detected. Later I switched to 320*320 image size as input, training speed is faster, but still can not detect the person object, I think the official document lacks this explanation.
  1 Comment
Felix Chen
Felix Chen on 25 Aug 2019
Yep, I did have the same issues, maybe change the anchor box would help.

Sign in to comment.

Zahra Moayed
Zahra Moayed on 5 Aug 2019
Hi all,
Please share if you found a solution for it. When I train with single object (person), I can get precision/recall of 0.92 but when I add another class (car) with same images and just few, the accuracy is 0, meaning even the person cannot be detected in an of the images even my training images!
All the matlab examples are tarined only on single objects but how about if we have more than one class? Does anyone hve any success to help me please?
  1 Comment
Oscar Lema
Oscar Lema on 26 Mar 2020
Have you found a solution??
I have the same problem. If I train with a class (airplane) everything goes ok, but if a add a second class (ship) with the same number of images, the detector detects nothing.

Sign in to comment.

cui on 6 Aug 2019
Hi , dear @Zahra Moayed:
Can I know the resolution of your input image? Also use resnet50 as the basic network training? if you can provide code to post here, thank you very much!
In addition,@Felix Chen, I saw that the YOLO author's settings for anchors are as follows:
So YOLOv2 I made some design choice errors, I made the anchor box size relative to the feature size of the last layer. Since the network is 32 downsampled. This means it is relative to 32 pixels, so the 9x9 anchor is actually 288px x 288px.
In YOLOv3, the anchor size is the actual pixel value. This simplifies a lot of things and is a bit difficult to implement.
  1 Comment
Zahra Moayed
Zahra Moayed on 7 Aug 2019
Hi Cui,
The size of my image are [1280,720] and when I found the anchorboxes, i resized them to be fit in [224 224] Resnet-50 input. but as I said, it only works with single class :(
anchorBoxes = [
131 100
60 50
50 37
92 76
75 61
anchorBoxes = [round(anchorBoxes(:,1)/5),round(anchorBoxes(:,2)/3)];%%[1280, 720]->[224, 224]

Sign in to comment.

Umang Tulsi
Umang Tulsi on 16 Apr 2020
Hey, I was having the same problem and I thought it wasn't working either. I tried searching the same thing and found your issue as well. 2 days later, I realised that the problem was in my execution, specifically with the use of the 'detect' function.
I was using the ACFObject Detector before, and later tried using YOLO for my work. The 'detect' function in ACF works with a threshold range of [-1 1] and has influence on processing time and accuracy of results. You will get results with both -1 and 1 as values (however at -1 the results will be only slightly better). For me this value was set at 1.
Whereas the 'detect' function with YOLOv2 implies that an actual threshold in the range [0 1]. Any scores below this threshold wont be displayed at all. This has nothing to do with processing time unlike the ACF. Since I had the threshold set at 1, I ofcourse couldn't get anything to appear in my detection. As soon as I set the threshold to 0.5, my mean average precision was 0.86 because now it only required scores to be higher than 0.5.
I dont know if this is the case for you as well but, for me it was a simple mistake of not realising that the Threshold property in ACF and YOLOv2 works and implies in different ways.
Hope, it was helpful!
  1 Comment
syahir afiq
syahir afiq on 2 Jul 2021
hi umang can u help me with my problem? i have problem with my detection

Sign in to comment.

Abolfazl Chaman Motlagh
Abolfazl Chaman Motlagh on 9 Nov 2020
Hi everyone. I had similar problem with yolo. The RCNN , FRCNN and FasterRCNN work very well on my dataset and test dataset. but Yolo doesnt work ... i tried using different parameters for training step and still nothing till i change the Learn-rate.
the default for learn rate in matlab for YOLOv2 is 1e-3 but when i use 1e-4 or less it become converging. hence it work pretty well (using the detect function). so try this option. (InitialLearnRate = 1e-4)
also i learn somthing interesitng for speed up training and better convergence. use few images (like 3 or 4 images) for every class you have and train it for like 2000 epoch ( every epoch will end fast because of dataset size) . and after the network overfitt on your few images. try to train it with all of images for like 50 epoch . (i get good answer even with 5 epoch!)
hope it solve your problem.

Community Treasure Hunt

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

Start Hunting!