facebookresearch / unbiased-teacher

PyTorch code for ICLR 2021 paper Unbiased Teacher for Semi-Supervised Object Detection
https://arxiv.org/abs/2102.09480
MIT License
409 stars 84 forks source link

How to calculate the Box Accuracy in Fig 4a? #39

Closed GeoffreyChen777 closed 2 years ago

GeoffreyChen777 commented 2 years ago

Anybody knows how to calculate this metric?

Thanks!

ycliu93 commented 2 years ago

Hi @GeoffreyChen777 , sorry for the late reply.

This is how I compute the metrics. Note that I decompose the factors of predicted boxes into IoU and box accuracy. For these predicted boxes with low IoU, I still compute its classification accuracy. You could try to further improve this metric by removing these low IoU boxes.

Let me know if you have other questions, thanks!

# gt_pps: all ground-truth boxes
# pred_pps: all predicted boxes/ pseudo-boxes
    def probe_iou_acc(self, gt_pps, pred_pps, name=''):

        mean_iou = 0.0
        pred_acc = 0.0
        for gt_pp, pred_pp in zip(gt_pps, pred_pps):

            if len(pred_pp)!= 0 :
                max_iou, max_idx = pairwise_iou(gt_pp.gt_boxes, pred_pp.pred_boxes).max(0)
                mean_iou += max_iou.mean()
                gt_cls = gt_pp.gt_classes[max_idx]
                pred_acc += (gt_cls == pred_pp.pred_classes).sum().float() / gt_cls.numel()
                raise ValueError('Unknown name for comparing gt and pseudo roi bbox.')
            else:
                mean_iou += torch.tensor(0).cuda()
                pred_acc += torch.tensor(0).cuda()

        metric = {}
        metric['bbox_prob_gt&'+name+'/mean_iou'] = mean_iou.item() / len(gt_pps)
        metric['bbox_prob_gt&'+name+'/accuracy'] = pred_acc.item() / len(gt_pps)

        return metric
GeoffreyChen777 commented 2 years ago

@ycliu93 thanks for your help!