-
Notifications
You must be signed in to change notification settings - Fork 120
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
[cli] support campplus_200k and eres2net_200k models of damo #281
Merged
Conversation
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
JiJiJiang
approved these changes
Mar 1, 2024
Good job! BTW, have you ever compared the extracted embedding of the same audio by using wespeaker cli and 3d-speaker inference codes? |
The outputs of both are the same:
|
Using the following code to convert the damo/eres2net model to wespeaker format: import torch
def convert_model(path, output_path):
states = torch.load(path, map_location='cpu')
adapter_layers = ["layer3.0", "layer3.1", "layer3.2", "layer3.3", "layer3.4", "layer3.5",
"layer4.0", "layer4.1", "layer4.2"]
for key in adapter_layers:
states[f"{key}.conv2_1.weight"] = states.pop(f"{key}.convs.0.weight")
states[f"{key}.bn2_1.weight"] = states.pop(f"{key}.bns.0.weight")
states[f"{key}.bn2_1.bias"] = states.pop(f"{key}.bns.0.bias")
states[f"{key}.bn2_1.running_mean"] = states.pop(f"{key}.bns.0.running_mean")
states[f"{key}.bn2_1.running_var"] = states.pop(f"{key}.bns.0.running_var")
states[f"{key}.bn2_1.num_batches_tracked"] = states.pop(f"{key}.bns.0.num_batches_tracked")
states[f"{key}.convs.0.weight"] = states.pop(f"{key}.convs.1.weight")
states[f"{key}.bns.0.weight"] = states.pop(f"{key}.bns.1.weight")
states[f"{key}.bns.0.bias"] = states.pop(f"{key}.bns.1.bias")
states[f"{key}.bns.0.running_mean"] = states.pop(f"{key}.bns.1.running_mean")
states[f"{key}.bns.0.running_var"] = states.pop(f"{key}.bns.1.running_var")
states[f"{key}.bns.0.num_batches_tracked"] = states.pop(f"{key}.bns.1.num_batches_tracked")
states[f"{key}.convs.1.weight"] = states.pop(f"{key}.convs.2.weight")
states[f"{key}.bns.1.weight"] = states.pop(f"{key}.bns.2.weight")
states[f"{key}.bns.1.bias"] = states.pop(f"{key}.bns.2.bias")
states[f"{key}.bns.1.running_mean"] = states.pop(f"{key}.bns.2.running_mean")
states[f"{key}.bns.1.running_var"] = states.pop(f"{key}.bns.2.running_var")
states[f"{key}.bns.1.num_batches_tracked"] = states.pop(f"{key}.bns.2.num_batches_tracked")
torch.save(states, output_path)
if __name__ == "__main__":
convert_model("/Users/user01/code/wespeaker-cli/pre_model/eres2net_commom/avg_model.pt",
"/Users/user01/code/wespeaker-cli/pre_model/eres2net_commom/avg_model_convert.pt") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
usags: