Implementation for the paper SoundCLR: Contrastive Learning of Representations For Improved Environmental Sound Classification
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
To train a classifier with ResNet-50 with cross-entropy loss:
$ python train_crossEntropyLoss.py
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
To train a classifier with ResNet-50 with hybrid loss:
$ python train_hybridLoss.py
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