Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -21,7 +21,7 @@ os.environ['USE_FLASH_ATTENTION'] = '1'
|
|
| 21 |
|
| 22 |
import torch
|
| 23 |
|
| 24 |
-
torch.set_float32_matmul_precision('
|
| 25 |
torch.backends.cuda.matmul.allow_tf32 = True # allow tf32 on matmul
|
| 26 |
torch.backends.cudnn.allow_tf32 = True # allow tf32 on cudnn
|
| 27 |
torch.backends.cuda.enable_mem_efficient_sdp(True)
|
|
@@ -108,7 +108,10 @@ def load_midi(input_midi):
|
|
| 108 |
|
| 109 |
raw_score = TMIDIX.midi2single_track_ms_score(input_midi.name)
|
| 110 |
|
| 111 |
-
escore_notes = TMIDIX.advanced_score_processor(raw_score,
|
|
|
|
|
|
|
|
|
|
| 112 |
|
| 113 |
escore_notes = TMIDIX.augment_enhanced_score_notes(escore_notes[0], timings_divider=16)
|
| 114 |
|
|
@@ -534,6 +537,11 @@ def reset(final_composition=[], generated_batches=[], block_lines=[]):
|
|
| 534 |
|
| 535 |
#==================================================================================
|
| 536 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 537 |
def reset_demo(final_composition=[], generated_batches=[], block_lines=[]):
|
| 538 |
|
| 539 |
final_composition = []
|
|
@@ -629,6 +637,7 @@ with gr.Blocks() as demo:
|
|
| 629 |
|
| 630 |
add_btn = gr.Button("Add batch", variant="primary")
|
| 631 |
remove_btn = gr.Button("Remove batch", variant="stop")
|
|
|
|
| 632 |
|
| 633 |
final_audio_output = gr.Audio(label="Final MIDI audio", format="mp3", elem_id="midi_audio")
|
| 634 |
final_plot_output = gr.Plot(label="Final MIDI plot")
|
|
@@ -639,7 +648,12 @@ with gr.Blocks() as demo:
|
|
| 639 |
|
| 640 |
remove_btn.click(remove_batch, [batch_number, num_gen_tokens, final_composition, generated_batches, block_lines],
|
| 641 |
[final_audio_output, final_plot_output, final_file_output, final_composition, generated_batches, block_lines])
|
| 642 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 643 |
demo.unload(reset_demo)
|
| 644 |
|
| 645 |
#==================================================================================
|
|
|
|
| 21 |
|
| 22 |
import torch
|
| 23 |
|
| 24 |
+
torch.set_float32_matmul_precision('medium')
|
| 25 |
torch.backends.cuda.matmul.allow_tf32 = True # allow tf32 on matmul
|
| 26 |
torch.backends.cudnn.allow_tf32 = True # allow tf32 on cudnn
|
| 27 |
torch.backends.cuda.enable_mem_efficient_sdp(True)
|
|
|
|
| 108 |
|
| 109 |
raw_score = TMIDIX.midi2single_track_ms_score(input_midi.name)
|
| 110 |
|
| 111 |
+
escore_notes = TMIDIX.advanced_score_processor(raw_score,
|
| 112 |
+
return_enhanced_score_notes=True,
|
| 113 |
+
apply_sustain=True
|
| 114 |
+
)
|
| 115 |
|
| 116 |
escore_notes = TMIDIX.augment_enhanced_score_notes(escore_notes[0], timings_divider=16)
|
| 117 |
|
|
|
|
| 537 |
|
| 538 |
#==================================================================================
|
| 539 |
|
| 540 |
+
def clear():
|
| 541 |
+
return None, None, None, [], []
|
| 542 |
+
|
| 543 |
+
#==================================================================================
|
| 544 |
+
|
| 545 |
def reset_demo(final_composition=[], generated_batches=[], block_lines=[]):
|
| 546 |
|
| 547 |
final_composition = []
|
|
|
|
| 637 |
|
| 638 |
add_btn = gr.Button("Add batch", variant="primary")
|
| 639 |
remove_btn = gr.Button("Remove batch", variant="stop")
|
| 640 |
+
clear_btn = gr.ClearButton()
|
| 641 |
|
| 642 |
final_audio_output = gr.Audio(label="Final MIDI audio", format="mp3", elem_id="midi_audio")
|
| 643 |
final_plot_output = gr.Plot(label="Final MIDI plot")
|
|
|
|
| 648 |
|
| 649 |
remove_btn.click(remove_batch, [batch_number, num_gen_tokens, final_composition, generated_batches, block_lines],
|
| 650 |
[final_audio_output, final_plot_output, final_file_output, final_composition, generated_batches, block_lines])
|
| 651 |
+
|
| 652 |
+
clear_btn.click(clear,
|
| 653 |
+
inputs=None,
|
| 654 |
+
outputs=[final_audio_output, final_plot_output, final_file_output, final_composition, block_lines]
|
| 655 |
+
)
|
| 656 |
+
|
| 657 |
demo.unload(reset_demo)
|
| 658 |
|
| 659 |
#==================================================================================
|