日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Raspberry Pi 4B 部署 YOLOX

發布時間:2025/5/22 编程问答 19 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Raspberry Pi 4B 部署 YOLOX 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

環境

  • Python:3.7.3
  • YOLOX:0.1.1rc0
  • torch:1.8.0
  • torchvision:0.9.0
  • OpenVINO:2021.4.582
  • g++ (Raspbian 8.3.0-6+rpi1) 8.3.0
  • raspberrypi:5.10.52-v7l+
  • 系統指令集:armv7l
  • numpy:1.20.3

組件

  • Raspberry Pi 4B 8G
  • NCS2

pi@raspberrypi:~/Desktop/YOLOX-main $ uname -a
Linux raspberrypi 5.10.52-v7l+ #1441 SMP Tue Aug 3 18:11:56 BST 2021 armv7l GNU/Linux

安裝git后下載

git clone https://github.com/Megvii-BaseDetection/YOLOX.git

安裝 torch 1.8.0

pip3 install torch-1.8.0a0+56b43f4-cp37-cp37m-linux_armv7l.whl

安裝 torchvision 0.9.0

pip3 install torchvision-0.9.0a0+8fb5838-cp37-cp37m-linux_armv7l.whl

安裝 torch 依賴

sudo apt-get install libopenblas-dev

pi@raspberrypi:~/Desktop/YOLOX-main $ sudo apt-get install libopenblas-dev
正在讀取軟件包列表… 完成
正在分析軟件包的依賴關系樹
正在讀取狀態信息… 完成
下列軟件包是自動安裝的并且現在不需要了:
gconf-service gconf2-common libgconf-2-4 python-colorzero
使用’sudo apt autoremove’來卸載它(它們)。
將會同時安裝下列軟件:
libopenblas-base
下列【新】軟件包將被安裝:
libopenblas-base libopenblas-dev
升級了 0 個軟件包,新安裝了 2 個軟件包,要卸載 0 個軟件包,有 3 個軟件包未被升級。
需要下載 3,845 kB 的歸檔。
解壓縮后會消耗 26.2 MB 的額外空間。
您希望繼續執行嗎? [Y/n]
獲取:1 http://mirrors.aliyun.com/raspbian/raspbian buster/main armhf libopenblas-base armhf 0.3.5+ds-3+rpi1 [1,980 kB]
獲取:2 http://mirrors.aliyun.com/raspbian/raspbian buster/main armhf libopenblas-dev armhf 0.3.5+ds-3+rpi1 [1,865 kB]
已下載 3,845 kB,耗時 3秒 (1,333 kB/s)
正在選中未選擇的軟件包 libopenblas-base:armhf。
(正在讀取數據庫 … 系統當前共安裝有 175576 個文件和目錄。)
準備解壓 …/libopenblas-base_0.3.5+ds-3+rpi1_armhf.deb …
正在解壓 libopenblas-base:armhf (0.3.5+ds-3+rpi1) …
正在選中未選擇的軟件包 libopenblas-dev:armhf。
準備解壓 …/libopenblas-dev_0.3.5+ds-3+rpi1_armhf.deb …
正在解壓 libopenblas-dev:armhf (0.3.5+ds-3+rpi1) …
正在設置 libopenblas-base:armhf (0.3.5+ds-3+rpi1) …
update-alternatives: 使用 /usr/lib/arm-linux-gnueabihf/openblas/libblas.so.3 來在自動模式中提供 /usr/lib/arm-linux-gnueabihf/libblas.so.3 (libblas.so.3-arm-linux-gnueabihf)
update-alternatives: 使用 /usr/lib/arm-linux-gnueabihf/openblas/liblapack.so.3 來在自動模式中提供 /usr/lib/arm-linux-gnueabihf/liblapack.so.3 (liblapack.so.3-arm-linux-gnueabihf)
正在設置 libopenblas-dev:armhf (0.3.5+ds-3+rpi1) …
update-alternatives: 使用 /usr/lib/arm-linux-gnueabihf/openblas/libblas.so 來在自動模式中提供 /usr/lib/arm-linux-gnueabihf/libblas.so (libblas.so-arm-linux-gnueabihf)
update-alternatives: 使用 /usr/lib/arm-linux-gnueabihf/openblas/liblapack.so 來在自動模式中提供 /usr/lib/arm-linux-gnueabihf/liblapack.so (liblapack.so-arm-linux-gnueabihf)
正在處理用于 libc-bin (2.28-10+rpi1) 的觸發器 …

