Update README.md
Browse files
README.md
CHANGED
@@ -22,6 +22,8 @@ tags:
|
|
22 |
***
|
23 |
|
24 |
```
|
|
|
|
|
25 |
In the heart of a grand piano black and blue,
|
26 |
A fuzzy monster with eyes of yellow hue,
|
27 |
Its fingers dance upon the ivory keys,
|
@@ -72,6 +74,31 @@ choco install fluidsynth
|
|
72 |
|
73 |
***
|
74 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
## Quick-start use example
|
76 |
|
77 |
```python
|
@@ -86,13 +113,13 @@ model = mpt.load_model()
|
|
86 |
sample_midi_path = mpt.get_sample_midi_files()[6][1]
|
87 |
|
88 |
# Load seed MIDI
|
89 |
-
input_tokens = mpt.midi_to_tokens(sample_midi_path
|
90 |
|
91 |
# Generate seed MIDI continuation
|
92 |
-
output_tokens = mpt.generate(model, input_tokens, 600, return_prime=True)
|
93 |
|
94 |
-
# Save output batch 0 to MIDI
|
95 |
-
mpt.tokens_to_midi(output_tokens[0]
|
96 |
```
|
97 |
|
98 |
***
|
@@ -113,13 +140,13 @@ model = mpt.load_model()
|
|
113 |
sample_midi_path = mpt.get_sample_midi_files()[6][1]
|
114 |
|
115 |
# Load seed MIDI
|
116 |
-
input_tokens = mpt.midi_to_tokens(sample_midi_path
|
117 |
|
118 |
# Generate long seed MIDI auto-continuation
|
119 |
output_tokens = mpt.generate_long(model, input_tokens, return_prime=True)
|
120 |
|
121 |
# Save output batch 0 to MIDI
|
122 |
-
mpt.tokens_to_midi(output_tokens[0]
|
123 |
```
|
124 |
|
125 |
### Pitches inpainting
|
@@ -136,13 +163,13 @@ model = mpt.load_model()
|
|
136 |
sample_midi_path = mpt.get_sample_midi_files()[6][1]
|
137 |
|
138 |
# Load seed MIDI
|
139 |
-
input_tokens = mpt.midi_to_tokens(sample_midi_path
|
140 |
|
141 |
# Inpaint pitches
|
142 |
output_tokens = mpt.inpaint_pitches(model, input_tokens)
|
143 |
|
144 |
# Save output to MIDI
|
145 |
-
mpt.tokens_to_midi(output_tokens
|
146 |
```
|
147 |
|
148 |
### Simple velocities inpainting
|
@@ -159,13 +186,13 @@ model = mpt.load_model(model_name='with velocity - 3 epochs')
|
|
159 |
sample_midi_path = mpt.get_sample_midi_files()[6][1]
|
160 |
|
161 |
# Load seed MIDI
|
162 |
-
input_tokens = mpt.midi_to_tokens(sample_midi_path
|
163 |
|
164 |
# Inpaint velocities
|
165 |
output_tokens = mpt.inpaint_velocities_simple(model, input_tokens)
|
166 |
|
167 |
# Save output to MIDI
|
168 |
-
mpt.tokens_to_midi(output_tokens
|
169 |
```
|
170 |
|
171 |
### Seq2Seq velocities inpainting
|
@@ -176,19 +203,19 @@ import monsterpianotransformer as mpt
|
|
176 |
|
177 |
# Load desired Monster Piano Transformer model
|
178 |
# There are several to choose from...
|
179 |
-
model = mpt.load_model(model_name='velocity inpainting -
|
180 |
|
181 |
# Get sample seed MIDI path
|
182 |
sample_midi_path = mpt.get_sample_midi_files()[6][1]
|
183 |
|
184 |
# Load seed MIDI
|
185 |
-
input_tokens = mpt.midi_to_tokens(sample_midi_path
|
186 |
|
187 |
# Inpaint velocities
|
188 |
output_tokens = mpt.inpaint_velocities_seq2seq(model, input_tokens, verbose=True)
|
189 |
|
190 |
# Save output to MIDI
|
191 |
-
mpt.tokens_to_midi(output_tokens
|
192 |
```
|
193 |
|
194 |
### Timings inpainting
|
@@ -237,7 +264,250 @@ output_tokens = mpt.inpaint_bridge(model, input_tokens)
|
|
237 |
mpt.tokens_to_midi(output_tokens)
|
238 |
```
|
239 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
240 |
***
|
241 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
242 |
### Project Los Angeles
|
243 |
### Tegridy Code 2025
|
|
|
22 |
***
|
23 |
|
24 |
```
|
25 |
+
Monster Piano by QVQ 7B
|
26 |
+
|
27 |
In the heart of a grand piano black and blue,
|
28 |
A fuzzy monster with eyes of yellow hue,
|
29 |
Its fingers dance upon the ivory keys,
|
|
|
74 |
|
75 |
***
|
76 |
|
77 |
+
## Gradio app
|
78 |
+
|
79 |
+
```sh
|
80 |
+
# pip package includes a demo Gradio app without audio output
|
81 |
+
|
82 |
+
# Please refer to monsterpianotransformer/gradio/app_full.py
|
83 |
+
# for a full version with fluidsynth audio output
|
84 |
+
|
85 |
+
monsterpianotransformer-gradio
|
86 |
+
```
|
87 |
+
|
88 |
+
***
|
89 |
+
|
90 |
+
## Available models
|
91 |
+
|
92 |
+
```python
|
93 |
+
# Import Monster Piano Transformer as mpt
|
94 |
+
import monsterpianotransformer as mpt
|
95 |
+
|
96 |
+
# Print a list of available models
|
97 |
+
mpt.load_model('models info')
|
98 |
+
```
|
99 |
+
|
100 |
+
***
|
101 |
+
|
102 |
## Quick-start use example
|
103 |
|
104 |
```python
|
|
|
113 |
sample_midi_path = mpt.get_sample_midi_files()[6][1]
|
114 |
|
115 |
# Load seed MIDI
|
116 |
+
input_tokens = mpt.midi_to_tokens(sample_midi_path)
|
117 |
|
118 |
# Generate seed MIDI continuation
|
119 |
+
output_tokens = mpt.generate(model, input_tokens, num_gen_tokens=600, return_prime=True)
|
120 |
|
121 |
+
# Save output batch # 0 to MIDI
|
122 |
+
mpt.tokens_to_midi(output_tokens[0])
|
123 |
```
|
124 |
|
125 |
***
|
|
|
140 |
sample_midi_path = mpt.get_sample_midi_files()[6][1]
|
141 |
|
142 |
# Load seed MIDI
|
143 |
+
input_tokens = mpt.midi_to_tokens(sample_midi_path)
|
144 |
|
145 |
# Generate long seed MIDI auto-continuation
|
146 |
output_tokens = mpt.generate_long(model, input_tokens, return_prime=True)
|
147 |
|
148 |
# Save output batch 0 to MIDI
|
149 |
+
mpt.tokens_to_midi(output_tokens[0])
|
150 |
```
|
151 |
|
152 |
### Pitches inpainting
|
|
|
163 |
sample_midi_path = mpt.get_sample_midi_files()[6][1]
|
164 |
|
165 |
# Load seed MIDI
|
166 |
+
input_tokens = mpt.midi_to_tokens(sample_midi_path)
|
167 |
|
168 |
# Inpaint pitches
|
169 |
output_tokens = mpt.inpaint_pitches(model, input_tokens)
|
170 |
|
171 |
# Save output to MIDI
|
172 |
+
mpt.tokens_to_midi(output_tokens)
|
173 |
```
|
174 |
|
175 |
### Simple velocities inpainting
|
|
|
186 |
sample_midi_path = mpt.get_sample_midi_files()[6][1]
|
187 |
|
188 |
# Load seed MIDI
|
189 |
+
input_tokens = mpt.midi_to_tokens(sample_midi_path)
|
190 |
|
191 |
# Inpaint velocities
|
192 |
output_tokens = mpt.inpaint_velocities_simple(model, input_tokens)
|
193 |
|
194 |
# Save output to MIDI
|
195 |
+
mpt.tokens_to_midi(output_tokens)
|
196 |
```
|
197 |
|
198 |
### Seq2Seq velocities inpainting
|
|
|
203 |
|
204 |
# Load desired Monster Piano Transformer model
|
205 |
# There are several to choose from...
|
206 |
+
model = mpt.load_model(model_name='velocity inpainting - 2 epochs')
|
207 |
|
208 |
# Get sample seed MIDI path
|
209 |
sample_midi_path = mpt.get_sample_midi_files()[6][1]
|
210 |
|
211 |
# Load seed MIDI
|
212 |
+
input_tokens = mpt.midi_to_tokens(sample_midi_path)
|
213 |
|
214 |
# Inpaint velocities
|
215 |
output_tokens = mpt.inpaint_velocities_seq2seq(model, input_tokens, verbose=True)
|
216 |
|
217 |
# Save output to MIDI
|
218 |
+
mpt.tokens_to_midi(output_tokens)
|
219 |
```
|
220 |
|
221 |
### Timings inpainting
|
|
|
264 |
mpt.tokens_to_midi(output_tokens)
|
265 |
```
|
266 |
|
267 |
+
### Single chord generation
|
268 |
+
|
269 |
+
```python
|
270 |
+
# Import Monster Piano Transformer as mpt
|
271 |
+
import monsterpianotransformer as mpt
|
272 |
+
|
273 |
+
# Load desired Monster Piano Transformer model
|
274 |
+
# There are several to choose from...
|
275 |
+
model = mpt.load_model()
|
276 |
+
|
277 |
+
# Generate single chord
|
278 |
+
output_tokens = mpt.generate_chord(model)
|
279 |
+
|
280 |
+
print(output_tokens)
|
281 |
+
```
|
282 |
+
|
283 |
+
### Chords progressions
|
284 |
+
|
285 |
+
```python
|
286 |
+
# Import Monster Piano Transformer as mpt
|
287 |
+
import monsterpianotransformer as mpt
|
288 |
+
|
289 |
+
# Load desired Monster Piano Transformer model
|
290 |
+
# There are several to choose from...
|
291 |
+
model = mpt.load_model('chords progressions - 3 epochs')
|
292 |
+
|
293 |
+
# Prime chord(s) as a list of lists of semitones and/or pitches
|
294 |
+
prime_chords = [
|
295 |
+
[0],
|
296 |
+
[0, 2],
|
297 |
+
[0, 2, 4],
|
298 |
+
[60],
|
299 |
+
[60, 62]
|
300 |
+
]
|
301 |
+
|
302 |
+
# Convert chords to chords tokens
|
303 |
+
chords_tokens = mpt.chords_to_chords_tokens(prime_chords)
|
304 |
+
|
305 |
+
# Generate chord progression continuation
|
306 |
+
output_tokens = mpt.generate(model, chords_tokens, num_gen_tokens=32, return_prime=True)
|
307 |
+
|
308 |
+
# Convert output tokens batch # 0 back to the chords list
|
309 |
+
chords_list = mpt.chords_tokens_to_chords(output_tokens[0])
|
310 |
+
|
311 |
+
print(chords_list)
|
312 |
+
```
|
313 |
+
|
314 |
+
### Chords texturing
|
315 |
+
|
316 |
+
```python
|
317 |
+
# Import Monster Piano Transformer as mpt
|
318 |
+
import monsterpianotransformer as mpt
|
319 |
+
|
320 |
+
# Load desired Monster Piano Transformer model
|
321 |
+
# There are several to choose from...
|
322 |
+
model = mpt.load_model('chords texturing - 3 epochs')
|
323 |
+
|
324 |
+
# Get sample seed MIDI path
|
325 |
+
sample_midi_path = mpt.get_sample_midi_files()[6][1]
|
326 |
+
|
327 |
+
# Convert MIDI to chords list
|
328 |
+
chords_list = mpt.midi_to_chords(sample_midi_path)
|
329 |
+
|
330 |
+
# Texture chords
|
331 |
+
output_tokens = mpt.texture_chords(model, chords_list)
|
332 |
+
|
333 |
+
# Save output to MIDI
|
334 |
+
mpt.tokens_to_midi(output_tokens)
|
335 |
+
```
|
336 |
+
|
337 |
***
|
338 |
|
339 |
+
## Advanced use examples
|
340 |
+
|
341 |
+
### Chords progressions generation and texturing
|
342 |
+
|
343 |
+
#### From custom chords list
|
344 |
+
|
345 |
+
```python
|
346 |
+
# Import Monster Piano Transformer as mpt
|
347 |
+
import monsterpianotransformer as mpt
|
348 |
+
|
349 |
+
# Load desired Monster Piano Transformer model
|
350 |
+
# There are several to choose from...
|
351 |
+
cp_model = mpt.load_model('chords progressions - 3 epochs')
|
352 |
+
tex_model = mpt.load_model('chords texturing - 3 epochs')
|
353 |
+
|
354 |
+
# Prime chord(s) as a list of lists of semitones and/or pitches
|
355 |
+
prime_chords = [
|
356 |
+
[0],
|
357 |
+
[0, 2],
|
358 |
+
[0, 2, 4]
|
359 |
+
]
|
360 |
+
|
361 |
+
# Convert chords to chords tokens
|
362 |
+
chords_tokens = mpt.chords_to_chords_tokens(prime_chords)
|
363 |
+
|
364 |
+
# Generate chords progression continuation
|
365 |
+
cp_tokens = mpt.generate(cp_model, chords_tokens, num_gen_tokens=64, return_prime=True)
|
366 |
+
|
367 |
+
# Generate pitches for chords in generated chords progression continuation
|
368 |
+
output_tokens = mpt.generate_chords_pitches(tex_model, cp_tokens[0])
|
369 |
+
|
370 |
+
# Convert output tokens to MIDI
|
371 |
+
mpt.chords_pitches_to_midi(output_tokens)
|
372 |
+
```
|
373 |
+
|
374 |
+
#### From custom MIDI
|
375 |
+
|
376 |
+
```python
|
377 |
+
# Import Monster Piano Transformer as mpt
|
378 |
+
import monsterpianotransformer as mpt
|
379 |
+
|
380 |
+
# Load desired Monster Piano Transformer model
|
381 |
+
# There are several to choose from...
|
382 |
+
cp_model = mpt.load_model('chords progressions - 3 epochs')
|
383 |
+
tex_model = mpt.load_model('chords texturing - 3 epochs')
|
384 |
+
|
385 |
+
# Get sample seed MIDI path
|
386 |
+
sample_midi_path = mpt.get_sample_midi_files()[7][1]
|
387 |
+
|
388 |
+
# Load seed MIDI
|
389 |
+
chords_tokens = mpt.midi_to_chords(sample_midi_path, return_only_chords=True)
|
390 |
+
|
391 |
+
# Generate chords progression continuation
|
392 |
+
cp_tokens = mpt.generate(cp_model, chords_tokens[:64], num_gen_tokens=64, return_prime=True)
|
393 |
+
|
394 |
+
# Generate pitches for chords in generated chords progression continuation
|
395 |
+
output_tokens = mpt.generate_chords_pitches(tex_model, cp_tokens[0])
|
396 |
+
|
397 |
+
# Convert output tokens to MIDI
|
398 |
+
mpt.chords_pitches_to_midi(output_tokens)
|
399 |
+
```
|
400 |
+
|
401 |
+
#### From custom MIDI with prime chords and prime chords pitches
|
402 |
+
|
403 |
+
```python
|
404 |
+
# Import Monster Piano Transformer as mpt
|
405 |
+
import monsterpianotransformer as mpt
|
406 |
+
|
407 |
+
# Load desired Monster Piano Transformer model
|
408 |
+
# There are several to choose from...
|
409 |
+
cp_model = mpt.load_model('chords progressions - 3 epochs')
|
410 |
+
tex_model = mpt.load_model('chords texturing - 3 epochs')
|
411 |
+
|
412 |
+
# Get sample seed MIDI path
|
413 |
+
sample_midi_path = mpt.get_sample_midi_files()[7][1]
|
414 |
+
|
415 |
+
# Load seed MIDI
|
416 |
+
chords_list = mpt.midi_to_chords(sample_midi_path)
|
417 |
+
|
418 |
+
# Number of prime chords
|
419 |
+
num_prime_chords = 64
|
420 |
+
|
421 |
+
# Create prime chords tokens list
|
422 |
+
prime_chords_tokens = [c[0][0] for c in chords_list[:num_prime_chords]]
|
423 |
+
|
424 |
+
# Create prime chords pitches list
|
425 |
+
prime_chords_pitches = [c[0][1:] for c in chords_list[:num_prime_chords]]
|
426 |
+
|
427 |
+
# Generate chords progression continuation
|
428 |
+
cp_tokens = mpt.generate(cp_model, prime_chords_tokens, num_gen_tokens=128, return_prime=True)
|
429 |
+
|
430 |
+
# Generate pitches for chords in generated chords progression continuation
|
431 |
+
output_tokens = mpt.generate_chords_pitches(tex_model, cp_tokens[0], prime_chords_pitches)
|
432 |
+
|
433 |
+
# Convert output tokens to MIDI
|
434 |
+
mpt.chords_pitches_to_midi(output_tokens, chords_list)
|
435 |
+
```
|
436 |
+
|
437 |
+
#### From custom chords list with chords texturing and timings inpainting
|
438 |
+
|
439 |
+
```python
|
440 |
+
# Import Monster Piano Transformer as mpt
|
441 |
+
import monsterpianotransformer as mpt
|
442 |
+
|
443 |
+
# Load desired Monster Piano Transformer model
|
444 |
+
# There are several to choose from...
|
445 |
+
cp_model = mpt.load_model('chords progressions - 3 epochs')
|
446 |
+
tex_model = mpt.load_model('chords texturing - 3 epochs')
|
447 |
+
tim_model = mpt.load_model('timings inpainting - 2 epochs')
|
448 |
+
|
449 |
+
# Prime chord(s) as a list of lists of semitones and/or pitches
|
450 |
+
prime_chords = [
|
451 |
+
[0],
|
452 |
+
[0, 2],
|
453 |
+
[0, 2, 4]
|
454 |
+
]
|
455 |
+
|
456 |
+
# Convert chords to chords tokens
|
457 |
+
chords_tokens = mpt.chords_to_chords_tokens(prime_chords)
|
458 |
+
|
459 |
+
# Generate chords progression continuation
|
460 |
+
cp_tokens = mpt.generate(cp_model, chords_tokens, num_gen_tokens=64, return_prime=True)
|
461 |
+
|
462 |
+
# Generate pitches for chords in generated chords progression continuation
|
463 |
+
cptcs_tokens = mpt.generate_chords_pitches(tex_model, cp_tokens[0], return_as_tokens_seq=True)
|
464 |
+
|
465 |
+
# Inpaint timings
|
466 |
+
output_tokens = mpt.inpaint_timings(tim_model, cptcs_tokens)
|
467 |
+
|
468 |
+
# Save output to MIDI
|
469 |
+
mpt.tokens_to_midi(output_tokens)
|
470 |
+
```
|
471 |
+
|
472 |
+
***
|
473 |
+
|
474 |
+
## Dev and tests
|
475 |
+
|
476 |
+
### Loading
|
477 |
+
|
478 |
+
```python
|
479 |
+
# You can load and use one or several models at the time
|
480 |
+
|
481 |
+
# Default model (without velocity - 3 epochs)
|
482 |
+
default_model = mpt.load_model()
|
483 |
+
|
484 |
+
# More models...
|
485 |
+
cp_model = mpt.load_model('chords progressions - 3 epochs')
|
486 |
+
tex_model = mpt.load_model('chords texturing - 3 epochs')
|
487 |
+
tim_model = mpt.load_model('timings inpainting - 2 epochs')
|
488 |
+
```
|
489 |
+
|
490 |
+
### Parameters
|
491 |
+
|
492 |
+
```python
|
493 |
+
# Dev models parameters can be accessed like so
|
494 |
+
|
495 |
+
# Max sequence length
|
496 |
+
print(default_model.max_seq_len)
|
497 |
+
|
498 |
+
# Max number of tokens
|
499 |
+
print(default_model.pad_value)
|
500 |
+
```
|
501 |
+
|
502 |
+
### Generation
|
503 |
+
|
504 |
+
```python
|
505 |
+
# Use generate or generate long functions for dev or testing with all models
|
506 |
+
|
507 |
+
# Just make sure to prime the models with at least one token within its tokens range
|
508 |
+
default_output = mpt.generate(default_model, input_tokens=[0], num_gen_tokens=32)
|
509 |
+
tex_output = mpt.generate_long(tex_model, input_tokens=[0], num_gen_tokens=32)
|
510 |
+
```
|
511 |
+
|
512 |
### Project Los Angeles
|
513 |
### Tegridy Code 2025
|