356 words
2 minutes
Diving into Latest YOLOv5

Cover image source: Source

Following my previous post about YOLOv3 object detection, this time I jumped into YOLOv5 (yes I tried the v4, but not yet hyped so I tried the v5) for object detection.

YOLOv5 has pretrained model which included 80 classes as the previous model has. I found that the way YOLOv5 presented in PyTorch is very similar to the Darknet version, although controversially this one seems like a PyTorch implementation from previous version but lighter (spill some tea, the original YOLO ended in v3). Here is the Ultralytics YOLOv5 repositories.

To begin with YOLOv5, you’ll need to clone the repository locally. Alternatively, there’s a Google Colab version available (refer to the README for the link).

Terminal window
git clone https://github.com/ultralytics/yolov5
cd yolov5

The repository provides several tutorials, but let’s jump straight into testing the object detection feature.

First Prediction Before running detection, grab any image you like. For instance, here’s using one from Pinterest. To detect objects, run

Terminal window
python detect.py <IMG_FILENAME>

We should expect the model to detect a person and a cat in this image. By default, YOLOv5 will use the yolov5s model — the smallest and fastest version.

result1

Image: Pinterest Source

Another try,

result2

Image: Pinterest Source

result3

Image: Pinterest Source

Comparison to YOLOv3#

While YOLOv3 has been widely used and appreciated for its accuracy and speed, YOLOv5 brings several improvements that are hard to ignore:

FeatureYOLOv3YOLOv5
FrameworkDarknet (C/CUDA)PyTorch (Python)
Deployment EaseRequires compilationEasy to set up and run in Python
Model VariantsTiny and Fulls, m, l, x (scalable architecture)
Inference SpeedSlower, especially on CPUFaster and lightweight
Training WorkflowManual data pipelineBuilt-in training, validation, logging
ONNX ExportNot nativeSupported out of the box

From both a development and usability perspective, YOLOv5 is clearly built with accessibility and speed in mind, especially for those already familiar with the PyTorch ecosystem.

Conclusion#

YOLOv5 shows promise for its usability, which combined with PyTorch makes it an easier option for modern computer vision tasks.

While it may be controversial (there is an interesting writing) due to its unofficial status in the YOLO family, since I saw it like the original project was abandoned because of the owner’s concern, then a company taking it over for their business product, YOLOv5 has some practical performance. For anyone getting into real-time object detection or prototyping vision applications, it’s worth exploring.


Diving into Latest YOLOv5
https://flatcurvature.github.io/posts/diving-into-yolov5/
Author
Flat Curvature
Published at
2020-08-26
License
CC BY-NC-SA 4.0