Skip to content

Conversation

@rootonchair
Copy link
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 March 28, 2025 15:26
@github-actions
Copy link
Contributor

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 March 28, 2025 15:28
@github-actions github-actions bot requested review from ydshieh and yonigozlan March 28, 2025 15:29
@Rocketknight1
Copy link
Member

cc @qubvel @yonigozlan

Copy link
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.

Hi @rootonchair, this one also looks great thanks a lot! Only some little changes to be made and tests to be modified. It would also be great to have an equivalence test between fast and slow with do_align_long_axis set to True

@rootonchair
Copy link
Contributor Author

@yonigozlan When adding test for do_align_long_axis, I observe failure cases coming from the slow processor so I have to update its preprocessing to convert all images to rgb and determine rotation axis base on input format, as align_long_axis is using (0,1) as their default rotation axis in np.rot

Copy link
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 thanks for fixing the issue with rot_axes! Overall LGTM after the last changes I suggested, and after running make style, make quality and make fix-copies as there are some formatting/styling issues

Comment on lines +154 to +160
if input_data_format == ChannelDimension.LAST:
rot_axes = (0, 1)
elif input_data_format == ChannelDimension.FIRST:
rot_axes = (1, 2)
else:
raise ValueError(f"Unsupported data format: {input_data_format}")

Copy link
Member

Choose a reason for hiding this comment

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

Great, thanks for fixing!

@rootonchair rootonchair requested a review from yonigozlan April 9, 2025 14:28
Copy link
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.

Hey @rootonchair! Thanks for iterating , some tests are failing which need some little changes. Also you'll need to merge your branch with main and resolve some conflicts

Comment on lines +223 to +229
if input_data_format == ChannelDimension.LAST:
rot_axes = (0, 1)
elif input_data_format == ChannelDimension.FIRST:
rot_axes = (1, 2)
else:
raise ValueError(f"Unsupported data format: {input_data_format}")

Copy link
Member

Choose a reason for hiding this comment

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

Looks like this broke some tests. input_data_format can be None, so if it is, input_data_format should be inferred before this with: input_data_format = infer_channel_dimension_format(images[0]) (it's done after now).
Same for donut in the slow processor.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah I see. Let me fix this part. Hope that it would pass this time

Copy link
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! Waiting to see if all tests pass then LGTM

@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.

@yonigozlan yonigozlan merged commit 7cc9e61 into huggingface:main Apr 14, 2025
20 checks passed
@rootonchair rootonchair deleted the donut_fast_image_processor branch April 15, 2025 18:01
cyr0930 pushed a commit to cyr0930/transformers that referenced this pull request Apr 18, 2025
* add donut fast image processor support

* run make style

* Update src/transformers/models/donut/image_processing_donut_fast.py

Co-authored-by: Parteek <[email protected]>

* update test, remove none default values

* add do_align_axis = True test, fix bug in slow image processor

* run make style

* remove np usage

* make style

* Apply suggestions from code review

* Update src/transformers/models/donut/image_processing_donut_fast.py

Co-authored-by: Yoni Gozlan <[email protected]>

* add size revert in preprocess

* make style

* fix copies

* add test for preprocess with kwargs

* make style

* handle None input_data_format in align_long_axis

---------

Co-authored-by: Parteek <[email protected]>
Co-authored-by: Yoni Gozlan <[email protected]>
zucchini-nlp pushed a commit to zucchini-nlp/transformers that referenced this pull request May 14, 2025
* add donut fast image processor support

* run make style

* Update src/transformers/models/donut/image_processing_donut_fast.py

Co-authored-by: Parteek <[email protected]>

* update test, remove none default values

* add do_align_axis = True test, fix bug in slow image processor

* run make style

* remove np usage

* make style

* Apply suggestions from code review

* Update src/transformers/models/donut/image_processing_donut_fast.py

Co-authored-by: Yoni Gozlan <[email protected]>

* add size revert in preprocess

* make style

* fix copies

* add test for preprocess with kwargs

* make style

* handle None input_data_format in align_long_axis

---------

Co-authored-by: Parteek <[email protected]>
Co-authored-by: Yoni Gozlan <[email protected]>
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.

5 participants