hkchengrex / Mask-Propagation

[CVPR 2021] MiVOS - Mask Propagation module. Reproduced STM (and better) with training code :star2:. Semi-supervised video object segmentation evaluation.
https://hkchengrex.github.io/MiVOS/
MIT License
127 stars 22 forks source link

About Fig.6 again #45

Closed csustYyh closed 1 year ago

csustYyh commented 1 year ago

Do you include the background when calculating mIoU? The results I calculated are somewhat unusual; the decrease in mIoU(-0.07 ~ -0.17) is not as significant as shown in Figure 6(-0.1 ~ -0.4). image image

I used the original data you provided, 81.5 and 83.1. image

About STCN, I used the original data you provided, 83.3(computed with official model without top-k) and 85.3. image image

Here is my code:

def calculate_iou(pred_mask, true_mask, class_id):
    pred_class = (pred_mask == class_id)
    true_class = (true_mask == class_id)

    intersection = np.logical_and(pred_class, true_class)
    union = np.logical_or(pred_class, true_class)

    iou = (np.sum(intersection) + 1e-6) / (np.sum(union) + 1e-6)

    return iou

def calculate_miou(pred_dir, gt_dir):
    pred_images = [Image.open(path) for path in pred_dir]
    gt_images = [Image.open(path) for path in gt_dir]

    num_classes = np.max(np.array(pred_images[0])) + 1  # Assuming class labels start from 0

    class_ious = np.zeros(num_classes)

    for class_id in range(num_classes):
        class_iou_sum = 0
        class_pixel_count = 0

        for i in range(len(pred_images)):
            pred_mask = np.array(pred_images[i])
            true_mask = np.array(gt_images[i])

            class_iou = calculate_iou(pred_mask, true_mask, class_id)

            class_iou_sum += class_iou
            class_pixel_count += np.sum(true_mask == class_id)

        class_ious[class_id] = class_iou_sum / len(pred_images)

    mean_iou = np.mean(class_ious)

    return mean_iou, class_ious
csustYyh commented 1 year ago

I excluded the background class when calculating, and I obtained the results(-0.1 ~ -0.25). image

csustYyh commented 1 year ago

In Fig.6, color bands showing the interquartile range, I thought it was mIoU,I misunderstood it. But I still want to know if my way of calculating mIoU is correct.

hkchengrex commented 1 year ago

I am not checking your code but the trend looks correct.

csustYyh commented 1 year ago

Thanks for your reply, I guess there is no bug.