sander-wood commited on
Commit
0b06f90
1 Parent(s): 52f2d82

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -12
app.py CHANGED
@@ -23,30 +23,30 @@ description = """
23
  <div>
24
 
25
  <a style="display:inline-block" href='https://github.com/sander-wood/tunesformer'><img src='https://img.shields.io/github/stars/sander-wood/tunesformer?style=social' /></a>
26
- <a style="display:inline-block" href="https://huggingface.co/datasets/sander-wood/massive_abcnotation_dataset"><img src="https://img.shields.io/badge/huggingface-dataset-ffcc66.svg"></a>
27
  <a style="display:inline-block" href="https://arxiv.org/pdf/2301.02884.pdf"><img src="https://img.shields.io/badge/arXiv-2301.02884-b31b1b.svg"></a>
28
  <a class="duplicate-button" style="display:inline-block" target="_blank" href="https://huggingface.co/spaces/sander-wood/tunesformer?duplicate=true"><img style="margin-top:0;margin-bottom:0" src="https://huggingface.co/datasets/huggingface/badges/raw/main/duplicate-this-space-md-dark.svg" alt="Duplicate Space"></a>
29
  </div>
30
 
31
  ## ℹ️ How to use this demo?
32
  1. Enter the control codes to set the musical form of the generated music. For details, please refer to the below "Control Codes" section. (optional)
33
- 2. Enter the prefix of the generated music. You can set the ABC header (i.e., note length, tempo, meter, and key) and the beginning of the music. (optional)
34
- 2. You can set the parameters (i.e., number of tunes, maximum length, top-p, temperature, and random seed) for the generation. (optional)
35
  3. Click "Submit" and wait for the result.
36
- 4. The generated ABC notation can be converted to MIDI or PDF using [EasyABC](https://sourceforge.net/projects/easyabc/), you can also use this [online renderer](https://ldzhangyx.github.io/abc/) to render the ABC notation.
37
 
38
  ## 📝 Control Codes
39
- There are 3 types of control codes: section bar `[BARS_NB]`, `[SECS_NS]`, and similarity `[SIM_EDS]`. The control codes can be used to set the musical form of the generated music:
40
 
41
- - `[BARS_NB]`: controls the number of bars in a section of the melody. For example, users could specify that they want a section to contain 8 bars, and TunesFormer would generate a section that fits within that structure. It counts on the bar symbol `|`. The value of `NB` ranges from 1 to 32, where 1 means one bar and 32 means thirty-two bars.
42
- - `[SECS_NS]`: controls the number of sections in the entire melody. This can be used to create a sense of structure and coherence within the melody, as different sections can be used to create musical themes or motifs. It counts on several symbols that are commonly used in ABC notation and can be used to represent section boundaries: `[|`,`||`,`|]`,`|:`,`::`, and `:|`. The value of `NS` ranges from 1 to 8, where 1 means one section and 8 means eight sections.
43
- - `[SIM_EDS]`: controls the similarity between the generated music and the prefix. The value of `EDS` is the edit distance similarity level between the current section and a previous section in the melody. The value of EDS ranges from 0 to 10, where 0 means no similarity and 10 means the same section.
44
 
45
- To provide a clearer understanding of the control codes, we provide an example below:
46
 
47
- `[SECS_3][BARS_8][SIM_3][BARS_8][SIM_10][SIM_3][BARS_8]`
48
-
49
- The first control code `[SECS_3]` specifies there are 3 sections in the tune, and the following control code `[BARS_8]` indicates the first section has 8 bars. The next two control codes `[SIM_3]` and `[BAR_8]` indicate that the EDS between section II and section I is approximately 0.3, and section II has 8 bars. The last three control codes `[SIM_10]`, `[SIM_3]` and `[BARS_8]` specify that section III is identical to section I while dissimilar to section II, and has 8 bars.
 
 
50
 
51
  ## ❕Notice
52
  - If the prefix is given, you must also provide the control codes.
 
23
  <div>
24
 
25
  <a style="display:inline-block" href='https://github.com/sander-wood/tunesformer'><img src='https://img.shields.io/github/stars/sander-wood/tunesformer?style=social' /></a>
26
+ <a style="display:inline-block" href="https://huggingface.co/datasets/sander-wood/irishman"><img src="https://img.shields.io/badge/huggingface-dataset-ffcc66.svg"></a>
27
  <a style="display:inline-block" href="https://arxiv.org/pdf/2301.02884.pdf"><img src="https://img.shields.io/badge/arXiv-2301.02884-b31b1b.svg"></a>
28
  <a class="duplicate-button" style="display:inline-block" target="_blank" href="https://huggingface.co/spaces/sander-wood/tunesformer?duplicate=true"><img style="margin-top:0;margin-bottom:0" src="https://huggingface.co/datasets/huggingface/badges/raw/main/duplicate-this-space-md-dark.svg" alt="Duplicate Space"></a>
29
  </div>
30
 
31
  ## ℹ️ How to use this demo?
32
  1. Enter the control codes to set the musical form of the generated music. For details, please refer to the below "Control Codes" section. (optional)
33
+ 2. Enter the prompt of the generated music. You can set the control codes to set the musical form, ABC header (i.e., note length, tempo, meter, and key) and the motif of the melody. (optional)
34
+ 2. You can set the parameters (i.e., number of tunes, maximum patch, top-p, top-k, temperature, random seed and show control code) for the generation. (optional)
35
  3. Click "Submit" and wait for the result.
36
+ 4. The generated ABC notation can be played or edited using [EasyABC]([ABC Sheet Music Editor - EasyABC](https://easyabc.sourceforge.net/), you can also use this [Online ABC Player](https://abc.rectanglered.com/) to render the tune.
37
 
38
  ## 📝 Control Codes
39
+ Inspired by [CTRL](https://huggingface.co/ctrl), we incorporate control codes into TunesFormer to represent musical forms. These codes, positioned ahead of the ABC notation, enable users to specify the structures of the generated tunes. The following control codes are introduced:
40
 
41
+ - **S:number of sections**: determines the number of sections in the entire melody. It counts on several symbols that can be used to represent section boundaries: `[|`, `||`, `|]`, `|:`, `::`, and `:|`. In our dataset, the range is 1 to 8 (e.g., `S:1` for a single-section melody, and `S:8` for a melody with eight sections).
 
 
42
 
43
+ - **B:number of bars**: specifies the desired number of bars within a section. It counts on the bar symbol `|`. In our dataset, the range is 1 to 32 (e.g., `B:1` for a one-bar section, and `B:32` for a section with 32 bars).
44
 
45
+ - **E:edit distance similarity**: controls the similarity level between the current section $c$ and a previous section $p$ in the melody. It is based on the Levenshtein distance $lev(c,p)$ , quantifying the difference between sections for creating variations or contrasts. Mathematically, it can be expressed as:
46
+ ```
47
+ eds(c,p) = 1 - lev(c,p) / max(|c|,|p|)
48
+ ```
49
+ where $|c|$ and $|p|$ are the string lengths of the two sections. It is discretized into 11 levels, ranging from no match at all to an exact match (e.g., `E:0` for no similarity, and `E:10` for an exact match).
50
 
51
  ## ❕Notice
52
  - If the prefix is given, you must also provide the control codes.