MMDetection (ver. 3)을 사용하면서 필요한 설정 방법들 정리 POST
MMDetection (ver. 2) 사용법 (기본적인 내용)
https://greeksharifa.github.io/references/2021/08/30/MMDetection/
Python, Machine & Deep Learning
Python, Machine Learning & Deep Learning
greeksharifa.github.io
Mask(Instance or Segmentation) 모델을 Detection 모델로 학습하기 위한 Config 파일 수정
예를들어, mask_rcnn 모델을 Detection Task로 학습시키고 싶을때 다음 Config 파일의 다음 부분을 수정하면 된다.
1. model
model = dict(
...
mask_head = None,
mask_roi_extractor = None,
... )
2. train_cfg
train_cfg = dict(
...
mask_size = 0
... )
3. train_pipeline
train_pipeline = [
...
dict(type='LoadAnnotations', with_bbox=True, with_mask=False),
...
dict(type='Collect', keys=['img', 'gt_bboxes', 'gt_labels'])
... ]
4. evaluation
evaludation = dict(interval=1, metric='bbox')
5. SynBN to BN
roi_head.bbox_head.norm_cfg = dict(type='BN', requires_grad=True)
Multi GPU (Distributed Train) 사용 방법
$ tools/dist_train.sh [config_file_dir] [gpu_num] [config]
$ tools/dist_train.sh custom/dino.py 2 --cfg-options randomness.seed=909 --work-dir work_dirs/dino
만약 RuntimeError: Address already in use 에러가 뜬다면, 해당 포트를 사용중이기 때문에 lsof -i 명령어로 사용중인 포트를 확인 후 kill -9 [pid_nume] 을 사용해 종료해준 후 실행한다.
Confusion Matrix 확인 방법
1. Train Dataset 또는 Valid Dataset Inference 결과 출력하기
python tools/test.py [config file] [.pth file] --out [결과를 저장할 위치 (.pkl)]
python tools/test.py custom/efficientdet_~~.py work_dirs/efficientdet_~~/best.pth --out work_dirs/efficientdet_~~/output.pkl
Gradient Accumulative 적용
1. accumulative_counts=8 를 넣어준다. Github
# optimizer
optim_wrapper = dict(
type='OptimWrapper',
accumulative_counts=8, # grad accumulative
optimizer=dict(
type='AdamW',
lr=0.0001, # 0.0002 for DeformDETR
weight_decay=0.0001),
# clip_grad=dict(max_norm=0.1, norm_type=2)
clip_grad=dict(max_norm=35, norm_type=2),
paramwise_cfg=dict(custom_keys={'backbone': dict(lr_mult=0.1)})
) # custom_keys contains sampling_offsets and reference_points in DeformDETR # noqa
'ML & DL > Practice' 카테고리의 다른 글
YOLO v8 사용하기 (ultralytics) (0) | 2023.05.20 |
---|---|
[MMDetection 2.0] 정리 (0) | 2023.05.16 |
[Ubuntu] Pytorch 에서 YOLO v3 사용하기 (ultralytics) (0) | 2022.03.19 |
[Ubuntu] YOLO Darknet(AlexeyAB) 학습 환경 구축 (0) | 2022.01.07 |
mrcnn(Mask-RCNN) 무작정 따라하기 (0) | 2021.11.07 |