Skip to content

Add Fast Image Processor for PoolFormer#37182

Merged
yonigozlan merged 8 commits intohuggingface:mainfrom
rootonchair:poolformer_fast_image_processor
Apr 23, 2025
Merged

Add Fast Image Processor for PoolFormer#37182
yonigozlan merged 8 commits intohuggingface:mainfrom
rootonchair:poolformer_fast_image_processor

Conversation

@rootonchair
Copy link
Copy Markdown
Contributor

What does this PR do?

Related #36978

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?

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

@github-actions github-actions Bot marked this pull request as draft April 1, 2025 18:44
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 1, 2025

Hi 👋, thank you for opening this pull request! The pull request is converted to draft by default. The CI will be paused while the PR is in draft mode. When it is ready for review, please click the Ready for review button (at the bottom of the PR page). This will assign reviewers and trigger CI.

@rootonchair rootonchair marked this pull request as ready for review April 1, 2025 18:45
@github-actions github-actions Bot requested review from ydshieh and yonigozlan April 1, 2025 18:45
Comment thread src/transformers/models/poolformer/image_processing_poolformer_fast.py Outdated
Comment thread src/transformers/models/poolformer/image_processing_poolformer_fast.py Outdated
Comment thread src/transformers/models/poolformer/image_processing_poolformer_fast.py Outdated
@Rocketknight1
Copy link
Copy Markdown
Member

cc @yonigozlan

Copy link
Copy Markdown
Member

@yonigozlan yonigozlan left a comment

Choose a reason for hiding this comment

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

Great work again @rootonchair ! Almost ready to merge :)

Comment on lines +219 to +220
crop_top = int((image_height - crop_height) / 2.0)
crop_left = int((image_width - crop_width) / 2.0)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do you get exactly equivalent result with slow image processors using this rather than the torchvision center_crop?
This has been an issue to fix in my backlog for a while, so thanks for addressing it 🤗. We can keep it here for now but I might use it in the base fast image processor class at some point, but we need a separate PR for that as it will impact a lot of models.

Copy link
Copy Markdown
Contributor Author

@rootonchair rootonchair Apr 14, 2025

Choose a reason for hiding this comment

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

Yes, according to the test, slow and fast center_crop produces the same result. I came across this issue while trying to fix the unit test. It turns out that the problem was slow center_crop trying to rounding down the coordinates while the fast one rounding it up. Feel free to use it at ease and don't hesitate to reach out if you have any questions 🤗

Comment on lines +122 to +127
@require_torch
@require_vision
class PoolFormerImageProcessingCropPctTest(PoolFormerImageProcessingTest):
def setUp(self):
super().setUp()
self.image_processor_tester = PoolFormerImageProcessingTester(self, crop_pct=None)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

is this to test without crop pct? it might be better to rename this PoolFormerImageProcessingNoCropPctTest otherwise it's kind of confusing

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes it is. I will change the name to make more sense

@rootonchair rootonchair requested a review from yonigozlan April 23, 2025 16:26
@HuggingFaceDocBuilderDev
Copy link
Copy Markdown

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.

@yonigozlan yonigozlan merged commit dea1919 into huggingface:main Apr 23, 2025
20 checks passed
zucchini-nlp pushed a commit to zucchini-nlp/transformers that referenced this pull request May 14, 2025
* support poolformer fast image processor

* support test for crop_pct=None

* run make style

* Apply suggestions from code review

* rename test

---------

Co-authored-by: Yoni Gozlan <74535834+yonigozlan@users.noreply.github.com>
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.

4 participants