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

[AutoProcessor] Add Wav2Vec2WithLM & small fix #14675

Conversation

patrickvonplaten
Copy link
Contributor

@patrickvonplaten patrickvonplaten commented Dec 8, 2021

What does this PR do?

Make AutoProcessor work correctly with local files and small fix

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.

@@ -39,6 +39,7 @@
("speech_to_text_2", "Speech2Text2Processor"),
("trocr", "TrOCRProcessor"),
("wav2vec2", "Wav2Vec2Processor"),
("wav2vec2_with_lm", "Wav2Vec2ProcessorWithLM"),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

need new folder for this

Copy link
Member

@LysandreJik LysandreJik left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -145,6 +146,9 @@ def from_pretrained(cls, pretrained_model_name_or_path, **kwargs):
key: kwargs[key] for key in ["revision", "use_auth_token", "local_files_only"] if key in kwargs
}
model_files = get_list_of_files(pretrained_model_name_or_path, **get_list_of_files_kwargs)
# strip to file name
model_files = [f.split("/")[-1] for f in model_files]
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't that be handled in get_list_of_files?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah I thought so too in the beginning, but think it's cleaner to get the actual file names from this function instead of trimming to the last file. What do you think? cc @sgugger as well

Copy link
Collaborator

Choose a reason for hiding this comment

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

It should be done at the model_files level to be consistent with the distant repos.

@patrickvonplaten
Copy link
Contributor Author

Test failure is unrelated

@patrickvonplaten
Copy link
Contributor Author

Failures are unrelated - merging

@patrickvonplaten patrickvonplaten merged commit ee4fa2e into huggingface:master Dec 8, 2021
@patrickvonplaten patrickvonplaten deleted the add_wav2vec2_with_lm_to_autoprocessor branch December 8, 2021 14:51
Copy link
Collaborator

@sgugger sgugger left a comment

Choose a reason for hiding this comment

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

Can't comment on the merged PR but I think we should strip the filenames in the get_list_of_files method to have a behavior that is consistent between repos and local folders. The files are not directly usable and you have to use cached_path anyway to actually use them, which will put again the folder name at the beginning.

@@ -145,6 +146,9 @@ def from_pretrained(cls, pretrained_model_name_or_path, **kwargs):
key: kwargs[key] for key in ["revision", "use_auth_token", "local_files_only"] if key in kwargs
}
model_files = get_list_of_files(pretrained_model_name_or_path, **get_list_of_files_kwargs)
# strip to file name
model_files = [f.split("/")[-1] for f in model_files]
Copy link
Collaborator

Choose a reason for hiding this comment

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

It should be done at the model_files level to be consistent with the distant repos.

Albertobegue pushed a commit to Albertobegue/transformers that referenced this pull request Jan 27, 2022
* [AutoProcessor] Add Wav2Vec2WithLM & small fix

* revert line removal

* Update src/transformers/__init__.py

* add test

* up

* up

* small fix
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.

None yet

3 participants