Training YOLO V2 with multiple (more than one) classes

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?

4 Kommentare

I have the same problem!
Have you found any solution for it? I still got this issue
I meet the same problem now!Have you find some solutions?
Hi Zahra Moayed,
I was also trying to train the yolo with multi class. I have a doubt. How did you mapped the training dataset table?
In my case, in some training image one class may not be there. In such cases how to fill the table? just leave it as empty? in that case matlab is throwing error. any help is much appreciated

Melden Sie sich an, um zu kommentieren.

Antworten (3)

Srivardhan Gadila
Srivardhan Gadila am 14 Aug. 2019
Bearbeitet: Srivardhan Gadila am 14 Aug. 2019

0 Stimmen

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.

3 Kommentare

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.
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.
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.

Melden Sie sich an, um zu kommentieren.

Zahra Moayed
Zahra Moayed am 7 Okt. 2019

0 Stimmen

Hi,
Is there any updates in the new version of Matlab regarding this issue? Or does anyone have any experience in training multiple classes?

5 Kommentare

I have brought this issue to the notice of our developers. They will investigate the matter further.
@Srivardhan Gadila , Any update on the issue?
Updates?
Any updates? I have the same problem, can detect 1 class but in case of multiple classes 0 recall
any updates?
m still facing same issue

Melden Sie sich an, um zu kommentieren.

Sunny Guha
Sunny Guha am 6 Apr. 2022

0 Stimmen

Hi Zahra
Please refer to this R2022a example on training YOLO v2 for multiple classes:
In general, there could be multiple issues that hinder performance of networks on multiple class datasets. Here are few of the things you can try to resolve the issues:
  1. Ensure the classes are close to balanced. If you cannot obtain more labels resort to data augmentation. The example I linked above contains steps on how to perform augmentation.
  2. Change backbone/feature extraction layer. Object detectors have a hard time detecting smaller objects. Bigger (spatial resolution) feature extraction layers can detect smaller objects.
  3. Try a different detector like yolov4 which perform multiscale detection.
Hope this helps.

7 Kommentare

Where can I find 'annotationsIndoor.mat' from the example you refered to?
Hi Damjan,
On the top-right corner of the example screen you can find the "Copy Command" button. This copies command needed to open the example and also save the relevant files in your documents folder.
For this examples the command is:
openExample('deeplearning_shared/MulticlassObjectDetectionUsingDeepLearningExample')
You can use this in MATLAB and MATLAB will open the example in the newly created folder with all the required files.
Hope this helps.
Hi Sunny,
thank you for such fast response. I tried the "Copy Command" but MATLAB cannot find the example.
I have both vision toolbox and deep learning toolbox installed. Is it maybe because MATLAB isn't installed in the default directory? Can I download example from somewhere?
Hi Damjan,
Could you please post the error message that you are encountering.
In the meantime these are some steps you can try.
  1. Run restoredefaultpath command to restore all default MATLAB paths.
  2. Run rehash toolboxcache command to clean and restore toolbox cache.
  3. Run which annotationsIndoor.mat command to find the location of the file in your installed MATLAB directory.
Let me know if this resolves the issue.
Damjan Konjevod
Damjan Konjevod am 9 Apr. 2022
Bearbeitet: Damjan Konjevod am 9 Apr. 2022
Hi Sunny,
I tried steps you recommended and it didnt work.
Error message that I get is:
Error using findExample (line 22)
Example "MulticlassObjectDetectionUsingDeepLearningExample" not found in "C:\Program Files\MATLAB\examples\deeplearning_shared\examples.xml".
Error in openExample (line 30)
metadata = findExample(exampleId);
ho lo stesso problema di damjan
I have tried yolo v2, v3 and v4 but problem is still there
good accuracy for single class and no detection in case of multiple object
please help

Melden Sie sich an, um zu kommentieren.

Produkte

Version

R2019a

Gefragt:

am 5 Aug. 2019

Kommentiert:

am 13 Dez. 2022

Community Treasure Hunt

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

Start Hunting!

Translated by