fiveai / MoCaE

The official implementation of "MoCaE: Mixture of Calibrated Experts Significantly Improves Accuracy in Object Detection"
https://arxiv.org/abs/2309.14976
Other
21 stars 2 forks source link

DOTA #4

Open YXB-NKU opened 2 months ago

YXB-NKU commented 2 months ago

how to get calibrators for rotated object detector ,can you provide more details

YXB-NKU commented 2 months ago

I want to test the results of an ensemble of two other models. However, when I read the .pkl file, I found that after calibration, the y_max for all 15 categories was 1, and the y_min was 0. To proceed, I simply replaced the folder names and swapped the test results in work_dirs with those from the other two models. Then, I used the mocae_rotated_object_detection.py script to calibrate the test results of these two models. However, I found that the performance was much worse than the original results of the two models.

kemaloksuz commented 2 months ago

We haven't released the calibration code for rotated object detection yet. We are planning to release that part as well but it is very unlikely that it will be released before ECCV. So, it can take between 1-2 months before we release it.

If you do not want to wait till then, you can also implement by modifying model_calibration.py accordingly (this is only supporting object detection at the moment). Overall, (1) it should read the detections in the validation set (you can see the current code to understand the format etc.) and (2) make the assignment between detections and gts based on IoUs. The second part can be implemented by using box_iou_quadri (from mmcv.ops import box_iou_quadri) and then replacing assign_post function with the function below:

def assign_rotated(ann_dict, det_bboxes, det_score, det_label, dataset_classes):
    num_classes = len(dataset_classes)
    ious = np.zeros([det_bboxes.shape[0]])
    ## Assign
    for k, v in ann_dict.items():
        # Convert to numpy and reshape
        gt_boxes = np.array(v).reshape(-1, 8)
        rel_idx = (det_label==k).nonzero()[0]
        ious_cl = (box_iou_quadri(torch.from_numpy(gt_boxes).float(), torch.from_numpy(det_bboxes[rel_idx]).float())).numpy()
        ious[rel_idx] = np.max(ious_cl, axis=0)
    return ious

Hope this helps, and sorry for delaying the calibration part for that task.

rookie0607 commented 1 month ago

We haven't released the calibration code for rotated object detection yet. We are planning to release that part as well but it is very unlikely that it will be released before ECCV. So, it can take between 1-2 months before we release it.

If you do not want to wait till then, you can also implement by modifying model_calibration.py accordingly (this is only supporting object detection at the moment). Overall, (1) it should read the detections in the validation set (you can see the current code to understand the format etc.) and (2) make the assignment between detections and gts based on IoUs. The second part can be implemented by using box_iou_quadri (from mmcv.ops import box_iou_quadri) and then replacing assign_post function with the function below:

def assign_rotated(ann_dict, det_bboxes, det_score, det_label, dataset_classes):
    num_classes = len(dataset_classes)
    ious = np.zeros([det_bboxes.shape[0]])
    ## Assign
    for k, v in ann_dict.items():
        # Convert to numpy and reshape
        gt_boxes = np.array(v).reshape(-1, 8)
        rel_idx = (det_label==k).nonzero()[0]
        ious_cl = (box_iou_quadri(torch.from_numpy(gt_boxes).float(), torch.from_numpy(det_bboxes[rel_idx]).float())).numpy()
        ious[rel_idx] = np.max(ious_cl, axis=0)
    return ious

Hope this helps, and sorry for delaying the calibration part for that task.

Is there any progress on open source?

rookie0607 commented 1 month ago

@kemaloksuz

kemaloksuz commented 1 month ago

Hi @rookie0607, thanks for your interest.

We have an intent to do that as I mentioned above. However, our schedule is quite busy and we could not have chance to look into this yet. We will let you know once we could incorporate this part into the code.