728x90
반응형

 

초창기 Object Detection 분야에서는 하나의 grid cell에 객체를 하나만 검출할 수 있었으며, 더 나아가 여러개의 grid에서 객체를 검출하기 위해 Anchor box라는 개념을 사용하여 객체를 탐지하였습니다. 여기서 Anchor box는 딥러닝 신경망이 검출해야할 object shape에 대한 가정입니다. 

 

하지만 Anchor box는 크기, 종횡비, 개수에 굉장히 민감하다는 단점이 있습니다. 이 Anchor box를 어떻게 설계하느냐에 따라 모델 성능에 영향을 미치게 됩니다. 또한 pre-defined anchor는 모델 일반화 성능을 해치게 되고, anchor box 크기와 다른 ground-truth를 검출하기 어렵다는 단점이 있습니다. 따라서 anchor box를 사용하지 않는 anchor-free기반의 object detection 방법들이 나오기 시작합니다. 

 

anchor-free 기반 object detection 방법들은 이미지에서 객체를 어떻게 예측할까요? 대표적으로 FCOS 모델과 같은 경우 feature map의 모든 픽셀 위치에서 해당 픽셀이 특정 object에 속한 픽셀인지 아닌지를 계산하는 방식을 사용합니다. 또한 centerness 개념을 도입하여 객체의 bounding box를 결정할 때 object center에서 멀리 떨어진 위치에서 예측된 값들의 영향력을 줄입니다. 

 

그리고 FCOS_PLUS에서는 정확도 향상을 위해 center sample이라는 것을 도입하여 center를 결정합니다. 아래 그림을 보시면 이해가 잘 됩니다. center sample을 사용하게 되면 AP가 1 point 정도 가까이 오른다고 합니다. 

 

 

A trick of using a small central region of the BBox for training improves AP by nearly 1 point as shown here. (23/07/2019)

공식 github 구현에도 기능이 포함되어 있으며 center sample의 radius만 조절하여 학습하면 됩니다.

최적의 값은 1.5 라고 알려져있습니다. 

 

  FCOS:
    # normalizing the regression targets with FPN strides
    NORM_REG_TARGETS: True
    # positioning centerness on the regress branch.
    # Please refer to https://github.com/tianzhi0549/FCOS/issues/89#issuecomment-516877042
    CENTERNESS_ON_REG: True
    # using center sampling and GIoU.
    # Please refer to https://github.com/yqyao/FCOS_PLUS
    CENTER_SAMPLING_RADIUS: 1.5
    IOU_LOSS_TYPE: "giou"

 

FCOS PLUS의 center sampling 구현은 아래와 같습니다. 공식 구현을 보셔도 좋습니다. 

   def get_sample_region(self, gt, strides, num_points_per, gt_xs, gt_ys, radius=1):
        num_gts = gt.shape[0]
        K = len(gt_xs)
        gt = gt[None].expand(K, num_gts, 4)
        center_x = (gt[..., 0] + gt[..., 2]) / 2
        center_y = (gt[..., 1] + gt[..., 3]) / 2
        center_gt = gt.new_zeros(gt.shape)
        # no gt
        if center_x[..., 0].sum() == 0:
            return gt_xs.new_zeros(gt_xs.shape, dtype=torch.uint8)
        beg = 0
        for level, n_p in enumerate(num_points_per):
            end = beg + n_p
            stride = strides[level] * radius
            xmin = center_x[beg:end] - stride
            ymin = center_y[beg:end] - stride
            xmax = center_x[beg:end] + stride
            ymax = center_y[beg:end] + stride
            # limit sample region in gt
            center_gt[beg:end, :, 0] = torch.where(xmin > gt[beg:end, :, 0], xmin, gt[beg:end, :, 0])
            center_gt[beg:end, :, 1] = torch.where(ymin > gt[beg:end, :, 1], ymin, gt[beg:end, :, 1])
            center_gt[beg:end, :, 2] = torch.where(xmax > gt[beg:end, :, 2], gt[beg:end, :, 2], xmax)
            center_gt[beg:end, :, 3] = torch.where(ymax > gt[beg:end, :, 3], gt[beg:end, :, 3], ymax)
            beg = end
        left = gt_xs[:, None] - center_gt[..., 0]
        right = center_gt[..., 2] - gt_xs[:, None]
        top = gt_ys[:, None] - center_gt[..., 1]
        bottom = center_gt[..., 3] - gt_ys[:, None]
        center_bbox = torch.stack((left, top, right, bottom), -1)
        inside_gt_bbox_mask = center_bbox.min(-1)[0] > 0
        return inside_gt_bbox_mask

 

 

이 center sample과 비슷하게 예전에 FoveaBox 라는 개념이 나왔었습니다. 이는 object existing possibility에 대한 category-sensitive semantic maps을 예측하고 객체를 포함하는 각 위치에 대해 category-agnostic bounding box를 생성합니다. 

 

 

아래 왼쪽 그림은 기존 anchor 기반 검출 방식이고, 오른쪽 그림은 FoveaBox 검출 방식입니다. anchor 기반 방식은 각 output spatial position에 anchor를 균일하게 배치하고 IoU를 사용하여 positive/negative anchor를 정의합니다. anchor-free 기반 방식의 FoveaBox는 positive/negative sample을 ground-truth box로 직접 정의하고 해당 위치에서 box의 경계를 예측합니다. 

 

 

 

이는 center sampling 방식과 굉장히 유사한데 세부사항은 다릅니다. 예를 들면 center sampling 에서는 9~ 16개의 center positive 위치만 sampling 된다고 합니다. 

 

 

 

 

 

 

 

 

 

참고자료 1 : https://github.com/yqyao/FCOS_PLUS/blob/master/fcos.pdf

 

GitHub - yqyao/FCOS_PLUS: Some improvements (center sample) about FCOS (FCOS: Fully Convolutional One-Stage Object Detection).

Some improvements (center sample) about FCOS (FCOS: Fully Convolutional One-Stage Object Detection). - GitHub - yqyao/FCOS_PLUS: Some improvements (center sample) about FCOS (FCOS: Fully Convolutio...

github.com

 

참고자료 2 : https://github.com/yqyao/FCOS_PLUS

 

GitHub - yqyao/FCOS_PLUS: Some improvements (center sample) about FCOS (FCOS: Fully Convolutional One-Stage Object Detection).

Some improvements (center sample) about FCOS (FCOS: Fully Convolutional One-Stage Object Detection). - GitHub - yqyao/FCOS_PLUS: Some improvements (center sample) about FCOS (FCOS: Fully Convolutio...

github.com

 

참고자료 3 : https://arxiv.org/abs/1904.03797

 

FoveaBox: Beyond Anchor-based Object Detector

We present FoveaBox, an accurate, flexible, and completely anchor-free framework for object detection. While almost all state-of-the-art object detectors utilize predefined anchors to enumerate possible locations, scales and aspect ratios for the search of

arxiv.org

 

728x90
반응형