###### tags: `yolov5`
# Yolov5 訓練 INFO
## ===== Data 類別 ========
nc = 4
- 0 : car
- 1 : hov
- 2 : person
- 3 : motorcycle
---
<br>
## ===== Yolov5 文件 & 資料夾 ========
- models Folder : 放置 model 架構資料 (.yaml)
- data : 放置 Data
- tutorial.ipynb : 官方 jp note 教學
- detect.py : 預測
- val.py : 驗證
- train.py 訓練
---
<br>
## ===== 訓練資料夾 ========
> - datasets
> - images
> - train
> - 00001.png
> - ...
> - labels
> - train
> - 00001.txt
> - ...
>
## ===== 預設偵測框-資料格式 ========
原始 txt 檔 label 資料
> txt 檔名 = 對應圖片
>
> label, 左上角 x, 左上 y, bb寬, bb高
>
> e.g : 0, 779, 276, 26, 60
x 往右為正、y 往下為正
> 圖片大小 : 1920 * 1080
上傳同以上格式 file
---
<br>
## ===== Bounding Box TXT File Preprossing ========
Bounding Box = bb
1. 將 bounding box (left_up_x, left_up_y) 校準成 (center_x, center_y)
2. 將 (center_x, center_y, width, height ) Normalize
>$centerX = leftX+\frac{width}{2}$
>
>$centerY = upY + \frac{height}{2}$
>
>X & width Normalize => $\frac{X}{ImageWidth}$
>
>Y & height Normalize => $\frac{Y}{ImageHeight}$
---
<br>
## ===== 訓練 ERROR ========
> [ 待優化 ]
>
> :::danger
> \> Unexpected bus error encountered in worker. This might be caused by insufficient shared memory (shm)
> :::
>
> > 網路查詢後,似乎是 Docker 設置的 shared memory size 太小(?)
> >
> > [Docker:Pytorch报错insufficient shared memory (shm)](https://blog.csdn.net/Felaim/article/details/109318772)
> >
> > [ERROR: Unexpected bus error encountered in worker](https://blog.csdn.net/DeliaPu/article/details/124633581)
>
> :::info
> - 解決方法 : 目前將 worker 改為 0 解決
>
> - 缺點 : 速度慢
> :::