AI-Powered Music Genre Classification & Interactive Visualization
Mujica is an interactive web application that visualizes music clustering based on AI-powered genre classification. Upload MP3 files or YouTube URLs to see songs positioned in a beautiful decagon visualization based on their genre probabilities.
Songs are positioned inside a 10-sided polygon (decagon) where each vertex represents one of 10 music genres. The position of each song is determined by weighted genre probabilities from a trained BiLSTM neural network with attention mechanism.
- BiLSTM with Attention - Deep learning model with 90%+ accuracy
- Multi-Segment Analysis - Analyzes 10 segments across the entire song for better accuracy
- 58 Audio Features - MFCCs, spectral features, tempo, harmony, and more
- 10 Genres - Blues, Classical, Country, Disco, Hip-Hop, Jazz, Metal, Pop, Reggae, Rock
- D3.js Decagon - Beautiful 10-sided polygon visualization
- Real-Time Updates - Songs appear instantly after processing
- Interactive Exploration - Hover, click, zoom, and pan
- Genre Color Coding - Each genre has its unique color
- MP3 File Upload - Drag & drop interface with validation (up to 50MB)
- YouTube Integration - Paste any YouTube URL to analyze songs
- Primary Genre - Top prediction with confidence percentage
- Probability Breakdown - All 10 genre probabilities with bar charts
- Song Metadata - Duration, upload date, source information
- Easy Management - Delete songs, view history
Songs are positioned using a weighted calculation:
- Each genre probability contributes to the X and Y coordinates
- Higher probability = closer to that genre's vertex
- Mixed genres appear in intermediate positions
- Node size reflects confidence level
POST /api/upload/mp3- Upload MP3 filePOST /api/upload/youtube- Process YouTube URL
GET /api/songs- List songs (paginated, filterable)GET /api/songs/{id}- Get song detailsDELETE /api/songs/{id}- Delete song
GET /api/cluster-data- Get all data for visualizationGET /api/health- Health check
π Full API documentation: http://localhost:8000/docs
Input (58 features)
β
Batch Normalization
β
LSTM Layer 1 (256 units) + Attention
β
LSTM Layer 2 (128 units) + Attention
β
LSTM Layer 3 (64 units)
β
Dense Layer (128 units)
β
Dense Layer (64 units)
β
Output (10 genres)
Training Details:
- Dataset: GTZAN Music Genre
- Samples: ~10,000 audio clips
- Accuracy: 90%+ on test set
- Framework: PyTorch
For improved accuracy, each song is analyzed using:
- 10 evenly-spaced segments across the full song duration
- 3 seconds per segment (standard training length)
- Averaged probabilities from all segments
- Fallback to single segment for clips < 3 seconds
This captures the full structure of the song rather than just a single clip!
cd c:/Users/muzam/mujica/soundscape/backend# Create venv
python -m venv venv
# Activate (Windows)
venv\Scripts\activate
# Activate (Linux/Mac)
source venv/bin/activatepip install -r requirements.txtNote: This may take 10-15 minutes as it installs PyTorch and other large packages.
FFmpeg is required to convert YouTube audio to MP3 format.
Windows:
# Option 1: Using Chocolatey (recommended)
choco install ffmpeg
# Option 2: Manual Installation
# 1. Download from: https://www.gyan.dev/ffmpeg/builds/
# 2. Extract to C:\ffmpeg
# 3. Add C:\ffmpeg\bin to your System PATH
# 4. Restart terminal/IDEMac:
brew install ffmpegLinux (Ubuntu/Debian):
sudo apt update
sudo apt install ffmpegLinux (Fedora/RHEL):
sudo dnf install ffmpegVerify Installation:
ffmpeg -versionYou should see version information. If not, restart your terminal and try again.
Check that the model file exists:
# Should see: pytorch_genre_classifier_best.pkl
dir ml_models\If missing, copy from your training directory:
copy ..\..\..\models\classification_model\pytorch_genre_classifier_best.pkl ml_models\# Start the server
uvicorn app.main:app --reload --host 0.0.0.0 --port 8000You should see:
π Starting SoundScape Backend...
π Creating database tables...
π€ Loading ML model...
β Model loaded successfully on cpu
Test Accuracy: XX.XX%
β Backend ready!
INFO: Uvicorn running on http://0.0.0.0:8000
Test it: Open http://localhost:8000/docs in your browser to see the API documentation.
Press Ctrl+C to stop the server when done testing.
# Open a NEW terminal (keep backend running in the first one)
cd c:/Users/muzam/mujica/soundscape/frontendnpm installNote: This may take 5-10 minutes.
Check that .env file exists with:
VITE_API_URL=http://localhost:8000/api
npm run dev