Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Identify sounds in short audio clips

License

NotificationsYou must be signed in to change notification settings

IBM/MAX-Audio-Classifier

Repository files navigation

Build StatusWebsite Status

IBM Developer Model Asset Exchange: Audio Classifier

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.

Model Metadata

DomainApplicationIndustryFrameworkTraining DataInput Data Format
AudioClassificationMultiKeras/TensorFlowGoogle AudioSetsigned 16-bit PCM WAV audio file

References

Licenses

ComponentLicenseLink
This repositoryApache 2.0LICENSE
Model FilesApache 2.0AudioSet
Model CodeMITAudioSet Classification
Test SamplesVariousSamples README

Pre-requisites:

  • 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.

Deployment options

Deploy from Quay

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.

Deploy on Red Hat OpenShift

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.

Deploy on Kubernetes

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

Run Locally

  1. Build the Model
  2. Deploy the Model
  3. Use the Model
  4. Development
  5. Cleanup

1. Build the Model

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-Classifier

To 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).

2. Deploy the Model

To run the Docker image, which automatically starts the model serving API, run:

$ docker run -it -p 5000:5000 max-audio-classifier

3. Use the Model

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.

Swagger Doc Screenshot

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/predict

You 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        }    ]}

4. Development

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).

5. Cleanup

To stop the Docker container, typeCTRL +C in your terminal.

Resources and Contributions

If you are interested in contributing to the Model Asset Exchange project or have any queries, please follow the instructionshere.


[8]ページ先頭

©2009-2026 Movatter.jp