-
Notifications
You must be signed in to change notification settings - Fork 3
Command Line Tools
- Training Videos
- Installation
- Labeling Sounds Using metadata.csv
- Command Line Tools
- JavaScript-defined Models
sound-info Sound info Sound info Sound info Sound info
The following videos are available.
- Installation
- Using Audacity to label sounds
- Model evaluation
- Model training
- Classifying sounds
- Classify server
Acquire the aisp-core-main-0.0.1-SNAPSHOT.zip. This can be found in the aisp-core/aisp-core-main/target directory.
- Install one of Java 8 through 14 (15 does not include Nashorn, which we require) JDK including javadoc.
- Setting JAVA_HOME or adding javadoc to the path is required.
- cd SOMEDIR
- unzip .../aisp-core-main-0.0.1-SNAPSHOT.zip to create a directory tree rooted at the directory
aisp
. - Set AISP_HOME and the PATH environment variables
- On Windows
- set AISP_HOME=%SOMEDIR%\aisp
- set PATH=%PATH%;%AISP_HOME%\bin
- On Linux
- export AISP_HOME=$SOMEDIR/aisp
- export PATH=$AISP_HOME/bin:$PATH
- On Windows
- Optional steps
- Enable GPUs on linux
- Run
sudo setup-aisp -gpu
to configure the run-time to have access to the GPU drivers and libraries - Note however, that using the GPUs requires
- Using the DCASE model from the GPU build of the zip file.
- Run
- Enable GPUs on linux
Now you should have access to the command line tools. Try executing train -help
and verify that you get the help text.
The toolkit uses a simple comma-separated value (CSV) file to assign labels, and optionally other metadata using tags, to .wav files found in the file system. The file is typically named metadata.csv and is usually in the same directory as the sounds, although this is not a requirement. For example,
and the contents of the metadata.csv file as follows:
CarEngine.wav,source=engine;status=normal,
Compressor.wav,source=compressor;status=normal,
Machine.wav,source=machine;status=normal,
OneCylinderEngine.wav[100-1000],source=engine;status=abnormal,
Formally, the format is as follows:
- There is no header (although earlier versions used one).
- Column 1 - contains the name of the wav file. If relative, then the file is located relative to the location of the metadata.csv file. Optionally, a segment of the referenced file may be specified using start and end millisecond offsets into the wav file, as shown above, using the
[start-end]
notation. - Column 2- a semi-colon (;) separate list of label=value pairs specifying the name of the label and its value.
- Column 3 - a semi-colon (;) separate list of tag=value pairs specifying the name of the tag and its value. Tags are sometimes used by client applications to hold application data such as device source, start time, etc.
Any of the command line tools that read labeled sounds from the file system, generally require a metadata.csv file to provide the labels.
The following tools, in rough order of usage, are available from the aisp-core project:
- sound-info - shows summary information about labeled data from 1 or more metadata.csv files.
- evaluate - get the accuracy for a model including confusion matrix.
- train - trains a model local or remotely on local sounds or those stored in a server.
- classify - enables classification of a sound against a trained model. Can be run as a server or continuous sound monitor.
- audacity2metadata - converts Audacity label files to metadata format used by the tool.s
- capture - records sounds from the environment and stores them locally or in a server.
- ls-models - list the model identifiers recognized by the other command line tools.
- cut-sounds - extracts fixed size segments from 1 or more sound files.
- model-info - loads a model from disk and displays its contents.
Here we show how to create a classifier/model using local sounds and then use it to classify a sound. The first shows how to do this by storing the trained model in the local file system.
train -model gmm -label status -output sample-model.cfr -sounds ai-signal-processing/aisp-core/aisp-core-samples/sample-sounds/chiller classify -file sample-model.cfr ai-signal-processing/aisp-core/aisp-core-samples/sample-sounds/chiller/chiller-1.wav
Next, we run the classify tool as a server and use curl to make a request for classification
classify -file sample-model.cfr -server > my.log 2>&1 & curl --data-binary "@ai-signal-processing/aisp-core/aisp-core-samples/sample-sounds/chiller/chiller-1.wav" \ -H "Content-Type: audio/wav" http://localhost/classifyWAV {"status":{"labelName":"status","labelValue":"normal","confidence":1.0,\ "rankedValues":[{"labelValue":"normal","confidence":1.0},{"labelValue":"noisy","confidence":2.2854295769327834E-22}]}}
Next, we run the classify tool as a continuous monitor
classify -file sample-model.cfr -monitor -sensor-name dcasesensor -iotp-properties iotp.properties > my.log 2>&1 &
and the local iotp.properties files might contain the following:
Organization-ID=jr9abcj
API-Key=a-jr9k9o-wgyf12380adsf823
Authentication-Token=3;adfgNPi+6L91Y980a3$2
Here we show how to capture, train and classify all locally.
# Start normal motor and capture 20 5 second sound clips in the local file system. capture -label status=normal -sound-dir ./sounds -n 20 # Start abnormal motor and capture 20 clips again capture -label status=abnormal -sound-dir ./sounds -n 20 # Train the model on the 40 sounds and their status label values train -label status -sound-dir ./sounds -output motor.cfr # Start monitoring the environment and send events to iotp classify -monitor -file motor.cfr -sensor-name rpi2 -iotp-properties iotp.props -user some.user -pwd passw0rd
Finally, we show how to pause and restart the classify tool when in monitoring mode using the commander tool
# Pause the classifying monitor commander -iotp-properties iotp.props -sensor-name rpi2 -user some.user -pwd passw0rd -command pause # Start the classifying monitor commander -iotp-properties iotp.props -sensor-name rpi2 -user some.user -pwd passw0rd -command unpause
Let assume you have a directory of 5 folds in directories fold1-fold5. There are no metadata.csv files defining the labels, but the files are named with a prefix that defines the label value. For example,
bad_bearing_01.wav
We first need to create the metadata.csv files. We use a Linux bash script as follows:
#!/bin/bash for fold in fold1 fold2 fold3 fold4 fold5; do (cd $fold; names2metadata *.wav > metadata.csv) done
This uses the name2metadata bash script tool (this only works on Linux for now) to generate the metadata.csv files in each of the fold directories.
We can now train a model as follows using 4 of the 5 folds
train -label source -model lpnn -output lpnn.cfr -sounds fold1,fold2,fold3,fold4
The -sounds option that takes a comma-separated list of metadata.csv and/or directories containing a metdata.csv. Note that on Windows, the -sounds argument needs to be surrounded by double-quotes when contains commas.
Then to evaluate that model using the held out fold (cm causes the confusion matrix to be displayed)
evaluate -file lpnn.cfr -cm -sounds fold5
And alternatively, you can have the evaluate tool define its own random folds and then train and evaluate the model
evaluate -train -model lpnn -sounds fold1,fold2,fold3,fold4,fold5 -cm -folds 4