組員: 范植貿, 蘇郁宸, 黃裕芳, 黃建凱, 藍莉淇
├── README.md
主要訓練程式碼
├── cfg.py 訓練相關參數
├── make_txt.py 把主辦單位給的csv轉成相關格式
├── train.txt 轉檔後的訓練標籤檔
├── val.txt 轉檔後的驗證標籤檔
├── train.py 執行訓練及其他參數調整
├── training 預設訓練及驗證圖片資料夾
├── log 訓練loss可視化(tensorboard)
├── checkpoint 儲存每個epoch的權重檔
├── yolov4.conv.137.pth YOLOv4 pretrained model
├── yolov4-csp.conv.142.pth Scaled YOLOv4 pretrained model
主要測試程式碼
├── TestResult.py 測試水稻
├── test_cfg.yaml 設定測試水稻參數
├── dataset.py 讀檔轉檔
├── classify.py MLP分類器
├── TestMask.py U-Net產生Type0 mask
├── testingType0 產生Type0 mask用
├── testing 預設測試圖片資料夾
├── tool
│ ├── coco_annotation.py
│ ├── config.py
│ ├── darknet2pytorch.py
│ ├── region_loss.py
│ ├── utils.py
│ └── yolo_layer.py
├── TypeX_model 對應不同type的model
│ ├── Best AP_(第x個epoch)x(資料增強倍數).pth
│ ├── ...
├── Result 測試結果圖及對應csv
- 圖片準備根據主辦單位給的訓練資料總共43張圖及對應labels (label格式為水稻中心點座標):
- 利用
make_txt.py
把主辦單位給的水稻中心excel檔轉成YOLO需要的train.txt
與val.txt
檔
- 準備Ground truth label (
train.txt
/val.txt
)
並將訓練圖片放入training資料夾,label格式如下image_path1 x1,y1,x2,y2,id x1,y1,x2,y2,id x1,y1,x2,y2,id ... image_path2 x1,y1,x2,y2,id x1,y1,x2,y2,id x1,y1,x2,y2,id ... ...
- 設定
cfg.py
參數
- 若選擇darknet當作backbone (
Cfg.use_darknet_cfg = True
)
需要先找對應的cfg (yolov4-csp.cfg
)檔,找到classes部分改為所需類別,以及filters部分
filters 的大小為 = (5 + classes)*3... [convolutional] size=1 stride=1 pad=1 filters=18 #(39) activation=linear [yolo] mask = 6,7,8 anchors = 12, 16, 19, 36, 40, 28, 36, 75, 76, 55, 72, 146, 142, 110, 192, 243, 459, 401 classes=1 #(8) ...
- 若不用darknet,則需要在
train.py
裡,Yolo_loss中的image_size調整resize大小class Yolo_loss(nn.Module): def __init__(self, n_classes=80, n_anchors=3, device=None, batch=2): super(Yolo_loss, self).__init__() self.device = device self.strides = [8, 16, 32] image_size = 640 self.n_classes = n_classes self.n_anchors = n_anchors
- train
python train.py -l [學習率] -g [GPU] -dir [訓練資料集位置] -classes [類別]
- AI CUP 競賽報告
- AI CUP 實驗記錄
- Public data
- Private data
- 測試時不需要更改相關路徑,只須確定所有相對路徑是否有圖片
- 測試時所有更改參數的地方都在
test_cfg.yaml
進行更改 - 預設測試資料路徑:
./testing
- 預設測試結果路徑:
./Result
python TestResult.py
-
我們每次上傳分數都會留下當次測試的參數細節、偵測結果圖與測試分數
(https://drive.google.com/drive/folders/1EZeyRFDi9dmy7UYNcRN06V7a6xarPK2G?usp=sharing)
p.s. 整體檔案大小31G 上面分享網址只包含最後一次更新分數計算的每次測試結果資料
若有需要可以聯絡我們 再把所有完整檔案分批傳送 -
Public best config (Copy to
test_cfg.yaml
)--- test: model ensemble: true image ensemble: true gpu: true model0_1: './Type0_model/Best AP_629x32.pth' model0_2: './Type0_model/Best AP_462x6.pth' model0_3: './Type0_model/Best AP_95x32_928.pth' model1_1: './Type1_model/Best AP_211_640csp.pth' model1_2: './Type1_model/Best AP_500.pth' model1_3: './Type1_model/Best AP_57x96.pth' model2_1: './Type2_model/Best F1_353.pth' model2_2: './Type2_model/Best F1_353.pth' model2_3: './Type2_model/Best AP_25x80.pth' type0_c_n: [0.1, 0] type1_c_n: [0.06, 0.15] type2_c_n: [0.5, 0.01] area constant0: 200 area constant1: 1300 area constant2: 0 data path: './testing/' mask path: './UNetMaskOptimize/' classes: 1 boundary: 0.5 width: 608 height: 608 save img: './Result/' save csv: './Result/csv' classifier: model path: './classifier/all_right_model.pth' name json: './classifier/custom_to_name.json' ...
-
-
參加隊伍: 523隊
-
最終排名: 總排名第 11 名 (佳作),
全國大專院校組第 9 名(原第4、第5為業界隊伍)
-
- Reference:
- E-mail: qaz5517359@gmail.com