Raspberry Pi 4B 安裝 OpenVINO,請參考以下鏈接,最新版本的OpenVINO,yolox也支持。
https://blog.csdn.net/qq_44989881/article/details/119792769?spm=1001.2014.3001.5501

安裝 numpy
注:如果 numpy 低于 1.20.0 版本強烈建議升級 numpy版本,否則會報 numpy 版本過低的錯誤。

pip3 install numpy==1.20.3

pi@raspberrypi:~/Desktop/YOLOX-main $ pip3 install numpy==1.20.3
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting numpy==1.20.3
Downloading https://www.piwheels.org/simple/numpy/numpy-1.20.3-cp37-cp37m-linux_armv7l.whl (11.6MB)
100% |████████████████████████████████| 11.6MB 38kB/s
Installing collected packages: numpy
Successfully installed numpy-1.20.3

安裝 yolox 需要的環境

pip3 install -r requirements.txt

pi@raspberrypi:~/Desktop/YOLOX-main $ pip3 install -r requirements.txt
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Requirement already satisfied: numpy in /usr/lib/python3/dist-packages (from -r requirements.txt (line 2)) (1.16.2)
Requirement already satisfied: torch>=1.7 in /home/pi/.local/lib/python3.7/site-packages (from -r requirements.txt (line 3)) (1.8.0a0+56b43f4)
Requirement already satisfied: opencv_python in /home/pi/.local/lib/python3.7/site-packages (from -r requirements.txt (line 4)) (4.5.3.56)
Collecting loguru (from -r requirements.txt (line 5))
Downloading https://files.pythonhosted.org/packages/6d/48/0a7d5847e3de329f1d0134baf707b689700b53bd3066a5a8cfd94b3c9fc8/loguru-0.5.3-py3-none-any.whl (57kB)
100% |████████████████████████████████| 61kB 744kB/s
Collecting scikit-image (from -r requirements.txt (line 6))
Downloading https://www.piwheels.org/simple/scikit-image/scikit_image-0.18.3-cp37-cp37m-linux_armv7l.whl (29.9MB)
100% |████████████████████████████████| 29.9MB 15kB/s
Collecting tqdm (from -r requirements.txt (line 7))
Downloading https://files.pythonhosted.org/packages/9c/05/cf212f57daa0eb6106fa668a04d74d932e9881fd4a22f322ea1dadb5aba0/tqdm-4.62.2-py2.py3-none-any.whl (76kB)
100% |████████████████████████████████| 81kB 1.7MB/s
Requirement already satisfied: torchvision in /home/pi/.local/lib/python3.7/site-packages (from -r requirements.txt (line 8)) (0.9.0a0+8fb5838)
Requirement already satisfied: Pillow in /usr/lib/python3/dist-packages (from -r requirements.txt (line 9)) (5.4.1)
Collecting thop (from -r requirements.txt (line 10))
Downloading https://files.pythonhosted.org/packages/6c/8b/22ce44e1c71558161a8bd54471123cc796589c7ebbfc15a7e8932e522f83/thop-0.0.31.post2005241907-py3-none-any.whl
Collecting ninja (from -r requirements.txt (line 11))
Downloading https://files.pythonhosted.org/packages/52/fd/6a82411fbc23b62bf5ddf511b09cb3d6059d1b84ec6833589aa064cea207/ninja-1.10.2.tar.gz
Installing build dependencies … done
Collecting tabulate (from -r requirements.txt (line 12))
Downloading https://files.pythonhosted.org/packages/ca/80/7c0cad11bd99985cfe7c09427ee0b4f9bd6b048bd13d4ffb32c6db237dfb/tabulate-0.8.9-py3-none-any.whl
Collecting tensorboard (from -r requirements.txt (line 13))
Downloading https://files.pythonhosted.org/packages/a0/20/a59a30c32330e4ff704faa4273b251db042d495e0c367bcdf045c6fe26e9/tensorboard-2.6.0-py3-none-any.whl (5.6MB)
100% |████████████████████████████████| 5.6MB 80kB/s
Collecting onnx==1.8.1 (from -r requirements.txt (line 16))
Downloading https://files.pythonhosted.org/packages/2b/8d/c924f54e19ec71543c18658d86e8337579d5a784bd524b7f18e2e2cd6f17/onnx-1.8.1.tar.gz (5.2MB)
100% |████████████████████████████████| 5.2MB 82kB/s
Installing build dependencies … done
Collecting onnxruntime==1.8.0 (from -r requirements.txt (line 17))
Could not find a version that satisfies the requirement onnxruntime==1.8.0 (from -r requirements.txt (line 17)) (from versions: )
No matching distribution found for onnxruntime==1.8.0 (from -r requirements.txt (line 17))

