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

Input data format #25464

Merged
merged 9 commits into from
Aug 16, 2023
Merged

Input data format #25464

merged 9 commits into from
Aug 16, 2023

Conversation

amyeroberts
Copy link
Collaborator

@amyeroberts amyeroberts commented Aug 11, 2023

What does this PR do?

Adds the input_data_format argument to all of the image processor methods.

This allows for passing in of images with an unusual number of channels, or ones where it's difficult to infer because of ambiguity e.g size (3, 3, 3).

This is an alternative to #24577

Fixes issues like:

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you read the contributor guideline,
    Pull Request section?
  • Was this discussed/approved via a Github issue or the forum? Please add a link
    to it if that's the case.
  • Did you make sure to update the documentation with your changes? Here are the
    documentation guidelines, and
    here are tips on formatting docstrings.
  • Did you write any new necessary tests?

@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Aug 11, 2023

The documentation is not available anymore as the PR was closed or merged.

Copy link
Collaborator

@sgugger sgugger left a comment

Choose a reason for hiding this comment

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

Thanks a lot for your work on this!

**kwargs,
) -> np.ndarray:
"""
Resize the image to the given size. Size can be `min_size` (scalar) or `(height, width)` tuple. If size is an
int, smaller edge of the image will be matched to this number.

Args:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice to add this here!

Image to resize.
size (`Dict[str, int]`):
The size of the output image.
size_divisor (`int`, *optional*, defaults to `0`):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit:

Suggested change
size_divisor (`int`, *optional*, defaults to `0`):
size_divisor (`int`, *optional*, defaults to 0):

Image to resize.
size (`Dict[str, int]`):
The size of the output image.
size_divisor (`int`, *optional*, defaults to `0`):
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
size_divisor (`int`, *optional*, defaults to `0`):
size_divisor (`int`, *optional*, defaults to 0):

( may have missed some so worth doing a quick search!)

@amyeroberts amyeroberts merged commit 6bca43b into huggingface:main Aug 16, 2023
@amyeroberts amyeroberts deleted the input-data-format branch August 16, 2023 16:45
blbadger pushed a commit to blbadger/transformers that referenced this pull request Nov 8, 2023
* Add copied from statements for image processors

* Move out rescale and normalize to base image processor

* Remove rescale and normalize from vit (post rebase)

* Update docstrings and tidy up

* PR comments

* Add input_data_format as preprocess argument

* Resolve tests and tidy up

* Remove num_channels argument

* Update doc strings -> default ints not in code formatting
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants