Darknet: Is there any way to convert yolov3 to detect just 1 object?

Created on 4 Sep 2018  Â·  12Comments  Â·  Source: pjreddie/darknet

Looking for a simple way to convert the yolov3 model to detect a subset of the 80 objects.
For example: if you only want to find people in the image, is there a way to convert the yolo model so that it only looks for people? Will that make the model smaller and faster?

Most helpful comment

There are 3 options you could opt for. 2 of which are done using training custom dataset. You could use an open source dataset online for these(Coco, OpenImages, Pascal, etc.) which have annotations in some format which you could then get converted to the required formats(.txt). Follow the repos' steps.

  1. YunYang1994/tensorflow-yolov3
    This repo does realtime computing(depending on the GPU you use) as it uses Tensorflow in the backend. You might need to tweak a few parameters here and there in the config.py file to get the desired results.
  1. spmallick/learnopencv/YOLOv3-Training-Snowman-Detector
    This is a pretty good repo. There is detailed instructions on how to use the darknet model and use it for training on a single class. The only problem with this method is, the final weights are stored as yolov3.weights format and the repo uses opencv to test it on new data. Since opencv has not yet added support to use NVIDIA GPUs, this might be really slow for videos and live streams. However you could consider seeing how to build opencv with CUDA here

And the third being the most straightforward and the simplest of all, using 'tensornets' developed by TaehoonLee. It is a python library that helps you choose the model and select the number of classes you would want your model to detect(in your case 1) from the 80 classes of the Coco Dataset.

  1. https://github.com/taehoonlee/tensornets

Cheers! (Y)

All 12 comments

I would make this question myself in the future...glad you did it! ...will follow this thread closely!

@ngek Hi, have you found some solution ? I'm facing same problem right now :/

Only workaround so far is to just ignore the other results which has no impact on size or thruput.

Hi @mat-sop ..... did you eventually try to detect only one class using the YOLO darknet? .... How did it go? ..... Regards!

Hi @Vic-TheGreat I eventually trained new model with smaller layers based on original Yolo. It worked well, but it was a private project so it wasn`t tested in a real environment.

@mat-sop thanks for the proper solution i will try this and will post after try result on this blog.

There are 3 options you could opt for. 2 of which are done using training custom dataset. You could use an open source dataset online for these(Coco, OpenImages, Pascal, etc.) which have annotations in some format which you could then get converted to the required formats(.txt). Follow the repos' steps.

  1. YunYang1994/tensorflow-yolov3
    This repo does realtime computing(depending on the GPU you use) as it uses Tensorflow in the backend. You might need to tweak a few parameters here and there in the config.py file to get the desired results.
  1. spmallick/learnopencv/YOLOv3-Training-Snowman-Detector
    This is a pretty good repo. There is detailed instructions on how to use the darknet model and use it for training on a single class. The only problem with this method is, the final weights are stored as yolov3.weights format and the repo uses opencv to test it on new data. Since opencv has not yet added support to use NVIDIA GPUs, this might be really slow for videos and live streams. However you could consider seeing how to build opencv with CUDA here

And the third being the most straightforward and the simplest of all, using 'tensornets' developed by TaehoonLee. It is a python library that helps you choose the model and select the number of classes you would want your model to detect(in your case 1) from the 80 classes of the Coco Dataset.

  1. https://github.com/taehoonlee/tensornets

Cheers! (Y)

@JasonACDsouza In your 3rd url (3. https://github.com/taehoonlee/tensornets)
Can you please kindly point me where it talks about selecting a single class(or preferred classes) in the read me. I went through the doc but couldn't find any mention of it.

@mat-sop thanks for the proper solution i will try this and will post after try result on this blog.

Any progress?
Thank you.

You can just read the annotation file and eliminate all those classes other than what you want to detect,using a simple python problem .

Hi @Vic-TheGreat I eventually trained new model with smaller layers based on original Yolo. It worked well, but it was a private project so it wasn`t tested in a real environment.

I wonder if the weight model size could be smaller for only 1 class ? In your case ?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ghost picture ghost  Â·  4Comments

MaverickLoneshark picture MaverickLoneshark  Â·  3Comments

HoracceFeng picture HoracceFeng  Â·  3Comments

ivomarvan picture ivomarvan  Â·  3Comments

job2003 picture job2003  Â·  3Comments