mirror of
https://github.com/huggingface/transformers.git
synced 2025-08-01 02:31:11 +06:00
Fix typing issues with SigLip2 (#37356)
* Fix issues * Fix comment --------- Co-authored-by: Pavel Iakubovskii <qubvel@gmail.com>
This commit is contained in:
parent
aaf129cdae
commit
953196a43d
@ -691,8 +691,12 @@ class BaseImageProcessorFast(BaseImageProcessor):
|
|||||||
|
|
||||||
# torch resize uses interpolation instead of resample
|
# torch resize uses interpolation instead of resample
|
||||||
resample = kwargs.pop("resample")
|
resample = kwargs.pop("resample")
|
||||||
|
|
||||||
|
# Check if resample is an int before checking if it's an instance of PILImageResampling
|
||||||
|
# because if pillow < 9.1.0, resample is an int and PILImageResampling is a module.
|
||||||
|
# Checking PILImageResampling will fail with error `TypeError: isinstance() arg 2 must be a type or tuple of types`.
|
||||||
kwargs["interpolation"] = (
|
kwargs["interpolation"] = (
|
||||||
pil_torch_interpolation_mapping[resample] if isinstance(resample, (PILImageResampling, int)) else resample
|
pil_torch_interpolation_mapping[resample] if isinstance(resample, (int, PILImageResampling)) else resample
|
||||||
)
|
)
|
||||||
|
|
||||||
# Pop kwargs that are not needed in _preprocess
|
# Pop kwargs that are not needed in _preprocess
|
||||||
|
@ -163,7 +163,7 @@ class Siglip2ImageProcessor(BaseImageProcessor):
|
|||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
do_resize: bool = True,
|
do_resize: bool = True,
|
||||||
resample: PILImageResampling = PILImageResampling.BILINEAR,
|
resample: "PILImageResampling" = PILImageResampling.BILINEAR,
|
||||||
do_rescale: bool = True,
|
do_rescale: bool = True,
|
||||||
rescale_factor: float = 1 / 255,
|
rescale_factor: float = 1 / 255,
|
||||||
do_normalize: bool = True,
|
do_normalize: bool = True,
|
||||||
@ -195,7 +195,7 @@ class Siglip2ImageProcessor(BaseImageProcessor):
|
|||||||
self,
|
self,
|
||||||
images: ImageInput,
|
images: ImageInput,
|
||||||
do_resize: Optional[bool] = None,
|
do_resize: Optional[bool] = None,
|
||||||
resample: Optional[PILImageResampling] = None,
|
resample: Optional["PILImageResampling"] = None,
|
||||||
do_rescale: Optional[bool] = None,
|
do_rescale: Optional[bool] = None,
|
||||||
rescale_factor: Optional[float] = None,
|
rescale_factor: Optional[float] = None,
|
||||||
do_normalize: Optional[bool] = None,
|
do_normalize: Optional[bool] = None,
|
||||||
|
Loading…
Reference in New Issue
Block a user