projectlosangeles commited on
Commit
b251ba1
·
verified ·
1 Parent(s): 0415d92

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +55 -25
app.py CHANGED
@@ -167,7 +167,6 @@ def load_midi(input_midi):
167
  print('Score hss', len(melody_chords), 'tokens')
168
  print('=' * 70)
169
 
170
-
171
  return melody_chords
172
 
173
  else:
@@ -176,10 +175,16 @@ def load_midi(input_midi):
176
  #==================================================================================
177
 
178
  @spaces.GPU
179
- def Generate_Music_Bridge(input_midi,
180
- model_temperature,
181
- model_sampling_top_p
182
- ):
 
 
 
 
 
 
183
 
184
  #===============================================================================
185
 
@@ -188,20 +193,33 @@ def Generate_Music_Bridge(input_midi,
188
  start_time = reqtime.time()
189
  print('=' * 70)
190
 
191
- print('=' * 70)
192
- print('Requested settings:')
193
- print('=' * 70)
194
- fn = os.path.basename(input_midi)
195
- fn1 = fn.split('.')[0]
196
- print('Input MIDI file name:', fn)
197
- print('Model temperature:', model_temperature)
198
- print('Model top p:', model_sampling_top_p)
199
-
200
- print('=' * 70)
201
 
202
- #==================================================================
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
203
 
204
- if input_midi is not None:
205
 
206
  print('Loading MIDI...')
207
 
@@ -460,11 +478,17 @@ with gr.Blocks() as demo:
460
  output_plot = gr.Plot(label="MIDI score plot")
461
  output_midi = gr.File(label="MIDI file", file_types=[".mid"])
462
 
463
- generate_btn.click(Generate_Music_Bridge,
464
- [input_midi,
 
 
 
 
 
 
465
  model_temperature,
466
- model_sampling_top_p
467
- ],
468
  [output_audio,
469
  output_plot,
470
  output_midi
@@ -472,17 +496,23 @@ with gr.Blocks() as demo:
472
  )
473
 
474
  gr.Examples(
475
- [["Sharing The Night Together.kar", 0.9, 0.96]
476
  ],
477
- [input_midi,
 
 
 
 
 
 
478
  model_temperature,
479
- model_sampling_top_p
480
  ],
481
  [output_audio,
482
  output_plot,
483
  output_midi
484
  ],
485
- Generate_Music_Bridge
486
  )
487
 
488
  #==================================================================================
 
167
  print('Score hss', len(melody_chords), 'tokens')
168
  print('=' * 70)
169
 
 
170
  return melody_chords
171
 
172
  else:
 
175
  #==================================================================================
176
 
177
  @spaces.GPU
178
+ def Inpaint_Pitches(patches_to_inpaint,
179
+ inpaint_every_nth_note,
180
+ forbid_original_pitches,
181
+ max_inpainted_pitch_dev,
182
+ max_inpaint_tries_per_note,
183
+ num_prime_tokens,
184
+ num_mem_tokens,
185
+ model_temperature,
186
+ model_sampling_top_k
187
+ ):
188
 
189
  #===============================================================================
190
 
 
193
  start_time = reqtime.time()
194
  print('=' * 70)
195
 
196
+ if input_midi is not None:
 
 
 
 
 
 
 
 
 
197
 
198
+ print('=' * 70)
199
+ print('Requested settings:')
200
+ print('=' * 70)
201
+ fn = os.path.basename(input_midi)
202
+ fn1 = fn.split('.')[0]
203
+ print('Input MIDI file name:', fn)
204
+ print('-' * 70)
205
+
206
+ print('Patches to inpaint:', patches_to_inpaint)
207
+ print('Inpaint every nth note:', inpaint_every_nth_note)
208
+ print('Forbid original pitches:', forbid_original_pitches)
209
+ print('Max inpainted pitch dev:', max_inpainted_pitch_dev)
210
+ print('Max inpaint tries per note:', max_inpaint_tries_per_note)
211
+ print('-' * 70)
212
+ print('Number of prime tokens:', num_prime_tokens)
213
+ print('Number of memory tokens:', num_mem_tokens)
214
+ print('-' * 70)
215
+ print('Model temperature:', model_temperature)
216
+ print('Model top p:', model_sampling_top_k)
217
+
218
+ print('=' * 70)
219
+
220
+ #==================================================================
221
 
222
+
223
 
224
  print('Loading MIDI...')
225
 
 
478
  output_plot = gr.Plot(label="MIDI score plot")
479
  output_midi = gr.File(label="MIDI file", file_types=[".mid"])
480
 
481
+ generate_btn.click(Inpaint_Pitches,
482
+ [patches_to_inpaint,
483
+ inpaint_every_nth_note,
484
+ forbid_original_pitches,
485
+ max_inpainted_pitch_dev,
486
+ max_inpaint_tries_per_note,
487
+ num_prime_tokens,
488
+ num_mem_tokens,
489
  model_temperature,
490
+ model_sampling_top_k
491
+ ],
492
  [output_audio,
493
  output_plot,
494
  output_midi
 
496
  )
497
 
498
  gr.Examples(
499
+ [["Orpheus-Music-Transformer-MI-Seed-1.mid", 0.9, 0.96]
500
  ],
501
+ [patches_to_inpaint,
502
+ inpaint_every_nth_note,
503
+ forbid_original_pitches,
504
+ max_inpainted_pitch_dev,
505
+ max_inpaint_tries_per_note,
506
+ num_prime_tokens,
507
+ num_mem_tokens,
508
  model_temperature,
509
+ model_sampling_top_k
510
  ],
511
  [output_audio,
512
  output_plot,
513
  output_midi
514
  ],
515
+ Inpaint_Pitches
516
  )
517
 
518
  #==================================================================================