All Projects → mlachmish → Musicgenreclassification

mlachmish / Musicgenreclassification

Licence: mit
Classify music genre from a 10 second sound stream using a Neural Network.

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Musicgenreclassification

Surface Defect Detection
🐎📈 Constantly summarizing open source dataset and important critical papers in the field of surface defect research which are very important. 🐋
Stars: ✭ 287 (-23.87%)
Mutual labels:  paper
Cyclegan
Tensorflow implementation of CycleGAN
Stars: ✭ 348 (-7.69%)
Mutual labels:  paper
Healthcare ml
A curated list of ML|NLP resources for healthcare.
Stars: ✭ 351 (-6.9%)
Mutual labels:  paper
Sgx Papers
A list of system papers using/about Intel SGX
Stars: ✭ 306 (-18.83%)
Mutual labels:  paper
Languagedetector
PHP Class to detect languages from any free text
Stars: ✭ 317 (-15.92%)
Mutual labels:  paper
Bestofml
The best resources around Machine Learning
Stars: ✭ 349 (-7.43%)
Mutual labels:  paper
Speech Separation Paper Tutorial
A must-read paper for speech separation based on neural networks
Stars: ✭ 288 (-23.61%)
Mutual labels:  paper
Optnet
OptNet: Differentiable Optimization as a Layer in Neural Networks
Stars: ✭ 361 (-4.24%)
Mutual labels:  paper
Akarin
Akarin is a powerful (not yet) server software from the 'new dimension'
Stars: ✭ 332 (-11.94%)
Mutual labels:  paper
Tg Reading List
A text generation reading list maintained by Tsinghua Natural Language Processing Group.
Stars: ✭ 352 (-6.63%)
Mutual labels:  paper
Vime
Code for the paper "Curiosity-driven Exploration in Deep Reinforcement Learning via Bayesian Neural Networks"
Stars: ✭ 310 (-17.77%)
Mutual labels:  paper
Paper
High performance Spigot fork that aims to fix gameplay and mechanics inconsistencies
Stars: ✭ 5,293 (+1303.98%)
Mutual labels:  paper
Action Recognition Visual Attention
Action recognition using soft attention based deep recurrent neural networks
Stars: ✭ 350 (-7.16%)
Mutual labels:  paper
Tucl
The first-ever paper on the Unix shell written by Ken Thompson in 1976 scanned, transcribed, and redistributed with permission
Stars: ✭ 303 (-19.63%)
Mutual labels:  paper
Benchmark results
Visual Tracking Paper List
Stars: ✭ 3,672 (+874.01%)
Mutual labels:  paper
Purpur
Purpur is a fork of Paper, Tuinity, and Airplane with the goal of providing new and interesting configuration options, which allow for creating a unique gameplay experience not seen anywhere else
Stars: ✭ 286 (-24.14%)
Mutual labels:  paper
Weightnorm
Example code for Weight Normalization, from "Weight Normalization: A Simple Reparameterization to Accelerate Training of Deep Neural Networks"
Stars: ✭ 347 (-7.96%)
Mutual labels:  paper
Slimefun4
Slimefun 4 - A unique Spigot/Paper plugin that looks and feels like a modpack. We've been giving you backpacks, jetpacks, reactors and much more since 2013.
Stars: ✭ 369 (-2.12%)
Mutual labels:  paper
Vsepp
PyTorch Code for the paper "VSE++: Improving Visual-Semantic Embeddings with Hard Negatives"
Stars: ✭ 354 (-6.1%)
Mutual labels:  paper
Inception V4
Inception-v4, Inception - Resnet-v1 and v2 Architectures in Keras
Stars: ✭ 350 (-7.16%)
Mutual labels:  paper

MusicGenreClassification

MusicGenreClassification

Academic research in the field of Deep Learning (Deep Neural Networks) and Sound Processing, Tel Aviv University.

Featured in Medium.

Abstract

This paper discuss the task of classifying the music genre of a sound sample.

Introduction

When I decided to work on the field of sound processing I thought that genre classification is a parallel problem to the image classification. To my surprise I did not found too many works in deep learning that tackled this exact problem. One paper that did tackle this classification problem is Tao Feng’s paper [1] from the university of Illinois. I did learned a lot from this paper, but honestly, they results the paper presented were not impressive.

