Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -248,13 +248,7 @@ def select_best_output(outputs, embeddings, src_embeddings, top_k=10):
|
|
| 248 |
#==================================================================================
|
| 249 |
|
| 250 |
@spaces.GPU
|
| 251 |
-
def Classify_MIDI_Genre(input_midi
|
| 252 |
-
input_melody,
|
| 253 |
-
melody_patch,
|
| 254 |
-
use_nth_note,
|
| 255 |
-
model_temperature,
|
| 256 |
-
model_sampling_top_k
|
| 257 |
-
):
|
| 258 |
|
| 259 |
#===============================================================================
|
| 260 |
|
|
@@ -282,7 +276,7 @@ def Classify_MIDI_Genre(input_midi,
|
|
| 282 |
|
| 283 |
#===============================================================================
|
| 284 |
|
| 285 |
-
print('
|
| 286 |
|
| 287 |
src_score = load_midi(input_midi.name)
|
| 288 |
|
|
@@ -461,25 +455,13 @@ with gr.Blocks() as demo:
|
|
| 461 |
|
| 462 |
#==================================================================================
|
| 463 |
|
| 464 |
-
gr.Markdown("## Upload
|
| 465 |
|
| 466 |
input_midi = gr.File(label="Input MIDI",
|
| 467 |
file_types=[".midi", ".mid", ".kar"]
|
| 468 |
)
|
| 469 |
-
|
| 470 |
-
input_melody = gr.Textbox(value="Hotel California",
|
| 471 |
-
label="Popular melodies database search query",
|
| 472 |
-
info='If the query is not found, random melody will be selected. Custom MIDI overrides search query'
|
| 473 |
-
)
|
| 474 |
-
|
| 475 |
-
gr.Markdown("## Generation options")
|
| 476 |
-
|
| 477 |
-
melody_patch = gr.Slider(-1, 127, value=-1, step=1, label="Source melody MIDI patch")
|
| 478 |
-
use_nth_note = gr.Slider(1, 8, value=1, step=1, label="Use each nth melody note")
|
| 479 |
-
model_temperature = gr.Slider(0.1, 1, value=0.9, step=0.01, label="Model temperature")
|
| 480 |
-
model_sampling_top_k = gr.Slider(1, 100, value=15, step=1, label="Model sampling top k value")
|
| 481 |
|
| 482 |
-
generate_btn = gr.Button("
|
| 483 |
|
| 484 |
gr.Markdown("## Generation results")
|
| 485 |
|
|
@@ -489,12 +471,7 @@ with gr.Blocks() as demo:
|
|
| 489 |
output_midi = gr.File(label="MIDI file", file_types=[".mid"])
|
| 490 |
|
| 491 |
generate_btn.click(Classify_MIDI_Genre,
|
| 492 |
-
[input_midi
|
| 493 |
-
input_melody,
|
| 494 |
-
melody_patch,
|
| 495 |
-
use_nth_note,
|
| 496 |
-
model_temperature,
|
| 497 |
-
model_sampling_top_k
|
| 498 |
],
|
| 499 |
[output_title,
|
| 500 |
output_audio,
|
|
|
|
| 248 |
#==================================================================================
|
| 249 |
|
| 250 |
@spaces.GPU
|
| 251 |
+
def Classify_MIDI_Genre(input_midi):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 252 |
|
| 253 |
#===============================================================================
|
| 254 |
|
|
|
|
| 276 |
|
| 277 |
#===============================================================================
|
| 278 |
|
| 279 |
+
print('Loading and prepping source MIDI...')
|
| 280 |
|
| 281 |
src_score = load_midi(input_midi.name)
|
| 282 |
|
|
|
|
| 455 |
|
| 456 |
#==================================================================================
|
| 457 |
|
| 458 |
+
gr.Markdown("## Upload any MIDI or select an example MIDI below")
|
| 459 |
|
| 460 |
input_midi = gr.File(label="Input MIDI",
|
| 461 |
file_types=[".midi", ".mid", ".kar"]
|
| 462 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 463 |
|
| 464 |
+
generate_btn = gr.Button("Classify", variant="primary")
|
| 465 |
|
| 466 |
gr.Markdown("## Generation results")
|
| 467 |
|
|
|
|
| 471 |
output_midi = gr.File(label="MIDI file", file_types=[".mid"])
|
| 472 |
|
| 473 |
generate_btn.click(Classify_MIDI_Genre,
|
| 474 |
+
[input_midi
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 475 |
],
|
| 476 |
[output_title,
|
| 477 |
output_audio,
|