YOLOv3 PyTorch Video/Image Model

Source: Deep Learning on Medium

YOLOv3 Implementation

Environment

In order to complete my implementation of YOLOv3 you need to have the proper computing environment. First and foremost, you need to be running a Conda Virtual Environment in shell mode. I would recommend a new clean Conda environment where you manually install the necessary libraries. Libraries required are:

There might be 1–2 minor libraries not listed. A quick google search would lead you to the Conda forge commands to install them.

CUDA is a hardware accelerator that any modern computer should be able to utilize. I do not recommend the installation of the CUDA ToolKit manually. Instead, I recommend that you proceed to install it through Consta forge simultaneously with PyTorch ( https://pytorch.org/get-started/locally/) to avoid problems.

In this section, I assumed that you were familiar with Conda Virtual Environments. If you are having problems following this part I would suggest you first familiarize yourself with the Conda Environment. There are many great tutorials on Medium and YouTube.

Download Code

After the virtual environment has been established, the next step is going to my GitHub to download the code. The link to my GitHub is: https://github.com/FranciscoReveriano/YOLOV3-Tutorial

You can either directly download it by command line or you can download the zip file. Of course, remember to unzip (extract) the folder if you download.

The code will have to run through the Anaconda command line. Make sure that you put your code into a directory that you can easily access through the command line. If you are unsure what I mean I would suggest you look in a tutorial on how to navigate the computer file system through the command line.

Download Weights

The next part is making sure you have the weights of the Pre-Trained model. This Yolov3 model is using the COCO trained DarkNet model. So this means having to download the weights here:

https://pjreddie.com/media/files/yolov3.weights

After downloading the weights you need to move them to your main directory/folder that you downloaded from my GitHub. At this point, your directory folder should like this.

Final Directory Setup

Running the Code

At this point, I am assuming you were able to download the code and have it in a directory. I am also assuming that your Conda environment is perfectly set and all required libraries are downloaded.

You should proceed to activate your Conda environment and head to the directory where your code is located. We will first attempt to test the classical test image (dog-cycle-car.png). You need to type the following on the command line:

python tutorialDetect.py — images dog-cycle-car.png — det det

If everything was set up successfully and your environment has all the necessary libraries. You should see the next commands on your Command Prompt:

Command Prompt Results

More importantly, if you go to the subdirectory /det in your main folder you will see that there is a new image.

/det Folder Containing Image

If you click on the image you will see that YOLOVv3 was able to detect and classify all three objects successfully.

You can proceed to upload any images you want and proceed to have YOLOv3 classify them. This implementation is very robust and should have little problems with most classifications.