[ 02 ]
Music Genre Classifier
Deep learning model that classifies music genres from audio with 94% accuracy
Accuracy
94% on 10 genre classification
Inference Speed
Under 500ms per 3 minute song
Dataset
5000 songs across 10 genres balanced
Architecture
CNN + LSTM hybrid on MFCC and spectral features
The Problem
The Challenge
Music streaming services face a real problem. When they get unclassified music, they either have to manually tag it which doesn't scale, or they use systems that get it wrong. Existing genre classifiers were either pretty dumb rule based systems that barely worked, or they were proprietary black boxes that no one could learn from. Genre classification is genuinely hard because music is so nuanced. A song might be rock or pop depending on who you ask. Plus new genres keep popping up. I wanted to build something that could actually learn audio patterns instead of relying on hand coded rules.
The Solution
How We Built It
I started by collecting audio data. Gathered about 5000 songs across 10 different genres like pop, rock, hip hop, jazz, classical, and some others. Made sure I had a good balance so the model wouldn't just memorize one genre. For the actual model, I extracted Mel frequency cepstral coefficients and spectral features from the raw audio. These are fancy ways of saying I broke down the audio into components that actually describe what we hear. Then I built a neural network that combines CNNs for capturing what instruments sound like and LSTMs for understanding how rhythm and tempo change over time. The model learns to connect those patterns to genres. During training I used data augmentation like pitch shifting and time stretching to make the model more robust. It's not just learning specific artists, it's learning the actual sound patterns. I ran the training on GPU for 200 epochs and ended up with a model that gets 94% accuracy on data it's never seen before. Inference is fast too, around half a second per song.
Key Features
MFCC and spectral feature extraction from raw audio files
CNN and LSTM hybrid architecture for learning temporal and spectral patterns
Data augmentation including pitch shift and time stretch
Confusion matrix analysis so you can see what gets confused like rock vs metal
REST API for real time predictions
Model versioning for tracking improvements
Ablation studies proving LSTM adds 8% accuracy
Tech Stack
Results & Impact
What We Achieved
The classifier gets 94% right on audio it never saw during training, which is solid. What's actually interesting is how it handles the hard cases. For songs that genuinely blend genres like indie pop, it returns the top three predictions with confidence scores so you can make the call yourself. It performs best on pure genres like metal and classical, and worst on blended stuff, which says as much about how fuzzy genre boundaries really are as it does about the model.
Lessons Learned
1. Hand crafted features like MFCCs actually outperformed raw spectrograms by 12%. Feature engineering still matters.
2. Class imbalance is a real problem. Some genres are way rarer than others. Had to use weighted loss functions.
3. Audio diversity matters a lot. If you train on 10 different artists per genre the model learns the genre not the artist.
4. Model optimization is critical. Original model was 10 times slower until I quantized it.
5. Genre is subjective and ambiguous songs legitimately exist between categories. Model uncertainty is valid.
Timeline
2 months total with data collection taking 4 weeks and model training taking 6 weeks
Role
Solo data scientist and ML engineer
Status
In Development
Interested in working together?
Let's build something meaningful. I'm always excited to discuss new projects and collaborate with talented people.