So I had to look on other, related but not exact papers. A very influential paper was Deep content-based music recommendation [2] This paper is about content-base music recommendation using deep learning techniques. The way they got the dataset, and the preprocessing they had done to the sound had really enlightened my implementation. Also, this paper was mentioned lately on “Spotify” blog [3]. Spotify recruited a deep learning intern that based on the above work implemented a music recommendation engine. His simple yet very efficient network made me think that Tao’s RBM was not the best approach and there for my implementation included a CNN instead like in the Spotify blog. One very important note is that Tao’s work published result only for 2,3 and 4 classes classification. Obviously he got really good result for 2 classes classification, but the more classes he tried to classify the poorer the result he got. My work classify the whole 10 classes challenge, a much more difficult task. A sub task for this project was to learn a new SDK for deep learning, I have been waiting for an opportunity to learn Google’s new TensorFlow[4]. This project is implemented in Python and the Machine Learning part is using TensorFlow.

The Dataset

Getting the dataset might be the most time consuming part of this work. Working with music is a big pain, every file is usually a couple of MBs, there are variety of qualities and parameters of recording (Number of frequencies, Bits per second, etc…). But the biggest pain is copyrighting, there are no legit famous songs dataset as they would cost money. Tao’s paper based on a dataset called GTZAN[5]. This dataset is quit small (100 songs per genre X 10 genres = overall 1,000 songs), and the copyright permission is questionable. This is from my perspective one of the reasons that held him from getting better results. So, I looked up for generating more data to learn from. Eventually I found MSD[6] dataset (Million Song Dataset). It is a freely-available collection of audio features and metadata for a million contemporary popular music tracks. Around 280 GB of pure metadata. There is a project on top of MSD called tagtraum[7] which classify MSD songs into genres. The problem now was to get the sound itself, here is where I got a little creative. I found that one of the tags every song have in the dataset is an id from a provider called 7Digital[8]. 7Digital is a SaaS provider for music application, it basically let you stream music for money. I signed up to 7Digital as a developer and after their approval i could access their API. Still any song stream costs money, But I found out that they are enabling to preview random 30 seconds of a song to the user before paying for them. This is more than enough for my deep learning task, So I wrote “previewDownloader.py” that downloads for every song in the MSD dataset a 30 sec preview. Unfortunately I had only my laptop for this mission, so I had to settle with only 1% of the dataset (around 2.8GB).

The genres I am classifying are:

  1. blues
  2. classical
  3. country
  4. disco
  5. hiphop
  6. jazz
  7. metal
  8. pop
  9. reggae
    10.rock

Music genre popularity

Preprocessing the data

Having a big data set isn't enough, in oppose to image tasks I cannot work straight on the raw sound sample, a quick calculation: 30 seconds × 22050 sample/sec- ond = 661500 length of vector, which would be heavy load for a convention machine learning method.

Following all the papers I read and researching a little on acoustic analysis, It is quit obvious that the industry is using Mel-frequency cepstral coefficients (MFCC) as the feature vector for the sound sample, I used librosa[9] implementation.

MFCCs are derived as follows:

  1. Take the Fourier transform of (a windowed excerpt of) a signal.
  2. Map the powers of the spectrum obtained above onto the mel scale, using triangular overlapping windows.
  3. Take the logs of the powers at each of the mel frequencies.
  4. Take the discrete cosine transform of the list of mel log powers, as if it were a signal.
  5. The MFCCs are the amplitudes of the resulting spectrum.

I had tried several window size and stride values, the best result I got was for size of 100ms and a stride of 40ms.

One more point was that Tao’s paper used MFCC features (step 5) while Sander used strait mel-frequencies (step 2).

MEL ppower over time

I tried both approaches and found out that I got extremely better results using just the mel-frequencies, but the trade-off was the training time of-course. Before continue to building a network I wanted to visualise the preprocessed data set, I implemented this through the t-SNE[10] algorithm.Below you can see the t-SNE graph for MFCC (step 5) and Mel-Frequencies (step 2):

t-SNE MFCC samples as genres

t-SNE mel-spectogram samples as genres

The Graph

After seeing the results Tao and Sander reached I decided to go with a convolu- tional neural network implementation. The network receive a 599 vector of mea-frequen- cy beans, each containing 128 frequencies which describe their window. The network consist with 3 hidden layers and between them I am doing a max pooling. Finally a fully connected layer and than softmax to end up with a 10 dimensional vector for our ten genre classes

