Skip to content

RandomErasing is buggy #1094

@Zhaoyi-Yan

Description

@Zhaoyi-Yan

@zhunzhong07 @fmassa
https://github.com/pytorch/vision/blob/master/torchvision/transforms/transforms.py#L1256-L1263

Here, you assume that img_h < img_w implictly, which is true for most images. However, for some images img_h > img_w.

if h < img_h and w < img_w:

This line of code equals to:

h/w <(ratio0~ratio1)/(scale0~scale1)

where the right falls in the range of (ratio0/scale1, ratio1/scale0), here is (0.9, 16.7). Then when h is more than 17 times of w, the loop runs forever.

If the user sets custom ratio and scale, this may happen more frequenently. At least, more checks are deserved to add. Or maybe give warnings if this probablity is high.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions