Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug in transforms.py #6547

Closed
fenneishi opened this issue Sep 8, 2022 · 3 comments · Fixed by #6548
Closed

bug in transforms.py #6547

fenneishi opened this issue Sep 8, 2022 · 3 comments · Fixed by #6548

Comments

@fenneishi
Copy link

fenneishi commented Sep 8, 2022

🐛 Describe the bug

location:

if h + 1 < th or w + 1 < tw:

fix:

if h + 1 < th or w + 1 < tw: ==>if h < th or w < tw:

cc @vfdev-5 @datumbox

@datumbox
Copy link
Contributor

datumbox commented Sep 8, 2022

@fenneishi thanks for reporting.

@vfdev-5 I see this was introduced at #2816. For h=100, th=101 this will lead to 101<101 which seems wrong. Do you remember if there was a specific reason for adding the +1s or you think it's a bug?

@vfdev-5
Copy link
Collaborator

vfdev-5 commented Sep 8, 2022

Yes, it is a bug. The condition if h + 1 < th or w + 1 < tw: was derived wrongly fromtorch.randint(0, h - th + 1, size=(1,)) as we need to generate a random int value. h - th + 1 is the upper non-inclusive boundary.

It should be h - th + 1 >= 2 -> h + 1 >= th + 2 -> h >= th + 1 or h > th. We also need to take into account that h == th. Thus, obviously correct condition is if h < th: raise error

@fenneishi
Copy link
Author

thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants