IoU of predicted and target masks in mask-rcnn

Here’s my mask IoU calculation:

    intersection = torch.sum((mask1 + mask2) > 1, -1)
    union = torch.sum((mask1 + mask2) > 0, -1)
    iou_score = intersection / (union + 1e-6)

I wonder if the >1 and >0 are correct for intersection and union of masks. I tried to print the values of target masks in Mask-rcnn of which have a shape of (batch, 28, 28). I’m seeing values of either zeros and ones through the whole array.

What does zeros array means, the mask with the object or an empty mask?