asigalov61 commited on
Commit
3897f18
1 Parent(s): 0764984

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -8
app.py CHANGED
@@ -25,7 +25,8 @@ from midi_to_colab_audio import midi_to_colab_audio
25
  @spaces.GPU
26
  def Generate_Rock_Song(input_midi,
27
  input_gen_type,
28
- input_number_prime_chords,
 
29
  input_use_original_durations,
30
  input_match_original_pitches_counts,
31
  input_number_prime_tokens,
@@ -51,6 +52,7 @@ def Generate_Rock_Song(input_midi,
51
  print('Input MIDI file name:', fn)
52
  print('Generation type:', input_gen_type)
53
  print('Number of prime chords:', input_number_prime_chords)
 
54
  print('Use original durations:', input_use_original_durations)
55
  print('Match original pitches counts:', input_match_original_pitches_counts)
56
  print('Number of prime tokens:', input_number_prime_tokens)
@@ -267,7 +269,7 @@ def Generate_Rock_Song(input_midi,
267
  for i in range(input_number_prime_chords):
268
  song.extend(prime_toks[i])
269
 
270
- for i in tqdm.tqdm(range(input_number_prime_chords, len(score_toks))):
271
 
272
  song.extend(score_toks[i])
273
 
@@ -412,13 +414,14 @@ if __name__ == "__main__":
412
  gr.Markdown("## Controlled generation options")
413
 
414
  input_number_prime_chords = gr.Slider(0, 512, value=128, step=8, label="Number of prime chords")
 
415
  input_use_original_durations = gr.Checkbox(label="Use original durations", value=False)
416
  input_match_original_pitches_counts = gr.Checkbox(label="Match original pitches counts", value=False)
417
 
418
  gr.Markdown("## Freestyle continuation options")
419
 
420
  input_number_prime_tokens = gr.Slider(0, 1024, value=512, step=16, label="Number of prime tokens")
421
- input_number_gen_tokens = gr.Slider(0, 2048, value=1024, step=16, label="Number of tokens to generate")
422
 
423
  gr.Markdown("## Model options")
424
 
@@ -438,7 +441,8 @@ if __name__ == "__main__":
438
 
439
  run_event = run_btn.click(Generate_Rock_Song, [input_midi,
440
  input_gen_type,
441
- input_number_prime_chords,
 
442
  input_use_original_durations,
443
  input_match_original_pitches_counts,
444
  input_number_prime_tokens,
@@ -450,13 +454,14 @@ if __name__ == "__main__":
450
  [output_midi_title, output_midi_summary, output_midi, output_audio, output_plot])
451
 
452
  gr.Examples(
453
- [["Sharing The Night Together.kar", "Controlled", 256, True, True, False, 512, 1024, 2048, 0.9, 10],
454
- ["Hotel California.mid", "Controlled", 256, True, True, False, 512, 1024, 2048, 0.9, 10],
455
- ["Nothing Else Matters.kar", "Controlled", 256, True, True, False, 512, 1024, 2048, 0.9, 10],
456
  ],
457
  [input_midi,
458
  input_gen_type,
459
- input_number_prime_chords,
 
460
  input_use_original_durations,
461
  input_match_original_pitches_counts,
462
  input_number_prime_tokens,
 
25
  @spaces.GPU
26
  def Generate_Rock_Song(input_midi,
27
  input_gen_type,
28
+ input_number_prime_chords,
29
+ input_number_gen_chords,
30
  input_use_original_durations,
31
  input_match_original_pitches_counts,
32
  input_number_prime_tokens,
 
52
  print('Input MIDI file name:', fn)
53
  print('Generation type:', input_gen_type)
54
  print('Number of prime chords:', input_number_prime_chords)
55
+ print('Number of chords to generate:', input_number_gen_chords)
56
  print('Use original durations:', input_use_original_durations)
57
  print('Match original pitches counts:', input_match_original_pitches_counts)
58
  print('Number of prime tokens:', input_number_prime_tokens)
 
269
  for i in range(input_number_prime_chords):
270
  song.extend(prime_toks[i])
271
 
272
+ for i in tqdm.tqdm(range(input_number_prime_chords, input_number_prime_chords+input_number_gen_chords)):
273
 
274
  song.extend(score_toks[i])
275
 
 
414
  gr.Markdown("## Controlled generation options")
415
 
416
  input_number_prime_chords = gr.Slider(0, 512, value=128, step=8, label="Number of prime chords")
417
+ input_number_gen_chords = gr.Slider(16, 1024, value=512, step=8, label="Number of chords to generate")
418
  input_use_original_durations = gr.Checkbox(label="Use original durations", value=False)
419
  input_match_original_pitches_counts = gr.Checkbox(label="Match original pitches counts", value=False)
420
 
421
  gr.Markdown("## Freestyle continuation options")
422
 
423
  input_number_prime_tokens = gr.Slider(0, 1024, value=512, step=16, label="Number of prime tokens")
424
+ input_number_gen_tokens = gr.Slider(0, 3072, value=1024, step=16, label="Number of tokens to generate")
425
 
426
  gr.Markdown("## Model options")
427
 
 
441
 
442
  run_event = run_btn.click(Generate_Rock_Song, [input_midi,
443
  input_gen_type,
444
+ input_number_prime_chords,
445
+ input_number_gen_chords,
446
  input_use_original_durations,
447
  input_match_original_pitches_counts,
448
  input_number_prime_tokens,
 
454
  [output_midi_title, output_midi_summary, output_midi, output_audio, output_plot])
455
 
456
  gr.Examples(
457
+ [["Sharing The Night Together.kar", "Controlled", 256, 512, True, True, False, 512, 1024, 2048, 0.9, 10],
458
+ ["Hotel California.mid", "Controlled", 256, 512, True, True, False, 512, 1024, 2048, 0.9, 10],
459
+ ["Nothing Else Matters.kar", "Controlled", 256, 512, True, True, False, 512, 1024, 2048, 0.9, 10],
460
  ],
461
  [input_midi,
462
  input_gen_type,
463
+ input_number_prime_chords,
464
+ input_number_gen_chords,
465
  input_use_original_durations,
466
  input_match_original_pitches_counts,
467
  input_number_prime_tokens,