The outcome of this tutorial is to feed images to our program and in return we will get predicted-labels on our images (like the one above) that will be saved to a folder. So, if you have 100 images that you want to get labelled for anything, thanks to Python, it can be done within a minute.
[[For source code scroll to the bottom]]
YOLO — You Only Look Once — is an extremely fast multi object detection algorithm which uses convolutional neural network (CNN) to detect and identify objects. Since this is a tutorial on how to implement YOLO using Python, I will not cover the technology that makes up this powerful algorithm. Also, keep in mind, this is a tutorial on object detection. If you want to learn how to build a face recognition system, click on the link below.
The first thing you need to understand is this isn’t quite a beginner’s program but anyone with programming knowledge can follow through. Also, just for simplicity’s sake, we will be using a pre-built model.
So, without wasting more time, let’s get into it!
Like always, we need to make sure we have our libraries, modules and packages installed. For this program we need OpenCV, DarkFlow, PIL and Glob.
If you don’t have these installed yet, open your command prompt.
For OpenCV type in : pip install opencv-python
For PIL type in : pip install Pillow==2.2.2
For Glob type in: pip install glob3
DarkFlow is a tensorFlow version of the framework “DarkNet” which is for YOLO. To get this setup and running, the easiest way would be to clone/download the “darkflow-master” folder from my github (link at the bottom of the page) and installing from there. So, after you clone/download the folder to your desktop, enter the folder, open command prompt and run the command :
pip install -e
python setup.py build_ext — — inplace
This should get DarkFlow installed to your system in no time. Now, we are all ready to start!
Since we are using pre-trained models and other technologies, make sure your project folder has these files —
To make things simpler, I would recommend cloning/downloading the folder “YOLO-Image-labelling” from https://github.com/WasekRahman/YOLO
You should have all of those files EXCEPT yolov2.weights. Yolov2.weights is around 200mb large and github wouldn’t let me commit that file.
Go to https://pjreddie.com/darknet/yolo/ and click on “weights” for YOLOv2 608×608 to get it.
After you get your files ready, let’s start coding! I promise from here it gets easy. So, we first import our packages/libraries/modules.