Skip to content

Conversation

@yonigozlan
Copy link
Member

What does this PR do?

Refactor siglip2 fast image processor to be more consistent with others and reduce diffs.
Also introduce unused_kwargs in BaseImageProcessorFast for processors that don't support all the default kwargs. Here SigLip doesn't support the size kwarg for example, which might be surprising for users considering it is supported by (almost) all other image processors. adding it in unused_kwargs allows to show a warning instead of raising an error.
Cc @qubvel

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

Copy link
Contributor

@qubvel qubvel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for refactoring! Lots of code removed 🔥

do_normalize: bool = True,
image_mean: Optional[Union[float, List[float]]] = None,
image_std: Optional[Union[float, List[float]]] = None,
do_convert_rgb: Optional[bool] = None,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we keep do_convert_rgb?

@qubvel
Copy link
Contributor

qubvel commented Feb 25, 2025

Can you please also check if we can make docs consistent for slow and fast image processors?

Screenshot 2025-02-25 at 19 13 44 Screenshot 2025-02-25 at 19 13 23

@yonigozlan
Copy link
Member Author

Can you please also check if we can make docs consistent for slow and fast image processors?

Yes indeed, that's a problem with all fast processors really. I'm trying to strike a good balance between having meaningful and correct docs, and not having the same image processing kwargs docs duplicated in every processors.
Maybe we can have a decorator that allows to override the default description of a kwarg if we need to?
In any case, I'll try to come up with something better than the current situation, but I'll probably open another PR for that

@qubvel
Copy link
Contributor

qubvel commented Feb 26, 2025

Sounds good, decorator might be a good approach!

Copy link
Collaborator

@ArthurZucker ArthurZucker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love seeing these go away! Thanks 🤗

valid_preprocess_kwargs = DefaultFastImageProcessorPreprocessKwargs
# Child classes should try to support the base processing methods as much as possible.
# If they can't, the corresponding unused kwargs should be added to this list.
unused_kwargs = []
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
unused_kwargs = []
unused_kwargs = None

list default are the worst!

@ArthurZucker
Copy link
Collaborator

Also let's use as much modular as possible! (will easy all futur refactoring)

@yonigozlan yonigozlan merged commit 48292a9 into huggingface:main Mar 13, 2025
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants