SegDiff
SegDiff copied to clipboard
Deprecated parameters in torchvision.transforms.functional.affine should be updated
@tomeramit Description:
In the following code (link to code), the function torchvision.transforms.functional.affine is used with deprecated parameters: resample and fillcolor.
def __call__(self, img, mask):
ret = self.get_params(self.degrees, self.translate, self.scale, self.shear, img.size)
return F.affine(img, *ret, resample=Image.BILINEAR, fillcolor=self.fillcolor), \
F.affine(mask, *ret, resample=Image.NEAREST, fillcolor=self.fillcolor)
🚫 Deprecated Parameters:
resample → should be replaced with interpolation
fillcolor → should be replaced with fill
According to the official torchvision documentation, these parameters were deprecated and are now replaced by interpolation and fill respectively.
✅ Suggested Fix: Update the code to use the current API:
from torchvision.transforms.functional import InterpolationMode
def __call__(self, img, mask):
ret = self.get_params(self.degrees, self.translate, self.scale, self.shear, img.size)
return F.affine(img, *ret, interpolation=InterpolationMode.BILINEAR, fill=self.fillcolor), \
F.affine(mask, *ret, interpolation=InterpolationMode.NEAREST, fill=self.fillcolor)
ℹ️ Environment: torchvision >= 0.10.0 (when this change was introduced)
Let me know if you’d like me to submit a PR for this fix.