本期主要介紹YoLov5的Window平臺環(huán)境搭建,其優(yōu)點在于移動設(shè)備端的部署會更加方便,基于Pytorch框架。
一、安裝準備
- python版本:3.7及更新的版本
- github項目下載解壓
- pytorch安裝:官網(wǎng)https://pytorch.org/get-started/locally/pytorch下載
二、使用項目requirements.txt來安裝相關(guān)依賴模塊
cmd進入項目解壓路徑,運行命令:
pip install -U -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
等待所有模塊安裝完成。
出現(xiàn)以下問題嘗試其他方案解決:
1. no module named cython, 需要你安裝cython
pip install Cython -i https://pypi.tuna.tsinghua.edu.cn/simple
2.pycocotools安裝失敗,報錯無效的數(shù)值參數(shù)“/Wno-cpp",解決方案:
(1)使用pip安裝
pip install git+https://github.com/philferriere/cocoapi.git#subdirectory=PythonAPI
(2)github項目地址https://github.com/philferriere/cocoapi下載源碼,并進行解壓。以管理員身份打開 cmd終端,并切換到 cocoapi\PythonAPI目錄。運行以下指令:
# install pycocotools locally
python setup.py build_ext --inplace
# install pycocotools to the Python site-packages
python setup.py build_ext install
參考博客:Windows下安裝 pycocotools http://www.lxweimin.com/p/8658cda3d553
三、測試
cmd進入yolov5項目路徑,運行命令:
python detect.py --source ./inference/images/bus.jpg
pytorch測試
運行報錯無scipy模塊,需要安裝scipy
pip install scipy -i https://pypi.tuna.tsinghua.edu.cn/simple
需要yolov5權(quán)重文件下載地址:
權(quán)重下載地址來自B站yolov5測試視頻https://www.bilibili.com/video/BV13A411B7uB?from=search&seid=2408528270299430159
https://pan.baidu.com/s/1Zk2Ksfl_v-apbRBQ_mqc6w
提取碼:00mp
測試結(jié)果:
yolov5測試