Code Monkey home page Code Monkey logo

symphonynet's Introduction

SymphonyNet

SymponyNet is an open-source project aiming to generate complex multi-track and multi-instrument music like symphony.

Introduction

Our method is fully compatible with other types of music like pop, piano, solo music, etc.

Schema

Have fun with SymphonyNet!

Installation Guide

We highly recommend users to run this project under conda environment. Conda will setup an isolated environment where you can install libraries that will not effect the overall system.

Prepare the Environment

After you install miniconda (or the larger anaconda), create an environment:

conda create -n sym_net python=3.7
conda activate sym_net

Checkout the Code

git clone ...SymphonyNet.git
cd SymphonyNet

Install Dependencies

When you install the python libraries, there are a number of C++ libraries and build dependencies your system will need installed. You can run the following to try to get all the needed bits installed (these commands require things like homebrew which you should hopefully already have installed):

make setup_osx

or

make setup_linux

If you want to try to install the dependencies yourself, or you likely already have them, you can try to just install the python libraries:

pip install -r requirements.txt

Note: The reason for using this convoluted process is we found the pytorch-fast-transformers package needs to be built using an installed version of torch, but directly install with pip requirements will not fully install torch before fast transformers needs the library. This will cause pytorch-fast-transformers to fail because torch is installed by pip - round and round.

Building pytorch-fast-transformers takes a while.


Once everything installs correctly, you can run make test_run, and you should get an output file of output.mid in the project root directory. By default that is using the CPU not GPUs.

Training pipeline

Step 1

Put your midi files into data/midis/

Step 2

Run python3 src/preprocess/preprocess_midi.py under project root path.


Note: The preprocess_midi.py multi-process all the Midis and convert them into a raw_corpus.txt file. In this file, each line of encoded text represents a full song.


Step 3 (Optional)

  • Run python3 src/preprocess/get_bpe_data.py if you want to train the model with Music BPE. More details about fast BPE implementation could be found here Music BPE.
  • Set BPE=1 in config.sh file

Note: We only provide music_bpe_exec file for linux system usage, if you are using MacOS or Windows, please re-compile the music_bpe_exec file here by following the instruction.


Step 4

Run python3 src/fairseq/make_data.py to convert the raw_corpus.txt into binary file for fairseq and create four vocabularies mentioned in the paper.

Step 5

Run sh train_linear_chord.sh to train your own model.

Generation pipeline

  • Put your checkpoint file into ckpt/. You can download our pretrained model here
  • Run python3 src/fairseq/gen_batch.py test.mid 5 0 1 to generate one symphony MIDI conditioned on the first 5 measures of test.mid, with no constraints of chord progression.
  • Or replace test.mid with your own prime MIDI and set how many measures of chords from the prime MIDI you may want to keep.
  • We provide a Google Colab file play_symphonynet.ipynb, where you could follow the generation guide.

License

SymphonyNet is released under the MIT license

symphonynet's People

Contributors

robrohan avatar symphonynet-anonymous 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.