Update README.md
Browse filesAdd `library_name` and update example code for `symupe==1.1.0 `
README.md
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
---
|
|
|
|
| 2 |
license: cc-by-nc-sa-4.0
|
| 3 |
datasets:
|
| 4 |
- SyMuPe/PERiScoPe
|
|
@@ -34,41 +35,36 @@ Introduced in the paper: [**SyMuPe: Affective and Controllable Symbolic Music Pe
|
|
| 34 |
|
| 35 |
## Quick Start
|
| 36 |
|
| 37 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
|
| 39 |
```python
|
| 40 |
import torch
|
| 41 |
from symusic import Score
|
| 42 |
-
|
| 43 |
-
from symupe.data.tokenizers import SyMuPe
|
| 44 |
-
from symupe.inference import AutoGenerator, perform_score, save_performances
|
| 45 |
-
from symupe.models import AutoModel
|
| 46 |
|
| 47 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 48 |
|
| 49 |
-
#
|
| 50 |
-
|
| 51 |
-
tokenizer =
|
| 52 |
-
|
| 53 |
-
# Prepare generator for the model
|
| 54 |
-
generator = AutoGenerator.from_model(model, tokenizer, device=device)
|
| 55 |
-
|
| 56 |
-
# Load score MIDI
|
| 57 |
-
score_midi = Score("score.mid")
|
| 58 |
|
| 59 |
# Perform score MIDI (tokenization is handled inside)
|
| 60 |
-
gen_results = perform_score(
|
| 61 |
-
|
| 62 |
-
score=score_midi,
|
| 63 |
use_score_context=True,
|
| 64 |
num_samples=8,
|
| 65 |
-
seed=23
|
| 66 |
)
|
| 67 |
# gen_results[i] is PerformanceRenderingResult(...) containing:
|
| 68 |
# - score_midi, score_seq, gen_seq, perf_seq, perf_midi, perf_midi_sus
|
| 69 |
|
| 70 |
-
# Save performed MIDI files
|
| 71 |
-
save_performances(gen_results, out_dir="samples/mlm"
|
| 72 |
```
|
| 73 |
|
| 74 |
## License
|
|
|
|
| 1 |
---
|
| 2 |
+
library_name: symupe
|
| 3 |
license: cc-by-nc-sa-4.0
|
| 4 |
datasets:
|
| 5 |
- SyMuPe/PERiScoPe
|
|
|
|
| 35 |
|
| 36 |
## Quick Start
|
| 37 |
|
| 38 |
+
Before using this model, ensure you have the `symupe` library installed:
|
| 39 |
+
```shell
|
| 40 |
+
pip install -U symupe
|
| 41 |
+
```
|
| 42 |
+
|
| 43 |
+
Use the following code to render performances:
|
| 44 |
|
| 45 |
```python
|
| 46 |
import torch
|
| 47 |
from symusic import Score
|
| 48 |
+
from symupe import AutoGenerator
|
|
|
|
|
|
|
|
|
|
| 49 |
|
| 50 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 51 |
|
| 52 |
+
# Build Generator by loading the model and tokenizer directly from the Hub
|
| 53 |
+
generator = AutoGenerator.from_pretrained("SyMuPe/MLM-base", device=device)
|
| 54 |
+
# model, tokenizer = generator.model, generator.tokenizer
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
|
| 56 |
# Perform score MIDI (tokenization is handled inside)
|
| 57 |
+
gen_results = generator.perform_score(
|
| 58 |
+
"score.mid",
|
|
|
|
| 59 |
use_score_context=True,
|
| 60 |
num_samples=8,
|
| 61 |
+
seed=23,
|
| 62 |
)
|
| 63 |
# gen_results[i] is PerformanceRenderingResult(...) containing:
|
| 64 |
# - score_midi, score_seq, gen_seq, perf_seq, perf_midi, perf_midi_sus
|
| 65 |
|
| 66 |
+
# Save performed MIDI files
|
| 67 |
+
generator.save_performances(gen_results, out_dir="samples/mlm")
|
| 68 |
```
|
| 69 |
|
| 70 |
## License
|