- Notifications
You must be signed in to change notification settings - Fork53
Identify sounds in short audio clips
License
IBM/MAX-Audio-Classifier
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
This repository contains code to instantiate and deploy an audio classification model. This model recognizes a signed 16-bitPCM wav file as an input, generates embeddings, appliesPCA transformation/quantization,uses the embeddings as an input to a multi-attention classifier and outputs top 5 class predictions and probabilities as output.The model currently supports 527 classes which are part of theAudioset Ontology. The classes and the label_ids can be found inclass_labels_indices.csv.The model was trained onAudioSet as described in the paper'Multi-level Attention Model for Weakly Supervised Audio Classification' by Yu et al.
The model has been tested across multiple audio classes, however it tends to perform best for Music / Speech categories. This is largely due to the bias towards these classes in the training dataset (90% of audio belong to either of these categories). Though the model is trained on data from Audioset which was extracted from YouTube videos, the model can be applied to a wide range of audio files outside the domain of music/speech. The test assets provided along with this model provide a broad range.
The model files are hosted on IBM Cloud Object Storage. The code in this repository deploys the model as a web servicein a Docker container. This repository was developed as part of theIBM Developer Model Asset Exchange and the public API is powered byIBM Cloud.
| Domain | Application | Industry | Framework | Training Data | Input Data Format |
|---|---|---|---|---|---|
| Audio | Classification | Multi | Keras/TensorFlow | Google AudioSet | signed 16-bit PCM WAV audio file |
Jort F. Gemmeke, Daniel P. W. Ellis, Dylan Freedman, Aren Jansen, Wade Lawrence, R. Channing Moore, Manoj Plakal, Marvin Ritter,"Audio set: An ontology and human-labeled dataset for audio events", IEEE ICASSP, 2017.
Qiuqiang Kong, Yong Xu, Wenwu Wang, Mark D. Plumbley,"Audio Set classification with attention model: A probabilistic perspective." arXiv preprint arXiv:1711.00927 (2017).
Changsong Yu, Karim Said Barsim, Qiuqiang Kong, Bin Yang ,"Multi-level Attention Model for Weakly Supervised Audio Classification." arXiv preprint arXiv:1803.02353 (2018).
S. Hershey, S. Chaudhuri, D. P. W. Ellis, J. F. Gemmeke, A. Jansen,R. C. Moore, M. Plakal, D. Platt, R. A. Saurous, B. Seybold et al.,"CNN architectures for large-scale audio classification," arXiv preprintarXiv:1609.09430, 2016.
| Component | License | Link |
|---|---|---|
| This repository | Apache 2.0 | LICENSE |
| Model Files | Apache 2.0 | AudioSet |
| Model Code | MIT | AudioSet Classification |
| Test Samples | Various | Samples README |
docker: TheDocker command-line interface. Follow theinstallation instructions for your system.- The minimum recommended resources for this model is 8 GB Memory and 4 CPUs.
- If you are on x86-64/AMD64, your CPU must supportAVX at the minimum.
To run the docker image, which automatically starts the model serving API, run:
$ docker run -it -p 5000:5000 quay.io/codait/max-audio-classifier
This will pull a pre-built image from the Quay.io container registry (or use an existing image if already cached locally) and run it.If you'd rather checkout and build the model locally you can follow therun locally steps below.
You can deploy the model-serving microservice on Red Hat OpenShift by following the instructions for the OpenShift web console or the OpenShift Container Platform CLIin this tutorial, specifyingquay.io/codait/max-audio-classifier as the image name.
You can also deploy the model on Kubernetes using the latest docker image on Quay.
On your Kubernetes cluster, run the following commands:
$ kubectl apply -f https://raw.githubusercontent.com/IBM/MAX-Audio-Classifier/master/max-audio-classifier.yaml
The model will be available internally at port5000, but can also be accessed externally through theNodePort.
A more elaborate tutorial on how to deploy this MAX model to production onIBM Cloud can be foundhere
Clone this repository locally. In a terminal, run the following command:
$ git clone https://github.com/IBM/MAX-Audio-Classifier.git
Change directory into the repository base folder:
$cd MAX-Audio-ClassifierTo build the Docker image locally, run:
$ docker build -t max-audio-classifier.All required model assets will be downloaded during the build process.Note that currently this Docker image is CPUonly (we will add support for GPU images later).
To run the Docker image, which automatically starts the model serving API, run:
$ docker run -it -p 5000:5000 max-audio-classifier
The API server automatically generates an interactive Swagger documentation page. Go tohttp://localhost:5000 to loadit. From there you can explore the API and also create test requests.
Note : The input is a 10 second signed 16-bit PCM wav audio file. Files longer than 10 seconds will be clipped so that only the first 10 seconds will be used by the model. Conversely, files shorter than 10 seconds will be repeated to create a clip 10 seconds in length.
Use themodel/predict endpoint to load a signed 16-bit PCM wav audio file (you can use thefireworks.wav file locatedin thesamples folder) and get predictions from the API.
You can also test it on the command line, for example (with thethunder.wav file):
$ curl -F"audio=@samples/thunder.wav;type=audio/wav" -XPOST http://localhost:5000/model/predictYou should see a JSON response like that below:
{"status":"ok","predictions": [ {"label_id":"/m/06mb1","label":"Rain","probability":0.7376469373703003 }, {"label_id":"/m/0ngt1","label":"Thunder","probability":0.60517817735672 }, {"label_id":"/t/dd00038","label":"Rain on surface","probability":0.5905200839042664 }, {"label_id":"/m/0jb2l","label":"Thunderstorm","probability":0.5793699026107788 }, {"label_id":"/m/07yv9","label":"Vehicle","probability":0.34878015518188477 } ]}To run the Flask API app in debug mode, editconfig.py to setDEBUG = True under the application settings. You willthen need to rebuild the Docker image (seestep 1).
To stop the Docker container, typeCTRL +C in your terminal.
If you are interested in contributing to the Model Asset Exchange project or have any queries, please follow the instructionshere.
About
Identify sounds in short audio clips
Topics
Resources
License
Security policy
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors10
Uh oh!
There was an error while loading.Please reload this page.

