music
sander-wood commited on
Commit
6469e4f
·
verified ·
1 Parent(s): df81ac5

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +36 -21
README.md CHANGED
@@ -49,7 +49,12 @@ To set up the MelodyT5 environment and install the necessary dependencies, follo
49
  ```bash
50
  pip install torch==1.13.1+cu116 torchvision==0.14.1+cu116 torchaudio==0.13.1 --extra-index-url https://download.pytorch.org/whl/cu116
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
 
@@ -80,49 +85,59 @@ 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. **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
  ```
117
  python -m torch.distributed.launch --nproc_per_node=8 --use_env train.py
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:
126
 
127
  ```
128
  %%input
@@ -139,7 +154,7 @@ Follow these steps to effectively utilize MelodyT5 for symbolic music processing
139
  K:D
140
  |: B |
141
  ```
142
-
143
  ## Inference Examples
144
  Below are the MelodyT5 results on seven MelodyHub tasks, using random samples from the validation set. Three independent outputs were generated without cherry-picking. Each `X:0` output corresponds to the original input for that task and is not generated by the model, while `X:1`, `X:2`, and `X:3` are generated outputs.
145
 
 
49
  ```bash
50
  pip install torch==1.13.1+cu116 torchvision==0.14.1+cu116 torchaudio==0.13.1 --extra-index-url https://download.pytorch.org/whl/cu116
51
  ```
52
+
53
+ 4. **Create Random Weights (Optional)**
54
+
55
+ If `SHARE_WEIGHTS = True` in `config.py`, run `random_model.py` to generate random weights for initializing the model with shared weights.
56
+
57
+ 5. **Download Pre-trained MelodyT5 Weights (Optional)**
58
 
59
  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).
60
 
 
85
 
86
  To perform inference tasks using MelodyT5, follow these steps:
87
 
88
+ 1. **Prepare Your Prompt**
 
 
 
89
  - Edit `prompt.txt` to specify the task and input for the model. Each line in `prompt.txt` should contain a single prompt.
90
 
91
+ 2. **Execute Inference**
92
  - Run the following command to execute the inference script:
93
  ```bash
94
  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
95
  ```
96
  Replace `<seed_value>` with your chosen seed value or leave it as `None` for a random seed.
97
+ - The script will generate melodies based on the prompts specified in `prompt.txt` using the configured parameters and save the results in the `output_tunes` folder.
98
 
99
  ## How to Use
100
+
101
  Follow these steps to effectively utilize MelodyT5 for symbolic music processing:
102
 
103
+ 1. **Prepare XML Data**
 
 
104
 
105
+ Ensure your data is in single-track XML format, which can be `.xml`, `.musicxml`, or `.mxl` files.
 
 
106
 
107
+ 2. **Convert to Standard Format**
108
 
109
+ - Place the folder containing your XML data in the `xml2abc` directory.
110
+ - Navigate to the `xml2abc` directory.
111
+ - Run the following command to convert your XML files into standard ABC notation format:
112
+
113
+ ```bash
114
+ python batch_xml2abc.py path_to_xml_directory
115
+ ```
116
+
117
+ - Replace `path_to_xml_directory` with the directory containing your XML files.
118
+
119
+ 3. **Design Input-Output Pairs**
120
+
121
+ After conversion, design input-output pairs based on your specific task requirements. You can refer to the data formats used in [MelodyHub](https://huggingface.co/datasets/sander-wood/melodyhub) for guidance.
122
 
123
+ 4. **Configure Your Model**
124
 
125
+ Adjust model hyperparameters, training parameters, and file paths in the `config.py` file as you see fit.
126
+
127
+ 5. **Train the Model**
128
+
129
+ Run the `train.py` script to train MelodyT5. Use the following command, adjusting for your specific setup:
130
 
131
  ```
132
  python -m torch.distributed.launch --nproc_per_node=8 --use_env train.py
133
  ```
134
+ This command utilizes distributed training across multiple GPUs (modify `--nproc_per_node` as needed).
135
 
136
+ 6. **Run Inference**
137
 
138
  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.
139
 
140
+ Ensure the input (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:
141
 
142
  ```
143
  %%input
 
154
  K:D
155
  |: B |
156
  ```
157
+
158
  ## Inference Examples
159
  Below are the MelodyT5 results on seven MelodyHub tasks, using random samples from the validation set. Three independent outputs were generated without cherry-picking. Each `X:0` output corresponds to the original input for that task and is not generated by the model, while `X:1`, `X:2`, and `X:3` are generated outputs.
160