!35010 Adapt to the new Resampling APIs of pillow 9.1.0
Merge pull request !35010 from xiaotianci/pillow_api_modification
This commit is contained in:
commit
bb8b479531
|
@ -616,7 +616,7 @@ class Dataset:
|
|||
... index = 0
|
||||
... for c in col:
|
||||
... img = Image.fromarray(c.astype('uint8')).convert('RGB')
|
||||
... img = img.resize((s, s), Image.ANTIALIAS)
|
||||
... img = img.resize((s, s))
|
||||
... output[index] = np.array(img)
|
||||
... index += 1
|
||||
... return (output,)
|
||||
|
|
|
@ -42,10 +42,16 @@ DE_PY_BORDER_TYPE = {Border.CONSTANT: 'constant',
|
|||
Border.REFLECT: 'reflect',
|
||||
Border.SYMMETRIC: 'symmetric'}
|
||||
|
||||
DE_PY_INTER_MODE = {Inter.NEAREST: Image.NEAREST,
|
||||
Inter.ANTIALIAS: Image.ANTIALIAS,
|
||||
Inter.LINEAR: Image.LINEAR,
|
||||
Inter.CUBIC: Image.CUBIC}
|
||||
if Image.__version__ >= "9.1.0":
|
||||
DE_PY_INTER_MODE = {Inter.NEAREST: Image.Resampling.NEAREST,
|
||||
Inter.ANTIALIAS: Image.Resampling.LANCZOS,
|
||||
Inter.LINEAR: Image.Resampling.BILINEAR,
|
||||
Inter.CUBIC: Image.Resampling.BICUBIC}
|
||||
else:
|
||||
DE_PY_INTER_MODE = {Inter.NEAREST: Image.NEAREST,
|
||||
Inter.ANTIALIAS: Image.ANTIALIAS,
|
||||
Inter.LINEAR: Image.LINEAR,
|
||||
Inter.CUBIC: Image.CUBIC}
|
||||
|
||||
|
||||
class AdjustGamma(py_transforms.PyTensorOperation):
|
||||
|
|
|
@ -53,10 +53,16 @@ class Inter(IntEnum):
|
|||
"""
|
||||
Function to return Python type for Interpolation Mode.
|
||||
"""
|
||||
python_values = {Inter.NEAREST: Image.NEAREST,
|
||||
Inter.ANTIALIAS: Image.ANTIALIAS,
|
||||
Inter.LINEAR: Image.LINEAR,
|
||||
Inter.CUBIC: Image.CUBIC}
|
||||
if Image.__version__ >= "9.1.0":
|
||||
python_values = {Inter.NEAREST: Image.Resampling.NEAREST,
|
||||
Inter.ANTIALIAS: Image.Resampling.LANCZOS,
|
||||
Inter.LINEAR: Image.Resampling.BILINEAR,
|
||||
Inter.CUBIC: Image.Resampling.BICUBIC}
|
||||
else:
|
||||
python_values = {Inter.NEAREST: Image.NEAREST,
|
||||
Inter.ANTIALIAS: Image.ANTIALIAS,
|
||||
Inter.LINEAR: Image.LINEAR,
|
||||
Inter.CUBIC: Image.CUBIC}
|
||||
return python_values.get(inter_type)
|
||||
|
||||
@staticmethod
|
||||
|
|
Loading…
Reference in New Issue