/SoundCLR

Implementation for "SoundCLR: Contrastive Learning of Representations For Improved Environmental Sound Classification," in pytorch.

Primary LanguagePythonMIT LicenseMIT

Contrastive-Learning-in-ESC

Implementation for the paper SoundCLR: Contrastive Learning of Representations For Improved Environmental Sound Classification

Three Training Schemes For The Audio Classifiers:

overview of our three models

Data Augmentation:

data augmentation process

Setup and Dependencies:

First, install the above dependencies.

Second, download ESC50 and US8K datasets and put them inside the 'data' directory, and assign True to the dataset that you want to use to train your model, in config.py

###Quickstart

Training with Cross-Entropy Loss

To train a classifier with ResNet-50 with cross-entropy loss:

$ python train_crossEntropyLoss.py

Training with Supervised-Contrastive Loss

Stage 1: To train a classifier with ResNet-50 with supervised-contrastive loss:

$ python train_contrastiveLoss.py

Stage2: and then update path_to_classifierModel in config.py with the path to the ResNet model trained in stage1, and:

$ python train_classifier.py

Training with Hybrid Loss

To train a classifier with ResNet-50 with hybrid loss:

$ python train_hybridLoss.py

Configuration Options

By modifying config.py file, you can change:

  • training hyperparameters
  • the alpha value for the hybrid loss
  • maximul-length and number of the masking segments