Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
6cc06d17
Unverified
Commit
6cc06d17
authored
Nov 11, 2022
by
amyeroberts
Committed by
GitHub
Nov 11, 2022
Browse files
Fix type - update any PIL.Image.Resampling (#20172)
parent
cbbeca3d
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
23 additions
and
25 deletions
+23
-25
src/transformers/image_transforms.py
src/transformers/image_transforms.py
+1
-1
src/transformers/image_utils.py
src/transformers/image_utils.py
+1
-1
src/transformers/models/donut/feature_extraction_donut.py
src/transformers/models/donut/feature_extraction_donut.py
+4
-5
src/transformers/models/glpn/image_processing_glpn.py
src/transformers/models/glpn/image_processing_glpn.py
+4
-4
src/transformers/models/maskformer/feature_extraction_maskformer.py
...ormers/models/maskformer/feature_extraction_maskformer.py
+4
-5
src/transformers/models/owlvit/feature_extraction_owlvit.py
src/transformers/models/owlvit/feature_extraction_owlvit.py
+4
-5
src/transformers/models/segformer/image_processing_segformer.py
...ansformers/models/segformer/image_processing_segformer.py
+2
-2
tests/models/flava/test_feature_extraction_flava.py
tests/models/flava/test_feature_extraction_flava.py
+3
-2
No files found.
src/transformers/image_transforms.py
View file @
6cc06d17
...
...
@@ -232,7 +232,7 @@ def resize(
The image to resize.
size (`Tuple[int, int]`):
The size to use for resizing the image.
resample (`int`, *optional*, defaults to `PIL
.
Image
.
Resampling.BILINEAR`):
resample (`int`, *optional*, defaults to `PILImageResampling.BILINEAR`):
The filter to user for resampling.
data_format (`ChannelDimension`, *optional*):
The channel dimension format of the output image. If `None`, will use the inferred format from the input.
...
...
src/transformers/image_utils.py
View file @
6cc06d17
...
...
@@ -372,7 +372,7 @@ class ImageFeatureExtractionMixin:
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
.
Resampling.BILINEAR`):
resample (`int`, *optional*, defaults to `PILImageResampling.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
...
...
src/transformers/models/donut/feature_extraction_donut.py
View file @
6cc06d17
...
...
@@ -48,11 +48,10 @@ class DonutFeatureExtractor(FeatureExtractionMixin, ImageFeatureExtractionMixin)
size (`Tuple(int)`, *optional*, defaults to [1920, 2560]):
Resize the shorter edge of the input to the minimum value of the given size. Should be a tuple of (width,
height). Only has an effect if `do_resize` is set to `True`.
resample (`int`, *optional*, defaults to `PIL.Image.Resampling.BILINEAR`):
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`.
resample (`int`, *optional*, defaults to `PILImageResampling.BILINEAR`):
An optional resampling filter. This can be one of `PILImageResampling.NEAREST`, `PILImageResampling.BOX`,
`PILImageResampling.BILINEAR`, `PILImageResampling.HAMMING`, `PILImageResampling.BICUBIC` or
`PILImageResampling.LANCZOS`. Only has an effect if `do_resize` is set to `True`.
do_thumbnail (`bool`, *optional*, defaults to `True`):
Whether to thumbnail the input to the given `size`.
do_align_long_axis (`bool`, *optional*, defaults to `False`):
...
...
src/transformers/models/glpn/image_processing_glpn.py
View file @
6cc06d17
...
...
@@ -42,7 +42,7 @@ class GLPNImageProcessor(BaseImageProcessor):
size_divisor (`int`, *optional*, defaults to 32):
When `do_resize` is `True`, images are resized so their height and width are rounded down to the closest
multiple of `size_divisor`. Can be overridden by `size_divisor` in `preprocess`.
resample (`PIL.Image` resampling filter, *optional*, defaults to `PIL
.
Image
.
Resampling.BILINEAR`):
resample (`PIL.Image` resampling filter, *optional*, defaults to `PILImageResampling.BILINEAR`):
Resampling filter to use if resizing the image. Can be overridden by `resample` in `preprocess`.
do_rescale (`bool`, *optional*, defaults to `True`):
Whether or not to apply the scaling factor (to make pixel values floats between 0. and 1.). Can be
...
...
@@ -80,7 +80,7 @@ class GLPNImageProcessor(BaseImageProcessor):
The image is resized so its height and width are rounded down to the closest multiple of
`size_divisor`.
resample:
`PIL.Image` resampling filter to use when resizing the image e.g. `PIL
.
Image
.
Resampling.BILINEAR`.
`PIL.Image` resampling filter to use when resizing the image e.g. `PILImageResampling.BILINEAR`.
data_format (`ChannelDimension` or `str`, *optional*):
The channel dimension format for the output image. If `None`, the channel dimension format of the input
image is used. Can be one of:
...
...
@@ -142,8 +142,8 @@ class GLPNImageProcessor(BaseImageProcessor):
When `do_resize` is `True`, images are resized so their height and width are rounded down to the
closest multiple of `size_divisor`.
resample (`PIL.Image` resampling filter, *optional*, defaults to `self.resample`):
`PIL.Image` resampling filter to use if resizing the image e.g. `PIL
.
Image
.
Resampling.BILINEAR`. Only
has
an effect if `do_resize` is set to `True`.
`PIL.Image` resampling filter to use if resizing the image e.g. `PILImageResampling.BILINEAR`. Only
has
an effect if `do_resize` is set to `True`.
do_rescale (`bool`, *optional*, defaults to `self.do_rescale`):
Whether or not to apply the scaling factor (to make pixel values floats between 0. and 1.).
return_tensors (`str` or `TensorType`, *optional*):
...
...
src/transformers/models/maskformer/feature_extraction_maskformer.py
View file @
6cc06d17
...
...
@@ -209,11 +209,10 @@ class MaskFormerFeatureExtractor(FeatureExtractionMixin, ImageFeatureExtractionM
max_size (`int`, *optional*, defaults to 1333):
The largest size an image dimension can have (otherwise it's capped). Only has an effect if `do_resize` is
set to `True`.
resample (`int`, *optional*, defaults to `PIL.Image.Resampling.BILINEAR`):
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`.
resample (`int`, *optional*, defaults to `PILImageResampling.BILINEAR`):
An optional resampling filter. This can be one of `PILImageResampling.NEAREST`, `PILImageResampling.BOX`,
`PILImageResampling.BILINEAR`, `PILImageResampling.HAMMING`, `PILImageResampling.BICUBIC` or
`PILImageResampling.LANCZOS`. Only has an effect if `do_resize` is set to `True`.
size_divisibility (`int`, *optional*, defaults to 32):
Some backbones need images divisible by a certain number. If not passed, it defaults to the value used in
Swin Transformer.
...
...
src/transformers/models/owlvit/feature_extraction_owlvit.py
View file @
6cc06d17
...
...
@@ -56,11 +56,10 @@ class OwlViTFeatureExtractor(FeatureExtractionMixin, ImageFeatureExtractionMixin
The size to use for resizing the image. Only has an effect if `do_resize` is set to `True`. If `size` is a
sequence like (h, w), output size will be matched to this. If `size` is an int, then image will be resized
to (size, size).
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`.
resample (`int`, *optional*, defaults to `PILImageResampling.BICUBIC`):
An optional resampling filter. This can be one of `PILImageResampling.NEAREST`, `PILImageResampling.BOX`,
`PILImageResampling.BILINEAR`, `PILImageResampling.HAMMING`, `PILImageResampling.BICUBIC` or
`PILImageResampling.LANCZOS`. Only has an effect if `do_resize` is set to `True`.
do_center_crop (`bool`, *optional*, defaults to `False`):
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.
...
...
src/transformers/models/segformer/image_processing_segformer.py
View file @
6cc06d17
...
...
@@ -228,7 +228,7 @@ class SegformerImageProcessor(BaseImageProcessor):
do_rescale
:
bool
,
do_normalize
:
bool
,
size
:
Optional
[
Dict
[
str
,
int
]]
=
None
,
resample
:
Optional
[
PILImageResampling
]
=
None
,
resample
:
PILImageResampling
=
None
,
rescale_factor
:
Optional
[
float
]
=
None
,
image_mean
:
Optional
[
Union
[
float
,
List
[
float
]]]
=
None
,
image_std
:
Optional
[
Union
[
float
,
List
[
float
]]]
=
None
,
...
...
@@ -325,7 +325,7 @@ class SegformerImageProcessor(BaseImageProcessor):
segmentation_maps
:
Optional
[
ImageInput
]
=
None
,
do_resize
:
Optional
[
bool
]
=
None
,
size
:
Optional
[
Dict
[
str
,
int
]]
=
None
,
resample
:
Optional
[
PILImageResampling
]
=
None
,
resample
:
PILImageResampling
=
None
,
do_rescale
:
Optional
[
bool
]
=
None
,
rescale_factor
:
Optional
[
float
]
=
None
,
do_normalize
:
Optional
[
bool
]
=
None
,
...
...
tests/models/flava/test_feature_extraction_flava.py
View file @
6cc06d17
...
...
@@ -31,6 +31,7 @@ if is_vision_available():
import
PIL
from
transformers
import
FlavaFeatureExtractor
from
transformers.image_utils
import
PILImageResampling
from
transformers.models.flava.image_processing_flava
import
(
FLAVA_CODEBOOK_MEAN
,
FLAVA_CODEBOOK_STD
,
...
...
@@ -89,7 +90,7 @@ class FlavaFeatureExtractionTester(unittest.TestCase):
self
.
min_resolution
=
min_resolution
self
.
max_resolution
=
max_resolution
self
.
size
=
size
self
.
resample
=
resample
if
resample
is
not
None
else
PIL
.
Image
.
Resampling
.
BICUBIC
self
.
resample
=
resample
if
resample
is
not
None
else
PILImageResampling
.
BICUBIC
self
.
do_normalize
=
do_normalize
self
.
image_mean
=
image_mean
self
.
image_std
=
image_std
...
...
@@ -105,7 +106,7 @@ class FlavaFeatureExtractionTester(unittest.TestCase):
self
.
codebook_do_resize
=
codebook_do_resize
self
.
codebook_size
=
codebook_size
self
.
codebook_resample
=
codebook_resample
if
codebook_resample
is
not
None
else
PIL
.
Image
.
Resampling
.
LANCZOS
self
.
codebook_resample
=
codebook_resample
if
codebook_resample
is
not
None
else
PILImageResampling
.
LANCZOS
self
.
codebook_do_center_crop
=
codebook_do_center_crop
self
.
codebook_crop_size
=
codebook_crop_size
self
.
codebook_do_map_pixels
=
codebook_do_map_pixels
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment