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

Add docstrings and fix VIVIT examples #25628

Merged
merged 3 commits into from
Aug 26, 2023
Merged

Add docstrings and fix VIVIT examples #25628

merged 3 commits into from
Aug 26, 2023

Conversation

Geometrein
Copy link
Contributor

@Geometrein Geometrein commented Aug 21, 2023

What does this PR do?

  • Add docstring for sample_frame_indicesmethod
  • Fix broken examples for VIVIT
    • Add missing Pytorch & VivitForVideoClassification imports
    • Resolve the referenced before assignment error caused by an undeclared videoreader variable.

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).

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.

Comment on lines +705 to +706
>>> indices = sample_frame_indices(clip_len=32, frame_sample_rate=4, seg_len=container.streams.video[0].frames)
>>> video = read_video_pyav(container=container, indices=indices)
Copy link
Contributor Author

@Geometrein Geometrein Aug 21, 2023

Choose a reason for hiding this comment

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

  1. videoreader was an undeclared variable. It has been replaced with an equivalent code.

  2. When seg_len is set to the whole video length frame_sample_rate needs to be set to 4 otherwise the model will assign a wrong class to the video invalidating the whole example.

@@ -698,7 +717,7 @@ def forward(
>>> # model predicts one of the 400 Kinetics-400 classes
>>> predicted_label = logits.argmax(-1).item()
>>> print(model.config.id2label[predicted_label])
eating spaghetti
LABEL_116
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The model actually doesn't output eating spaghetti it outputs LABEL_116which corresponds to eating spaghetti in kinetics 400.

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint.

@ArthurZucker
Copy link
Collaborator

cc @Rocketknight1

Copy link
Member

@Rocketknight1 Rocketknight1 left a comment

Choose a reason for hiding this comment

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

Doctests pass locally for me and the docstrings look good!

@Rocketknight1
Copy link
Member

@Geometrein Thanks for the PR - ping me whenever you're happy for me to merge!

@Geometrein
Copy link
Contributor Author

Thanks for your review @Rocketknight1!
It's good to go, feel free to merge :)

@Rocketknight1 Rocketknight1 merged commit 686c68f into huggingface:main Aug 26, 2023
parambharat pushed a commit to parambharat/transformers that referenced this pull request Sep 26, 2023
* fix docstrings and examples

* docstring update

* add missing whitespace
blbadger pushed a commit to blbadger/transformers that referenced this pull request Nov 8, 2023
* fix docstrings and examples

* docstring update

* add missing whitespace
EduardoPach pushed a commit to EduardoPach/transformers that referenced this pull request Nov 18, 2023
* fix docstrings and examples

* docstring update

* add missing whitespace
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.

4 participants