Spaces:
Running
on
Zero
Running
on
Zero
asigalov61
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -318,12 +318,6 @@ def generate_music(prime,
|
|
318 |
|
319 |
#==================================================================================
|
320 |
|
321 |
-
final_composition = []
|
322 |
-
generated_batches = []
|
323 |
-
block_lines = []
|
324 |
-
|
325 |
-
#==================================================================================
|
326 |
-
|
327 |
def generate_callback(input_midi,
|
328 |
num_prime_tokens,
|
329 |
num_gen_tokens,
|
@@ -334,7 +328,7 @@ def generate_callback(input_midi,
|
|
334 |
model_sampling_top_p
|
335 |
):
|
336 |
|
337 |
-
global generated_batches
|
338 |
generated_batches = []
|
339 |
|
340 |
if not final_composition and input_midi is not None:
|
@@ -475,7 +469,7 @@ def add_batch(batch_number):
|
|
475 |
|
476 |
def remove_batch(batch_number, num_tokens):
|
477 |
|
478 |
-
global final_composition
|
479 |
|
480 |
if len(final_composition) > num_tokens:
|
481 |
final_composition = final_composition[:-num_tokens]
|
@@ -506,9 +500,9 @@ def remove_batch(batch_number, num_tokens):
|
|
506 |
|
507 |
def reset():
|
508 |
|
509 |
-
global final_composition
|
510 |
-
global generated_batches
|
511 |
-
global block_lines
|
512 |
|
513 |
final_composition = []
|
514 |
generated_batches = []
|
@@ -543,6 +537,14 @@ with gr.Blocks() as demo:
|
|
543 |
for faster execution and endless generation!
|
544 |
""")
|
545 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
546 |
gr.Markdown("## Upload seed MIDI or click 'Generate' button for random output")
|
547 |
|
548 |
input_midi = gr.File(label="Input MIDI", file_types=[".midi", ".mid", ".kar"])
|
|
|
318 |
|
319 |
#==================================================================================
|
320 |
|
|
|
|
|
|
|
|
|
|
|
|
|
321 |
def generate_callback(input_midi,
|
322 |
num_prime_tokens,
|
323 |
num_gen_tokens,
|
|
|
328 |
model_sampling_top_p
|
329 |
):
|
330 |
|
331 |
+
# global generated_batches
|
332 |
generated_batches = []
|
333 |
|
334 |
if not final_composition and input_midi is not None:
|
|
|
469 |
|
470 |
def remove_batch(batch_number, num_tokens):
|
471 |
|
472 |
+
# global final_composition
|
473 |
|
474 |
if len(final_composition) > num_tokens:
|
475 |
final_composition = final_composition[:-num_tokens]
|
|
|
500 |
|
501 |
def reset():
|
502 |
|
503 |
+
# global final_composition
|
504 |
+
# global generated_batches
|
505 |
+
# global block_lines
|
506 |
|
507 |
final_composition = []
|
508 |
generated_batches = []
|
|
|
537 |
for faster execution and endless generation!
|
538 |
""")
|
539 |
|
540 |
+
#==================================================================================
|
541 |
+
|
542 |
+
final_composition = gr.State([])
|
543 |
+
generated_batches = gr.State([])
|
544 |
+
block_lines = gr.State([])
|
545 |
+
|
546 |
+
#==================================================================================
|
547 |
+
|
548 |
gr.Markdown("## Upload seed MIDI or click 'Generate' button for random output")
|
549 |
|
550 |
input_midi = gr.File(label="Input MIDI", file_types=[".midi", ".mid", ".kar"])
|