$ sh run.sh
-
System
- OS
$ uname -a Linux 78709cb2ea9c 4.4.0-59-generic #80-Ubuntu SMP Fri Jan 6 17:47:47 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
커널: 4.4.0-59-generic 버전
OS: x86 계열의 64bit 운영체제- CPU
$ cat /proc/cpuinfo Intel(R) Xeon(R) Gold 5120 CPU @ 2.20GHz
- GPU
- aistage 에서 제공받은 v100 GPU (NVIDIA 테슬라 Tesla V100 32G GPU)
-
Python
- version: 3.7.11
Get the trash dataset
$ wget https://aistages-prod-server-public.s3.amazonaws.com/app/Competitions/000076/data/data.tar.gz
$ tar xvfz data.tar.gz
$ mv ./data/ ./dataset
$ rm ./data.tar.gz
$ rm -rf ./dataset/*/.*.jpg
Check the dataset structure and format(COCO format)
./
└─dataset/
├─train/
| ├─0000.jpg
| ├─ ...
| └─48xx.jpg
├─test/
| ├─0000.jpg
| ├─ ...
| └─4870.jpg
├─train.json
└─test.json
Trash Dataset Copy Rights: Naver Connect
Trash Dataset Copy Rights License: CC-BY-2.0
-
MMDetection
$ cd ./mmdetection $ pip install -v -e .
reference: MMDetection github
-
YOLOv5
$ cd ./yolov5 $ pip install -r requirements.txt
reference: YOLOv5 github
-
convert2Yolo
$ git clone https://github.com/ssaru/convert2Yolo.git $ cd ./convert2Yolo $ pip3 install -r requirements.txt
reference: conver2Yolo github
-
WBF (Weighted Boxes Fusion)
$ pip install ensemble-boxes
reference: WBF github
./
├─dataset/
| ├─train/
| | ├─0000.jpg
| | ├─ ...
| | └─48xx.jpg
| ├─test/
| | ├─0000.jpg
| | ├─ ...
| | └─4870.jpg
| ├─train.json
| └─test.json
|
├─mmdetection/
├─yolov5/
├─convert2Yolo
|
├─submissions_for_single_model/
| ├─submission_yolov5s.csv
| ├─submission_faster_rcnn.csv
| ├─...
| └─submission_swin.csv
|
├─run.py
├─run.sh
|
└─submission.csv # Result of "python run.py" or "sh run.sh"
-
Prepare the
*.names
file as below.$ cat ./dataset/trash_coco.names General trash Paper Paper pack Metal Glass Plastic Styrofoam Plastic bag Battery Clothing
-
Convert dataset format by using
convert2Yolo
$ cd ./convert2Yolo $ python3 example.py \ --datasets COCO \ --img_path ../dataset/ \ --label ../dataset/train.json \ --convert_output_path ../dataset/ \ --img_type ".jpg" \ --manifest_path ../dataset \ --cls_list_file ../dataset/trash_coco.names
-
Then, we have the following structure.
./ ├─dataset/ | ├─train/ | | ├─0000.jpg | | ├─0000.txt # YOLO format | | ├─ ... | | ├─48xx.jpg | | └─48xx.txt # YOLO format | ├─test/ | | ├─0000.jpg | | ├─ ... | | └─4870.jpg | ├─train.json # COCO format | └─test.json # COCO format | ├─mmdetection/ ├─yolov5/ ├─convert2Yolo | ├─submissions_for_single_model/ | ├─submission_yolov5s.csv | ├─submission_faster_rcnn.csv | ├─... | └─submission_swin.csv | ├─run.py ├─run.sh | └─submission.csv # Result of "python run.py" or "sh run.sh"
-
detectors-cascade-rcnn-r50
$ cd ./mmdetection $ python tools/train.py \ configs/trash/detectors_cascade_rcnn_r50.py
-
cascade-rcnn-swin-base
$ cd ./mmdetection $ python tools/train.py \ configs/trash/swin/cascade_rcnn_swin_base_fpn.py
-
cascade-rcnn-r50-fpn
$ cd ./mmdetection $ python tools/train.py \ configs/trash/cascade_rcnn_r50_fpn.py
-
YOLOv5x6
- Before training
$ cd ./yolov5 $ pip install -r requirements.txt
- Train pre-trained model for 10-epochs
$ python train.py \ --img 1024 --batch 4 --epochs 10 --data custom.yaml \ --weights yolov5x6.pt --cache --name 10epoch
- Train pre-trained model for 20-epochs
$ python train.py \ --img 1024 --batch 4 --epochs 20 --data custom.yaml \ --weights yolov5x6.pt --cache --name 20epochs
-
detectors-cascade-rcnn-r50
$ cd ./mmdetection $ python tools/test.py \ confings/trash/detectors_cascade_rcnn_r50.py \ work_dirs/detectors_cascade_rcnn_r50/best*.pth \ --out work_dirs/detectors_cascade_rcnn_r50/best.pkl $ python tools/pkl_to_submission.py \ --pkl work_dirs/detectors_cascade_rcnn_r50/best.pkl \ --csv work_dirs/detectors_cascade_rcnn_r50.csv $ cp work_dirs/detectors_cascade_rcnn_r50.csv \ ../submissions_for_single_model/submission_detectors_cascade_rcnn_r50.csv
-
cascade-rcnn-r50-fpn
$ cd ./mmdetection $ python confings/trash/cascade_rcnn_r50_fpn.py \ work_dirs/cascade_rcnn_r50_fpn/best*.pth \ --out work_dirs/cascade_rcnn_r50_fpn/best.pkl $ python tools/pkl_to_submission.py \ --pkl work_dirs/cascade_rcnn_r50_fpn/best.pkl \ --csv work_dirs/cascade_rcnn_r50_fpn.csv $ cp work_dirs/cascade_rcnn_r50_fpn.csv \ ../submissions_for_single_model/submission_cascade_rcnn_r50_fpn.csv
-
cascade-rcnn-swin-base
$ cd ./mmdetection $ python confings/trash/swin/cascade_rcnn_swin_base_fpn.py \ work_dirs/cascade_rcnn_swin_base_fpn/best*.pth \ --out work_dirs/cascade_rcnn_swin_base_fpn/best.pkl $ python tools/pkl_to_submission.py \ --pkl work_dirs/cascade_rcnn_swin_base_fpn/best.pkl \ --csv work_dirs/cascade_rcnn_swin_base_fpn.csv $ cp work_dirs/cascade_rcnn_swin_base_fpn.csv \ ../submissions_for_single_model/submission_cascade_rcnn_r50_fpn.csv
-
YOLOv5x6
- Ensemble 2 models (Use YOLOv5 built-in ensemble)
$ cd ./yolov5 $ python detect.py \ --weights ./weights/runs/10epoch/train/best.pt ./weights/runs/20epoch/train/best.pt \ --source ../dataset/test/ \ --imgsz 1024 \ --max-det 100 \ --device 0 \ --classes 0 1 2 3 4 5 6 7 8 9 \ --save-txt --save-conf \ --nosave \ --augment
- Convert labels to CSV file
$ cd ./yolov5 $ python convertcsv.py
- Ensemble 2 models (Use YOLOv5 built-in ensemble)
- WBF (Weighted Boxes Fusion)
- Config Format
{ "csvs": ["./output_0.csv", "./output_1.csv", "./output_2.csv", "./output_3.csv", "./output_4.csv", "./output_5.csv" ], "save_path": "./result_outputs.csv", "ensemble_mode": "wbf", "weights": "None", "iou_thr": 0.5, "skip_box_thr": 0.0001, "sigma": 0.1, "img_size": 1024 }
csvs: 단일 모델이 예측한 결과
csv
파일들
ensemble_mode: Choose the ensemble mode (wbf
,nms
,nmw
,snms
)
- Config Format
$ python ensemble.py
이름 | 김서기 | 김승훈 | 손지아 | 이상은 | 조익수 | 배민한 |
---|---|---|---|---|---|---|
역할 |