Spaces:
Running
Running
Commit
·
cbc2b68
1
Parent(s):
6fb91e3
Update app.py
Browse files
app.py
CHANGED
|
@@ -15,19 +15,15 @@ import matplotlib.pyplot as plt
|
|
| 15 |
|
| 16 |
in_space = os.getenv("SYSTEM") == "spaces"
|
| 17 |
|
| 18 |
-
def run(
|
| 19 |
-
|
| 20 |
-
if mid == None:
|
| 21 |
-
|
| 22 |
-
for m in progress.tqdm(meta_data):
|
| 23 |
-
mid_seq = m[1][17:-1]
|
| 24 |
-
mid_seq_ticks = m[1][16][1]
|
| 25 |
-
mdata = m[1][:16]
|
| 26 |
-
break
|
| 27 |
-
|
| 28 |
-
elif mid is not None:
|
| 29 |
-
mid_seq = MIDI.midi2score(mid)
|
| 30 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
x = []
|
| 33 |
y = []
|
|
@@ -67,11 +63,6 @@ if __name__ == "__main__":
|
|
| 67 |
|
| 68 |
soundfont_path = "SGM-v2.01-YamahaGrand-Guit-Bass-v2.7.sf2"
|
| 69 |
meta_data_path = "meta-data/LAMD_META_10000.pickle"
|
| 70 |
-
|
| 71 |
-
models_info = {"generic pretrain model": ["skytnt/midi-model", ""],
|
| 72 |
-
"j-pop finetune model": ["skytnt/midi-model-ft", "jpop/"],
|
| 73 |
-
"touhou finetune model": ["skytnt/midi-model-ft", "touhou/"]}
|
| 74 |
-
|
| 75 |
|
| 76 |
print('Loading meta-data...')
|
| 77 |
with open(meta_data_path, 'rb') as f:
|
|
@@ -89,17 +80,8 @@ if __name__ == "__main__":
|
|
| 89 |
" for faster running and longer generation"
|
| 90 |
)
|
| 91 |
|
| 92 |
-
with gr.Tabs():
|
| 93 |
-
with gr.TabItem("instrument prompt") as tab1:
|
| 94 |
-
|
| 95 |
-
search_prompt = gr.Textbox(label="search prompt")
|
| 96 |
-
|
| 97 |
-
with gr.TabItem("midi prompt") as tab2:
|
| 98 |
-
input_midi = gr.File(label="input midi", file_types=[".midi", ".mid"], type="binary")
|
| 99 |
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
input_allow_cc = gr.Checkbox(label="allow midi cc event", value=True)
|
| 103 |
|
| 104 |
search_btn = gr.Button("search", variant="primary")
|
| 105 |
|
|
@@ -108,7 +90,7 @@ if __name__ == "__main__":
|
|
| 108 |
output_midi_seq = gr.Textbox(label="output midi metadata")
|
| 109 |
output_plot = gr.Plot(label="output midi plot")
|
| 110 |
|
| 111 |
-
run_event = search_btn.click(run, [
|
| 112 |
[output_midi_seq, output_midi, output_audio, output_plot])
|
| 113 |
|
| 114 |
app.queue(1).launch(server_port=opt.port, share=opt.share, inbrowser=True)
|
|
|
|
| 15 |
|
| 16 |
in_space = os.getenv("SYSTEM") == "spaces"
|
| 17 |
|
| 18 |
+
def run(midi, progress=gr.Progress()):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
+
mid_seq = MIDI.midi2score(midi)
|
| 21 |
+
|
| 22 |
+
for m in progress.tqdm(meta_data):
|
| 23 |
+
mid_seq = m[1][17:-1]
|
| 24 |
+
mid_seq_ticks = m[1][16][1]
|
| 25 |
+
mdata = m[1][:16]
|
| 26 |
+
break
|
| 27 |
|
| 28 |
x = []
|
| 29 |
y = []
|
|
|
|
| 63 |
|
| 64 |
soundfont_path = "SGM-v2.01-YamahaGrand-Guit-Bass-v2.7.sf2"
|
| 65 |
meta_data_path = "meta-data/LAMD_META_10000.pickle"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
|
| 67 |
print('Loading meta-data...')
|
| 68 |
with open(meta_data_path, 'rb') as f:
|
|
|
|
| 80 |
" for faster running and longer generation"
|
| 81 |
)
|
| 82 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 83 |
|
| 84 |
+
input_midi = gr.File(label="input midi", file_types=[".midi", ".mid"], type="binary")
|
|
|
|
|
|
|
| 85 |
|
| 86 |
search_btn = gr.Button("search", variant="primary")
|
| 87 |
|
|
|
|
| 90 |
output_midi_seq = gr.Textbox(label="output midi metadata")
|
| 91 |
output_plot = gr.Plot(label="output midi plot")
|
| 92 |
|
| 93 |
+
run_event = search_btn.click(run, [input_midi],
|
| 94 |
[output_midi_seq, output_midi, output_audio, output_plot])
|
| 95 |
|
| 96 |
app.queue(1).launch(server_port=opt.port, share=opt.share, inbrowser=True)
|