Coder Social home page Coder Social logo

yufriza / musicgenrecnn Goto Github PK

View Code? Open in Web Editor NEW

This project forked from thomas-bouvier/music-genre-recognition

0.0 0.0 0.0 7.41 MB

Musical genre recognition using a CNN

License: Do What The F*ck You Want To Public License

Python 100.00%

musicgenrecnn's Introduction

music-genre-recognition

Introduction

Music genre recognition algorithm using a convolutional neural network (CNN).

The algorithm split up the input songs into 3s slices. The melspectrogram of every slice is then computed, giving us input images for the CNN. 1D convolutions are used.

Accuracy is around 80% at the moment.

Dataset

Download the GTZAN dataset here and extract it in a musics folder.

You can also get already formatted data for the CNN and the trained model here, and simply extract the files.

Requirements

The following modules can be installed via pip or using an IDE like PyCharm:

How to run

Train

To train the model you can run the following command:

python main.py -m train

This will load the audio files, format it and train the model.

Note that it can take a long time, especially with Tensorflow CPU and it will require some RAM.

You can also add the following parameters to the command:

  • --no-save-data Once the data is loaded and formatted, it is saved as a .npy file so that you don't need to do that part again. With this flag, the data won't be saved.
  • --no-save-model The trained model is saved in a .h5 file. With this flag, the model is not saved.
  • --load-data If you already have .npy files with the formatted data, this flag will load them instead of loading data from audio files. Data won't be saved again afterwards.
  • --debug Enable debug mode (shows more information).

Test

You will need a trained model to test.

Once you have your model and your audio file, put them in the root folder.

To test the model against your own audio file, run the following command:

python main.py -m test -song your_song.mp3

This will load the file, process it and run it through the model. If you want to make this test for multiple song, put them all in a folder and run:

python main.py -m test -folder your_folder

All the files within the folder must be audio files, and this folder must be in the root folder.

You can add the following parameter:

  • --debug Enable debug mode (shows more information).

Results

Accuracy of the model is 82%, however it works best with old songs (before 2000) since the dataset used to train it was created around this time. Since music has evolved, it will make more mistakes on modern songs.

musicgenrecnn's People

Contributors

henkan avatar thomas-bouvier avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.