MATLAB Answers

Training YOLO V2 with multiple (more than one) classes

42 views (last 30 days)
Zahra Moayed
Zahra Moayed on 5 Aug 2019
Commented: jingxue chen on 15 Jul 2020
Hi all,
When I train YOLOV2 with single class (person) using trainYOLOv2ObjectDetector, I can get precision/recall of 0.92 but when I add another class (car) with same images and just few car labels, the accuracy is 0, meaning even the person cannot be detected in any of the images even my training images!
I even use AnchorBox estimation and treid many times.
All the matlab examples are tarined only on single objects but how about if we have more than one class to be trained? Does anyone have any success to help me please?

Answers (2)

Srivardhan Gadila
Srivardhan Gadila on 14 Aug 2019
Edited: Srivardhan Gadila on 14 Aug 2019
The procedure is same for both single and multi-class. The zero accuracy may imply that the dataset is biased, so try having nearly equal number of labels for cars and persons.


Zahra Moayed
Zahra Moayed on 15 Aug 2019
Thanks SriVardhan. It might help a lot.
My dataset consists of many video frames, some of them contain more vehicles and some of them have only Pedestrians. From the Matlab example, in a single frame (image), there are roughly same amount of different classes. For example, for each image, there are one vehicle and one stop sign. In my case, I have some frames only with Pedestrians and some only with Vehicles; there are some contains both but the numbers are not equal at all in single image.
My question is: you suggest to use similar amount of objects. Do you mean in a complete dataset or within one frame? With the first situation, I can find frames to compensate the balance but in the later case, it is very difficult to find such frames to have equal number of vehicles and pedestrians.
Sorry to ask this, I am stuck in this for a while, labeling and training. I do not to waste more time on this and get no results.
THANKS a lot. it will help a lot if it works.
Srivardhan Gadila
Srivardhan Gadila on 19 Aug 2019
In general the first case should produce the good results i.e., having the following equally: Images/Frames having 1. Only vehicles 2. Only Pedestrains 3. Both Vehicles and Pedestrains.
Zahra Moayed
Zahra Moayed on 26 Aug 2019
Hi Srivardhan,
To update, I built another labelling session to contain both People and Car. Number of objects are 137 and 141 for people and car, respectively so the dataset is totally fine.
Still after multiple trial, I got 0 accuracy, nothing is detected at all.
One question: do you train any network with YOLOV2 with multiple classes before? I want to narrow down the problem to see if the issue is from my side or the YOLO V2 release has got issue.
Thanks a lot.

Sign in to comment.

Zahra Moayed
Zahra Moayed on 7 Oct 2019
Is there any updates in the new version of Matlab regarding this issue? Or does anyone have any experience in training multiple classes?

Community Treasure Hunt

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

Start Hunting!