Music Genre Classification using a Convolutional Neural Network (CNN).
- Dataset: Place the dataset in the following structure:
dataset/ ├── data/ │ └── genres_original/ - Metadata: The file
project_data/tracks.csvcontains the list of all tracks in the dataset and their names. - Spectrograms: Spectrograms will be generated and stored in the
project_data/spectrograms/folder.
Poetry is used for dependency management. Install it using the following command:
pip install poetryRun the following command to install all dependencies:
poetry installSelect the created virtual environment in your IDE or activate it using:
poetry shellTo add a new dependency to the project, use the following command:
poetry add <package-name>For example, to add numpy:
poetry add numpySpectrogram extraction is done using the audio_to_spectrogram_v2.ipynb notebook. The notebook contains the code to extract spectrograms from the audio files in the dataset.
The spectrograms will be saved in the project_data/spectrograms/ folder.
Use the utility function from utils.py to load individual spectrograms. Pass the path to the spectrograms folder and the track name as arguments.
- Ensure the dataset is correctly placed in the
dataset/folder before running any scripts. - For more details on the dataset, refer to the
fma_metadatadocumentation.