Skip to content

Commit

Permalink
fix PIL sample mode deprecated warning (#42307)
Browse files Browse the repository at this point in the history
* fix PIL sample mode deprecated warning

* compatible with old pil version
  • Loading branch information
LielinJiang authored Apr 28, 2022
1 parent 9fd2c54 commit c7a258f
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions python/paddle/vision/transforms/functional_pil.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,25 @@
Sequence = collections.abc.Sequence
Iterable = collections.abc.Iterable

_pil_interp_from_str = {
'nearest': Image.NEAREST,
'bilinear': Image.BILINEAR,
'bicubic': Image.BICUBIC,
'box': Image.BOX,
'lanczos': Image.LANCZOS,
'hamming': Image.HAMMING
}
try:
# PIL version >= "9.1.0"
_pil_interp_from_str = {
'nearest': Image.Resampling.NEAREST,
'bilinear': Image.Resampling.BILINEAR,
'bicubic': Image.Resampling.BICUBIC,
'box': Image.Resampling.BOX,
'lanczos': Image.Resampling.LANCZOS,
'hamming': Image.Resampling.HAMMING
}
except:
_pil_interp_from_str = {
'nearest': Image.NEAREST,
'bilinear': Image.BILINEAR,
'bicubic': Image.BICUBIC,
'box': Image.BOX,
'lanczos': Image.LANCZOS,
'hamming': Image.HAMMING
}

__all__ = []

Expand Down

0 comments on commit c7a258f

Please sign in to comment.