ML-Computer Vision/MMdetection

[mmdetection] 탐지 개체수 설정방법

dohyeon2 2022. 8. 9. 15:25

mmdetection에는 이미지 하나당 감지될 수 있는 개체수가 정해져있다. (default 100)

내가 다루는 데이터의 경우 하나의 이미지에 보통 2~300개의 instance가 존재하므로 위 설정을 바꿀 필요가 있었다. 

 

변경방법은 다음과 같다. 

 

mmdetection/configs/_base_/models/mask_rcnn_r50_fpn.py

 

위 파일에서 맨 아래부분의 test_cfg 부분을 살펴보면

 rcnn 내부에 max_per_img 이 변수가 하나의 이미지에서 탐지할 수 있는 최대 개체수 파라미터다. 

해당 파라미터를 1000으로 변경하면 최대 1000개까지 instance를 탐지할 수 있다.

test_cfg=dict(
    rpn=dict(
        nms_pre=1000,
        max_per_img=1000,
        nms=dict(type='nms', iou_threshold=0.7),
        min_bbox_size=0),
    rcnn=dict(
        score_thr=0.05,
        nms=dict(type='nms', iou_threshold=0.5),
        max_per_img=100,  # the maximum number of detectable objects
        mask_thr_binary=0.5)))

 

이상!