asigalov61 commited on
Commit
d46af9a
·
verified ·
1 Parent(s): 45cd096

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -7
app.py CHANGED
@@ -443,10 +443,14 @@ def CompareMIDIs(input_src_midi, input_trg_midi, input_sampling_resolution, inpu
443
 
444
  comp_cos_sims.append(cos_sim)
445
 
446
- min_cos_sim = min(comp_cos_sims)
447
- avg_cos_sim = sum(comp_cos_sims) / len(comp_cos_sims)
448
- max_cos_sim = max(comp_cos_sims)
449
 
 
 
 
 
450
  print('=' * 70)
451
  print('Done!')
452
  print('=' * 70)
@@ -476,7 +480,7 @@ def CompareMIDIs(input_src_midi, input_trg_midi, input_sampling_resolution, inpu
476
  print('-' * 70)
477
  print('Req execution time:', (reqtime.time() - start_time), 'sec')
478
 
479
- return output_src_audio, output_src_plot, output_trg_audio, output_trg_plot
480
 
481
  # =================================================================================================
482
 
@@ -519,7 +523,11 @@ if __name__ == "__main__":
519
 
520
  run_btn = gr.Button("compare", variant="primary")
521
 
522
- gr.Markdown("## Inpainting results")
 
 
 
 
523
 
524
  output_src_audio = gr.Audio(label="Source MIDI audio", format="mp3", elem_id="midi_audio")
525
  output_src_plot = gr.Plot(label="Source MIDI plot")
@@ -528,14 +536,14 @@ if __name__ == "__main__":
528
  output_trg_plot = gr.Plot(label="Target MIDI plot")
529
 
530
  run_event = run_btn.click(CompareMIDIs, [input_src_midi, input_trg_midi, input_sampling_resolution, input_sampling_overlap],
531
- [output_src_audio, output_src_plot, output_trg_audio, output_trg_plot])
532
 
533
  gr.Examples(
534
  [
535
  ["Honesty.kar", "Hotel California.mid", 200, 0]
536
  ],
537
  [input_src_midi, input_trg_midi, input_sampling_resolution, input_sampling_overlap],
538
- [output_src_audio, output_src_plot, output_trg_audio, output_trg_plot],
539
  CompareMIDIs,
540
  cache_examples=True,
541
  )
 
443
 
444
  comp_cos_sims.append(cos_sim)
445
 
446
+ output_min_sim = min(comp_cos_sims)
447
+ output_avg_sim = sum(comp_cos_sims) / len(comp_cos_sims)
448
+ output_max_sim = max(comp_cos_sims)
449
 
450
+ print('Min sim:', output_min_sim)
451
+ print('Avg sim:', output_avg_sim)
452
+ print('max sim:', output_max_sim)
453
+
454
  print('=' * 70)
455
  print('Done!')
456
  print('=' * 70)
 
480
  print('-' * 70)
481
  print('Req execution time:', (reqtime.time() - start_time), 'sec')
482
 
483
+ return output_src_audio, output_src_plot, output_trg_audio, output_trg_plot, output_min_sim, output_avg_sim, output_max_sim
484
 
485
  # =================================================================================================
486
 
 
523
 
524
  run_btn = gr.Button("compare", variant="primary")
525
 
526
+ gr.Markdown("## MIDI comparison results")
527
+
528
+ output_min_sim = gr.Number(label="Minimum similarity")
529
+ output_avg_sim = gr.Number(label="Average similarity")
530
+ output_max_sim = gr.Number(label="Maximum similarity")
531
 
532
  output_src_audio = gr.Audio(label="Source MIDI audio", format="mp3", elem_id="midi_audio")
533
  output_src_plot = gr.Plot(label="Source MIDI plot")
 
536
  output_trg_plot = gr.Plot(label="Target MIDI plot")
537
 
538
  run_event = run_btn.click(CompareMIDIs, [input_src_midi, input_trg_midi, input_sampling_resolution, input_sampling_overlap],
539
+ [output_src_audio, output_src_plot, output_trg_audio, output_trg_plot, output_min_sim, output_avg_sim, output_max_sim])
540
 
541
  gr.Examples(
542
  [
543
  ["Honesty.kar", "Hotel California.mid", 200, 0]
544
  ],
545
  [input_src_midi, input_trg_midi, input_sampling_resolution, input_sampling_overlap],
546
+ [output_src_audio, output_src_plot, output_trg_audio, output_trg_plot, output_min_sim, output_avg_sim, output_max_sim],
547
  CompareMIDIs,
548
  cache_examples=True,
549
  )