Update README.md
Browse files
README.md
CHANGED
@@ -6,12 +6,12 @@ tags:
|
|
6 |
- music
|
7 |
---
|
8 |
# MelodyT5: A Unified Score-to-Score Transformer for Symbolic Music Processing [ISMIR 2024]
|
9 |
-
This repository contains the code for the MelodyT5 model as described in the paper [MelodyT5: A Unified Score-to-Score Transformer for Symbolic Music Processing](https://arxiv.org/abs/2407.02277).
|
10 |
|
11 |
-
|
12 |
|
13 |
## Model Description
|
14 |
-
|
|
|
15 |
|
16 |
We provide the codes of MelodyT5 on [GitHub](https://github.com/sanderwood/melodyt5).
|
17 |
|
@@ -51,14 +51,14 @@ To set up the MelodyT5 environment and install the necessary dependencies, follo
|
|
51 |
```
|
52 |
4. **Download Pre-trained MelodyT5 Weights (Optional)**
|
53 |
|
54 |
-
For those interested in starting with pre-trained models, MelodyT5 weights are available on [Hugging Face](https://huggingface.co/sander-wood/melodyt5/blob/main/weights.pth).
|
55 |
|
56 |
## Usage
|
57 |
|
58 |
- `config.py`: Configuration settings for training and inference.
|
59 |
- `inference.py`: Perform inference tasks (e.g., generation and harmonization) using trained models.
|
60 |
- `prompt.txt`: Text file containing the prompt to specify a task and its input for the model.
|
61 |
-
- `random_model.py`:
|
62 |
- `train.py`: Script for training the MelodyT5 model.
|
63 |
- `utils.py`: Utility functions supporting model operations and data processing.
|
64 |
|
@@ -80,29 +80,37 @@ These parameters control how the model generates melodies based on the input pro
|
|
80 |
|
81 |
To perform inference tasks using MelodyT5, follow these steps:
|
82 |
|
83 |
-
1. **
|
|
|
|
|
|
|
84 |
- Edit `prompt.txt` to specify the task and input for the model. Each line in `prompt.txt` should contain a single prompt.
|
85 |
|
86 |
-
|
87 |
- Run the following command to execute the inference script:
|
88 |
```bash
|
89 |
python inference.py -num_tunes 3 -max_patch 128 -top_p 0.8 -top_k 8 -temperature 2.6 -seed <seed_value> -show_control_code True
|
90 |
```
|
91 |
Replace `<seed_value>` with your chosen seed value or leave it as `None` for a random seed.
|
92 |
-
|
93 |
-
3. **Interpreting the Output**
|
94 |
- The script will generate melodies based on the prompts specified in `prompt.txt` using the configured parameters.
|
95 |
|
96 |
## How to Use
|
97 |
Follow these steps to effectively utilize MelodyT5 for symbolic music processing:
|
98 |
|
99 |
1. Prepare Your Data
|
|
|
100 |
Ensure your dataset follows the format and style of MelodyHub, which uses ABC notation for uniform representation of melodies. If not using MelodyHub data, adapt your dataset to match this style.
|
101 |
|
102 |
2. Configure Your Model
|
|
|
103 |
Adjust model hyperparameters, training parameters, and file paths in the config.py file.
|
104 |
|
105 |
-
3.
|
|
|
|
|
|
|
|
|
|
|
106 |
Run the train.py script to train MelodyT5. Use the following command, adjusting for your specific setup:
|
107 |
|
108 |
```
|
@@ -110,7 +118,8 @@ Follow these steps to effectively utilize MelodyT5 for symbolic music processing
|
|
110 |
```
|
111 |
This command utilizes distributed training across multiple GPUs (modify --nproc_per_node as needed).
|
112 |
|
113 |
-
|
|
|
114 |
To perform inference tasks such as melody generation or harmonization, execute `inference.py`. The script reads prompts from `prompt.txt` to specify the task and input for the model. Customize prompts in `prompt.txt` to define different tasks and inputs for MelodyT5. Refer to the examples below for guidance on setting up prompts.
|
115 |
|
116 |
Ensure the encoder input is complete, while the output (decoder input) is optional. If you need the model to continue a given output, use `%%input` and `%%output` to mark the beginning of each section. Additionally, the output must not contain incomplete bars. Here is an example prompt:
|
|
|
6 |
- music
|
7 |
---
|
8 |
# MelodyT5: A Unified Score-to-Score Transformer for Symbolic Music Processing [ISMIR 2024]
|
|
|
9 |
|
10 |
+
This repository contains the code for the MelodyT5 model as described in the paper [MelodyT5: A Unified Score-to-Score Transformer for Symbolic Music Processing](https://arxiv.org/abs/2407.02277).
|
11 |
|
12 |
## Model Description
|
13 |
+
|
14 |
+
MelodyT5 is an unified framework for symbolic music processing, using an encoder-decoder architecture to handle multiple melody-centric tasks, such as generation, harmonization, and segmentation, by treating them as score-to-score transformations. Pre-trained on [MelodyHub](https://huggingface.co/datasets/sander-wood/melodyhub), a large dataset of melodies in ABC notation, it demonstrates the effectiveness of multi-task transfer learning in symbolic music processing.
|
15 |
|
16 |
We provide the codes of MelodyT5 on [GitHub](https://github.com/sanderwood/melodyt5).
|
17 |
|
|
|
51 |
```
|
52 |
4. **Download Pre-trained MelodyT5 Weights (Optional)**
|
53 |
|
54 |
+
For those interested in starting with pre-trained models, MelodyT5 weights are available on [Hugging Face](https://huggingface.co/sander-wood/melodyt5/blob/main/weights.pth).
|
55 |
|
56 |
## Usage
|
57 |
|
58 |
- `config.py`: Configuration settings for training and inference.
|
59 |
- `inference.py`: Perform inference tasks (e.g., generation and harmonization) using trained models.
|
60 |
- `prompt.txt`: Text file containing the prompt to specify a task and its input for the model.
|
61 |
+
- `random_model.py`: Use this script to initialize the model with random weights when `SHARE_WEIGHTS = TRUE` in `config.py` (default setting).
|
62 |
- `train.py`: Script for training the MelodyT5 model.
|
63 |
- `utils.py`: Utility functions supporting model operations and data processing.
|
64 |
|
|
|
80 |
|
81 |
To perform inference tasks using MelodyT5, follow these steps:
|
82 |
|
83 |
+
1. **Create Random Weights**
|
84 |
+
- Run `random_model.py` to generate random weights for initializing the model.
|
85 |
+
|
86 |
+
2. **Prepare Your Prompt**
|
87 |
- Edit `prompt.txt` to specify the task and input for the model. Each line in `prompt.txt` should contain a single prompt.
|
88 |
|
89 |
+
3. **Execute Inference**
|
90 |
- Run the following command to execute the inference script:
|
91 |
```bash
|
92 |
python inference.py -num_tunes 3 -max_patch 128 -top_p 0.8 -top_k 8 -temperature 2.6 -seed <seed_value> -show_control_code True
|
93 |
```
|
94 |
Replace `<seed_value>` with your chosen seed value or leave it as `None` for a random seed.
|
|
|
|
|
95 |
- The script will generate melodies based on the prompts specified in `prompt.txt` using the configured parameters.
|
96 |
|
97 |
## How to Use
|
98 |
Follow these steps to effectively utilize MelodyT5 for symbolic music processing:
|
99 |
|
100 |
1. Prepare Your Data
|
101 |
+
|
102 |
Ensure your dataset follows the format and style of MelodyHub, which uses ABC notation for uniform representation of melodies. If not using MelodyHub data, adapt your dataset to match this style.
|
103 |
|
104 |
2. Configure Your Model
|
105 |
+
|
106 |
Adjust model hyperparameters, training parameters, and file paths in the config.py file.
|
107 |
|
108 |
+
3. Create Random Weights
|
109 |
+
|
110 |
+
If `SHARE_WEIGHTS = True` in `config.py`, run `random_model.py` to generate random weights for initializing the model with shared weights.
|
111 |
+
|
112 |
+
4. Train the Model
|
113 |
+
|
114 |
Run the train.py script to train MelodyT5. Use the following command, adjusting for your specific setup:
|
115 |
|
116 |
```
|
|
|
118 |
```
|
119 |
This command utilizes distributed training across multiple GPUs (modify --nproc_per_node as needed).
|
120 |
|
121 |
+
5. Run Inference
|
122 |
+
|
123 |
To perform inference tasks such as melody generation or harmonization, execute `inference.py`. The script reads prompts from `prompt.txt` to specify the task and input for the model. Customize prompts in `prompt.txt` to define different tasks and inputs for MelodyT5. Refer to the examples below for guidance on setting up prompts.
|
124 |
|
125 |
Ensure the encoder input is complete, while the output (decoder input) is optional. If you need the model to continue a given output, use `%%input` and `%%output` to mark the beginning of each section. Additionally, the output must not contain incomplete bars. Here is an example prompt:
|