Nanny-level tutorial, the latest 64-bit system deployment of Raspberry Pi yolov5

Tip: After the article is written, the table of contents can be automatically generated. How to generate it can refer to the help document on the right


foreword

Deploy yolov5 on the Raspberry Pi (you can also run yolov5-lite)
using the latest version of the 64-bit system of the Raspberry Pi.
The hardware is the Raspberry Pi 4B4G version, and the python version is 3.9.

1. Install 64-bit system on Raspberry Pi

1. Download the image file.
Download the official image file of Raspberry Pi (you can also download it in the official burning software)

2. Format the SD card
using the SD Card Formatter software. After opening, you can automatically find your memory card. Any click on Format You can format it
. 3. Download the Raspberry Pi Imager
official website to download
insert image description here
. Select the latest 64-bit system to burn.
Click Settings, set to open ssh, and configure the network
insert image description here

2. Preliminary preparation of Raspberry Pi

1. Change the source of the system, replace the Tsinghua source,
refer to this blog
After updating the installation package, the default python version will become 2.7, here it needs to be 3.9
2. Change the python version,
refer to this blog
After the replacement, you can start deploying the yolov5 operating environment 3.
To solve the vnc blue screen and the problem of not being able to open the Raspberry Pi desktop
refer to this blog
. The personal test is super easy to use

3. Configure the deployment environment

1. Install dependencies

sudo apt-get install libopenblas-dev libblas-dev m4 cmake cython python3-dev python3-yaml python3-setuptools python3-wheel python3-pillow python3-numpy

Use winscp to transfer the downloaded yolov5 6.0 version to the Raspberry Pi
yolov5 project address

2. Install opencv

sudo apt-get install python3-opencv

Check if the installation was successful

python
import cv2

3. Install PyTorch
https://download.pytorch.org/whl/torch_stable.html
to find the corresponding torch and torchvision
Here, the torch1.8.1 version of python3.9 and the torchvision0.9.1 version of python3.9 are selected.
insert image description here
insert image description here
Transfer the installation file to the Raspberry Pi, and cd into the directory where the Raspberry Pi saves the file.
Installation instructions

pip3 install torch-1.8.1-cp39-cp39-manylinux2014_aarch64.whl
pip3 install torchvision-0.9.1-cp39-cp39-manylinux2014_aarch64.whl

After the installation is complete, update numpy

sudo pip3 install numpy --upgrade

Check if the installation was successful

python
import torch
import torchvison

If no error is reported, it means that the installation is successful.
Partners who are unsuccessful in this step can look at the fifth point, maybe it can be solved

Fourth, install the yolov5 environment to run the program

1. Modify the requirements.txt of yolov5

cd /home/xie/yolov5  #那个xie是我的用户名,注意要填自己的用户名
sudo nano requirements.txt

Comment out the lines corresponding to torch, opencv and torchvison in the file

Download the installation package

pip3 install requirements.txt

After the installation is complete, delete the yolov5s.pt file in the yolov5 directory. Then run the detect.py file under the yolov5 file.
insert image description here

3. Use camera detection

cd yolov5#修改成你自己保存yolov5项目文件的目录地址
python3 detect.py --source 0

Five, the pit in the configuration environment

1. After installing torch
or updating numpy, when running yolov5 detect.py and still reporting torch errors,
I installed python3.9's torch1.8.1 version and python3.9's torchvision0.9.1 version for the first time, but it can be used again. It cannot be used when flashing into the system. So I chose the torch1.9.0 linux version and torchvision.0.10.0.
Go to the website and look for https://download.pytorch.org/whl/torch_stable.html
Select the installation package with the following name to download

torch-1.9.0-cp39-cp39-linux_aarch64.whl

torchvision-0.10.0-cp39-cp39-manylinux2014_aarch64.whl

2. detect.py reports an error about SPPF.
Refer to this article

Guess you like

Origin blog.csdn.net/weixin_53798505/article/details/125235377
Recommended