-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Change needed in Whisper fine-tuning recipe to accommodate transformers4.30.0 #2016
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -104,7 +104,8 @@ def __init__( | |
| self._hop_length = feature_extractor.hop_length | ||
| self._n_samples = feature_extractor.n_samples | ||
| self.register_buffer( | ||
| "_mel_filters", torch.as_tensor(feature_extractor.mel_filters) | ||
| "_mel_filters", | ||
| torch.as_tensor(feature_extractor.mel_filters, dtype=torch.float32), | ||
| ) | ||
|
|
||
| self.model = WhisperModel.from_pretrained(source, cache_dir=save_path) | ||
|
|
@@ -244,7 +245,7 @@ def _log_mel_spectrogram(self, audio): | |
| magnitudes = stft[..., :-1].abs() ** 2 | ||
|
|
||
| filters = self._mel_filters | ||
| mel_spec = filters @ magnitudes | ||
| mel_spec = filters.transpose(0, 1) @ magnitudes | ||
|
Adel-Moumen marked this conversation as resolved.
Outdated
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't understand why it is coming from the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Whats the torch and trasnformers version are you using? I'll try the exact same version.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. log_transformer==4.30.2_script_changed.txt I attach the log files for your reference.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. in transformers >= 4.30, they change how they compute feature_extractor.mel_filters. As a result in transformers >= 4.30, the shape of feature_extractor.mel_filters is (201,80) while in the prev version, it was (80,201). It causes a problem in our _log_mel_spectrogram function ,we copy from openAI, when we calculate mel_spec = filters @ magnitudes. It expects the filter to be (80,201).
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks Pooneh,I see. Do you know why they changed their 'feature_extractor.mel_filters' ?
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is related to this PR on transformers: Basically what they do is replacing the hand-rolled STFT in the different models including whisper with the one from audio_util. In Transformers version <= 4.28: In version >= 4.29: Final Points:
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Adel-Moumen and @sangeet2020 I am thinking about applying transpose only if the shape is not n_mels, n_freqs, So it could also work for an older version of transformers. |
||
|
|
||
| log_spec = torch.clamp(mel_spec, min=1e-10).log10() | ||
| log_spec = torch.maximum( | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.