YOLO: You Only Look Once
The “You Only Look Once,” or YOLO, family of models are a series of end-to-end deep learning models designed for fast object detection, developed by Joseph Redmon, et al. and first described in the 2015 paper titled “You Only Look Once: Unified, Real-Time Object Detection.”
What is YOLO object detection?
YOLO is a deep learning based approach of object detection. There are two types of object detection algorithm in the field on deep learning. These two types are:

Detection using R-CNN (A classification based algorithm)
- Classification based algorithms - There are two steps involved in these types of algorithms.
-
Step1: involves selecting a group of Region of Interest (ROI) in the images where the chances that object is present are high.
-
Step2: involves application of Convolutional Neural Networks (CNN) to the regions selected in first step to detect the presence of an object.
Problem associated with these types of algorithms is that we need to execute a detector in each of the ROI, and this makes the process of object detection very slow and highly expensive in terms of computation.
- Regression-based algorithms - These types of algorithms are faster then the above algorithm. There is no selection of the ROI, instead the bounding boxes and the labels are predicted for the whole image at once. This makes the detection faster than classification algorithms. One of the most famous type of regression algorithms is YOLO (You Only Look Once). Since, the inception of YOLO, it has been used in healthcare,self-driving cars, etc.

Detection using YOLO (A regression based algorithm)
Working of YOLO: A quick walkthrough
Why YOLO is such an useful algorithm!
- YOLO first takes image as an input
- The framework divides a photo into a grid of NxN grids. (Let’s us suppose a 3x3 grid)

- Now, on each grid the task of image classification and localization is applied.
- Then, the YOLO algorithm will predict the bounding boxes and the class probabilities of each objects respectively.
Training YOLO on a custom dataset
We will follow the following steps to train YOLO v5 model (PyTorch version) on a custom dataset.
Dataset: The dataset we have chosed here is a blood object detection dataset
Cloning YOLOv5 repository

Installing all the necessary dependencies

Loading the custom dataset annotated on Roboflow in YOLO v5 (PyTorch) format.

This is the YAML file which Roboflow wrote for public to use their platform to create annotated dataset and then train YOLO effectively.

The dataset contains 874 images and the objects to be detected are ‘Platelets’, ‘WBC’, and ‘RBC’ in blood microscopic images.
Defining model configuration and architecture

Customizing iPython writefile so we can write variables


Using
nvidia-smi
to retrieve gpu info and stats. Here, we are using Google Colaboratory so we have been provided with Nvidia Tesla T4

Model Training and Evaluation
Now, we will be starting the model training and evaluation. For evaluation we will be using Mean Average Precision mAP@0.5.

Let’s have a quick of our ground truth data

Printing the augmented training data

Printing the evaluation results

Conclusion
I hoped you enjoyed training custom YOLO v5 object detector! YOLO v5 is lightweight and extremely easy to use. YOLO v5 trains quickly, inferences quickly, and performs well.