use `Image.Resampling` namespace for PIL mapping

PIL shows a deprecation warning when accessing resampling constants via the `Image` namespace. The suggested namespace is `Image.Resampling`. This commit updates `_pil_interpolation_to_str` to use the `Image.Resampling` namespace.

```
/tmp/ipykernel_11959/698124036.py:2: DeprecationWarning: NEAREST is deprecated and will be removed in Pillow 10 (2023-07-01). Use Resampling.NEAREST or Dither.NONE instead.
  Image.NEAREST: 'nearest',
/tmp/ipykernel_11959/698124036.py:3: DeprecationWarning: BILINEAR is deprecated and will be removed in Pillow 10 (2023-07-01). Use Resampling.BILINEAR instead.
  Image.BILINEAR: 'bilinear',
/tmp/ipykernel_11959/698124036.py:4: DeprecationWarning: BICUBIC is deprecated and will be removed in Pillow 10 (2023-07-01). Use Resampling.BICUBIC instead.
  Image.BICUBIC: 'bicubic',
/tmp/ipykernel_11959/698124036.py:5: DeprecationWarning: BOX is deprecated and will be removed in Pillow 10 (2023-07-01). Use Resampling.BOX instead.
  Image.BOX: 'box',
/tmp/ipykernel_11959/698124036.py:6: DeprecationWarning: HAMMING is deprecated and will be removed in Pillow 10 (2023-07-01). Use Resampling.HAMMING instead.
  Image.HAMMING: 'hamming',
/tmp/ipykernel_11959/698124036.py:7: DeprecationWarning: LANCZOS is deprecated and will be removed in Pillow 10 (2023-07-01). Use Resampling.LANCZOS instead.
  Image.LANCZOS: 'lanczos',
```
pull/1256/head
Jakub Kaczmarzyk 3 years ago committed by GitHub
parent d07d015173
commit 19b65a5c27
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -36,12 +36,12 @@ class ToTensor:
_pil_interpolation_to_str = { _pil_interpolation_to_str = {
Image.NEAREST: 'nearest', Image.Resampling.NEAREST: 'nearest',
Image.BILINEAR: 'bilinear', Image.Resampling.BILINEAR: 'bilinear',
Image.BICUBIC: 'bicubic', Image.Resampling.BICUBIC: 'bicubic',
Image.BOX: 'box', Image.Resampling.BOX: 'box',
Image.HAMMING: 'hamming', Image.Resampling.HAMMING: 'hamming',
Image.LANCZOS: 'lanczos', Image.Resampling.LANCZOS: 'lanczos',
} }
_str_to_pil_interpolation = {b: a for a, b in _pil_interpolation_to_str.items()} _str_to_pil_interpolation = {b: a for a, b in _pil_interpolation_to_str.items()}

Loading…
Cancel
Save