projectlosangeles commited on
Commit
f1fea9b
·
verified ·
1 Parent(s): 9321d56

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -4
app.py CHANGED
@@ -186,6 +186,7 @@ def load_midi(input_midi):
186
  @spaces.GPU
187
  def Humanize_MIDI(input_midi,
188
  num_prime_toks,
 
189
  humanize_durations,
190
  humanize_velocities,
191
  model_temperature,
@@ -206,6 +207,7 @@ def Humanize_MIDI(input_midi,
206
  fn1 = fn.split('.')[0]
207
  print('Input MIDI file name:', fn)
208
  print('Number of prime tokens:', num_prime_toks)
 
209
  print('Humanize durations:', humanize_durations)
210
  print('Humanize velocities:', humanize_velocities)
211
  print('Model temperature:', model_temperature)
@@ -238,6 +240,8 @@ def Humanize_MIDI(input_midi,
238
  print('Generating...')
239
 
240
  final_song = score[:num_prime_toks]
 
 
241
 
242
  for t in tqdm.tqdm(score[num_prime_toks:]):
243
 
@@ -276,6 +280,11 @@ def Humanize_MIDI(input_midi,
276
 
277
  final_song.append(dur_vel_tok)
278
 
 
 
 
 
 
279
  #==================================================================
280
 
281
  print('=' * 70)
@@ -428,11 +437,12 @@ with gr.Blocks() as demo:
428
  )
429
 
430
  gr.Markdown("## Generation options")
431
-
432
- num_prime_toks = gr.Slider(0, 1024, value=0, step=1, label="Number of prime tokens")
433
-
434
  humanize_durations = gr.Checkbox(value=False, label="Humanize durations")
435
  humanize_velocities = gr.Checkbox(value=True, label="Humanize velocities")
 
 
 
436
 
437
  model_temperature = gr.Slider(0.1, 1, value=0.9, step=0.01, label="Model temperature")
438
  model_sampling_top_p = gr.Slider(0.1, 0.99, value=0.96, step=0.01, label="Model sampling top p value")
@@ -449,6 +459,7 @@ with gr.Blocks() as demo:
449
  generate_btn.click(Humanize_MIDI,
450
  [input_midi,
451
  num_prime_toks,
 
452
  humanize_durations,
453
  humanize_velocities,
454
  model_temperature,
@@ -461,10 +472,11 @@ with gr.Blocks() as demo:
461
  )
462
 
463
  gr.Examples(
464
- [["Sharing The Night Together.kar", 0, False, True, 0.9, 0.96]
465
  ],
466
  [input_midi,
467
  num_prime_toks,
 
468
  humanize_durations,
469
  humanize_velocities,
470
  model_temperature,
 
186
  @spaces.GPU
187
  def Humanize_MIDI(input_midi,
188
  num_prime_toks,
189
+ num_hum_notes,
190
  humanize_durations,
191
  humanize_velocities,
192
  model_temperature,
 
207
  fn1 = fn.split('.')[0]
208
  print('Input MIDI file name:', fn)
209
  print('Number of prime tokens:', num_prime_toks)
210
+ print('Number of notes to humanize:', num_hum_notes)
211
  print('Humanize durations:', humanize_durations)
212
  print('Humanize velocities:', humanize_velocities)
213
  print('Model temperature:', model_temperature)
 
240
  print('Generating...')
241
 
242
  final_song = score[:num_prime_toks]
243
+
244
+ hn_count = 0
245
 
246
  for t in tqdm.tqdm(score[num_prime_toks:]):
247
 
 
280
 
281
  final_song.append(dur_vel_tok)
282
 
283
+ hn_count += 1
284
+
285
+ if hn_count == num_hum_notes:
286
+ break
287
+
288
  #==================================================================
289
 
290
  print('=' * 70)
 
437
  )
438
 
439
  gr.Markdown("## Generation options")
440
+
 
 
441
  humanize_durations = gr.Checkbox(value=False, label="Humanize durations")
442
  humanize_velocities = gr.Checkbox(value=True, label="Humanize velocities")
443
+
444
+ num_prime_toks = gr.Slider(0, 1024, value=0, step=1, label="Number of prime tokens")
445
+ num_hum_notes = gr.Slider(128, 2048, value=512, step=1, label="Number of notes to humanize")
446
 
447
  model_temperature = gr.Slider(0.1, 1, value=0.9, step=0.01, label="Model temperature")
448
  model_sampling_top_p = gr.Slider(0.1, 0.99, value=0.96, step=0.01, label="Model sampling top p value")
 
459
  generate_btn.click(Humanize_MIDI,
460
  [input_midi,
461
  num_prime_toks,
462
+ num_hum_notes,
463
  humanize_durations,
464
  humanize_velocities,
465
  model_temperature,
 
472
  )
473
 
474
  gr.Examples(
475
+ [["Sharing The Night Together.kar", 0, 1024, False, True, 0.9, 0.96]
476
  ],
477
  [input_midi,
478
  num_prime_toks,
479
+ num_hum_notes,
480
  humanize_durations,
481
  humanize_velocities,
482
  model_temperature,