-
Notifications
You must be signed in to change notification settings - Fork 1
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
added wav2vec2 model, and related conf/utils files. #107
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
c32e79d
added wav2vec2 model, and related conf/utils files.
danielle-hausler 379d7b0
Update soundbay/models.py
danielle-hausler 5881694
Update models.py
danielle-hausler a11e2d2
Merge branch 'master' into feature/wav2vec
danielle-hausler 92d4ea2
Update models.py
danielle-hausler File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# @package _global_ | ||
_augmentations: | ||
time_stretch: | ||
_target_: audiomentations.TimeStretch | ||
min_rate: 0.9 | ||
max_rate: 1.1 | ||
p: 0 | ||
time_masking: | ||
_target_: audiomentations.TimeMask | ||
min_band_part: 0.05 | ||
max_band_part: 0.2 | ||
p: 0 | ||
frequency_masking: | ||
_target_: audiomentations.BandStopFilter | ||
|
||
min_center_freq: ${data.min_freq} | ||
max_center_freq: ${data.max_freq} | ||
min_bandwidth_fraction: 0.05 | ||
max_bandwidth_fraction: 0.2 | ||
p: 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# @package _global_ | ||
model: | ||
criterion: | ||
_target_: torch.nn.CrossEntropyLoss | ||
model: | ||
_target_: models.WAV2VEC2 | ||
num_classes: 2 | ||
pretrained: True | ||
freeze_encoder: False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# @package _global_ | ||
optim: | ||
epochs: 100 | ||
optimizer: | ||
_target_: torch.optim.Adam | ||
lr: 0.001 | ||
scheduler: | ||
_target_: torch.optim.lr_scheduler.ExponentialLR | ||
gamma: 0.995 | ||
freeze_layers_for_finetune: True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# @package _global_ | ||
_preprocessors: [] | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# @package _global_ | ||
defaults: | ||
- ../data: defaults | ||
- ../augmentations: wav2vec2 | ||
- ../preprocessors: wav2vec2 | ||
- ../model: wav2vec2 | ||
- ../optim: wav2vec2 | ||
- ../experiment: defaults |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import json | ||
import yaml | ||
import urllib | ||
|
||
def load_config(filepath: str): | ||
assert filepath.endswith(("json", "yaml", "yml")), "Only json and yaml files are supported." | ||
|
||
is_url = filepath.startswith("http") | ||
is_json = filepath.endswith("json") | ||
is_yaml = filepath.endswith(("yaml", "yml")) | ||
|
||
if is_url and is_json: | ||
return load_json_from_url(filepath) | ||
elif is_url and is_yaml: | ||
return load_yaml_from_url(filepath) | ||
elif is_json: | ||
return load_json(filepath) | ||
elif is_yaml: | ||
return load_yaml(filepath) | ||
else: | ||
raise ValueError("File format not supported.") | ||
|
||
|
||
def load_json_from_url(url: str): | ||
with urllib.request.urlopen(url) as url: | ||
return json.load(url) | ||
|
||
def load_yaml_from_url(url: str): | ||
with urllib.request.urlopen(url) as url: | ||
return yaml.safe_load(url) | ||
|
||
def load_json(filepath: str): | ||
with open(filepath, "r") as file: | ||
return json.load(file) | ||
|
||
def load_yaml(filepath: str): | ||
with open(filepath, "r") as file: | ||
return yaml.safe_load(file) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
if there are no preprocessors why is this file needed and not use the
defaults
?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.
wav2vec is working on the raw input (the waveform) and the defaults file has a preprocess of the data into a spectrogram.