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

Modify ProcessorTesterMixin for better generalization #32637

Conversation

yonigozlan
Copy link
Member

@yonigozlan yonigozlan commented Aug 12, 2024

What does this PR do?

Follows this #32544 (comment). It will help avoid rewriting many tests for ProcessorTest classes that inherit from ProcessorTesterMixin.

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?

@molbap @zucchini-nlp @amyeroberts

@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 marked this pull request as ready for review August 12, 2024 19:06
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 working on this! I think we can do one more thing to clean up tests, left a comment. Up to you

Comment on lines +175 to +177
inputs = processor(
text=input_str, images=image_input, return_tensors="pt", max_length=112, padding="max_length"
)
Copy link
Member

Choose a reason for hiding this comment

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

nit: a bit redundant to indicate max-length when init tokenizer and when calling. IMO we can remove it from init because we're testing kwargs at call

Or we can even explicitly init with a padding=longest and test if kwargs overrides defaults, as the test name suggests

Copy link
Collaborator

Choose a reason for hiding this comment

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

+1 on removing from the init.

Checking the kwargs overrides is also a good idea - we should add a new test to isolate and check this behaviour

Comment on lines 187 to 188
if not tokenizer.pad_token:
tokenizer.pad_token = "[TEST_PAD]"
Copy link
Member

Choose a reason for hiding this comment

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

I see this recurring in all tests, maybe we should add pad token when saving dummy tokenizer, so it's loaded with a pad id

Copy link
Collaborator

Choose a reason for hiding this comment

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

+1

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.

LGTM as well 👍

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.

Thanks for updating!

+1 on all of @zucchini-nlp comment's - overall LGTM :)

Comment on lines 187 to 188
if not tokenizer.pad_token:
tokenizer.pad_token = "[TEST_PAD]"
Copy link
Collaborator

Choose a reason for hiding this comment

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

+1

Comment on lines +175 to +177
inputs = processor(
text=input_str, images=image_input, return_tensors="pt", max_length=112, padding="max_length"
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

+1 on removing from the init.

Checking the kwargs overrides is also a good idea - we should add a new test to isolate and check this behaviour

…tokenizer kwargs, remove unnecessary test overwrites in grounding dino
@yonigozlan
Copy link
Member Author

Thanks for the reviews! I have made the requested modifications, and removed now unnecessary tests for grounding-dino. If you think these modifications look ok I'll merge!

@yonigozlan yonigozlan merged commit 5bcbdff into huggingface:main Aug 13, 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.

5 participants