Open Acly opened 1 year ago
Reproducer:
>>> mask = torch.zeros([1, 4, 4]) >>> mask[0, 0:2, 0:2] = torch.ones([2, 2]) >>> mask tensor([[[1., 1., 0., 0.], [1., 1., 0., 0.], [0., 0., 0., 0.], [0., 0., 0., 0.]]]) >>> MaskNodes.MaskToRegion().get_region(mask, 0, 'multiple_of', 2, 2, 0, 0, 'match_ratio') (tensor([[[1., 1., 1., 0.], [1., 1., 1., 0.], [1., 1., 1., 0.], [0., 0., 0., 0.]]]),)
I believe the width/height calculation is wrong? it should rather be:
width = max_x - min_x + 1 height = max_y - min_y + 1
Also this code should probably clamp max_x/max_y to the mask's max, ie. mask_width - 1 and mask_height - 1.
max_x
max_y
mask_width - 1
mask_height - 1
Reproducer:
I believe the width/height calculation is wrong? it should rather be: