Hello, this is swim-lover. Object detection is done with Python and Pytorch. I’ve just started Python, but I’m studying with the concept of “learning while using”.
In Part (3), object detection was performed using YoLov3. This time, I would like to try YoLov5.
YoLov5 was released on June 9, 2020. As of August 27, 2022, it seems that it has progressed to YoLov7.
I used the following repository as a reference.
There are 5 versions YoloV5 ,”n, s, m, l, x” as of July 28, 2022.
vesion “n” is 4.5FLOPS and the processing load is the lowest. As a result,
The processing speed is fastest.
On the other hand, mAPval, an evaluation index for object detection, has the lowest score.
Setting up Colab
Let’s try it on Colab.
Mount google driver on Colab.
from google.colab import drive drive.mount('/content/drive')
Move to directry ‘test_yolo_v5’ which was made beforehand.
cd drive/MyDrive cd test_yolo_v5
Execute git clobe command.
!git clone https://github.com/ultralytics/yolov5 cd yolov5
And also, Install the releted module required to run YoLov5.
pip install -r requirements.txt
Try inference processing using a trained model.
Load a trained model. The parameter is set using yolo5s.
# Model model = torch.hub.load('ultralytics/yolov5', 'yolov5s') # or yolov5n - yolov5x6, custom
Download a sample image file.
# Images img = 'https://ultralytics.com/images/zidane.jpg' # or file, Path, PIL, OpenCV, numpy, list
# Inference results = model(img)
Check the result.
# Results results.save()
It was an amazing image.
Try an another image. This is my own image which was used this page.
Two overlapping bikes were recognized as one bike.
Try next image.
In addition to detecting four bicycles, Bottle can also be detected. YoLov3 did not detect Bottle.
This time, I tried to YoLov5. I would like to try object detection from the next time onwards.
I’m an embedded software engineer. I have avoided front-end technology so far, but I started studying to acquire technology in a different field.
My hobbies are swimming, road bike, running and mountaineering.
We will send out information about embedded technology, front-end technology that we have studied, and occasional hobby exercises.