panns_inference: audio tagging and sound event detection inference toolbox
Project description
PANNs inferece
panns_inference provides an easy to use Python interface for audio tagging and sound event detection. The audio tagging and sound event detection models are trained from PANNs: Large-Scale Pretrained Audio Neural Networks for Audio Pattern Recognition: https://github.com/qiuqiangkong/audioset_tagging_cnn
Installation
PyTorch>=1.0 is required.
$ pip install panns-inference
Usage
$ python3 example.py
For example:
import librosa
import panns_inference
from panns_inference import AudioTagging, SoundEventDetection, labels
audio_path = 'examples/R9_ZSCveAHg_7s.wav'
(audio, _) = librosa.core.load(audio_path, sr=32000, mono=True)
audio = audio[None, :] # (batch_size, segment_samples)
print('------ Audio tagging ------')
at = AudioTagging(device='cuda')
(clipwise_output, embedding) = at.inference(audio)
print('------ Sound event detection ------')
sed = SoundEventDetection(device='cuda')
framewise_output = sed.inference(audio)
Results
------ Audio tagging ------ Checkpoint path: /root/panns_data/Cnn14_mAP=0.431.pth GPU number: 1 Speech: 0.893 Telephone bell ringing: 0.754 Inside, small room: 0.235 Telephone: 0.183 Music: 0.092 Ringtone: 0.047 Inside, large room or hall: 0.028 Alarm: 0.014 Animal: 0.009 Vehicle: 0.008 ------ Sound event detection ------ Checkpoint path: /root/panns_data/Cnn14_mAP=0.431.pth GPU number: 1 Save fig to appendixes/sed_result.pdf
Sound event detection plot:
Cite
[1] Kong, Qiuqiang, Yin Cao, Turab Iqbal, Yuxuan Wang, Wenwu Wang, and Mark D. Plumbley. "PANNs: Large-Scale Pretrained Audio Neural Networks for Audio Pattern Recognition." arXiv preprint arXiv:1912.10211 (2019).
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file panns-inference-0.0.5.tar.gz
.
File metadata
- Download URL: panns-inference-0.0.5.tar.gz
- Upload date:
- Size: 6.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3.post20200330 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3949db9f9105137c645cc06978bbee8954afe2e305ca81b8b221e600213fb9cb |
|
MD5 | c9bb404945488005c50e2a8fd0da4a79 |
|
BLAKE2b-256 | 5ab1576a0be758fd2ad463b6d998960b868771bf8b2ad609a77ade77206dd71e |
File details
Details for the file panns_inference-0.0.5-py3-none-any.whl
.
File metadata
- Download URL: panns_inference-0.0.5-py3-none-any.whl
- Upload date:
- Size: 7.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3.post20200330 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4b9b410433327bba1aaf67ef9870fd2fed5777cc11f43c56a44e9140507b5c62 |
|
MD5 | a942316c5b97cd6863a43d0c629e35e8 |
|
BLAKE2b-256 | dcda62b85c561d87960a6ff5e96c46cdefe5e74a8213c7a3ee34a0d54a4394e1 |