Messy Mashup
An end-to-end audio classification framework featuring synthetic audio generation, Mel spectrogram processing, custom CNN architectures, ResNet-based transfer learning, and model evaluation under distribution shift.
- PyTorch
- PyTorch Lightning
- Torchaudio
- Librosa
- NumPy
- TorchMetrics
- KaggleHub
- W&B

Overview
Messy Mashup is an end-to-end deep learning system developed to classify music genres from noisy and artificially mixed audio recordings.
Unlike conventional music genre classification systems that operate on relatively clean audio tracks, this project addresses a more challenging scenario involving recombined instrument stems, variations in tempo and loudness, and environmental background noise.
The system integrates synthetic dataset generation, digital audio processing, spectrogram-based feature representation, convolutional neural networks, transfer learning, experiment tracking, and automated inference.
The project focuses on investigating how deep learning models generalize when the distribution of evaluation data differs from the training environment.
Problem Statement
Music genre classification becomes particularly challenging when audio recordings contain overlapping instruments, inconsistent acoustic characteristics, and environmental disturbances.
Models trained on clean music recordings may perform well under controlled conditions but struggle when exposed to distorted or artificially mixed audio.
The Messy Mashup challenge requires classifying noisy audio samples into one of ten music genres.
The primary objectives of the project were to:
- Generate synthetic training samples from individual instrument stems.
- Develop a consistent audio preprocessing and feature extraction pipeline.
- Compare custom convolutional neural networks with transfer learning approaches.
- Investigate model performance under noisy and distribution-shifted conditions.
- Build modular and reusable training, evaluation, and inference workflows.
My Contribution
I designed and implemented the machine learning pipeline, covering dataset construction, audio preprocessing, model development, training, evaluation, and competition submission generation.
My key contributions include:
- Developed a synthetic audio dataset generation pipeline using instrument-stem recombination and environmental noise.
- Implemented tempo-based grouping using Librosa to combine stems from musically similar recordings.
- Designed audio preprocessing workflows involving resampling, mono-channel conversion, duration normalization, and Mel spectrogram extraction.
- Implemented custom convolutional neural network architectures for spectrogram-based classification.
- Adapted a pretrained ResNet-18 architecture to process single-channel audio spectrograms.
- Developed a shared PyTorch Lightning base model to standardize training, validation, optimization, and metric tracking.
- Integrated Weights & Biases for experiment monitoring, confusion matrices, and performance visualization.
- Implemented checkpoint-based model selection using validation Macro F1.
- Integrated KaggleHub for model artifact management and checkpoint retrieval.
- Developed an automated inference pipeline for generating competition submissions.
System Architecture
The project follows a modular machine learning architecture that separates dataset construction, audio preprocessing, model development, training, and inference.
| Component | Responsibility |
|---|---|
| Dataset Generation | Instrument-stem mixing, tempo grouping, noise injection, and synthetic sample creation |
| Audio Processing | Resampling, mono conversion, duration normalization, and spectrogram extraction |
| Data Pipeline | Loading preprocessed tensors, label encoding, batching, and dataset management |
| Model Layer | Custom CNN architectures and pretrained ResNet-18 |
| Training Pipeline | Optimization, validation, checkpointing, and hardware-aware execution |
| Experiment Tracking | Metric logging, confusion matrices, training duration, and model artifacts |
| Inference Pipeline | Audio preprocessing, checkpoint loading, genre prediction, and submission generation |
Dataset Composition
The project uses three primary sources of audio data:
- Instrument Stems: Individual musical components extracted from songs belonging to different genres.
- ESC-50 Environmental Noise: Environmental audio recordings used to introduce background disturbances.
- Competition Mashups: Noisy audio recordings used for external evaluation.
The classification task covers ten music genres: blues, classical, country, disco, hip-hop, jazz, metal, pop, reggae, and rock.
Synthetic Dataset Generation
A major component of the project is the generation of synthetic audio samples from individual instrument stems.
Each source song contains four musical components:
- Vocals
- Drums
- Bass
- Other instruments
To construct synthetic mashups, the pipeline first estimates song tempo using the drum stems and organizes songs into tempo-based groups.
Instrument stems are then sampled from songs belonging to the same genre and tempo group.
The dataset generation process consists of:
- Estimate the tempo of source songs.
- Group songs into predefined tempo ranges.
- Randomly select individual instrument stems from the corresponding group.
- Resample audio to a common sampling rate.
- Convert multi-channel audio into mono waveforms.
- Apply randomized amplitude gains to individual stems.
- Combine the selected instrument components.
- Inject randomly positioned environmental noise.
- Crop or pad the resulting waveform to a fixed duration.
- Generate and store its Mel spectrogram representation.
This approach attempts to reproduce characteristics of noisy competition recordings while creating additional labeled examples for supervised learning.
Tempo-based grouping improves the compatibility of selected stems, although it does not perform exact beat alignment or tempo synchronization.
Audio Processing and Feature Extraction
Raw audio waveforms contain large sequences of amplitude measurements, making direct processing computationally demanding.
Instead of operating directly on waveforms, the system transforms audio into Mel spectrograms that represent the distribution of acoustic energy across time and perceptually scaled frequency bands.
The audio processing configuration includes:
| Parameter | Configuration |
|---|---|
| Sampling Rate | 22,050 Hz |
| Training Audio Duration | 30 seconds |
| Audio Channels | Mono |
| Mel Frequency Bands | 128 |
| Spectrogram Dimensions | 128 × 128 |
| Input Tensor Shape | 1 × 128 × 128 |
The preprocessing pipeline converts Mel spectrograms into decibel-scale representations and resizes them to a standardized spatial resolution.
Precomputed spectrogram tensors are stored as PyTorch files, allowing the training pipeline to load processed features without repeatedly performing computationally expensive audio transformations.
This separates CPU-intensive dataset construction from model training.
Custom Convolutional Neural Networks
Custom convolutional neural networks were implemented to establish task-specific deep learning baselines.
The improved CNN architecture consists of four convolutional blocks with progressively increasing channel dimensions:
32 → 64 → 128 → 256
Each convolutional block incorporates:
- Two-dimensional convolution.
- Batch normalization.
- ReLU activation.
- Max pooling.
These layers extract hierarchical time-frequency features from the input spectrograms.
The convolutional representation is subsequently processed through global average pooling and a fully connected classification head.
Dropout regularization is applied within the classification head to reduce overfitting.
The final output consists of ten class logits corresponding to the supported music genres.
Transfer Learning with ResNet-18
To investigate whether pretrained visual representations can be adapted to audio classification, a ResNet-18 architecture was modified to accept single-channel Mel spectrograms.
The adaptation includes:
- Replacing the original three-channel input convolution with a single-channel convolution.
- Freezing the backbone parameters.
- Unfreezing the final residual block for task-specific fine-tuning.
- Replacing the original classification head with a custom fully connected network.
- Introducing dropout regularization before the final classification layer.
Although ResNet-18 was originally developed for image recognition, spectrograms provide a two-dimensional representation containing localized acoustic patterns that can be processed using convolutional architectures.
This experiment investigates the applicability of visual transfer learning to audio-domain representations.
Training and Experimentation Pipeline
A shared abstract base model was implemented using PyTorch Lightning to standardize training and evaluation across different architectures.
Individual model implementations define their forward-pass architecture, while the base model handles common machine learning operations.
The training framework includes:
- Adam optimization.
- Cross-entropy classification loss.
- Training and validation Macro F1 tracking.
- Validation accuracy and confusion matrices.
- Training and validation epoch-duration logging.
- Checkpoint selection based on validation Macro F1.
- Retention of the three highest-scoring checkpoints.
- Automatic CPU or GPU selection.
- Mixed-precision training when CUDA is available.
- Seed-based reproducibility controls.
- Weights & Biases experiment tracking.
- KaggleHub model artifact integration.
This design reduces duplication between experimental architectures and allows new models to be incorporated into the existing training workflow.
Inference and Competition Submission
The inference pipeline separates model evaluation from the training process.
During inference, the system:
- Retrieves the selected model checkpoint using KaggleHub.
- Reconstructs the corresponding model architecture.
- Loads the competition audio files.
- Converts audio recordings into standardized Mel spectrogram representations.
- Performs batched inference without gradient computation.
- Selects the highest-scoring genre for each recording.
- Generates a CSV submission containing sample identifiers and predicted genres.
The separation between training and inference enables previously trained models to be evaluated independently without repeating the training process.
Engineering Challenges
Generating Representative Training Data
One of the central challenges was constructing labeled training data that approximates the characteristics of noisy competition mashups.
Randomly combining arbitrary instrument stems can produce unrealistic audio samples because songs may have significantly different tempos and acoustic properties.
To improve compatibility, the synthetic dataset generation pipeline groups recordings by estimated tempo before mixing their stems.
Random amplitude adjustments and environmental noise injection introduce additional variation into the generated samples.
However, synthetic data generation cannot necessarily reproduce every characteristic of the external evaluation distribution.
Efficient Audio Preprocessing
Audio loading, resampling, tempo estimation, stem mixing, and spectrogram generation introduce substantial preprocessing requirements.
Performing all these operations repeatedly during model training could create a computational bottleneck.
The project addresses this by generating and storing processed spectrogram tensors before training.
This introduces a practical trade-off between disk usage, preprocessing time, and training efficiency.
Learning Time-Frequency Representations
Unlike tabular datasets, audio signals contain temporal and frequency-dependent information.
The system uses Mel spectrograms to transform waveforms into structured time-frequency representations that can be processed using convolutional neural networks.
Convolutional layers learn local acoustic patterns, while deeper layers combine these patterns into higher-level representations relevant to genre classification.
Adapting Pretrained Models to Audio Data
Pretrained image classification models are designed around visual inputs, whereas Mel spectrograms represent acoustic information.
Adapting ResNet-18 required modifying its input and output layers while determining which pretrained parameters should remain frozen and which should be fine-tuned.
This experiment provided practical exposure to transfer learning across different data modalities and highlighted the limitations of assuming that image-domain representations will automatically generalize to audio tasks.
Validation Integrity and Distribution Shift
The most significant experimental limitation was the difference between internal validation performance and external competition performance.
The model achieved substantially stronger results on synthetically generated validation samples than on the competition's noisy mashups.
Potential contributing factors include differences in noise characteristics, mixing procedures, preprocessing consistency, and overlap between source recordings used to construct training and validation samples.
This highlighted the need for stronger source-level dataset isolation and validation samples that more accurately represent the intended evaluation environment.
Technical Decisions
| Decision | Rationale |
|---|---|
| Stem-based dataset generation | Creates additional labeled audio samples using available musical components |
| Tempo-based grouping | Reduces incompatibility between instrument stems selected from different songs |
| Environmental noise injection | Introduces acoustic variation into synthetic training examples |
| Mel spectrogram representation | Converts waveforms into structured time-frequency features suitable for CNNs |
| Fixed-size spectrogram tensors | Standardizes model inputs and enables efficient batching |
| Offline preprocessing | Separates CPU-intensive audio processing from model training |
| Custom CNN architectures | Provides task-specific convolutional classification baselines |
| ResNet-18 transfer learning | Investigates adaptation of pretrained visual features to audio representations |
| Global average pooling | Reduces convolutional feature maps into compact classification representations |
| PyTorch Lightning | Standardizes reusable training and evaluation workflows |
| Macro F1 checkpoint selection | Evaluates performance across all genres with equal class weighting |
| Weights & Biases | Supports experiment comparison and performance diagnostics |
| KaggleHub | Provides model checkpoint storage and retrieval |
Results & Outcomes
The project resulted in a functional audio machine learning framework supporting synthetic dataset generation, spectrogram-based learning, multiple model architectures, experiment tracking, and automated competition inference.
Experimental Results
| Evaluation | Score |
|---|---|
| Internal Validation Macro F1 | Approximately 0.84 |
| Kaggle Private Leaderboard Score | 0.40286 |
The pretrained ResNet-18 inference configuration references a checkpoint with a validation Macro F1 score of 0.8389.
Although the model demonstrated strong performance on the internal validation dataset, its significantly lower competition score indicates limited generalization to the external audio distribution.
These results should not be interpreted as evidence that the system achieves 84% classification accuracy on unseen real-world recordings.
Implementation Outcomes
- Classification pipeline supporting ten music genres.
- Automated synthetic dataset generation using four instrument-stem categories.
- Standardized audio preprocessing at a sampling rate of 22.05 kHz.
- Spectrogram-based feature extraction and offline tensor storage.
- Two custom CNN implementations and a pretrained ResNet-18 implementation.
- Shared training and validation infrastructure.
- Experiment tracking with class-level confusion matrices.
- Checkpoint-based inference and automated competition submission generation.
Experimental Findings
The project demonstrated that achieving strong internal validation performance does not necessarily guarantee effective generalization.
Synthetic training data may reproduce certain characteristics of the target problem while failing to capture important aspects of the external evaluation distribution.
The performance gap also emphasizes the importance of source-level dataset separation, representative validation data, and consistency between training and inference preprocessing.
Rather than treating the leaderboard score as an isolated measure of success, the project provides a foundation for investigating these limitations through improved experimental design.
Lessons Learned
Developing Messy Mashup expanded my understanding of machine learning engineering beyond conventional text and structured datasets.
The project provided practical experience in:
- Digital audio processing and waveform manipulation.
- Audio sampling rates, resampling, and duration normalization.
- Mel spectrogram generation and time-frequency representations.
- Synthetic dataset generation and audio augmentation.
- Designing convolutional neural networks for acoustic classification.
- Adapting pretrained computer vision architectures to audio inputs.
- Implementing reusable deep learning training infrastructure.
- Managing model checkpoints and experiment artifacts.
- Evaluating classification performance using Macro F1 and confusion matrices.
- Recognizing the limitations of synthetic validation and distribution-shifted evaluation.
The most important learning was that reliable machine learning systems depend on representative data, rigorous validation, and consistent preprocessing rather than model complexity or internal validation scores alone.
Future Improvements
Potential directions for improving the system include:
Dataset and Validation
- Splitting source songs into disjoint training and validation pools before generating synthetic mashups.
- Recording the source identity of every instrument stem used in each generated sample.
- Improving reproducibility through deterministic dataset generation.
- Introducing more realistic noise augmentation and signal-to-noise ratio control.
- Applying beat alignment and time stretching for more accurate stem synchronization.
- Creating validation datasets that more closely resemble external competition audio.
Model Architecture
- Investigating audio-specific pretrained architectures such as Audio Spectrogram Transformers and PANNs.
- Improving transfer learning initialization for single-channel spectrograms.
- Exploring residual and attention-based classification architectures.
- Evaluating temporal pooling and higher-resolution spectrogram representations.
- Investigating model ensembles and multi-crop inference.
Training and Evaluation
- Introducing SpecAugment, Mixup, and additional training-time augmentation.
- Standardizing preprocessing between training and inference datasets.
- Performing systematic ablation studies.
- Conducting class-wise error analysis and domain-shift investigations.
- Evaluating inference latency and computational requirements.
- Improving reproducibility through versioned datasets and experiment configurations.