Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -274,6 +274,10 @@ def save_midi(tokens):
|
|
274 |
@spaces.GPU
|
275 |
def generate_music(prime, num_gen_tokens, num_gen_batches, model_temperature, model_top_p):
|
276 |
"""Generate music tokens given prime tokens and parameters."""
|
|
|
|
|
|
|
|
|
277 |
inputs = prime if prime else [18816]
|
278 |
print("Generating...")
|
279 |
inp = torch.LongTensor([inputs] * num_gen_batches).cuda()
|
@@ -413,12 +417,16 @@ def remove_batch(batch_number, num_tokens, final_composition, generated_batches,
|
|
413 |
|
414 |
def clear():
|
415 |
"""Clear outputs and reset state."""
|
|
|
416 |
print('Clear batch...')
|
|
|
417 |
return None, None, None, [], []
|
418 |
|
419 |
def reset(final_composition=[], generated_batches=[], block_lines=[]):
|
420 |
"""Reset composition state."""
|
421 |
-
|
|
|
|
|
422 |
return [], [], []
|
423 |
|
424 |
# -----------------------------
|
|
|
274 |
@spaces.GPU
|
275 |
def generate_music(prime, num_gen_tokens, num_gen_batches, model_temperature, model_top_p):
|
276 |
"""Generate music tokens given prime tokens and parameters."""
|
277 |
+
|
278 |
+
if len(prime) > 7168:
|
279 |
+
prime = [18816] + prime[-7168:]
|
280 |
+
|
281 |
inputs = prime if prime else [18816]
|
282 |
print("Generating...")
|
283 |
inp = torch.LongTensor([inputs] * num_gen_batches).cuda()
|
|
|
417 |
|
418 |
def clear():
|
419 |
"""Clear outputs and reset state."""
|
420 |
+
print_sep()
|
421 |
print('Clear batch...')
|
422 |
+
print_sep()
|
423 |
return None, None, None, [], []
|
424 |
|
425 |
def reset(final_composition=[], generated_batches=[], block_lines=[]):
|
426 |
"""Reset composition state."""
|
427 |
+
print_sep()
|
428 |
+
print('Reset MIDI...')
|
429 |
+
print_sep()
|
430 |
return [], [], []
|
431 |
|
432 |
# -----------------------------
|