Description
Initially, torchvision
supported int
's for the interpolation
(or their former equivalent) arguments on our transforms. They were usually not passed directly, but rather as part of the Pillow constants, like PIL.Image.BILINEAR
.
#2952 (review) proposed to decouple our transforms from Pillow and this was achieved through the torchvision.transforms.InterpolationMode
enum introduced later in the same PR. Although, the new enum was used as default value from then on, int
's were still supported. Still, the language around them somewhat "soft-deprecated" them:
vision/torchvision/transforms/transforms.py
Line 301 in 9b5a3fe
With the release of Pillow==9.1.0
, they deprecated the int
constants and switched to their own enums as well. In response we introduced support for these enums as well in #5898 and deprecated int
s in #5974.
Our deprecation was scheduled for removal in the upcoming 0.15 release and was acted upon in #7176.
However, there are two factors we didn't consider there:
-
@NicolasHug pointed out that using ints is still widespread for Meta internal users
-
Pillow
seemed to have walked back on their deprecation in9.4.0
as well:In Pillow 9.1.0, the following constants were deprecated. That has been reversed and these constants will now remain available.
This follows API changes for Resampling modes python-pillow/Pillow#6537 which acknowledges that the change is too disruptive. However, since removing the enums now would also be BC breaking (Revert replacing and deprecating constants with enums python-pillow/Pillow#6684), they just reinstated the former int constants in python-pillow/Pillow@bcdb208
Given that our deprecation just followed Pillow
's, I think we can also revert the removal and deprecation. Between >= 9.1.0
and < 9.4.0
, Pillow
never dropped support for int
's. Thus, the only issues our users could run into when using int
's on that versions is that Pillow
will emit a deprecation warning. Our default values use our enum anyway
vision/torchvision/transforms/transforms.py
Line 315 in 539c6e2
If we go that route note that we also need add support for int
's to our prototype transforms. They don't have that, since we designed with the scheduled removal in mind.
Thoughts?
cc @vfdev-5