YOLO Object Detection

1. Set up your environment.

export CUDA_HOME=/usr/local/cuda
export PATH=$CUDA_HOME/bin:$PATH
export LD_LIBRARY_PATH=$CUDA_HOME/lib64:$LD_LIBRARY_PATH

Note

You can also add path to .bashrc.

2. Check nvcc is workable.

nvcc --version
../../../../_images/nvcc1.png

3. Retrive darknet repository from github.

sudo apt update
sudo apt install git
git clone https://github.com/AlexeyAB/darknet.git

4. Build darknet with CUDNN and OpenCV support.

Modify darknet’s Makefile with the following:

  • GPU=1

  • CUDNN=1

  • OPENCV=1

sudo apt update
sudo apt install make build-essential
cd darknet
# Edit Makefile GPU=1, CUDNN=1, OPENCV=1
make

5. Download the pre-trained weights.

wget https://pjreddie.com/media/files/yolov3-tiny.weights

Note

ADLINK doesn’t own the pre-trained data. This pre-trained data is a contribution from original author in community.

6. Run object detector from example image.

./darknet detect cfg/yolov3-tiny.cfg yolov3-tiny.weights data/dog.jpg
../../../../_images/run-yolo1.png ../../../../_images/predictions1.jpg