asigalov61 commited on
Commit
a8bfec5
1 Parent(s): ab2128c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -28,7 +28,7 @@ from midi_to_colab_audio import midi_to_colab_audio
28
 
29
  # =================================================================================================
30
 
31
- @spaces.GPU
32
  def Harmonize_Melody(input_src_midi,
33
  source_melody_transpose_value,
34
  model_top_k_sampling_value,
@@ -117,13 +117,13 @@ def Harmonize_Melody(input_src_midi,
117
 
118
  model_path = 'Melody_Harmonizer_Transformer_Trained_Model_14961_steps_0.4155_loss_0.8664_acc.pth'
119
 
120
- model.load_state_dict(torch.load(model_path))
121
 
122
- model.cuda()
123
 
124
  dtype = torch.bfloat16
125
 
126
- ctx = torch.amp.autocast(device_type='cuda', dtype=dtype)
127
 
128
  model.eval()
129
 
@@ -151,7 +151,7 @@ def Harmonize_Melody(input_src_midi,
151
 
152
  data.append(mel_chunk[j])
153
 
154
- x = torch.tensor([data], dtype=torch.long, device='cuda')
155
 
156
  with ctx:
157
  out = model.generate(x,
 
28
 
29
  # =================================================================================================
30
 
31
+ # @spaces.GPU
32
  def Harmonize_Melody(input_src_midi,
33
  source_melody_transpose_value,
34
  model_top_k_sampling_value,
 
117
 
118
  model_path = 'Melody_Harmonizer_Transformer_Trained_Model_14961_steps_0.4155_loss_0.8664_acc.pth'
119
 
120
+ model.load_state_dict(torch.load(model_path, map_location='cpu'))
121
 
122
+ model.cpu()
123
 
124
  dtype = torch.bfloat16
125
 
126
+ ctx = torch.amp.autocast(device_type='cpu', dtype=dtype)
127
 
128
  model.eval()
129
 
 
151
 
152
  data.append(mel_chunk[j])
153
 
154
+ x = torch.tensor([data], dtype=torch.long, device='cpu')
155
 
156
  with ctx:
157
  out = model.generate(x,