musicaiz.models.transformer_composers¶
Transformer Composers¶
This submodule presents a GPT2 model that generates music.
The tokenization is previously done with musanalysis
MMMTokenizer()
class.
Installation¶
To train these models you should install torch with cuda. We recommend torch version 1.11.0 with cuda 113:
>>> pip3 install torch==1.11.0 --extra-index-url https://download.pytorch.org/whl/cu113
Apart from that, apex is also necessary. To install it properly, follow the instructions in: https://github.com/NVIDIA/apex
Configurations¶
... |
|
Dataloaders¶
|
Builds the train a validation dataloaders. |
|
Read one txt file and retrieves the vocabulary. |
Model¶
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Train¶
|
|
Generation¶
|
This function generates a sequence from a pretrained model. |
Gradio App¶
There’s a simple app for this model built with Gradio. To try the demo locally run:
>>> python models/transformer_composers/app.py
Examples¶
Train model:
>>> python models/transformer_composers/train.py --dataset_path="..." --is_splitted True
Generate Sequence:
>>> python models/transformer_composers/generate.py --dataset_path H:/GitHub/musicaiz-datasets/jsbchorales/mmm/all_bars --dataset_name jsbchorales --save_midi True --file_path ../midi