Giter VIP home page Giter VIP logo

ismir2019-music-style-translation's Introduction

Supervised symbolic music style translation

This is the code for the ISMIR 2019 paper ‘Supervised symbolic music style translation using synthetic data’. If you use the code in your research, please cite the paper as:

Ondřej Cífka, Umut Şimşekli, Gaël Richard. “Supervised Symbolic Music Style Translation Using Synthetic Data”, 20th International Society for Music Information Retrieval Conference, Delft, The Netherlands, 2019. doi:10.5281/zenodo.3527878.

Check out the 📻 example outputs and the accompanying 📝 blog post, which summarizes the paper. You might also be interested in our more recent paper [🧑‍💻 code, 🌎 website] on one-shot accompaniment style transfer.

The repository contains the following directories:

  • code – code for training and evaluating models
  • experiments – configuration files for the models from the paper
  • data – data preparation recipes

You can either download the trained models, or train your own by following the steps below. If you encounter any problems, please feel free to open an issue.

Installation

Clone the repository and make sure you have Python 3.6 or later. Then run the following commands.

  1. (optional) To make sure you have the right versions of the most important packages, run:

    pip install -r requirements.txt

    Alternatively, if you use conda, you can create your environment using

    conda env create -f environment.yml

    This will also install the correct versions of the CUDA and CuDNN libraries.

    If you wish to use different (more recent) package versions, you may skip this step; the code should still work.

  2. Install the package with:

    pip install './code[gpu]'

    Or for the non-GPU version (only if you skipped step 1):

    pip install './code[nogpu]'

Data

See the data README for how to prepare the data.

Training a model

The scripts for training the models are in the ismir2019_cifka.models package.

The experiments directory has a subdirectory for each model from the paper. The model.yaml file in each directory contains all the hyperparameters and other settings required to train and use the model; the first line also tells you what type of model it is (i.e. seq2seq_style or roll2seq_style). For example, to train the all2bass model, run the following command inside the experiments directory:

python -m ismir2019_cifka.models.roll2seq_style --logdir all2bass train

You may need to adjust the paths in model.yaml to point to your dataset.

Running a model

Before running a trained model on some MIDI files, we need to use the chop_midi script to chop them up into segments and save them in the expected format (see the data README for more information), e.g.:

python -m ismir2019_cifka.data.chop_midi \
    --no-drums \
    --force-tempo 60 \
    --bars-per-segment 8 \
    --include-segment-id \
    song1.mid song2.mid songs.pickle

Then we can run the model, providing the input file, the output file and the target style. For example:

python -m ismir2019_cifka.models.roll2seq_style --logdir all2bass run songs.pickle output.pickle ZZREGGAE

To listen to the outputs, we need to convert them back to MIDI files, which involves time-stretching the music from 60 BPM to the desired tempo, assigning an instrument, and concatenating the segments of each song:

python -m ismir2019_cifka.data.notes2midi \
   --instrument 'Fretless Bass' \
   --stretch 60:115 \
   --group-by-name \
   --time-unit 4 \
   output.pickle outputs

Evaluation

To reproduce the results on the Bodhidharma dataset, first download the trained models and prepare the dataset, then change to the experiments directory and run ./evaluate_bodhidharma.sh. Note that this will run each model many times on the entire dataset (once for each target style), so you might want to start with only a subset of the models or styles or run a number of them in parallel. The results will be stored in the results subdirectory; use the evaluation.ipynb Jupyter notebook to load and plot them.

To compute the metrics on your own data, use python -m ismir2019_cifka.evaluate directly. To better understand all the arguments, see how they are used in evaluate_bodhidharma.sh. The tricky ones are:

  • --data-prefix: where to look for the model outputs inside the model directory; for example, if you pass --data-prefix outputs/test_, then the outputs of model model1 in style A will be taken from model1/outputs/test_A.pickle
  • --style-profile-dir: a directory containing JSON files with reference style profiles; you can generate these using python -m ismir2019_cifka.eval.style_profile

Alternatively, you can import the evaluation metrics from the ismir2019_cifka.eval package and use them from your own code.

Acknowledgment

This work has received funding from the European Union’s Horizon 2020 research and innovation programme under the Marie Skłodowska-Curie grant agreement No. 765068.

Copyright notice

Copyright 2019 Ondřej Cífka of Télécom Paris, Institut Polytechnique de Paris.
All rights reserved.

ismir2019-music-style-translation's People

Contributors

cifkao avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

ismir2019-music-style-translation's Issues

IndexError: list index out of range

Hi, I get a 'IndexError: list index out of range' error when I try to train the model by running the following command inside the 'experiments' directory.
python -m ismir2019_cifka.models.roll2seq_style --logdir all2bass train

屏幕快照 2019-08-26 22 31 07

I used 60 of the songs in 2 different styles as training set. Obviously too few but I'm just trying to get this training process going. The data is prepared following the 'README' steps.
Maybe you could give me a hand?

Resources

Hello,

Could you please say on which resources did you train your model?

I'm running roll2seq all2bass model and even for batch size 1 have runtime error on one V100.

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.