๐ŸŽง Music Classification ยท Deep Learning

ML_contest
Vocals โ†’ Spectrograms โ†’ Ensemble

An end-to-end pipeline for a 4-class music audio classification Kaggle contest: source-separate each track's vocals, turn them into a mel-spectrogram, and classify with an ensemble of CNN and attention networks.

83.04% test accuracy ยท ResNeXt-50 + DenseNet-201 ensemble
Python 3.9+ PyTorch 2.3 torchvision ยท torchaudio Spleeter SLURM / HPC

The pipeline

From raw .mp3 clips to a submission .csv, in five stages.

waveform โ†’ mel-spectrogram โ†’ CNN / attention โ†’ 4 classes 0123

How one clip becomes a prediction โ€” the winning class (argmax over 4) is highlighted. Class bars are illustrative.

01 ยท SEPARATE

Vocal split

Spleeter 2stems isolates the vocals from each clip.

โ†’
02 ยท FEATURES

Mel-spectrogram

Each vocal track becomes a mel-spectrogram tensor (.pt).

โ†’
03 ยท DATASET

Load & balance

Crop, normalize, and optionally oversample the minority class.

โ†’
04 ยท TRAIN

CNN / attention

Mixup + SpecAugment, SGD with cosine warm restarts.

โ†’
05 ยท PREDICT

Ensemble

Soft-voting & a stacked meta-model produce the final CSV.

Model zoo

Swap architectures with a single name flag in main.py.

ConvNet

ResNeXt 50 / 101

Single-channel input, patched stem, 4-class head.

ConvNet

DenseNet-201

Dense connectivity backbone for spectrograms.

Regularized

Shake-ResNet / ResNeXt

Shake-Shake regularization variants.

Attention

Residual Attention Net

56 / 92-layer attention architectures.

Baseline

ResNet-18

Lightweight convolutional baseline.

Sequence

LSTM / Transformer

Recurrent & attention sequence baselines.

Quick start

Two isolated environments โ€” Spleeter pins an older TensorFlow that the PyTorch stack can't share.

1 ยท Training / inference (PyTorch)

# Python 3.9+
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt

python main.py            # train / infer
python naive_ensumble.py  # ensemble โ†’ CSV

2 ยท Preprocessing (Spleeter)

python -m venv .venv-spleeter
source .venv-spleeter/bin/activate
pip install -r requirements_spleeter.txt

python voice_split.py                  # separate vocals
python data_processing/gray_scale.py   # .wav โ†’ .pt

โš ๏ธ Scripts use absolute paths hard-coded to an HPC scratch directory (/scratch/hh3043/ML_contest/โ€ฆ). Update the dataset, checkpoint, and output paths before running elsewhere.

Under the hood

Training recipe

The schedule and tricks that moved the needle โ€” all reproducible from the code.

Cosine-annealing learning rate

5e-3 0 start end training progress โ†’

Augmentation schedule

Mixup + CE Cross-entropy epoch 0 E / 2 E SpecAugment (time + freq masking) applied every batch, throughout

Stem adapted for 128ร—128 input

standard torchvision7ร—7 ยท s2โ†’maxpool s2 โ†“ heavy early downsampling adapted (this project)3ร—3 ยท s1โ†’no pool โ†“ resolution preserved

What worked

Key findings from the project report.

+ Signal

Grayscale > RGB

Single-channel spectrogram images outperformed RGB renderings.

โ‰ˆ +2%

Mixup + SpecAugment

Combined augmentation added roughly two points of accuracy.

Winner

Unweighted ensemble

Summing probabilities beat a learned meta-model, which overfit.

Future

K-fold & generative

K-fold CV and GAN/autoencoder augmentation are promising next steps.