安裝 YOLOX

python3 setup.py install

安裝 loguru

pip3 install loguru

pi@raspberrypi:~/Desktop/YOLOX-main $ pip3 install loguru
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting loguru
Using cached https://files.pythonhosted.org/packages/6d/48/0a7d5847e3de329f1d0134baf707b689700b53bd3066a5a8cfd94b3c9fc8/loguru-0.5.3-py3-none-any.whl
Installing collected packages: loguru
Successfully installed loguru-0.5.3

安裝 thop

pip3 install thop

pi@raspberrypi:~/Desktop/YOLOX-main $ pip3 install thop
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting thop
Using cached https://files.pythonhosted.org/packages/6c/8b/22ce44e1c71558161a8bd54471123cc796589c7ebbfc15a7e8932e522f83/thop-0.0.31.post2005241907-py3-none-any.whl
Requirement already satisfied: torch>=1.0.0 in /home/pi/.local/lib/python3.7/site-packages (from thop) (1.8.0a0+56b43f4)
Requirement already satisfied: numpy in /home/pi/.local/lib/python3.7/site-packages (from torch>=1.0.0->thop) (1.20.3)
Requirement already satisfied: typing-extensions in /home/pi/.local/lib/python3.7/site-packages (from torch>=1.0.0->thop) (3.10.0.2)
Installing collected packages: thop
Successfully installed thop-0.0.31.post2005241907

安裝 pycocotools

pip3 install pycocotools

pi@raspberrypi:~/Desktop/YOLOX-main $ pip3 install pycocotools
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting pycocotools
Downloading https://www.piwheels.org/simple/pycocotools/pycocotools-2.0.2-cp37-cp37m-linux_armv7l.whl (304kB)
100% |████████████████████████████████| 307kB 91kB/s
Collecting cython>=0.27.3 (from pycocotools)
Downloading https://files.pythonhosted.org/packages/ec/30/8707699ea6e1c1cbe79c37e91f5b06a6266de24f699a5e19b8c0a63c4b65/Cython-0.29.24-py2.py3-none-any.whl (979kB)
100% |████████████████████████████████| 983kB 237kB/s
Requirement already satisfied: matplotlib>=2.1.0 in /usr/lib/python3/dist-packages (from pycocotools) (3.0.2)
Requirement already satisfied: setuptools>=18.0 in /usr/lib/python3/dist-packages (from pycocotools) (40.8.0)
Installing collected packages: cython, pycocotools
Successfully installed cython-0.29.24 pycocotools-2.0.2

安裝 tqdm

pip3 install tqdm

pi@raspberrypi:~/Desktop/YOLOX-main $ pip3 install tqdm
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting tqdm
Using cached https://files.pythonhosted.org/packages/9c/05/cf212f57daa0eb6106fa668a04d74d932e9881fd4a22f322ea1dadb5aba0/tqdm-4.62.2-py2.py3-none-any.whl
Installing collected packages: tqdm
Successfully installed tqdm-4.62.2

以下為我在 Raspberry Pi 4B 測試的結果:
IOU還存在一些問題,后續再微調以下。

查看樹莓派有哪些設備支持 OpenVINO

pi@raspberrypi:~/Desktop $ source /opt/intel/openvino_2021/bin/setupvars.sh
[setupvars.sh] OpenVINO environment initialized
pi@raspberrypi:~/Desktop $ python3
Python 3.7.3 (default, Jan 22 2021, 20:04:44)
[GCC 8.3.0] on linux
Type “help”, “copyright”, “credits” or “license” for more information.
>>> from openvino.inference_engine import IECore
>>> ie = IECore()
>>> print(ie.available_devices)
[‘MYRIAD’]

注:
MYRIAD為神經計算棒插入樹莓派后顯示的設備名稱。
如果插入的對象為Windows 10電腦則顯示:[‘CPU’, ‘GNA’, ‘GPU’, ‘MYRIAD’]

出現問題:

問題1:

pi@raspberrypi:~/Desktop/YOLOX-main $ pip3 install -r requirements.txt
Could not find a version that satisfies the requirement onnxruntime==1.8.0 (from -r requirements.txt (line 17)) (from versions: )
No matching distribution found for onnxruntime==1.8.0 (from -r requirements.txt (line 17))

因為在這里我只使用 OpenViNO 用不到 onnxruntime 這個包,所以忽略此問題。

