Closed shaibagon closed 2 months ago
Happended using pillow
version 10.4.0 and 9.5.0.
It is because numpy 2.0 stopped doing the auto conversion in the new versions. In version 1.24.4, when I do np.uint8(-34)
I got DeprecationWarning: NumPy will stop allowing conversion of out-of-bound Python integers to integer arrays. The conversion of -34 to uint8 will fail in the future.
While in numpy 2.0, I got OverflowError: Python integer -34 out of bounds for uint8
. Pytorch should make changes to their transform functions and anywhere that require automatic uint conversion to adapt to the new numpy changes.
@zhmiao thank you.
I downgraded to numpy==1.26.4
and the problem disappeared.
However, no DeprecationWarning
is shown in this version.
Is it possible that numpy 2
is a bigger issue? See, e.g., #8530
Hi @shaibagon , thanks for the report.
TL;DR: This will be fixed in torchvision 0.19 which we'll release later this week.
A bit more detail for anyone else hitting this: as @zhmiao pointed, this is related to numpy2. That's not related to Pillow, and that's not related to torchvision's version either (for any version <= 0.18). The fix was made in https://github.com/pytorch/vision/pull/8463. Updating torchvision to >= 0.19
once it's released (in a few days) should fix the problem. Meanwhile, the workaround is to downgrade numpy to any version <2
.
Closing as 0.19 is out. Feel free to reopen if the issue persists.
@NicolasHug Thank you!
🐛 Describe the bug
Using
ColorJitter
augmentations in torchvision 0.18.1 results in anOverflowError
. This was not observed in oldertorchvision
versions (tested with 0.15.0).How to reproduce:
This code will through:
Versions