KingNish commited on
Commit
3fe10eb
·
verified ·
1 Parent(s): 6932a08

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -19
app.py CHANGED
@@ -219,7 +219,7 @@ def generate_music(
219
  input_ids=input_ids,
220
  max_new_tokens=max_new_tokens,
221
  min_new_tokens=100,
222
- do_sample=True,
223
  top_p=top_p,
224
  temperature=temperature,
225
  repetition_penalty=repetition_penalty,
@@ -227,8 +227,8 @@ def generate_music(
227
  pad_token_id=mmtokenizer.eoa,
228
  logits_processor=LogitsProcessorList([BlockTokenRangeProcessor(0, 32002), BlockTokenRangeProcessor(32016, 32016)]),
229
  guidance_scale=guidance_scale,
230
- use_cache=True, # KV Caching is enabled here!
231
- top_k=50,
232
  num_beams=1
233
  )
234
  if output_seq[0][-1].item() != mmtokenizer.eoa:
@@ -290,7 +290,7 @@ def generate_music(
290
  for npy in stage1_output_set:
291
  codec_result = np.load(npy)
292
  decodec_rlt = []
293
- with torch.no_grad():
294
  decoded_waveform = codec_model.decode(
295
  torch.as_tensor(codec_result.astype(np.int16), dtype=torch.long).unsqueeze(0).permute(1, 0, 2).to(
296
  device))
@@ -419,22 +419,24 @@ with gr.Blocks() as demo:
419
  gr.Examples(
420
  examples=[
421
  [
422
- "rap piano street tough piercing vocal hip-hop synthesizer clear vocal male",
423
  """[verse]
424
- Late nights grinding, writing down these rhymes
425
- Clock is ticking fast, can't afford to waste time
426
- Haters gonna hate, but I brush it off
427
- Turn the negativity into something strong
428
- Mama working hard, wanna make her proud
429
- Echoes of her prayers cutting through the crowd
430
- Friends turned strangers, but it's all good
431
- Focused on my path like I always knew I would
432
-
433
- [chorus]
434
- This is my life, and I'm aiming for the top
435
- Never gonna quit, no, I'm never gonna stop
436
- Through the highs and lows, I'mma keep it real
437
- Living out my dreams with this mic and a deal
 
 
438
 
439
  """
440
  ],
 
219
  input_ids=input_ids,
220
  max_new_tokens=max_new_tokens,
221
  min_new_tokens=100,
222
+ do_sample=False, # just testing what happens
223
  top_p=top_p,
224
  temperature=temperature,
225
  repetition_penalty=repetition_penalty,
 
227
  pad_token_id=mmtokenizer.eoa,
228
  logits_processor=LogitsProcessorList([BlockTokenRangeProcessor(0, 32002), BlockTokenRangeProcessor(32016, 32016)]),
229
  guidance_scale=guidance_scale,
230
+ use_cache=True,
231
+ # top_k=50,
232
  num_beams=1
233
  )
234
  if output_seq[0][-1].item() != mmtokenizer.eoa:
 
290
  for npy in stage1_output_set:
291
  codec_result = np.load(npy)
292
  decodec_rlt = []
293
+ with torch.inference_mode(), torch.autocast(device_type='cuda', dtype=torch.float16):
294
  decoded_waveform = codec_model.decode(
295
  torch.as_tensor(codec_result.astype(np.int16), dtype=torch.long).unsqueeze(0).permute(1, 0, 2).to(
296
  device))
 
419
  gr.Examples(
420
  examples=[
421
  [
422
+ "Bass Metalcore Thrash Metal Furious bright vocal male Angry aggressive vocal Guitar",
423
  """[verse]
424
+ Step back cause I'll ignite
425
+ Won't quit without a fight
426
+ No escape, gear up, it's a fierce fight
427
+ Brace up, raise your hands up and light
428
+ Fear the might. Step back cause I'll ignite
429
+ Won't back down without a fight
430
+ It keeps going and going, the heat is on.
431
+
432
+ [chorus]
433
+ Hot flame. Hot flame.
434
+ Still here, still holding aim
435
+ I don't care if I'm bright or dim: nah.
436
+ I've made it clear, I'll make it again
437
+ All I want is my crew and my gain.
438
+ I'm feeling wild, got a bit of rebel style.
439
+ Locked inside my mind, hot flame.
440
 
441
  """
442
  ],