asigalov61 commited on
Commit
b8a6849
·
verified ·
1 Parent(s): 87a12d2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -43
app.py CHANGED
@@ -510,29 +510,25 @@ if __name__ == "__main__":
510
 
511
  input_midi = gr.File(label="Input MIDI", file_types=[".midi", ".mid", ".kar"])
512
 
513
- gr.Markdown("## Select generation type")
514
 
515
- input_gen_type = gr.Radio(["Controlled", "Freestyle"], value='Controlled', label="Generation type")
516
-
517
- gr.Markdown("## Controlled generation options")
518
-
519
- input_number_prime_chords = gr.Slider(0, 512, value=0, step=8, label="Number of prime chords")
520
- input_number_gen_chords = gr.Slider(16, 512, value=256, step=8, label="Number of chords to generate")
521
- input_use_original_durations = gr.Checkbox(label="Use original durations", value=True)
522
- input_match_original_pitches_counts = gr.Checkbox(label="Match original pitches counts", value=True)
523
 
524
- gr.Markdown("## Freestyle continuation options")
525
 
526
- input_number_prime_tokens = gr.Slider(0, 1024, value=512, step=16, label="Number of prime tokens")
527
- input_number_gen_tokens = gr.Slider(0, 3072, value=1024, step=16, label="Number of tokens to generate")
528
 
529
  gr.Markdown("## Model options")
530
 
531
- input_num_memory_tokens = gr.Slider(1024, 4096, value=2048, step=16, label="Number of memory tokens")
532
- input_model_temperature = gr.Slider(0.1, 1.0, value=0.9, step=0.05, label="Model temperature")
533
- input_model_top_p = gr.Slider(0.1, 1, value=0.96, step=0.01, label="Model sampling top p value")
534
 
535
- run_btn = gr.Button("generate", variant="primary")
536
 
537
  gr.Markdown("## Generation results")
538
 
@@ -543,40 +539,32 @@ if __name__ == "__main__":
543
  output_midi = gr.File(label="Output MIDI file", file_types=[".mid"])
544
 
545
  run_event = run_btn.click(Convert_Score_to_Performance, [input_midi,
546
- input_gen_type,
547
- input_number_prime_chords,
548
- input_number_gen_chords,
549
- input_use_original_durations,
550
- input_match_original_pitches_counts,
551
- input_number_prime_tokens,
552
- input_number_gen_tokens,
553
- input_num_memory_tokens,
554
- input_model_temperature,
555
- input_model_top_p,
556
- ],
557
  [output_midi_title, output_midi_summary, output_midi, output_audio, output_plot])
558
 
559
  gr.Examples(
560
- [["asap_midi_score_21.mid", "Controlled", 0, 512, True, True, 512, 1024, 2048, 0.9, 0.96],
561
- ["asap_midi_score_45.mid", "Controlled", 128, 256, False, False, 512, 1024, 2048, 0.9, 0.96],
562
- ["asap_midi_score_69.mid", "Controlled", 128, 256, True, True, 512, 1024, 2048, 0.9, 0.96],
563
- ["asap_midi_score_118.mid", "Controlled", 128, 256, True, True, 512, 1024, 2048, 0.9, 0.96],
564
- ["asap_midi_score_167.mid", "Controlled", 128, 256, True, True, 512, 1024, 2048, 0.9, 0.96],
565
  ],
566
  [input_midi,
567
- input_gen_type,
568
- input_number_prime_chords,
569
- input_number_gen_chords,
570
- input_use_original_durations,
571
- input_match_original_pitches_counts,
572
- input_number_prime_tokens,
573
- input_number_gen_tokens,
574
- input_num_memory_tokens,
575
- input_model_temperature,
576
- input_model_top_p,
577
  ],
578
  [output_midi_title, output_midi_summary, output_midi, output_audio, output_plot],
579
- Generate_Rock_Song,
580
  cache_examples=True,
581
  )
582
 
 
510
 
511
  input_midi = gr.File(label="Input MIDI", file_types=[".midi", ".mid", ".kar"])
512
 
513
+ gr.Markdown("## Select conversion type")
514
 
515
+ input_conv_type = gr.Radio(["Durations and Velocities", "Durations", "Velocities"],
516
+ value="Durations and Velocities",
517
+ label="Conversion type"
518
+ )
 
 
 
 
519
 
520
+ gr.Markdown("## Conversion options")
521
 
522
+ input_number_prime_notes = gr.Slider(0, 512, value=0, step=8, label="Number of prime notes")
523
+ input_number_conv_notes = gr.Slider(0, 3072, value=1024, step=16, label="Number of notes to convert")
524
 
525
  gr.Markdown("## Model options")
526
 
527
+ input_model_dur_top_k = gr.Slider(1, 100, value=1, step=1, label="Model sampling top k value for durations")
528
+ input_model_dur_temperature = gr.Slider(0.5, 1.5, value=1.1, step=0.05, label="Model temperature for durations")
529
+ input_model_vel_temperature = gr.Slider(0.5, 1.5, value=1.5, step=0.05, label="Model temperature for velocities")
530
 
531
+ run_btn = gr.Button("convert", variant="primary")
532
 
533
  gr.Markdown("## Generation results")
534
 
 
539
  output_midi = gr.File(label="Output MIDI file", file_types=[".mid"])
540
 
541
  run_event = run_btn.click(Convert_Score_to_Performance, [input_midi,
542
+ input_conv_type,
543
+ input_number_prime_notes,
544
+ input_number_conv_notes,
545
+ input_model_dur_top_k,
546
+ input_model_dur_temperature,
547
+ input_model_vel_temperature
548
+ ],
 
 
 
 
549
  [output_midi_title, output_midi_summary, output_midi, output_audio, output_plot])
550
 
551
  gr.Examples(
552
+ [["asap_midi_score_21.mid", "Durations and Velocities", 8, 600, 1, 1.1, 1.5],
553
+ ["asap_midi_score_45.mid", "Durations and Velocities", 8, 600, 1, 1.1, 1.5],
554
+ ["asap_midi_score_69.mid", "Durations and Velocities", 8, 600, 1, 1.1, 1.5],
555
+ ["asap_midi_score_118.mid", "Durations and Velocities", 8, 600, 1, 1.1, 1.5],
556
+ ["asap_midi_score_167.mid", "Durations and Velocities", 8, 600, 1, 1.1, 1.5],
557
  ],
558
  [input_midi,
559
+ input_conv_type,
560
+ input_number_prime_notes,
561
+ input_number_conv_notes,
562
+ input_model_dur_top_k,
563
+ input_model_dur_temperature,
564
+ input_model_vel_temperature
 
 
 
 
565
  ],
566
  [output_midi_title, output_midi_summary, output_midi, output_audio, output_plot],
567
+ Convert_Score_to_Performance,
568
  cache_examples=True,
569
  )
570