YOLO 공식 깃허브를 가보면 요구하는 python 버전이 명시되어 있다.
→ 21.10.12 기준 3.6.0
라즈베리파이 4에서 터미널을 열고python --version
이라고 치면 3.7.XX 로 나오는데 3.6보단 커서 python3 update는 안해주고 넘어갔다.
그리고 requirements.txt 를 복붙해서 넣어주고 pip3 install -r requirements.txt
를 해줬다.
이거 하고 torch가 다운이 안됐단 걸 보고 https://github.com/Kashu7100/pytorch-armv7l 이 깃허브를 참고했다.
sudo apt install libopenblas-dev libblas-dev m4 cmake cython python3-dev python3-yaml python3-setuptools
export NO_CUDA=1
export NO_DISTRIBUTED=1
export NO_MKLDNN=1
export BUILD_TEST=0
export MAX_JOBS=4
git clone https://github.com/pytorch/pytorch --recursive && cd pytorch
git checkout v1.7.0
git submodule update --init --recursive
python3 setup.py bdist_wheel
# 위에 python 이라고 하면 안되니까 꼭 python3 로 하기!(위 깃허브 readme랑 다름)
마지막 명령어 python3 setup.py bdist_wheel가 지옥의 구간임.. 개오래 걸림.
이후
YOLOv5 object detection on Raspberry pi 4
이 비디오를 참고해서 마저 install 안된 것들 처리해준다.
```
git clone https://github.com/ultralytics/yolov5.git
cd yolov5/
ls
python3 detect.py --source data/images --weights yolov5s.pt --conf 0.25
# Traceback (most recent call last):
# File "detect.py", line 14, in <module>
# import cv2exit
#ModuleNotFoundError: No module named 'cv2'
pip3 install opencv-python==4.4.0.40
# Installing collected packages: opencv-python
# Successfully installed opencv-python-4.4.0.40
python3 detect.py --source data/images --weights yolov5s.pt --conf 0.25
# Traceback (most recent call last):
# File "detect.py", line 14, in <module>
# import cv2
# File "/home/pi/.local/lib/python3.7/site-packages/cv2/__init__.py", line 5, in <module>
# from .cv2 import *
# ImportError: libcblas.so.3: cannot open shared object file: No such file or directory
sudo apt-get install libatlas-base-dev
# 로그 생략
python3 detect.py --source data/images --weights yolov5s.pt --conf 0.25
# RuntimeError: module compiled against API version 0xe but this version of numpy is 0xd
# Traceback (most recent call last):
# File "detect.py", line 14, in <module>
# import cv2
# File "/home/pi/.local/lib/python3.7/site-packages/cv2/__init__.py", line 5, in <module>
# from .cv2 import *
# ImportError: numpy.core.multiarray failed to import
pip3 install numpy==1.19.3
# Successfully installed numpy-1.19.3
python3 detect.py --source data/images --weights yolov5s.pt --conf 0.25
# ModuleNotFoundError: No module named 'pandas'
pip3 install pandas
# Successfully installed pandas-1.3.3 pytz-2021.3
python3 detect.py --source data/images --weights yolov5s.pt --conf 0.25
# ValueError: numpy.ndarray size changed, may indicate binary incompatibility. Expected 44 from C header, got 40 from PyObject
pip3 install --upgrade numpy
# Successfully installed numpy-1.21.2
python3 detect.py --source data/images --weights yolov5s.pt --conf 0.25
# ModuleNotFoundError: No module named 'tqdm'
pip3 install tqdm
# Successfully installed tqdm-4.62.3
python3 detect.py --source data/images --weights yolov5s.pt --conf 0.25
# ModuleNotFoundError: No module named 'seaborn'
pip3 install seaborn
# Successfully installed scipy-1.7.1 seaborn-0.11.2
python3 detect.py --source data/images --weights yolov5s.pt --conf 0.25
# Results saved to runs/detect/exp3
```