問題2:

安裝的 torch 找不到,無法使用:

pi@raspberrypi:~/Desktop/YOLOX-main $ python3
Python 3.7.3 (default, Jan 22 2021, 20:04:44)
[GCC 8.3.0] on linux
Type “help”, “copyright”, “credits” or “license” for more information.
>>> import torch
Traceback (most recent call last):
File “”, line 1, in
File “/home/pi/.local/lib/python3.7/site-packages/torch/init.py”, line 196, in
from torch._C import *
ImportError: libopenblas.so.0: cannot open shared object file: No such file or directory

安裝好pytorch之后import發現沒法用,這可能是因為沒有安裝依賴:

sudo apt-get install libopenblas-dev

參考一個最近和我一樣需要在 Raspberry Pi 4B 上部署YOLO dalao的文章,
最后得到了解決:
在樹莓派4B上部署自己訓練的yolov5模型(配合NCS2加速)
https://blog.csdn.net/qq_44166630/article/details/119994949?spm=1001.2014.3001.5501

問題3:

缺少 openvino 模塊

Traceback (most recent call last):
File “./demo/OpenVINO/python/openvino_inference.py”, line 15, in
from openvino.inference_engine import IECore
ModuleNotFoundError: No module named ‘openvino’

Raspberry Pi 4B安裝 OpenVINO? 工具包:
https://blog.csdn.net/qq_44989881/article/details/119792769?spm=1001.2014.3001.5501

或者
設置 openvino 的環境變量

source /opt/intel/openvino_2021/bin/setupvars.sh

pi@raspberrypi:~/Desktop $ source /opt/intel/openvino_2021/bin/setupvars.sh
[setupvars.sh] OpenVINO environment initialized

問題4:

numpy 版本太低,導致無法使用 OpenVINO 運行,如果安裝大于 1.16.6 小于 1.20.1版本,也會出現 OpenVINO 版本過低類似的錯誤。

(yolox) C:\Users\vvcat\Desktop\YOLOX-0.1.0>pip install numpy==1.15.1
Collecting numpy==1.15.1
Downloading numpy-1.15.1-cp37-none-win_amd64.whl (13.5 MB)
|████████████████████████████████| 13.5 MB 92 kB/s
Installing collected packages: numpy
ERROR: pip’s dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
scipy 1.7.1 requires numpy<1.23.0,>=1.16.5, but you have numpy 1.15.1 which is incompatible.
scikit-image 0.18.3 requires numpy>=1.16.5, but you have numpy 1.15.1 which is incompatible.
onnxruntime 1.8.0 requires numpy>=1.16.6, but you have numpy 1.15.1 which is incompatible.
onnx 1.8.1 requires numpy>=1.16.6, but you have numpy 1.15.1 which is incompatible.
matplotlib 3.4.3 requires numpy>=1.16, but you have numpy 1.15.1 which is incompatible.

建議 numpy 安裝 1.20.0 版本 以上
本文章使用 1.20.3 版本的 numpy

pip3 install numpy==1.20.3

問題5:

ModuleNotFoundError: No module named ‘loguru’
ModuleNotFoundError: No module named ‘thop’
ModuleNotFoundError: No module named ‘pycocotools’
ModuleNotFoundError: No module named ‘tqdm’

缺少以上模塊,建議 一個一個的都安裝上去。

pip3 install xxxx

問題6:

安裝了 yolox 缺找不到 yolox 這個模塊

raceback (most recent call last):
File “./demo/OpenVINO/python/openvino_inference.py”, line 17, in
from yolox.data.data_augment import preproc as preprocess
ModuleNotFoundError: No module named ‘yolox’

通過 pwd 命令查看 YOLOX 項目的根路徑

pi@raspberrypi:~/Desktop/YOLOX-main $ pwd
/home/pi/Desktop/YOLOX-main

在報錯的py文件下,添加該路徑

import sys sys.path.append(r'/home/pi/Desktop/YOLOX-main')

折騰沒有結束,有時間繼續更新…

樹莓派4B 安裝torch:torch1.8.0+torchvision0.9.0
https://blog.csdn.net/qq_44166630/article/details/119647498?spm=1001.2014.3001.5501

用于在 Raspberry Pi 4B 上安裝 Pytorch 1.8.0 和 Pytorch Vision 0.9.0 版的文件:https://github.com/sungjuGit/PyTorch-and-Vision-for-Raspberry-Pi-4B

總結

以上是生活随笔為你收集整理的Raspberry Pi 4B 部署 YOLOX的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。