文章目錄
- 前言
- 一、環境搭建
- 二、測驗
- 三、訓練
- 3.1 下載資料集
- 3.2 在./lib/config/default.py中修改相關引數
- 四、模型評估
- 五、可能遇到的報錯
- 5.1 測驗視頻報錯 IndexError: boolean index did not match indexed array along dimension 0; dimension is 1536 but corresponding boolean dimension is 1440
- 5.2 訓練報錯 TypeError: can't pickle generator objects,EOFError: Ran out of input
- 5.3 調小batch_size后仍然RuntimeError: CUDA out of memory.
- 5.4 AttributeError: 'list' object has no attribute 'seek'. You can only torch.load from a file that is seekable. Please pre-load the data into a buffer like io.BytesIO and try to load from it
- 總結
前言
本文將詳細介紹YOLOP 訓練+測驗+模型評估的程序和個人遇到的所有報錯,一、環境搭建
必要環境:Windows10+python3.7+CUDA10.1+CUDNN7.6.5
-
創建yolop虛擬環境
conda create -n yolo_p python=3.7 -
下載pytorch (pytorch版本>=1.7)
conda install pytorch==1.7.0 torchvision==0.8.0 torchaudio==0.7.0 cudatoolkit=10.1 -c pytorch -
下載YOLOP原始碼
地址:https://github.com/hustvl/YOLOP -
安裝所需要的依賴包
pip install -r requirements.txt
二、測驗
- 運行
python tools/demo.py --source ./inference/videos/1.mp4
測驗圖片:–source 圖片路徑 (或存放圖片的檔案夾路徑)
測驗視頻:–source 視頻路徑 (或存放視頻的檔案夾路徑)
相機實時:–source 0
默認用cpu測驗效果,如果想改成gpu,修改demo.py 198行如下,

效果如下:


三、訓練
3.1 下載資料集
-
下載檢測任務圖片:
https://bdd-data.berkeley.edu/portal.html#download -
下載檢測任務標簽:
https://drive.google.com/file/d/1Ge-R8NTxG1eqd4zbryFo-1Uonuh0Nxyl/view -
下載可行駛區域分割任務標簽:
https://drive.google.com/file/d/1xy_DhUZRHR8yrZG3OwTQAHhYTnXn7URv/view -
下載車道線分割任務標簽:
https://drive.google.com/file/d/1lDNTPIQj_YLNZVkksKM25CvCHuquJ8AP/view資料集結構

這里為了方便我自己劃分了部分資料集進行訓練
下載地址:
鏈接:https://pan.baidu.com/s/1XixhZtU3nNfxKLvV3RZqGQ
提取碼:ed8n
3.2 在./lib/config/default.py中修改相關引數
-
修改第九行
_C.WORKERS = 0

-
修改96行,121行
_C.TRAIN.BATCH_SIZE_PER_GPU為合適大小(博主電腦比較菜這里填的1)

-
根據注釋修改53-56行路徑

-
運行
python tools/train.py開始訓練

四、模型評估
- 運行
python tools/test.py --weights weights/End-to-end.pth

五、可能遇到的報錯
5.1 測驗視頻報錯 IndexError: boolean index did not match indexed array along dimension 0; dimension is 1536 but corresponding boolean dimension is 1440
解決方案:
-
在tools/demo.py 128行前加入如下代碼
img_det=cv2.resize(img_det,(da_seg_mask.shape[1],da_seg_mask.shape[0]) ,interpolation=cv2.INTER_AREA)
-
洗掉./lib/utils/plot.py 第60行的resize

-
在demo.py 148行下加入如下代碼,運行demo.py查看效果
cv2.namedWindow("test", cv2.WINDOW_NORMAL) cv2.resizeWindow("test", int(img_det.shape[1] * 0.5), int(img_det.shape[0] * 0.5)) cv2.imshow("test", img_det) cv2.waitKey(30)
效果:

5.2 訓練報錯 TypeError: can’t pickle generator objects,EOFError: Ran out of input
解決方案:
- 修改./lib/config/default.py第九行_C.WORKERS = 0

5.3 調小batch_size后仍然RuntimeError: CUDA out of memory.
解決方案:
- 修改./lib/config/default.py第19行_C.CUDNN.BENCHMARK = False

5.4 AttributeError: ‘list’ object has no attribute ‘seek’. You can only torch.load from a file that is seekable. Please pre-load the data into a buffer like io.BytesIO and try to load from it
解決方案
- 暴力洗掉test.py39行的nargs=’+’

總結
困,想睡覺

有什么問題,歡迎評論區交流!
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/297396.html
標籤:其他
