"server/text_generation_server/models/flash_starcoder2.py" did not exist on "c86f58d37cfff019fea878d8f2bf9b4da26c1d8e"
Unverified Commit d126f302 authored by Johannes L's avatar Johannes L Committed by GitHub
Browse files

[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 version
parent 8b4dcf1d
...@@ -37,15 +37,27 @@ cv2_interp_codes = { ...@@ -37,15 +37,27 @@ cv2_interp_codes = {
'lanczos': cv2.INTER_LANCZOS4 '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: if Image is not None:
pillow_interp_codes = { if hasattr(Image, 'Resampling'):
'nearest': Image.NEAREST, pillow_interp_codes = {
'bilinear': Image.BILINEAR, 'nearest': Image.Resampling.NEAREST,
'bicubic': Image.BICUBIC, 'bilinear': Image.Resampling.BILINEAR,
'box': Image.BOX, 'bicubic': Image.Resampling.BICUBIC,
'lanczos': Image.LANCZOS, 'box': Image.Resampling.BOX,
'hamming': Image.HAMMING '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, def imresize(img,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment