Accompanying code for my blog post "Solving Grade 8 Music Theory question with deep learning — Completing a melody with Tensorflow".
Listen to samples generated by the model here https://soundcloud.com/quan-lim-2/sets/simple-lstm
- Tensorflow 1.15.0
- pretty_midi
- beautifulsoup4
- tqdm
$ git clone git@github.com:daQuincy/Simple-Music-char-rnn.git
$ cd Simple-Music-char-rnn
$ docker build -f Dockerfile --tag music:1.0 .
Once image is done building, start a container and mount the cloned folder.
docker run -it --gpus all --ipc=host --device /dev/nvidia0 --device /dev/nvidia-uvm --device /dev/nvidia-uvm-tools --device /dev/nvidiactl -v ${PWD}:/home/ubuntu/music music:1.0 bash
Ignore --gpus
, --ipc
and --device
tags if running on CPU.
$ python scrape.py
$ python data.py
Training configurations can be edited at config.py
$ python train.py
Example:
$ python inference.py \
--prime_midi prime_midi.mid # input midi file
--output_file output.mid # output midi file
--checkpoint experiments/experiment_1/yamaha # training checkpoint
--temperature 0.8 [OPTIONAL] # model temperature
--length 120 [OPTIONAL] # number of notes of generated music