Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix pillow deperate warning #3404

Merged
merged 3 commits into from
Oct 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions paddlenlp/transformers/clip/feature_extraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import paddle
import numpy as np
from PIL import Image

from PIL.Image import Resampling
from ..feature_extraction_utils import BatchFeature
from ..tokenizer_utils_base import TensorType
from ..image_utils import ImageFeatureExtractionMixin
Expand All @@ -37,10 +37,10 @@ class CLIPFeatureExtractor(ImageFeatureExtractionMixin):
Whether to resize the input to a certain `size`.
size (`int`, *optional*, defaults to 224):
Resize the input to the given size. Only has an effect if `do_resize` is set to `True`.
resample (`int`, *optional*, defaults to `PIL.Image.BICUBIC`):
An optional resampling filter. This can be one of `PIL.Image.NEAREST`, `PIL.Image.BOX`,
`PIL.Image.BILINEAR`, `PIL.Image.HAMMING`, `PIL.Image.BICUBIC` or `PIL.Image.LANCZOS`. Only has an effect
if `do_resize` is set to `True`.
resample (`int`, *optional*, defaults to `PIL.Image.Resampling.BICUBIC`):
An optional resampling filter. This can be one of `PIL.Image.NEAREST`, `PIL.Image.Resampling.BOX`,
`PIL.Image.Resampling.BILINEAR`, `PIL.Image.Resampling.HAMMING`, `PIL.Image.Resampling.BICUBIC` or
`PIL.Image.Resampling.LANCZOS`. Only has an effect if `do_resize` is set to `True`.
do_center_crop (`bool`, *optional*, defaults to `True`):
Whether to crop the input at the center. If the input size is smaller than `crop_size` along any edge, the
image is padded with 0's and then center cropped.
Expand All @@ -61,7 +61,7 @@ class CLIPFeatureExtractor(ImageFeatureExtractionMixin):
def __init__(self,
do_resize=True,
size=224,
resample=Image.BICUBIC,
resample=Resampling.BICUBIC,
do_center_crop=True,
crop_size=224,
do_normalize=True,
Expand Down
11 changes: 6 additions & 5 deletions paddlenlp/transformers/ernie_vil/feature_extraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import paddle
import numpy as np
from PIL import Image
from PIL.Image import Resampling

from ..feature_extraction_utils import BatchFeature
from ..tokenizer_utils_base import TensorType
Expand All @@ -38,10 +39,10 @@ class ErnieViLFeatureExtractor(ImageFeatureExtractionMixin):
Whether to resize the input to a certain `size`.
size (`int`, *optional*, defaults to 224):
Resize the input to the given size. Only has an effect if `do_resize` is set to `True`.
resample (`int`, *optional*, defaults to `PIL.Image.BICUBIC`):
An optional resampling filter. This can be one of `PIL.Image.NEAREST`, `PIL.Image.BOX`,
`PIL.Image.BILINEAR`, `PIL.Image.HAMMING`, `PIL.Image.BICUBIC` or `PIL.Image.LANCZOS`. Only has an effect
if `do_resize` is set to `True`.
resample (`int`, *optional*, defaults to `PIL.Image.Resampling.BICUBIC`):
An optional resampling filter. This can be one of `PIL.Image.Resampling.NEAREST`, `PIL.Image.Resampling.BOX`,
`PIL.Image.Resampling.BILINEAR`, `PIL.Image.Resampling.HAMMING`, `PIL.Image.Resampling.BICUBIC` or
`PIL.Image.Resampling.LANCZOS`. Only has an effect if `do_resize` is set to `True`.
do_center_crop (`bool`, *optional*, defaults to `True`):
Whether to crop the input at the center. If the input size is smaller than `crop_size` along any edge, the
image is padded with 0's and then center cropped.
Expand All @@ -62,7 +63,7 @@ class ErnieViLFeatureExtractor(ImageFeatureExtractionMixin):
def __init__(self,
do_resize=True,
size=224,
resample=Image.BICUBIC,
resample=Resampling.BICUBIC,
do_center_crop=True,
crop_size=224,
do_normalize=True,
Expand Down
10 changes: 5 additions & 5 deletions paddlenlp/transformers/image_utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# coding=utf-8
# Copyright 2021 The HuggingFace Inc. team.
# Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
# Copyright 2021 The HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -18,9 +18,9 @@
from typing import List, Union
import paddle
import numpy as np
from PIL import Image
import PIL.Image
import PIL.ImageOps
from PIL.Image import Resampling

import requests

Expand Down Expand Up @@ -210,7 +210,7 @@ def normalize(self, image, mean, std):
def resize(self,
image,
size,
resample=Image.BILINEAR,
resample=Resampling.BILINEAR,
default_to_square=True,
max_size=None):
"""
Expand All @@ -224,7 +224,7 @@ def resize(self,
If `size` is an int and `default_to_square` is `True`, then image will be resized to (size, size). If
`size` is an int and `default_to_square` is `False`, then smaller edge of the image will be matched to
this number. i.e, if height > width, then image will be rescaled to (size * height / width, size).
resample (`int`, *optional*, defaults to `PIL.Image.BILINEAR`):
resample (`int`, *optional*, defaults to `PIL.Image.Resampling.BILINEAR`):
The filter to user for resampling.
default_to_square (`bool`, *optional*, defaults to `True`):
How to convert `size` when it is a single int. If set to `True`, the `size` will be converted to a
Expand Down Expand Up @@ -376,7 +376,7 @@ def flip_channel_order(self, image):
def rotate(self,
image,
angle,
resample=Image.NEAREST,
resample=Resampling.NEAREST,
expand=0,
center=None,
translate=None,
Expand Down