Spaces:
Runtime error
Runtime error
root commited on
Commit ·
e7ab0ec
1
Parent(s): 48275bf
norm description
Browse files- app.py +2 -0
- codeclm/models/codeclm_gen.py +1 -1
- levo_inference.py +4 -7
app.py
CHANGED
|
@@ -140,6 +140,8 @@ def generate_song(lyric, description=None, prompt_audio=None, genre=None, cfg_co
|
|
| 140 |
description = None
|
| 141 |
elif description is not None and description != "":
|
| 142 |
genre = None
|
|
|
|
|
|
|
| 143 |
|
| 144 |
progress(0.0, "Start Generation")
|
| 145 |
start = time.time()
|
|
|
|
| 140 |
description = None
|
| 141 |
elif description is not None and description != "":
|
| 142 |
genre = None
|
| 143 |
+
if description[-1] != ".":
|
| 144 |
+
description = description + "."
|
| 145 |
|
| 146 |
progress(0.0, "Start Generation")
|
| 147 |
start = time.time()
|
codeclm/models/codeclm_gen.py
CHANGED
|
@@ -278,12 +278,12 @@ class CodecLM_gen:
|
|
| 278 |
if type_info is not None:
|
| 279 |
attr["text"]["type_info"] = type_info[i]
|
| 280 |
conditions.append(attr)
|
| 281 |
-
print("conditions", conditions)
|
| 282 |
if prepare_null_condition:
|
| 283 |
cfg_inference = ClassifierFreeGuidanceDropoutInference()
|
| 284 |
null_conditions = cfg_inference(conditions, condition_types=["audio", "text"],
|
| 285 |
customized=None)
|
| 286 |
conditions = conditions + null_conditions
|
|
|
|
| 287 |
tokenized_conditions = self.condition_provider.tokenize(conditions)
|
| 288 |
# import pdb; pdb.set_trace()
|
| 289 |
condition_tensors = self.condition_provider(tokenized_conditions)
|
|
|
|
| 278 |
if type_info is not None:
|
| 279 |
attr["text"]["type_info"] = type_info[i]
|
| 280 |
conditions.append(attr)
|
|
|
|
| 281 |
if prepare_null_condition:
|
| 282 |
cfg_inference = ClassifierFreeGuidanceDropoutInference()
|
| 283 |
null_conditions = cfg_inference(conditions, condition_types=["audio", "text"],
|
| 284 |
customized=None)
|
| 285 |
conditions = conditions + null_conditions
|
| 286 |
+
print("conditions", conditions)
|
| 287 |
tokenized_conditions = self.condition_provider.tokenize(conditions)
|
| 288 |
# import pdb; pdb.set_trace()
|
| 289 |
condition_tensors = self.condition_provider(tokenized_conditions)
|
levo_inference.py
CHANGED
|
@@ -48,7 +48,7 @@ class LeVoInference(torch.nn.Module):
|
|
| 48 |
enforce_eager=True,
|
| 49 |
dtype="bfloat16",
|
| 50 |
gpu_memory_utilization=0.65,
|
| 51 |
-
max_num_seqs=
|
| 52 |
tokenizer=None,
|
| 53 |
skip_tokenizer_init=True,
|
| 54 |
enable_prompt_embeds=True,
|
|
@@ -82,7 +82,7 @@ class LeVoInference(torch.nn.Module):
|
|
| 82 |
pmt_wav = None
|
| 83 |
melody_is_wav = True
|
| 84 |
|
| 85 |
-
description = description if description else '.'
|
| 86 |
description = '[Musicality-very-high]' + ', ' + description
|
| 87 |
generate_inp = {
|
| 88 |
'descriptions': [lyric.replace(" ", " ")],
|
|
@@ -106,11 +106,8 @@ class LeVoInference(torch.nn.Module):
|
|
| 106 |
)
|
| 107 |
# 拆成现支持的batch 3 CFG形式
|
| 108 |
prompts = [{"prompt_embeds": embed} for embed in fused_input]
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
promptss+=prompts
|
| 112 |
-
uncondi = prompts[1]
|
| 113 |
-
promptss = promptss[::2] + [uncondi]
|
| 114 |
outputs = self.llm.generate(promptss, sampling_params=sampling_params)
|
| 115 |
token_ids_CFG = torch.tensor(outputs[1].outputs[0].token_ids)
|
| 116 |
token_ids_CFG = token_ids_CFG[:-1].unsqueeze(0).unsqueeze(0)
|
|
|
|
| 48 |
enforce_eager=True,
|
| 49 |
dtype="bfloat16",
|
| 50 |
gpu_memory_utilization=0.65,
|
| 51 |
+
max_num_seqs=8,
|
| 52 |
tokenizer=None,
|
| 53 |
skip_tokenizer_init=True,
|
| 54 |
enable_prompt_embeds=True,
|
|
|
|
| 82 |
pmt_wav = None
|
| 83 |
melody_is_wav = True
|
| 84 |
|
| 85 |
+
description = description.lower() if description else '.'
|
| 86 |
description = '[Musicality-very-high]' + ', ' + description
|
| 87 |
generate_inp = {
|
| 88 |
'descriptions': [lyric.replace(" ", " ")],
|
|
|
|
| 106 |
)
|
| 107 |
# 拆成现支持的batch 3 CFG形式
|
| 108 |
prompts = [{"prompt_embeds": embed} for embed in fused_input]
|
| 109 |
+
condi, uncondi = prompts[0], prompts[1]
|
| 110 |
+
promptss = [condi, condi, uncondi]
|
|
|
|
|
|
|
|
|
|
| 111 |
outputs = self.llm.generate(promptss, sampling_params=sampling_params)
|
| 112 |
token_ids_CFG = torch.tensor(outputs[1].outputs[0].token_ids)
|
| 113 |
token_ids_CFG = token_ids_CFG[:-1].unsqueeze(0).unsqueeze(0)
|