3. https://dacon.i
o
3
- 이미지 아이디를 기준으로 전체 학습 데이터셋의 20%를 validation
데이터셋으로 분리
- 기존 학습 및 테스트 이미지가 2depth구조로 저장되어 있어서
1depth구조로 변경
- Augmentation
○ Random Flip: 0.5%
1. 데이터셋 전처리
4. https://dacon.i
o
4
2. model / 학습 및 검증
DetectoRS + Resnet50
https://arxiv.org/pdf/2006.02334.pdf
이미지 출처: https://medium.com/visionwizard/detectors-state-of-the-art-object-detector-from-google-research-e0b89abdd1fc
5. https://dacon.i
o
5
2. 학습 절차 / 학습 및 검증
총 4번의 Transfer Learning 과 Fine Tuning
1. Transfer Learning (backbone model, resnet50)
a. image scale: 1333, 800
i. 기존 pretrained된 모델 해상도에 맞게 Transfer learning
b. trained with splited traininig data
c. optimizer = dict(type='SGD', lr=0.02, momentum=0.9, weight_decay=0.0001)
d. training epoch: from 1epoch to 12epoch
e. transfer learning from pretrained torchvision://resnet50 with imagenet
2. Fine-Tuning 1
a. image scale: 800, 800
i. 대회 데이터셋 해상도에 맞게 해상도 변경
b. trained with all training data
i. 전체 학습 데이터로 학습
c. finetuning from work_dirs/fashion_detectors/epoch_12.pth
d. optimizer = dict(type='SGD', lr=0.02, momentum=0.9, weight_decay=0.0001)
e. training epoch: from 12epoch to 24epoch
6. https://dacon.i
o
6
2. 학습 절차 / 학습 및 검증
총 4번의 Transfer Learning 과 Fine Tuning
3. Fine-Tuning 2
a. image scale: 800, 800
b. trained with all traininig data
c. finetuning from work_dirs/fashion_detectors/epoch_24.pth
d. optimizer = dict(type='SGD', lr=0.004, momentum=0.9, weight_decay=0.0001)
i. loss가 튀어 learning rate를 급격하게 낮춤
e. training epoch: from 24epcoh to 36epoch
4. Fine-Tuning 3
a. image scale: 800, 800
b. trained with all traininig data
c. finetuning from work_dirs/fashion_detectors/epoch_34.pth
i. 36epoch보다 34epoch의 리더보드 AP점수가 높아서 34epoch 모델 사용
d. optimizer = dict(type='SGD', lr=0.002, momentum=0.9, weight_decay=0.0001)
i. loss가 튀어 learning rate를 약간 낮춤.
e. training epoch: from 34epoch to 50epoch
7. https://dacon.i
o
7
2. Validation / 학습 및 검증
- Segmentation의 Average Precision 활용
- 학습데이터의 20%인 validation 데이터셋으로 검증
- Leader Board 활용
- Validation 의 AP 가 높은 단일 모델들을 Leader Board 점수로
다시 한번 검증
- Validation의 AP와 Leader Board의 점수가 서로 다른 경우가
있어서 Validation의 AP를 완전하게 믿을 수 없었던 상황
- Leader Board AP로 TOP2모델로 epoch34와 epoch50 두 모델
을 선택
8. https://dacon.i
o
8
3. 앙상블 평가
- 싱글 모델로 Leader Board AP가 가장 높았던 두 모델 선택
- epoch34와 epoch50
- 각 모델을 개별적으로 테스트
- 테스트 파이프 라인
test_pipeline = [
dict(type='LoadImageFromFile'),
dict(
type='MultiScaleFlipAug',
img_scale=(800, 800),
flip=False,
transforms=[
dict(type='Resize', keep_ratio=True),
dict(type='RandomFlip'),
dict(type='Normalize', **img_norm_cfg),
dict(type='Pad', size_divisor=32),
dict(type='ImageToTensor', keys=['img']),
dict(type='Collect', keys=['img']),
])
]
9. https://dacon.i
o
9
3. 앙상블 평가
테스트 파라미터
test_cfg = dict(
rpn=dict(
nms_across_levels=False,
nms_pre=1000,
nms_post=1000,
max_num=1000,
nms_thr=0.7,
min_bbox_size=0),
rcnn=dict(
score_thr=0.81,
nms=dict(type='soft_nms', iou_threshold=0.5),
max_per_img=100,
mask_thr_binary=0.5)
)
soft_nms사용, score_thr 0.81로 튜닝하여 단일 모델 리더보드 AP score 약 7.8% 향상
10. 10
각 모델의 마스크들을 비교해서 merge 시도
- Rule1
- 이미지에 마스크가 하나만 탐지되면 무조건 결과에 추가한다.
- Rule2
- 이미지에 마스크가 여러개일때 두 마스크의 iou가 threshold 이상(best: 70%)이
면 두 mask를 머지하고(더하고) 더 좋은 모델의 category값으로 결과에 추가한
다.
- Rule3
- merge되지 않은 나머지 마스크들은 그대로 결과에 포함시킨다.
- 이 단순한 로직으로 리더보드 기준 약 1% 향상
3. 앙상블 평가
model1 model2
발견못함
결과에 포함
model1 model2
iou threshold
이상이면
두 mask 영역
더해서 포함
image
id
mask mask
id
결과 파일
iou threshold
이하이거나 겹
치지 않으면 그
대로 포함
1 2
3
11. https://dacon.i
o
11
3. 시도한 기법들(실패)
- Augmentations
- https://github.com/albumentations-team/albumentations
- Albumentations의 거의 모든 기법들을 활용
- baseline과 비교했을때 loss값이 두배가량 더 높음.
- Validation AP와 LeaderBoard AP모두 더 낮음.
- Mask Filtering
- 이미지의 1%정도 되는 크기의 mask를 결과에서 삭제함.
- LeaderBoard AP 더 낮아짐.
- Ensemble
- 동일한 마스크를 merge할때 교집합(mask1 * mask2) 영역만
merge하면 LeaderBoard AP가 더 낮아짐.