KingNish commited on
Commit
75625eb
·
verified ·
1 Parent(s): 067f38e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -1
app.py CHANGED
@@ -96,6 +96,12 @@ codec_model.load_state_dict(parameter_dict['codec_model'])
96
  codec_model.to(device)
97
  codec_model.eval()
98
 
 
 
 
 
 
 
99
 
100
  def generate_music(
101
  max_new_tokens=5,
@@ -219,6 +225,8 @@ def generate_music(
219
  BlockTokenRangeProcessor(32016, 32016)]),
220
  guidance_scale=guidance_scale,
221
  use_cache=True,
 
 
222
  )
223
  if output_seq[0][-1].item() != mmtokenizer.eoa:
224
  tensor_eoa = torch.as_tensor([[mmtokenizer.eoa]]).to(model.device)
@@ -257,6 +265,7 @@ def generate_music(
257
  np.save(inst_save_path, instrumentals)
258
  stage1_output_set.append(vocal_save_path)
259
  stage1_output_set.append(inst_save_path)
 
260
 
261
  print("Converting to Audio...")
262
 
@@ -308,7 +317,6 @@ def generate_music(
308
  print(e)
309
 
310
  # vocoder to upsample audios
311
- vocal_decoder, inst_decoder = build_codec_model(config_path, vocal_decoder_path, inst_decoder_path)
312
  vocoder_output_dir = os.path.join(output_dir, 'vocoder')
313
  vocoder_stems_dir = os.path.join(vocoder_output_dir, 'stems')
314
  vocoder_mix_dir = os.path.join(vocoder_output_dir, 'mix')
 
96
  codec_model.to(device)
97
  codec_model.eval()
98
 
99
+ vocal_decoder, inst_decoder = build_codec_model(config_path, vocal_decoder_path, inst_decoder_path)
100
+ vocal_decoder.to(device)
101
+ inst_decoder.to(device)
102
+ vocal_decoder.eval()
103
+ inst_decoder.eval()
104
+
105
 
106
  def generate_music(
107
  max_new_tokens=5,
 
225
  BlockTokenRangeProcessor(32016, 32016)]),
226
  guidance_scale=guidance_scale,
227
  use_cache=True,
228
+ top_k=50,
229
+ num_beams=1,
230
  )
231
  if output_seq[0][-1].item() != mmtokenizer.eoa:
232
  tensor_eoa = torch.as_tensor([[mmtokenizer.eoa]]).to(model.device)
 
265
  np.save(inst_save_path, instrumentals)
266
  stage1_output_set.append(vocal_save_path)
267
  stage1_output_set.append(inst_save_path)
268
+
269
 
270
  print("Converting to Audio...")
271
 
 
317
  print(e)
318
 
319
  # vocoder to upsample audios
 
320
  vocoder_output_dir = os.path.join(output_dir, 'vocoder')
321
  vocoder_stems_dir = os.path.join(vocoder_output_dir, 'stems')
322
  vocoder_mix_dir = os.path.join(vocoder_output_dir, 'mix')