Adding support for LayoutLMvX variants for object-detection.#20143
Merged
Narsil merged 4 commits intohuggingface:mainfrom Nov 10, 2022
Merged
Adding support for LayoutLMvX variants for object-detection.#20143Narsil merged 4 commits intohuggingface:mainfrom
object-detection.#20143Narsil merged 4 commits intohuggingface:mainfrom
Conversation
|
The documentation is not available anymore as the PR was closed or merged. |
sgugger
approved these changes
Nov 9, 2022
Collaborator
sgugger
left a comment
There was a problem hiding this comment.
Thanks for adding this! Just have a couple of nits.
| dict(zip(keys, vals)) | ||
| for vals in zip(raw_annotation["scores"], raw_annotation["labels"], raw_annotation["boxes"]) | ||
| ] | ||
| if self.tokenizer: |
Collaborator
There was a problem hiding this comment.
Suggested change
| if self.tokenizer: | |
| if self.tokenizer is not None: |
sgugger
reviewed
Nov 9, 2022
| for vals in zip(raw_annotation["scores"], raw_annotation["labels"], raw_annotation["boxes"]) | ||
| ] | ||
| if self.tokenizer is not None: | ||
| w, h = target_size[0].tolist() |
Collaborator
There was a problem hiding this comment.
Full names here please :-)
Collaborator
There was a problem hiding this comment.
(Not sure why it didn't go through in my review)
alaradirik
reviewed
Nov 10, 2022
| dict(zip(keys, vals)) | ||
| for vals in zip(raw_annotation["scores"], raw_annotation["labels"], raw_annotation["boxes"]) | ||
| ] | ||
| if self.tokenizer is not None: |
Contributor
There was a problem hiding this comment.
Could you add a comment above the if else statement to clarify which model this is for (for future use purposes)?
alaradirik
approved these changes
Nov 10, 2022
Contributor
alaradirik
left a comment
There was a problem hiding this comment.
Thank you for adding this, looks good to me!
mpierrau
pushed a commit
to mpierrau/transformers
that referenced
this pull request
Dec 15, 2022
…ngface#20143) * Adding support for LayoutLMvX variants for `object-detection`. * Revert bogs `layoutlm` feature extractor which does not exist (it was a V2 model) . * Updated condition. * Handling the comments.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Adding support for
layoutlmtoobject-detection.LayoutLMv{2,3} can be used for
object-detection.However the classes are
ForTokenClassificationwhich not all classes can supporta vision + OCR type of inference. (the model needs
bboxobject even if we splittedout the OCR).
The current implementation changes
object-detectiontomultimodalsincenow the models require
tokenizerfor the layoutlm variants. (This does notaffect existing working pipelines).
Then it uses reflection at runtime to see if the model is using a
tokenizer.This is not a great way to go about it but was the "simpler" change I could think
of.
As long as we don't have support for other model architecture, I'm hesitant to
make "cleaner" modifications, since I don't know if other architectures will
support the same invariants or not.
Fixes # (issue)
Before submitting
Pull Request section?
to it if that's the case.
documentation guidelines, and
here are tips on formatting docstrings.
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.