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

Uniformize kwargs for processors - GroundingDINO #31964

Merged
merged 23 commits into from
Aug 8, 2024

Conversation

SangbumChoi
Copy link
Contributor

@SangbumChoi SangbumChoi commented Jul 15, 2024

What does this PR do?

Fixes one model from #31911

We don;t want our tracker issue to be closed after the PR is merged, so I edited the magic keyword a bit

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.

@zucchini-nlp @NielsRogge @EduardoPach

Copy link
Member

@zucchini-nlp zucchini-nlp left a comment

Choose a reason for hiding this comment

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

Thanks for helping us to make the processors more uniform!

Can you also add a test for this, it is available in:

from ...test_processing_common import ProcessorTesterMixin

@SangbumChoi SangbumChoi marked this pull request as draft July 16, 2024 02:02
@SangbumChoi SangbumChoi changed the title Uniform kwargs for processors - GroundingDINO Uniform kwargs for processors + Docs update - GroundingDINO Jul 23, 2024
@SangbumChoi
Copy link
Contributor Author

@zucchini-nlp

if hasattr(self, "tmpdirname"):

I think the circleCI fails since the upper PR is not merged in to main. Otherwise requesting for second review!

@SangbumChoi SangbumChoi marked this pull request as ready for review July 24, 2024 01:48
@SangbumChoi SangbumChoi marked this pull request as draft July 24, 2024 12:07
src/transformers/processing_utils.py Show resolved Hide resolved
src/transformers/processing_utils.py Outdated Show resolved Hide resolved
src/transformers/processing_utils.py Show resolved Hide resolved
src/transformers/processing_utils.py Outdated Show resolved Hide resolved
@SangbumChoi
Copy link
Contributor Author

SangbumChoi commented Jul 30, 2024

@zucchini-nlp Hi now I understand the full logic and had a one question on this PR.
It seems that initial PR was designed in here

https://github.com/huggingface/transformers/pull/31197/files#diff-767679f9407c55e91d247ac9ab5359a867414676ae6083959bd2c5cf4e1113c7

with based on following image processor

https://github.com/molbap/transformers/blob/bcce00766b8faa0bd48e0dfe4d0ec72db761f56a/src/transformers/models/efficientnet/image_processing_efficientnet.py

However, not all the processor has the crop_size argument for image_processor some of them has only size. I think in order to make it model-wise compatibility I recommend to change this to size.

https://github.com/molbap/transformers/blob/bcce00766b8faa0bd48e0dfe4d0ec72db761f56a/tests/test_processing_common.py

otherwise I can override these test for groundingdino only

WDYT? cc. @molbap

(BTW, I reverted all the irrelevant commit and major CI fail is related to this comment)

@zucchini-nlp
Copy link
Member

IIRC the test will fail if we pass in both, crop_size and size, because one of the args will not be used by image processor. If that's the case, we can override since it is about making tests happy

@molbap
Copy link
Contributor

molbap commented Jul 30, 2024

Since only these two arguments are passed, we could also inspect in the test method and figure out which is used for a given model, then call with that one - skipping the test entirely is also acceptable, yes

@SangbumChoi SangbumChoi changed the title Uniform kwargs for processors + Docs update - GroundingDINO Uniform kwargs for processors - GroundingDINO Aug 4, 2024
@SangbumChoi SangbumChoi changed the title Uniform kwargs for processors - GroundingDINO Uniformize kwargs for processors - GroundingDINO Aug 5, 2024
@SangbumChoi SangbumChoi marked this pull request as ready for review August 5, 2024 06:58
@SangbumChoi
Copy link
Contributor Author

SangbumChoi commented Aug 5, 2024

IIRC the test will fail if we pass in both, crop_size and size, because one of the args will not be used by image processor. If that's the case, we can override since it is about making tests happy

Well this was not the exactly the case. As I mentioned GroundingDINO processor -> image_processor does not have function of crop_size. However, the major test in test_processor_common.py uses crop_size which is not used in the groundingdino. This will result the output shape as same as input since resizing technique is not applied.

I manually changed this to inherit size instead of crop_size to add resizing technique!

@zucchini-nlp Request for the review!

Copy link
Member

@zucchini-nlp zucchini-nlp 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, thanks for working on it! Left one tiny comment

Copy link
Contributor

@molbap molbap 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 @SangbumChoi 🙏
I added a comment as well on a test.

Copy link
Member

@zucchini-nlp zucchini-nlp left a comment

Choose a reason for hiding this comment

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

Requesting review from core maintainer :)

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

Copy link
Collaborator

@amyeroberts amyeroberts 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 - thanks for handling this!

Copy link
Collaborator

@amyeroberts amyeroberts left a comment

Choose a reason for hiding this comment

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

❤️

@amyeroberts amyeroberts merged commit d3b3551 into huggingface:main Aug 8, 2024
21 checks passed
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.

7 participants