DEV Community

Ethan
Ethan

Posted on

Setting up YOLO with Darknet

Introduction

Hello! In this tutorial I will show you how to setup YOLO with Darknet.


What is YOLO?

YOLO (You Only Look Once) is a single stage detector that is popular due to it's speed and accuracy, it has been used in various applications to detect people, animals, traffic signals etc.

There are other object detectors such as R-CNN however, they are not as reliable as YOLO.

In this tutorial we will be building YOLOv3, v3 is significantly larger than previous models but it is the best one to use.


What is Darknet?

Darknet is an open source neural network framework written in C and CUDA. It is fast, easy to install, and supports CPU and GPU computation.


Setting up YOLO with Darknet

First we need to install darknet

git clone https://github.com/pjreddie/darknet && cd darknet
make
Enter fullscreen mode Exit fullscreen mode

Next we need to download the pre-trained weights

wget https://pjreddie.com/media/files/yolov3.weights
wget https://pjreddie.com/media/files/yolov3-tiny.weights
Enter fullscreen mode Exit fullscreen mode

Or you can use the following bash script:
https://gist.github.com/ethand91/62ec891bf30ba38ab47553e4952057e8

Now we can try out the detector on the sample images provided in the repository.

./darknet detector test cfg/coco.data cfg/yolov3.cfg yolov3.weights data/horses.jpg
Enter fullscreen mode Exit fullscreen mode

If all goes well you should see the predictions in the terminal, there will also be a file called "predictions.jpg" which when opened should look something like the below image:

Sample


Making the detection faster with GPU

You can get the same results but with much faster time by enabling the GPU flag.
To do this just modify the Makefile.

GPU=1
Enter fullscreen mode Exit fullscreen mode

Then rerun make

make
Enter fullscreen mode Exit fullscreen mode

Conclusion

In this tutorial I have shown how to setup Yolo with Darknet.
I am currently interested in yolov4 ๐Ÿ‘€

If you have any cool sample/projects please share. ๐Ÿ˜ƒ


Like me work? I post about a variety of topics, if you would like to see more please like and follow me.
Also I love coffee.

โ€œBuy Me A Coffeeโ€

Top comments (0)