asigalov61 commited on
Commit
f3f03b1
·
verified ·
1 Parent(s): d9add7e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -12
app.py CHANGED
@@ -91,7 +91,7 @@ midi_gas_pse_pickle = hf_hub_download(repo_id='asigalov61/MIDI-GAS',
91
  repo_type='dataset'
92
  )
93
 
94
- midi_gas_pse = [a[3] for a in TMIDIX.Tegridy_Any_Pickle_File_Reader(midi_gas_pse_pickle)]
95
 
96
  print('=' * 70)
97
  print('Done!')
@@ -102,7 +102,7 @@ print('=' * 70)
102
  print('=' * 70)
103
  print('Instantiating model...')
104
 
105
- device_type = 'cpu'
106
  dtype = 'bfloat16'
107
 
108
  ptdtype = {'bfloat16': torch.bfloat16, 'float16': torch.float16}[dtype]
@@ -247,7 +247,7 @@ def select_best_output(outputs, embeddings, src_embeddings, top_k=10):
247
 
248
  #==================================================================================
249
 
250
- # @spaces.GPU
251
  def Classify_MIDI_Genre(input_midi,
252
  input_melody,
253
  melody_patch,
@@ -327,10 +327,10 @@ def Classify_MIDI_Genre(input_midi,
327
  print('Rendering results...')
328
  print('=' * 70)
329
 
330
- sname = ' --- '.join(all_scores[result[1][0]][:3])
331
- print('Sample entry', sname)
332
 
333
- song = all_scores[result[1][0]][3]
334
  print('Sample INTs', song[:15])
335
  print('=' * 70)
336
 
@@ -402,18 +402,18 @@ def Classify_MIDI_Genre(input_midi,
402
 
403
 
404
  audio = midi_to_colab_audio(new_fn,
405
- soundfont_path=SOUDFONT_PATH,
406
- sample_rate=16000,
407
- volume_scale=10,
408
- output_for_gradio=True
409
- )
410
 
411
  print('Done!')
412
  print('=' * 70)
413
 
414
  #===============================================================================
415
 
416
- output_title = str(sname)
417
  output_midi = str(new_fn)
418
  output_audio = (16000, audio)
419
 
 
91
  repo_type='dataset'
92
  )
93
 
94
+ midi_gas_pse = np.array([a[3] for a in TMIDIX.Tegridy_Any_Pickle_File_Reader(midi_gas_pse_pickle)])
95
 
96
  print('=' * 70)
97
  print('Done!')
 
102
  print('=' * 70)
103
  print('Instantiating model...')
104
 
105
+ device_type = 'cuda'
106
  dtype = 'bfloat16'
107
 
108
  ptdtype = {'bfloat16': torch.bfloat16, 'float16': torch.float16}[dtype]
 
247
 
248
  #==================================================================================
249
 
250
+ @spaces.GPU
251
  def Classify_MIDI_Genre(input_midi,
252
  input_melody,
253
  melody_patch,
 
327
  print('Rendering results...')
328
  print('=' * 70)
329
 
330
+ song_name = ' --- '.join(midi_gas_ps[result[1][0]][:3])
331
+ print('Song entry', song_name)
332
 
333
+ song = midi_gas_ps[result[1][0]][3]
334
  print('Sample INTs', song[:15])
335
  print('=' * 70)
336
 
 
402
 
403
 
404
  audio = midi_to_colab_audio(new_fn,
405
+ soundfont_path=SOUDFONT_PATH,
406
+ sample_rate=16000,
407
+ volume_scale=10,
408
+ output_for_gradio=True
409
+ )
410
 
411
  print('Done!')
412
  print('=' * 70)
413
 
414
  #===============================================================================
415
 
416
+ output_title = str(song_name)
417
  output_midi = str(new_fn)
418
  output_audio = (16000, audio)
419