yhenon / pytorch-retinanet

Pytorch implementation of RetinaNet object detection.
Apache License 2.0
2.14k stars 665 forks source link

question about nms #79

Open feixiangdekaka opened 5 years ago

feixiangdekaka commented 5 years ago

the nms doesn't according score ,why not according each class and score .

Owen-Fish commented 4 years ago

agreed.

xu1718191411 commented 4 years ago

Yes, I found each anchor Box just fetch the heightest score.Thant means when useing torchvision.ops.nms(boxes, scores, iou_threshold), the scores does not indicate the the same class. https://github.com/yhenon/pytorch-retinanet/blob/master/retinanet/model.py

` scores = torch.max(classification, dim=2, keepdim=True)[0]

        scores_over_thresh = (scores > 0.05)[0, :, 0]

        if scores_over_thresh.sum() == 0:
            # no boxes to NMS, just return
            return [torch.zeros(0), torch.zeros(0), torch.zeros(0, 4)]

        classification = classification[:, scores_over_thresh, :]
        transformed_anchors = transformed_anchors[:, scores_over_thresh, :]
        scores = scores[:, scores_over_thresh, :]

        anchors_nms_idx = nms(transformed_anchors[0,:,:], scores[0,:,0], 0.5)

`

should it be link that?

for i in range(class_num): nms(boxes, scores[i], iou_threshold)

Could you give us some advise? Thank you

xu1718191411 commented 4 years ago

MayBe the new commit has solved this issue. https://github.com/yhenon/pytorch-retinanet/commit/af6e78e6e27ceed1611888ae20c5fabc5ed5ae0f