Coder Social home page Coder Social logo

drumclassification's Introduction

Drum classification

A PyTorch drum classification model trained on Magenta's Expanded Groove MIDI Dataset.

Final project for Computational Data Analysis (CSE-6740).

Training

Download data

Download and extract the full E-GMD dataset zip into the dataset/ directory at the repository root.

This zip includes all MIDI, audio, and metadata. Your directory structure should look like this:

DrumClassification/
    dataset/
        e-gmd-v1.0.0/
            drummer1/
            drummer2/
            ...
            e-gmd-v1.0.0.csv
    ...

Prepare data for training

This step is already done, resulting in the CSV files at the root of the dataset/ directory. However, if you would like to change any aspect of the data preprocessing, such as including a different set of drum kit types, the full data preprocessing pipeline can be run as follows:

See the scripts for explanations of their roles in data preparation.

$ pip install pandas mido torchaudio  # Install packages needed for preprocessing.
$ python create_slim_metadata.py  # Outputs `dataset/e-gmd-v1.0.0-slim.csv`
$ python create_label_mapping  # Outputs `dataset/note_occurrences_slim.csv` and `label_mapping.csv`
$ python chop_dataset.py  # Outputs `dataset/chopped_raw.csv`
$ python clean_chopped_raw.py  # Outputs `dataset/chopped.csv`

Explore the dataset

The explore_dataset.ipynb notebook provides a variety of data exploration tools, such as:

  • visualizing relevant data distrubutions
  • previewing the "chopped" drum hit clips
  • listening to random supercuts of clips for all training labels

Train

$ pip install torch torchaudio pandas numpy matplotlib tqdm
$ pip install SoundFile  # torchaudio needs a backend to load wav files.
$ python train.py

Run pretrained model

A pretrained classification model is provided at pretrained/final.zip. To evaluate this model over the test set, unzip it to pretrained/final.pth and run:

$ pip install pandas seaborn torch torchaudio SoundFile
$ python inference.py

This assumes you have already downloaded the dataset as explained above.

drumclassification's People

Contributors

khiner avatar

Watchers

 avatar  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.