Nural Network

I did implement another network for MFCC feature instead of mel-frequencies, the only differences are in the sizes (13 frequencies per window instead of 128).

Visualisation of various filters (from Sander’s paper):

Filters visualization

• Filter 14 seems to pick up vibrato singing. • Filter 242 picks up some kind of ringing ambience. • Filter 250 picks up vocal thirds, i.e. multiple singers singing the same thing, but the notes are a major third (4 semitones) apart. • Filter 253 picks up various types of bass drum sounds.

Results

As I explained in the introduction, the papers I based my work on did not solve the exact problem I did, for example Tao’s paper published results for classifying 2,3 and 4 classes (Genres).

Tao Feng's results

I did looked for benchmarks outside the deep learning field and I found a paper titled “A BENCHMARK DATASET FOR AUDIO CLASSIFICATION AND CLUSTERING” [11]. This paper benchmark a very similar task to mine, the genres it classifies: Blues, Electronic, Jazz, Pop, HipHop, Rock, Folk, Alternative, Funk.

Benchmark results

My results:

My results

Code

Documentation

• previewDownloader.py: USAGE: python previewDownloader.py [path to MSD data] This script iterate over all ‘.h5’ in a directory and download a 30 seconds sample from 7digital.

• preproccess.py: USAGE: python preproccess.py [path to MSD mp3 data] This script pre-processing the sound files. Calculating MFCC for a sliding window and saving the result in a ‘.pp’ file.

• formatInput.py: USAGE: python formatInput.py [path to MSD pp data] The script iterates over all ‘.pp’ files and generates ‘data’ and ‘labels’ that will be used as an input to the NN. Moreover, the script output a t-SNE graph at the end.

• train.py: USAGE: python train.py This script builds the neural network and feeds it with ‘data’ and ‘labels’. When it is done it will save ‘model.final’.

Complete Installation

  • Download the dataset files from https://www.dropbox.com/s/8ohx6m23co1qaz3/DataSet.zip?dl=0.
  • Unzip file
  • Place dataset files in the structure they are ordered in

References

[1] Tao Feng, Deep learning for music genre classification, University of Illinois. https://courses.engr.illinois.edu/ece544na/fa2014/Tao_Feng.pdf [2]Aar̈onvandenOord,SanderDieleman,BenjaminSchrauwen,Deepcontent- based music recommendation. http://papers.nips.cc/paper/5004-deep-content-based- music-recommendation.pdf [3] SANDER DIELEMAN, RECOMMENDING MUSIC ON SPOTIFY WITH DEEP LEARNING, AUGUST 05, 2014. http://benanne.github.io/2014/08/05/spotify-cnns.html [4] https://www.tensorflow.org [5] GTZAN Genre Collection. http://marsyasweb.appspot.com/download/ data_sets/ [6] Thierry Bertin-Mahieux, Daniel P.W. Ellis, Brian Whitman, and Paul Lamere. The Million Song Dataset. In Proceedings of the 12th International Society for Music Information Retrieval Conference (ISMIR 2011), 2011. http:// labrosa.ee.columbia.edu/millionsong/ [7] Hendrik Schreiber. Improving genre annotations for the million song dataset. In Proceedings of the 16th International Conference on Music Information Retrieval (IS- MIR), pages 241-247, 2015. http://www.tagtraum.com/msd_genre_datasets.html [8] https://www.7digital.com [9] https://github.com/bmcfee/librosa [10] http://scikit-learn.org/stable/modules/generated/sklearn.manifold.TSNE.html [11] Helge Homburg, Ingo Mierswa, Bu l̈ent Mo l̈ler, Katharina Morik and Michael Wurst, A BENCHMARK DATASET FOR AUDIO CLASSIFICATION AND CLUSTERING, University of Dortmund, AI Unit. http://sfb876.tu-dortmund.de/PublicPublicationFiles/ homburg_etal_2005a.pdf

Author

Matan Lachmish a.k.a The Big Fat Ninja The Big Fat Ninja
https://thebigfatninja.xyz

attribution

Icon made by Freepik from www.flaticon.com

License

MusicGenreClassification is available under the MIT license. See the LICENSE file for more info.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].