-
Notifications
You must be signed in to change notification settings - Fork 31.1k
Correctly handle unbatched audio inputs in Gemma3nAudioFeatureExtractor #42076
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
Conversation
|
Thanks for sending this fix @kho! |
|
cc @zucchini-nlp @Rocketknight1 for a review to help us land this for Gemma 3n. |
| if is_batched: | ||
| raw_speech = [np.asarray([rs]).T for rs in raw_speech] | ||
| elif not is_batched and not isinstance(raw_speech, np.ndarray): | ||
| raw_speech = np.asarray(raw_speech) | ||
|
|
||
| if not is_batched: # always return a batch | ||
| raw_speech = [np.asarray([raw_speech])] | ||
| raw_speech = [np.asarray([raw_speech]).T] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not very related to this PR, but let's unify a bit these blocks for easier reading, maybe smth like below. Otherwise LGTM
if not is_batched:
raw_speech = [np.asarray(raw_speech)]
raw_speech = [np.asarray([rs]).T for rs in raw_speech]There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point! I just realized that we also don't need the np.asarray() call in the if statement. PTAL and thanks for reviewing!
…AudioFeatureExtractor
|
[For maintainers] Suggested jobs to run (before merge) run-slow: gemma3n |
zucchini-nlp
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
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. |
…or (huggingface#42076) * Correctly handle unbatched audio inputs in Gemma3nAudioFeatureExtractor * Simplify the logic for batching the unbatched speech input in Gemma3nAudioFeatureExtractor
What does this PR do?
Correctly handle unbatched audio inputs in Gemma3nAudioFeatureExtractor
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.