How sivapprakash-chinnaraj/mgc works
Project type and purpose
• This is a machine-learning pipeline plus lightweight web UI. It ingests audio files, converts them into mel spectrograms, trains a CNN model, and exposes inference via a Streamlit app.
File structure
• Top level:
• app.py – Streamlit front-end for model inference
• notebooks/ – exploratory notebooks and saved model artifacts
• requirements.txt – dependencies
• src/
• preprocessing.py – audio → mel spectrogram conversion
• (implicitly) model.py – CNN training and evaluation (referenced in README)
• Generated artifacts during runtime:
• notebooks/genre_classifier_model.h5 and model.h5 – trained model binaries
• spectrograms/ folder (not shown but described) – image dataset
Extract key architecture insights from README
• Two distinct pipelines:
a. Data preparation: audio files → spectrogram generation → image dataset
b. Model lifecycle: training (model.py) → saved model → inference (app.py)
• Technologies: Python, Librosa (audio processing), TensorFlow (CNN), Streamlit (UI)
Main components
a. Data layer
• Raw audio files (DATA STORE)
• Spectrogram artifact store (FILE SYSTEM or object storage)
b. Processing layer
• Preprocessing module (preprocessing.py)
• Model training module (model.py)
c. Model artifact
• Trained CNN model (model.h5)
d. Serving layer
• Streamlit app (app.py)
• User interface (browser)
e. External services/libraries
• Librosa, NumPy, TensorFlow, Pillow, Matplotlib, Scikit-learn
Relationships and interactions (data flow)
1. Raw audio → preprocessing.py → mel spectrogram PNGs
2. Spectrograms → model.py → train CNN → output model.h5
3. User uploads .wav in Streamlit UI → app.py
4. app.py calls preprocessing logic (in-memory) → converts to spectrogram → loads model.h5 → predicts genre → displays result
Architectural patterns and principles
• Layered pipeline: clear separation of preprocessing, training, serving
• Artifact versioning: model binaries stored alongside code
• Single codebase monolith: uses modules rather than microservices
• Reusability: preprocessing module shared by training and inference