Welcome to Raspberry Pi 5 repository
3.yolov5
yolov5
1 What is YOLO?
YOLO, an acronym for 'You only look once', is an algorithm for object detection that divides images into a grid system. Each cell in the grid is responsible for detecting objects or objects whose physical center point falls within the network itself. YOLO is one of the most famous object detection algorithms due to its speed and accuracy.
2. What is YOLO V5
YOLO V5 is an open source version of YOLO developed by Ultralytics and is completely implemented based on PyTorch, which has brought good news to a large number of AI personnel. While we were still amazed at YOLOv4's various cool operations and rich experimental comparisons, YOLOv5 brought stronger, real-time, and more accurate target detection technology.
- Faster and more real-time According to official figures, the current version of YOLOv5 has the fastest inference time of 0.007 seconds per image, that is, 140 frames per second (FPS). On the CPU, the inference time of each image is as fast as 7ms. , meaning 140 frames per second (FPS)! Far greater than the 20 frames required by the human eye. In comparison, YOLOv4 can only reach 50 frames under the same conditions. On the GPU, the FPS is higher, up to 400.
- Smaller (less memory) The weight file size of YOLOv5 is only 1/9 of YOLOv4.
- Shorter training time. In the case of a single V-100 GPU, the training time of YOLOv5 on the COCO 2017 data set is:

This chapter is suitable for building the Raspberry Pi 5B official image by yourself. If you are using the YAHBOOM version of the image, this tutorial can be ignored.
Required hardware: Raspberry Pi 5B The hardware is Raspberry Pi 5B 4G version, and the python version is 3.11
Install PyTorch
The official download URL is: https://download.pytorch.org/whl/torch_stable.html

If you download it yourself, you need to find the corresponding torch and torchvision versions.
This experiment downloaded torch-2.1.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl and torchvision-0.16.2-cp311-cp311-linux_aarch64.whl
The above two files can be obtained from the attachment and transferred to the Raspberry Pi through winSCP
Installation command:
xpip3 install torch-2.1.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whlpip3 install torchvision-0.16.2-cp311-cp311-linux_aarch64.whl
After the installation is complete, update numpy
xxxxxxxxxxsudo pip3 install numpy --upgrade --ignore-installed
Check whether the installation is successful
If you run as shown below and there are no errors, it means the installation is successful.

Download the source code of yolov5
Can be obtained from the attachment and uploaded to the Raspberry Pi via winscp
You can also get it directly from (https://github.com/ultralytics/yolov5), and then upload the file to the Raspberry Pi through winscp.
Install yolov5 environment running program
xxxxxxxxxxcd /home/pi/yolov5-master/ #This is to enter the yolov5 folder in your Raspberry Pi systemsudo nano requirements.txt
Comment out the lines corresponding to torch, opencv and torchvison in the file, then save and exit the file.

Download the installation package
xxxxxxxxxxpip3 install requirements.txt
The picture below indicates successful installation

Use camera detection
xcd /home/pi/yolOv5-usb / # This goes into the yolov5 folder on your Raspberry pi system, suitable for USB camerapython3 detect.py --source 0cd /home/pi/yolOv5-csi / # This is the yolov5 folder that goes into your Raspberry pi system, suitable for CSI camerapython3 detect.py --source 0
