Spaces:
Runtime error
Runtime error
asigalov61
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -23,7 +23,7 @@ in_space = os.getenv("SYSTEM") == "spaces"
|
|
23 |
# =================================================================================================
|
24 |
|
25 |
@spaces.GPU
|
26 |
-
def GenerateAccompaniment(input_midi, input_num_tokens, input_conditioning_type):
|
27 |
print('=' * 70)
|
28 |
print('Req start time: {:%Y-%m-%d %H:%M:%S}'.format(datetime.datetime.now(PDT)))
|
29 |
start_time = reqtime.time()
|
@@ -75,6 +75,7 @@ def GenerateAccompaniment(input_midi, input_num_tokens, input_conditioning_type)
|
|
75 |
print('Input file name:', fn)
|
76 |
print('Req num toks:', input_num_tokens)
|
77 |
print('Conditioning type:', input_conditioning_type)
|
|
|
78 |
print('-' * 70)
|
79 |
|
80 |
#===============================================================================
|
@@ -185,7 +186,7 @@ def GenerateAccompaniment(input_midi, input_num_tokens, input_conditioning_type)
|
|
185 |
|
186 |
if delta_time != 0:
|
187 |
melody_chords.extend([delta_time, dur+128, ptc+256])
|
188 |
-
if
|
189 |
if len(c) > 1:
|
190 |
times.append(delta_time)
|
191 |
durs.append(dur+128)
|
@@ -376,6 +377,7 @@ if __name__ == "__main__":
|
|
376 |
input_midi = gr.File(label="Input MIDI", file_types=[".midi", ".mid", ".kar"])
|
377 |
input_num_tokens = gr.Slider(4, 128, value=32, step=1, label="Number of composition chords to generate progression for")
|
378 |
input_conditioning_type = gr.Radio(["Chords", "Chords-Times", "Chords-Times-Durations"], label="Conditioning type")
|
|
|
379 |
|
380 |
run_btn = gr.Button("generate", variant="primary")
|
381 |
|
@@ -388,24 +390,24 @@ if __name__ == "__main__":
|
|
388 |
output_midi = gr.File(label="Output MIDI file", file_types=[".mid"])
|
389 |
|
390 |
|
391 |
-
run_event = run_btn.click(GenerateAccompaniment, [input_midi, input_num_tokens, input_conditioning_type],
|
392 |
[output_midi_title, output_midi_summary, output_midi, output_audio, output_plot])
|
393 |
|
394 |
gr.Examples(
|
395 |
-
[["Chords-Progressions-Transformer-Piano-Seed-1.mid", 128, "Chords"],
|
396 |
-
["Chords-Progressions-Transformer-Piano-Seed-2.mid", 128, "Chords"],
|
397 |
-
["Chords-Progressions-Transformer-Piano-Seed-3.mid", 128, "Chords"],
|
398 |
-
["Chords-Progressions-Transformer-Piano-Seed-4.mid", 128, "Chords"],
|
399 |
-
["Chords-Progressions-Transformer-Piano-Seed-5.mid", 128, "Chords"],
|
400 |
-
["Chords-Progressions-Transformer-Piano-Seed-6.mid", 128, "Chords"],
|
401 |
-
["Chords-Progressions-Transformer-MI-Seed-1.mid", 128, "Chords"],
|
402 |
-
["Chords-Progressions-Transformer-MI-Seed-2.mid", 128, "Chords"],
|
403 |
-
["Chords-Progressions-Transformer-MI-Seed-3.mid", 128, "Chords"],
|
404 |
-
["Chords-Progressions-Transformer-MI-Seed-4.mid", 128, "Chords"],
|
405 |
-
["Chords-Progressions-Transformer-MI-Seed-5.mid", 128, "Chords"],
|
406 |
-
["Chords-Progressions-Transformer-MI-Seed-6.mid", 128, "Chords"]
|
407 |
],
|
408 |
-
[input_midi, input_num_tokens, input_conditioning_type],
|
409 |
[output_midi_title, output_midi_summary, output_midi, output_audio, output_plot],
|
410 |
GenerateAccompaniment,
|
411 |
cache_examples=True,
|
|
|
23 |
# =================================================================================================
|
24 |
|
25 |
@spaces.GPU
|
26 |
+
def GenerateAccompaniment(input_midi, input_num_tokens, input_conditioning_type, input_strip_notes):
|
27 |
print('=' * 70)
|
28 |
print('Req start time: {:%Y-%m-%d %H:%M:%S}'.format(datetime.datetime.now(PDT)))
|
29 |
start_time = reqtime.time()
|
|
|
75 |
print('Input file name:', fn)
|
76 |
print('Req num toks:', input_num_tokens)
|
77 |
print('Conditioning type:', input_conditioning_type)
|
78 |
+
print('Strip notes:', input_strip_notes)
|
79 |
print('-' * 70)
|
80 |
|
81 |
#===============================================================================
|
|
|
186 |
|
187 |
if delta_time != 0:
|
188 |
melody_chords.extend([delta_time, dur+128, ptc+256])
|
189 |
+
if input_strip_notes:
|
190 |
if len(c) > 1:
|
191 |
times.append(delta_time)
|
192 |
durs.append(dur+128)
|
|
|
377 |
input_midi = gr.File(label="Input MIDI", file_types=[".midi", ".mid", ".kar"])
|
378 |
input_num_tokens = gr.Slider(4, 128, value=32, step=1, label="Number of composition chords to generate progression for")
|
379 |
input_conditioning_type = gr.Radio(["Chords", "Chords-Times", "Chords-Times-Durations"], label="Conditioning type")
|
380 |
+
input_strip_notes = gr.Checkbox(label="Strip notes from the composition")
|
381 |
|
382 |
run_btn = gr.Button("generate", variant="primary")
|
383 |
|
|
|
390 |
output_midi = gr.File(label="Output MIDI file", file_types=[".mid"])
|
391 |
|
392 |
|
393 |
+
run_event = run_btn.click(GenerateAccompaniment, [input_midi, input_num_tokens, input_conditioning_type, input_strip_notes],
|
394 |
[output_midi_title, output_midi_summary, output_midi, output_audio, output_plot])
|
395 |
|
396 |
gr.Examples(
|
397 |
+
[["Chords-Progressions-Transformer-Piano-Seed-1.mid", 128, "Chords", False],
|
398 |
+
["Chords-Progressions-Transformer-Piano-Seed-2.mid", 128, "Chords-Times", False],
|
399 |
+
["Chords-Progressions-Transformer-Piano-Seed-3.mid", 128, "Chords-Times-Druations", False],
|
400 |
+
["Chords-Progressions-Transformer-Piano-Seed-4.mid", 128, "Chords", False],
|
401 |
+
["Chords-Progressions-Transformer-Piano-Seed-5.mid", 128, "Chords-Times", False],
|
402 |
+
["Chords-Progressions-Transformer-Piano-Seed-6.mid", 128, "Chords-Times-Durations", False],
|
403 |
+
["Chords-Progressions-Transformer-MI-Seed-1.mid", 128, "Chords", False],
|
404 |
+
["Chords-Progressions-Transformer-MI-Seed-2.mid", 128, "Chords-Times", False],
|
405 |
+
["Chords-Progressions-Transformer-MI-Seed-3.mid", 128, "Chords-Times-Durations", False],
|
406 |
+
["Chords-Progressions-Transformer-MI-Seed-4.mid", 128, "Chords-Times", False],
|
407 |
+
["Chords-Progressions-Transformer-MI-Seed-5.mid", 128, "Chords", False],
|
408 |
+
["Chords-Progressions-Transformer-MI-Seed-6.mid", 128, "Chords-Times-Durations", False]
|
409 |
],
|
410 |
+
[input_midi, input_num_tokens, input_conditioning_type, input_strip_notes],
|
411 |
[output_midi_title, output_midi_summary, output_midi, output_audio, output_plot],
|
412 |
GenerateAccompaniment,
|
413 |
cache_examples=True,
|