fix(bigvgan): add 44k/BigVGANv2 support to trainer and loader
44k variants use BigVGANv2 directly as the vocoder (no wrapper, no @inference_mode decorator), accessible at feature_utils.tod.vocoder. 16k wraps BigVGANVocoder inside BigVGAN, accessed at .vocoder.vocoder. Both trainer and loader now branch on model["mode"]. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -22,8 +22,9 @@ class SelvaBigvganLoader:
|
||||
RETURN_NAMES = ("model",)
|
||||
OUTPUT_TOOLTIPS = ("SELVA_MODEL with the fine-tuned BigVGAN vocoder injected.",)
|
||||
DESCRIPTION = (
|
||||
"Loads a fine-tuned BigVGAN vocoder checkpoint from SelVA BigVGAN Trainer "
|
||||
"and replaces the vocoder weights in the SELVA_MODEL. "
|
||||
"Loads a fine-tuned BigVGAN/BigVGANv2 vocoder checkpoint from SelVA BigVGAN Trainer "
|
||||
"and replaces the vocoder weights in the SELVA_MODEL in-place. "
|
||||
"Supports both 16k and 44k models. "
|
||||
"Connect the output to SelVA Sampler instead of the base model loader."
|
||||
)
|
||||
|
||||
@@ -47,16 +48,18 @@ class SelvaBigvganLoader:
|
||||
if not p.exists():
|
||||
raise FileNotFoundError(f"[BigVGAN] Checkpoint not found: {p}")
|
||||
|
||||
if model["mode"] != "16k":
|
||||
raise NotImplementedError(
|
||||
"[BigVGAN] Fine-tuned loader only supports 16k mode."
|
||||
)
|
||||
|
||||
ckpt = torch.load(str(p), map_location="cpu", weights_only=False)
|
||||
if "generator" not in ckpt:
|
||||
raise ValueError(f"[BigVGAN] Expected {{'generator': ...}} in checkpoint, got keys: {list(ckpt.keys())}")
|
||||
|
||||
vocoder = model["feature_utils"].tod.vocoder.vocoder
|
||||
mode = model["mode"]
|
||||
if mode == "16k":
|
||||
vocoder = model["feature_utils"].tod.vocoder.vocoder # BigVGANVocoder
|
||||
elif mode == "44k":
|
||||
vocoder = model["feature_utils"].tod.vocoder # BigVGANv2 directly
|
||||
else:
|
||||
raise ValueError(f"[BigVGAN] Unknown mode: {mode}")
|
||||
|
||||
vocoder.load_state_dict(ckpt["generator"])
|
||||
vocoder.eval()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user