sander-wood commited on
Commit
3d67675
1 Parent(s): e45150c

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +103 -0
README.md CHANGED
@@ -1,3 +1,106 @@
1
  ---
2
  license: mit
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: mit
3
+ pipeline_tag: text-generation
4
+ tags:
5
+ - music
6
  ---
7
+
8
+ # TunesFormer
9
+
10
+ ## Model description
11
+
12
+ TunesFormer is a Transformer-based melody generation system trained on 285,449 melodies with musical forms (represented by control codes), where all scores are represented in ABC notation. It was introduced in the paper [TunesFormer: Forming Tunes with Control Codes](https://arxiv.org/abs/2301.02884) by Wu et al. The code is released in [this repository](https://huggingface.co/sander-wood/tunesformer), and the dataset is released in [huggingface](https://huggingface.co/datasets/sander-wood/abc_cc).
13
+
14
+ By utilizing specific symbols commonly found in ABC notation to indicate section boundaries, TunesFormer can understand and generate melodies with given musical forms based on control codes.
15
+
16
+ ## Intended uses & limitations
17
+
18
+ You can use this model for melody generation conditioned on musical forms. All scores generated by this model can be written on one stave (for vocal solo or instrumental solo) in standard classical notation, and are in a variety of styles, e.g., blues, classical, folk, jazz, pop, and world music. The generated tunes are in ABC notation, and can be converted to sheet music or audio using [this website](https://ldzhangyx.github.io/abc/), or [this software](https://sourceforge.net/projects/easyabc/).
19
+
20
+ TunesFormer supports the generation of up to 8 sections, and up to 32 bars per section. In addition, although TunesFormer mostly generates music correctly according to the control codes, due to the random nature of sampling, the musical structure generated by the model occasionally does not match that specified by the control codes when more than 6 sections are generated, or when more than 17 bars are generated for a single section. For more information, please check [our paper](https://arxiv.org/abs/2301.02884).
21
+
22
+ ### How to use
23
+
24
+ 1. Install dependencies:
25
+ ```
26
+ torch 1.9.1+cu111
27
+ samplings 0.1.7
28
+ transformers 4.18.0
29
+ ```
30
+
31
+ 2. Set the `control_codes` and `prompt` in the script `run_inference.py` for conditional music generation.
32
+ ```
33
+ control_codes = "[SECS_3][BARS_4][SIM_6][BARS_4][SIM_10][SIM_6][BARS_4]"
34
+ prompt = """L:1/4
35
+ M:4/4
36
+ K:C
37
+ "C" C C G G |"F" A A"C" G2 |"G" F F"C" E E |"G" D D"C" C2 ||"""
38
+ ```
39
+ For TunesFormer, the input is a concatenation of `control_codes` and `prompt`. Both `control_codes` and `prompt` are optional. However, if you need to set the prompt, you must set the control codes.
40
+
41
+ 3. Run the script `run_inference.py`. When running a script for the first time, the downloaded files will be cached for future reuse.
42
+
43
+ ```
44
+ python run_inference.py -num_tunes 3 -max_length 1024 -top_p 0.9 -temperature 1.0 -seed 1
45
+ ```
46
+
47
+ 4. Enjoy tunes in the folder `output_tunes`! If you want to convert these ABC tunes to sheet music or audio, please refer to `Intended uses & limitations`.
48
+ ```
49
+ X:1
50
+ L:1/4
51
+ M:4/4
52
+ K:C
53
+ "C" C C G G |"F" A A"C" G2 |"G" F F"C" E E |"G" D D"C" C2 ||"C" G G"F" A A |"G" G G"C" E2 |
54
+ "G" F F"C" E E |"G" D D"C" C2 ||"C" C C G G |"F" A A"C" G2 |"G" F F"C" E E |"G" D D"C" C2 |]
55
+
56
+ X:2
57
+ L:1/4
58
+ M:4/4
59
+ K:C
60
+ "C" C C G G |"F" A A"C" G2 |"G" F F"C" E E |"G" D D"C" C2 ||"C" E E"F" F F |"C" G G"F" A2 |
61
+ "G7" F F"C" E E |"G" D D"C" C2 ||"C" C C G G |"F" A A"C" G2 |"G" F F"C" E E |"G" D D"C" C2 |]
62
+
63
+ X:3
64
+ L:1/4
65
+ M:4/4
66
+ K:C
67
+ "C" C C G G |"F" A A"C" G2 |"G" F F"C" E E |"G" D D"C" C2 ||"C" G G"F" A A |"C" G G"F" F2 |
68
+ "C" E E"G" D D |"G" D D"C" C2 ||"C" C C G G |"F" A A"C" G2 |"G" F F"C" E E |"G" D D"C" C2 |]
69
+ ```
70
+
71
+ ### Usage
72
+ ```
73
+ optional arguments:
74
+ -h, --help show this help message and exit
75
+ -num_tunes NUM_TUNES the number of independently computed returned tunes
76
+ -max_length MAX_LENGTH
77
+ integer to define the maximum length in tokens of each
78
+ tune
79
+ -top_p TOP_P float to define the tokens that are within the sample
80
+ operation of text generation
81
+ -temperature TEMPERATURE
82
+ the temperature of the sampling operation
83
+ -seed SEED seed for randomstate
84
+ ```
85
+
86
+ ### BibTeX entry and citation info
87
+
88
+ ```bibtex
89
+ @misc{https://doi.org/10.48550/arxiv.2301.02884,
90
+ doi = {10.48550/ARXIV.2301.02884},
91
+
92
+ url = {https://arxiv.org/abs/2301.02884},
93
+
94
+ author = {Wu, Shangda and Sun, Maosong},
95
+
96
+ keywords = {Sound (cs.SD), Audio and Speech Processing (eess.AS), FOS: Computer and information sciences, FOS: Computer and information sciences, FOS: Electrical engineering, electronic engineering, information engineering, FOS: Electrical engineering, electronic engineering, information engineering},
97
+
98
+ title = {TunesFormer: Forming Tunes with Control Codes},
99
+
100
+ publisher = {arXiv},
101
+
102
+ year = {2023},
103
+
104
+ copyright = {Creative Commons Attribution 4.0 International}
105
+ }
106
+ ```