How devanshrai23/iml-music-genre-mood works
This repository is an explainable music genre and mood classification product, exposed as a web demo backed by Python inference services. The primary workflow is audio upload → clip preprocessing and feature/spectrogram generation → genre-model predictions and explanations → interactive playback and attention visualization. A separate mood workflow predicts calibrated mood from Spotify-style descriptors. Training, benchmark reporting, and cross-paradigm explanation are additional product capabilities described in the README; their internal wiring is not fully shown in the sampled source.
Main entry points: App.tsx Web app router · predict.py Genre predictor · AnalysisPlayer.tsx Analysis player · api.ts API client
Components 24
Web experience
- Web app router
web/src/App.tsx - Genre lab
web/src/pages/Lab.tsx - Explanation view
web/src/pages/Explain.tsx - Results explorer
web/src/pages/Results.tsx - Mood explorer
web/src/pages/Mood.tsx - Analysis player
web/src/components/AnalysisPlayer.tsx - Audio playback
web/src/components/useAudio.ts - Attention spectrogram
web/src/components/SpectrogramView.tsx - Genre display helpers
web/src/genres.ts - API client
web/src/api.ts
Inference service
- FastAPI service
api/main.py
Genre analysis
- Genre predictor
musicml/predict.py - Audio preprocessing
musicml/audio.py - Genre networks
musicml/models.py - Model configuration
musicml/config.py
Mood analysis
- Mood predictor
musicml/predict.py - Mood model training
src/mood_final.py
Model development
- Handcrafted features
src/extract_features.py - Mel spectrograms
src/make_spectrograms.py - Attention-CNN training
src/train_cnn.py - Attention-CRNN training
src/train_crnn.py - TreeSHAP analysis
src/explain_shap.py - Explanation comparison
src/compare_explanations.py
Other components
- Listener
Connections 27
- Listener → Web app router: uses
web/src/App.tsx - Web app router → Genre lab: routes to
web/src/App.tsx - Web app router → Explanation view: routes to
web/src/App.tsx - Web app router → Results explorer: routes to
web/src/App.tsx - Web app router → Mood explorer: routes to
web/src/App.tsx - Genre lab → API client: requests analysis
- API client → FastAPI service: calls endpoints
- Mood explorer → API client: requests mood
web/src/pages/Mood.tsx - Results explorer → API client: loads metrics
web/src/pages/Results.tsx - FastAPI service → Genre predictor: invokes analysis
api/main.py - FastAPI service → Mood predictor: invokes prediction
api/main.py - Genre predictor → Audio preprocessing: preprocesses audio
musicml/predict.py - Genre predictor → Genre networks: loads networks
musicml/predict.py - Audio preprocessing → Model configuration: uses parameters
musicml/audio.py - Genre predictor → Model configuration: uses labels
musicml/predict.py - Genre lab → Analysis player: presents analysis
- Analysis player → Audio playback: controls playback
web/src/components/AnalysisPlayer.tsx - Analysis player → Attention spectrogram: renders overlay
web/src/components/AnalysisPlayer.tsx - Analysis player → Genre display helpers: formats predictions
web/src/components/AnalysisPlayer.tsx - Mood explorer → Mood predictor: sends descriptors
- Handcrafted features → Genre predictor: provides descriptors
- Mel spectrograms → Attention-CNN training: provides spectrograms
- Mel spectrograms → Attention-CRNN training: provides spectrograms
- Mood model training → Mood predictor: produces model
- Handcrafted features → TreeSHAP analysis: explains features
- Attention-CRNN training → Explanation comparison: provides attention model
- TreeSHAP analysis → Explanation comparison: compares attributions
README.md