This library enables training decoder-only transformer models to generate music in ABC notation. It also includes scripts for running inference and a simple web application interface.
ABCTransformer is designed to facilitate the training of transformer-based models for music generation. It supports music composition in ABC notation, providing tools for model training, inference, and a web-based interface for interaction.
- Training transformer models for music generation in ABC notation
- Running inference to generate music samples in ABC as well as synthesized WAV files
- Web application interface developed with Gradio allows for easy interaction with the model
Here are some examples of music generated by the model trained on The Nottingham Music Database:
2.mp4
3.mp4
sample.mp4
6.mp4
10.mp4
5.mp4
-
Install Python 3.10 Ensure you have Python 3.10 installed. You can use
pyenvfor managing Python versions.pyenv install 3.10.0 pyenv local 3.10.0 -
Install Fluidsynth Fluidsynth is required for audio synthesis.
sudo apt install fluidsynth -
Install Requirements Install the necessary Python packages.
pip install -r requirements.txt
If you want to use as custom dataset in ABC format you need to preprocess it using preprocess_datasets.py script.
Model, Tokenizer and Trainer config files are located inside the config directory
To train the model, run:
python train.py
Run logs and checkpoints are saved inside the runs directory
If you want to experiment with different decoding strategies and parameters you must modify this line:
strategy = TopKSampling(temperature=1.0, k=8)
inside the generate.py script. Currently implemented strategies are: TopKSampling, GreedySearch and AncestralSampling
To generate a sample, run:
python generate.py
To launch the web application, run:
python app.py
This project is licensed under the GNU General Public License v3.0. See the LICENSE file for details.
