mirror of https://github.com/open-mmlab/mmcv.git
[Enhancement] Add support for latest Pillow resampling filter naming scheme (#1931)
* Add support for latest Pillow resampling filter naming scheme * Comments added * Shortened comments, lint fixes * Added specific Pillow versionpull/1944/head
parent
8b4dcf1dfb
commit
d126f3026c
|
@ -37,15 +37,27 @@ cv2_interp_codes = {
|
|||
'lanczos': cv2.INTER_LANCZOS4
|
||||
}
|
||||
|
||||
# Pillow >=v9.1.0 use a slightly different naming scheme for filters.
|
||||
# Set pillow_interp_codes according to the naming scheme used.
|
||||
if Image is not None:
|
||||
pillow_interp_codes = {
|
||||
'nearest': Image.NEAREST,
|
||||
'bilinear': Image.BILINEAR,
|
||||
'bicubic': Image.BICUBIC,
|
||||
'box': Image.BOX,
|
||||
'lanczos': Image.LANCZOS,
|
||||
'hamming': Image.HAMMING
|
||||
}
|
||||
if hasattr(Image, 'Resampling'):
|
||||
pillow_interp_codes = {
|
||||
'nearest': Image.Resampling.NEAREST,
|
||||
'bilinear': Image.Resampling.BILINEAR,
|
||||
'bicubic': Image.Resampling.BICUBIC,
|
||||
'box': Image.Resampling.BOX,
|
||||
'lanczos': Image.Resampling.LANCZOS,
|
||||
'hamming': Image.Resampling.HAMMING
|
||||
}
|
||||
else:
|
||||
pillow_interp_codes = {
|
||||
'nearest': Image.NEAREST,
|
||||
'bilinear': Image.BILINEAR,
|
||||
'bicubic': Image.BICUBIC,
|
||||
'box': Image.BOX,
|
||||
'lanczos': Image.LANCZOS,
|
||||
'hamming': Image.HAMMING
|
||||
}
|
||||
|
||||
|
||||
def imresize(img,
|
||||
|
|
Loading…
Reference in New Issue