- This project provides scripts to handle audio data processing & training a TensorFlow
Danger Classification Modelusing theYAMnetaudio embedding extraction layer (transfer learning)
- Python Version:
dev: 3.12.9 (github_codespace)training: 3.11.11 (google_colab)
- Target OS: Linux (No support for windows)
- Operate: Ubuntu 22.04.4 LTS x86_64 (Google colab Q1 2025)
- Develop: Debian GNU/Linux 12 x86_64 (See
/.devcontainer/devcontainer.json) - CUDA Version: 12.*
- See
/environment.ymlfor conda - See
/requirements.txtfor pip
- install conda/ miniconda into your distribution
- create conda environment from
environemnt.yml
conda env update --file ./environment.yml --prune
- activate conda environment
conda activate sra-env
- Run setup
python setup.py
- Training
python workflow.py
- run setup script
python setup.py
- run setup script
python workflow.py
-
For each dataset:
- Download dataset
- Filter sound file based on defined sound classes at
/classes.csv - Move filtered sound files into the main dataset path
/dataset/ - Normalize:
- Rename filtered sound files in
/dataset/to system rulef"{class_name}_{original_dataset}_{original_idx}"
- Rename filtered sound files in
- Save filtered dataset meta into a .csv file in
/ds/meta - Append filtered dataset meta to the main dataset meta in
/ds/meta
-
After pre-processing each dataset
- Augmentation
- Calculate
meandatapointcountfor each label inclasses.csv - For each
labelinclasses.csv- if
count<mean- duplicate random data in
labelto match withmean
- duplicate random data in
- if
count>mean- remove random data in
labelto match withmean
- remove random data in
- if
- Calculate
- Normalize:
- For each
.wavfile in/dataset/- Convert to PCM 16 wav format
- Convert bit depth from any to
16
- For each
- Assign fold label for each data point
- Save augmented, folded dataset state into a .csv file
- Augmentation
-
Training: See details at
workflow.py:train()
- Register the new dataset info object to
datasets.json(based on the previous format) - Human class mapping for added dataset to system-defined labels id in
config.json:classmapping.default - Create a new dataset
.pyfile inside/ds/, filename must be identical to the datasetkeyfield value at the registered object in step0 - Create the dataset class, extending
DataSetfromds.dataset.py - Implement necessary methods
- Add the dataset class constructor to
datasets_registryinworkflow.py - Run script
workflow.py --process_data_only
- Run script :D
workflow.py --use_processed