Vision: BalancedPositiveNegativeSampler generates wrong samples indexes?

Created on 13 Dec 2019  路  2Comments  路  Source: pytorch/vision

Hi. I have a question about usage of zeros_like() function used in BalancedPositiveNegativeSampler: https://github.com/pytorch/vision/blob/2d7c0667a5b1f4827a9bed828df20218af2a9081/torchvision/models/detection/_utils.py#L74

If I am right zeros_like() function doesn't return tensor with zeros (empty mask), so observations aren't sampled correctly for RPN learning.

I came across a situation where I have {-1, 0, 1} values in labels for one image after https://github.com/pytorch/vision/blob/2d7c0667a5b1f4827a9bed828df20218af2a9081/torchvision/models/detection/rpn.py#L477

matched_idxs_per_image.unique()
>>> tensor([-1.,  0.,  1.])

which put into zeros_like() in #L74 gives values in {0, 1, 255}

zeros_like(
    matched_idxs_per_image, dtype=torch.uint8
).unique()
>>> tensor([  0,   1, 255], dtype=torch.uint8)

Please let me know if I am right or I misunderstood something in the code. :)

bug models object detection

Most helpful comment

Oh, thanks a lot for the bug report, this was a bug introduced in https://github.com/pytorch/vision/pull/1407 , I'm fixing this right away

All 2 comments

Oh, thanks a lot for the bug report, this was a bug introduced in https://github.com/pytorch/vision/pull/1407 , I'm fixing this right away

Should be fixed in #1670

Was this page helpful?
0 / 5 - 0 ratings