asigalov61 commited on
Commit
79d84fe
1 Parent(s): 87aa9dd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -14
app.py CHANGED
@@ -23,7 +23,7 @@ in_space = os.getenv("SYSTEM") == "spaces"
23
  # =================================================================================================
24
 
25
  @spaces.GPU
26
- def GenerateDrums(input_midi, input_num_tokens, input_top_k_value):
27
  print('=' * 70)
28
  print('Req start time: {:%Y-%m-%d %H:%M:%S}'.format(datetime.datetime.now(PDT)))
29
  start_time = reqtime.time()
@@ -75,6 +75,7 @@ def GenerateDrums(input_midi, input_num_tokens, input_top_k_value):
75
  print('Input file name:', fn)
76
  print('Req num toks:', input_num_tokens)
77
  print('Req top_k value:', input_top_k_value)
 
78
  print('-' * 70)
79
 
80
  #===============================================================================
@@ -120,7 +121,7 @@ def GenerateDrums(input_midi, input_num_tokens, input_top_k_value):
120
  output = []
121
 
122
  temperature=0.9
123
- max_drums_limit=5
124
  num_memory_tokens=4096
125
 
126
  for c in comp_times[:input_num_tokens]:
@@ -291,6 +292,7 @@ if __name__ == "__main__":
291
  input_midi = gr.File(label="Input MIDI", file_types=[".midi", ".mid", ".kar"])
292
  input_num_tokens = gr.Slider(16, 2048, value=256, step=16, label="Number of composition chords to generate drums for")
293
  input_top_k_value = gr.Slider(1, 50, value=5, step=1, label="Model sampling top_k value")
 
294
 
295
  run_btn = gr.Button("generate", variant="primary")
296
 
@@ -303,21 +305,21 @@ if __name__ == "__main__":
303
  output_midi = gr.File(label="Output MIDI file", file_types=[".mid"])
304
 
305
 
306
- run_event = run_btn.click(GenerateDrums, [input_midi, input_num_tokens, input_top_k_value],
307
  [output_midi_title, output_midi_summary, output_midi, output_audio, output_plot])
308
 
309
  gr.Examples(
310
- [["Ultimate-Drums-Transformer-Melody-Seed-1.mid", 128, 5],
311
- ["Ultimate-Drums-Transformer-Melody-Seed-2.mid", 128, 5],
312
- ["Ultimate-Drums-Transformer-Melody-Seed-3.mid", 128, 5],
313
- ["Ultimate-Drums-Transformer-Melody-Seed-4.mid", 128, 5],
314
- ["Ultimate-Drums-Transformer-Melody-Seed-5.mid", 128, 5],
315
- ["Ultimate-Drums-Transformer-Melody-Seed-6.mid", 128, 5],
316
- ["Ultimate-Drums-Transformer-MI-Seed-1.mid", 128, 5],
317
- ["Ultimate-Drums-Transformer-MI-Seed-2.mid", 128, 5],
318
- ["Ultimate-Drums-Transformer-MI-Seed-3.mid", 128, 5],
319
- ["Ultimate-Drums-Transformer-MI-Seed-4.mid", 128, 5]],
320
- [input_midi, input_num_tokens, input_top_k_value],
321
  [output_midi_title, output_midi_summary, output_midi, output_audio, output_plot],
322
  GenerateDrums,
323
  cache_examples=True,
 
23
  # =================================================================================================
24
 
25
  @spaces.GPU
26
+ def GenerateDrums(input_midi, input_num_tokens, input_top_k_value, input_max_drums_per_step):
27
  print('=' * 70)
28
  print('Req start time: {:%Y-%m-%d %H:%M:%S}'.format(datetime.datetime.now(PDT)))
29
  start_time = reqtime.time()
 
75
  print('Input file name:', fn)
76
  print('Req num toks:', input_num_tokens)
77
  print('Req top_k value:', input_top_k_value)
78
+ print('Req max number of drums pitches:', input_max_drums_per_step)
79
  print('-' * 70)
80
 
81
  #===============================================================================
 
121
  output = []
122
 
123
  temperature=0.9
124
+ max_drums_limit=input_max_drums_per_step
125
  num_memory_tokens=4096
126
 
127
  for c in comp_times[:input_num_tokens]:
 
292
  input_midi = gr.File(label="Input MIDI", file_types=[".midi", ".mid", ".kar"])
293
  input_num_tokens = gr.Slider(16, 2048, value=256, step=16, label="Number of composition chords to generate drums for")
294
  input_top_k_value = gr.Slider(1, 50, value=5, step=1, label="Model sampling top_k value")
295
+ input_max_drums_per_step = gr.Slider(1, 10, value=5, step=1, label="Maximum number of drums pitches per step")
296
 
297
  run_btn = gr.Button("generate", variant="primary")
298
 
 
305
  output_midi = gr.File(label="Output MIDI file", file_types=[".mid"])
306
 
307
 
308
+ run_event = run_btn.click(GenerateDrums, [input_midi, input_num_tokens, input_top_k_value, input_max_drums_per_step],
309
  [output_midi_title, output_midi_summary, output_midi, output_audio, output_plot])
310
 
311
  gr.Examples(
312
+ [["Ultimate-Drums-Transformer-Melody-Seed-1.mid", 128, 5, 5],
313
+ ["Ultimate-Drums-Transformer-Melody-Seed-2.mid", 128, 5, 5],
314
+ ["Ultimate-Drums-Transformer-Melody-Seed-3.mid", 128, 5, 5],
315
+ ["Ultimate-Drums-Transformer-Melody-Seed-4.mid", 128, 5, 5],
316
+ ["Ultimate-Drums-Transformer-Melody-Seed-5.mid", 128, 5, 5],
317
+ ["Ultimate-Drums-Transformer-Melody-Seed-6.mid", 128, 5, 5],
318
+ ["Ultimate-Drums-Transformer-MI-Seed-1.mid", 128, 5, 5],
319
+ ["Ultimate-Drums-Transformer-MI-Seed-2.mid", 128, 5, 5],
320
+ ["Ultimate-Drums-Transformer-MI-Seed-3.mid", 128, 5, 5],
321
+ ["Ultimate-Drums-Transformer-MI-Seed-4.mid", 128, 5, 5]],
322
+ [input_midi, input_num_tokens, input_top_k_value, input_max_drums_per_step],
323
  [output_midi_title, output_midi_summary, output_midi, output_audio, output_plot],
324
  GenerateDrums,
325
  cache_examples=True,