Skip to content

Add Fast Image Processor for LayoutLMv2#37203

Merged
yonigozlan merged 11 commits intohuggingface:mainfrom
rootonchair:layoutlmv2_fast_image_processor
Apr 14, 2025
Merged

Add Fast Image Processor for LayoutLMv2#37203
yonigozlan merged 11 commits intohuggingface:mainfrom
rootonchair:layoutlmv2_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 2, 2025 10:57
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 2, 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 2, 2025 10:57
@github-actions github-actions Bot requested review from ydshieh and yonigozlan April 2, 2025 10:57
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.

Looks great @rootonchair , very little left to change. Thanks for contributing!

Comment thread src/transformers/models/layoutlmv2/image_processing_layoutlmv2_fast.py Outdated
Comment on lines +127 to +129
words, boxes = apply_tesseract(
image.cpu(), ocr_lang, tesseract_config, input_data_format=ChannelDimension.FIRST
)
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.

could you add a logger.warning_once if images are not on cpu, to warn that apply_ocr can only be performed on cpu

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.

Sure, I will add a check and make a warning here

Comment thread tests/models/layoutlmv2/test_image_processing_layoutlmv2.py Outdated
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! let's merge with main and fix conflicts then LGTM!

Comment thread src/transformers/models/layoutlmv2/image_processing_layoutlmv2_fast.py Outdated
rootonchair and others added 3 commits April 12, 2025 02:06
…_fast.py

Co-authored-by: Yoni Gozlan <74535834+yonigozlan@users.noreply.github.com>
…air/transformers into layoutlmv2_fast_image_processor
@rootonchair
Copy link
Copy Markdown
Contributor Author

Hmm, the test fails due to long running time. @yonigozlan could you help me check? Maybe re-run the job may solve the problem

@yonigozlan
Copy link
Copy Markdown
Member

Rerunning the jobs @rootonchair :)

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.

Failing tests are unrelated, LGTM :)

@yonigozlan yonigozlan merged commit e16775d into huggingface:main Apr 14, 2025
19 of 20 checks passed
@rootonchair rootonchair deleted the layoutlmv2_fast_image_processor branch April 15, 2025 18:04
cyr0930 pushed a commit to cyr0930/transformers that referenced this pull request Apr 18, 2025
* add support layoutlmv2

* make style

* Apply suggestions from code review

Co-authored-by: Yoni Gozlan <74535834+yonigozlan@users.noreply.github.com>

* add warning and clean up

* make style

* Update src/transformers/models/layoutlmv2/image_processing_layoutlmv2_fast.py

Co-authored-by: Yoni Gozlan <74535834+yonigozlan@users.noreply.github.com>

---------

Co-authored-by: Yoni Gozlan <74535834+yonigozlan@users.noreply.github.com>
zucchini-nlp pushed a commit to zucchini-nlp/transformers that referenced this pull request May 14, 2025
* add support layoutlmv2

* make style

* Apply suggestions from code review

Co-authored-by: Yoni Gozlan <74535834+yonigozlan@users.noreply.github.com>

* add warning and clean up

* make style

* Update src/transformers/models/layoutlmv2/image_processing_layoutlmv2_fast.py

Co-authored-by: Yoni Gozlan <74535834+yonigozlan@users.noreply.github.com>

---------

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.

2 participants