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

Add zipformer recipe for audio tagging #1421

Merged
merged 33 commits into from
Apr 9, 2024

Conversation

marcoyang1998
Copy link
Collaborator

@marcoyang1998 marcoyang1998 commented Dec 19, 2023

This PR adds a recipe for audio tagging using Zipformer. We use AudioSet as the training set.

Without using knowledge distillation, the Zipformer-M model achieves mAP value of 45.1. Using knowledge distillation could further improve the results (will add support for this in another PR)

  • Add usage example
  • Upload the pre-trained model

@marcoyang1998
Copy link
Collaborator Author

You can use the pretrained model to predict the audio events of an audio clip through the following command:

python zipformer/pretrained.py \
    --checkpoint zipformer/exp_at_as_full/pretrained.pt \
    --label-dict downloads/audioset/class_labels_indices.csv \
    downloads/audioset/eval/wav/__p-iA312kg_70.000_80.000.wav

You should see the following output:

2024-03-20 18:40:35,611 INFO [pretrained.py:175] Reading sound files: ['downloads/audioset/eval/wav/__p-iA312kg_70.000_80.000.wav']
2024-03-20 18:40:35,616 INFO [pretrained.py:181] Decoding started
Top 5 predicted labels of the 0 th audio are ['Cat', 'Animal', 'Domestic animals, pets', 'Meow', 'Caterwaul'] with probability of [0.9497291445732117, 0.8830551505088806, 0.8787704110145569, 0.2819702923297882, 0.18947316706180573]

@marcoyang1998
Copy link
Collaborator Author

egs/audioset/AT/local/generate_audioset_manifest.py Outdated Show resolved Hide resolved
egs/audioset/AT/local/generate_audioset_manifest.py Outdated Show resolved Hide resolved
egs/audioset/AT/local/generate_audioset_manifest.py Outdated Show resolved Hide resolved
egs/audioset/AT/local/generate_audioset_manifest.py Outdated Show resolved Hide resolved
egs/audioset/AT/zipformer/at_datamodule.py Outdated Show resolved Hide resolved
egs/audioset/AT/zipformer/at_datamodule.py Outdated Show resolved Hide resolved
egs/audioset/AT/local/generate_audioset_manifest.py Outdated Show resolved Hide resolved
egs/audioset/AT/zipformer/at_datamodule.py Outdated Show resolved Hide resolved
egs/audioset/AT/zipformer/at_datamodule.py Outdated Show resolved Hide resolved
egs/audioset/AT/zipformer/at_datamodule.py Outdated Show resolved Hide resolved
egs/audioset/AT/zipformer/train.py Show resolved Hide resolved
egs/audioset/AT/zipformer/train.py Outdated Show resolved Hide resolved
@marcoyang1998
Copy link
Collaborator Author

Since there is no official way of downloading AudioSet now, this recipe assumes that you have your own version of AudioSet. The required structure of the dataset will be given in prepare.sh (will add in the next commit).

egs/audioset/AT/zipformer/train.py Outdated Show resolved Hide resolved
egs/audioset/AT/zipformer/train.py Outdated Show resolved Hide resolved
egs/audioset/AT/zipformer/evaluate.py Outdated Show resolved Hide resolved
egs/audioset/AT/zipformer/evaluate.py Outdated Show resolved Hide resolved
egs/audioset/AT/zipformer/evaluate.py Outdated Show resolved Hide resolved
egs/audioset/AT/zipformer/evaluate.py Outdated Show resolved Hide resolved
egs/audioset/AT/zipformer/export.py Outdated Show resolved Hide resolved
egs/audioset/AT/zipformer/export.py Outdated Show resolved Hide resolved
egs/audioset/AT/zipformer/export.py Show resolved Hide resolved
@marcoyang1998
Copy link
Collaborator Author

Added jit_pretrained.py. The script produces the same results as pretrained.py.

@marcoyang1998
Copy link
Collaborator Author

@csukuangfj Can we merge this now?

Copy link
Collaborator

@csukuangfj csukuangfj left a comment

Choose a reason for hiding this comment

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

Thanks! Just left a minor comment.

@marcoyang1998 marcoyang1998 merged commit 1732daf into k2-fsa:master Apr 9, 2024
7 checks passed
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.

2 participants