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.
From raw .mp3 clips to a submission .csv, in five stages.
How one clip becomes a prediction โ the winning class (argmax over 4) is highlighted. Class bars are illustrative.
Spleeter 2stems isolates the vocals from each clip.
Each vocal track becomes a mel-spectrogram tensor (.pt).
Crop, normalize, and optionally oversample the minority class.
Mixup + SpecAugment, SGD with cosine warm restarts.
Soft-voting & a stacked meta-model produce the final CSV.
Swap architectures with a single name flag in main.py.
Single-channel input, patched stem, 4-class head.
Dense connectivity backbone for spectrograms.
Shake-Shake regularization variants.
56 / 92-layer attention architectures.
Lightweight convolutional baseline.
Recurrent & attention sequence baselines.
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.
[128, 130] mel-spectrogram, sliced to [128, 128] and reshaped to [1, 128, 128] โ a single-channel image.128ร128 input the first conv is changed to 3ร3 stride-1 and the early max-pool is skipped, avoiding over-downsampling.torchaudio.naive_ensumble.py soft-votes ResNeXt-50 + DenseNet-201; meta_model.py stacks a meta-learner on the base outputs.The schedule and tricks that moved the needle โ all reproducible from the code.
Key findings from the project report.
Single-channel spectrogram images outperformed RGB renderings.
Combined augmentation added roughly two points of accuracy.
Summing probabilities beat a learned meta-model, which overfit.
K-fold CV and GAN/autoencoder augmentation are promising next steps.