This project is an implementation of Music Transformer(https://arxiv.org/abs/1809.04281) using GPT-2.
The GPT-2 source code was used from the link below.
https://github.com/openai/gpt-2
The difference with the GPT-2 source is that this used only decoder and relative position embedding.
- pip3 install tensorflow Note: This is on version 2
- pip3 install numpy==1.19.5 Note: There is a bug with the later version, switch to latest when this is resolved.
- pip3 install librosa
- pip3 install tensorboardX
- pip3 install tqdm
- pip3 install python3-midi https://github.com/louisabraham/python3-midi
- Jupyter notebooks also needs to be installed.
-
Download and extract Maestro dataset V.3.0.0 from the following link https://magenta.tensorflow.org/datasets/maestro
-
jupyter notebook preprocessing.ipynb to launch the notebook
By default, the notebook assumes the dataset is stored in the local directory. Modify maestro_dir into your own maestro dataset path in the file. The files will be processed and written to ./dataset
-
Modify the data_dirs and load_dir, save_dir.
data_dirs: the directories to load preprocessed data files
load_dir: the directory to load a model
save_dir: the directory to save a model -
jupyter notebook Music-GPT-2.ipynb to launch the notebook you can increase the batch size by changing batch_size variable.
Run 'Output MIDI file' cell in Music-GPT-2.ipynb to make a new MIDI file. You should input load_dir, and variable N means the sequence length of what you want to make. It should be greater than the hyper-parameter n_time.
Three samples created by Music-GPT-2
https://soundcloud.com/hutenheum/sets/three-musical-moments-by-gpt-2
