Spaces:
Running
Running
hub ckpt
Browse filesFiles changed (3)
71 unmodified lines727374757576777871 unmodified lines y_final[:,:,t_start:t_end] = y_chunk[:,:,chunk_start:chunk_end] return y_final
def inference(cfm_model, vae_model, cond, text, duration, style_prompt, negative_style_prompt, start_time):def inference(cfm_model, vae_model, cond, text, duration, style_prompt, negative_style_prompt, start_time, steps): # import pdb; pdb.set_trace() with torch.inference_mode(): generated, _ = cfm_model.sample(5 unmodified lines6789910111213141516151617181913 unmodified lines3334353636373839403 unmodified lines44454646474849505 unmodified linesfrom mutagen.mp3 import MP3import osimport numpy as np
from huggingface_hub import hf_hub_downloadfrom diffrhythm.model import DiT, CFM
def prepare_model(device): # prepare cfm model dit_ckpt_path = "/home/node59_tmpdata3/hkchen/music_opensource/dit_model_dpo_normal.pt" dit_config_path = "/home/node59_tmpdata3/hkchen/DiffRhythm/diffrhythm/diffrhythm/config/diffrhythm-1b.json" dit_ckpt_path = hf_hub_download(repo_id="ASLP-lab/DiffRhythm-base", filename="cfm_model.pt") dit_config_path = "./diffrhythm/config/diffrhythm-1b.json" with open(dit_config_path) as f: model_config = json.load(f) dit_model_cls = DiT13 unmodified lines muq = muq.to(device).eval() # prepare vae vae = torch.jit.load("/home/node59_tmpdata3/hkchen/F5-TTS-V0/infer/vae_infer.pt").to(device) vae_ckpt_path = hf_hub_download(repo_id="ASLP-lab/DiffRhythm-vae", filename="vae_model.pt") vae = torch.jit.load(vae_ckpt_path).to(device) return cfm, tokenizer, muq, vae 3 unmodified lines return torch.zeros(1, max_frames, 64).to(device)
def get_negative_style_prompt(device): file_path = "/home/node59_tmpdata3/hkchen/DiffRhythm/diffrhythm/diffrhythm/infer/example/vocal.npy" file_path = "./prompt/negative_prompt.npy" vocal_stlye = np.load(file_path) vocal_stlye = torch.from_numpy(vocal_stlye).to(device) # [1, 512]123version https://git-lfs.github.com/spec/v1oid sha256:6cb7d74eb7a8eda12acb8247b21d373928301db8a8cb0db480d341799fed3ce5size 2176diffrhythm/infer/infer.py+1-1
diffrhythm/infer/infer_utils.py+6-5
prompt/negative_prompt.npyAdded+3