Commit ·
15ab81a
1
Parent(s): 1044cda
Fix MMAudio inference_mode error (torch.no_grad); fix Hunyuan weights subdir path
Browse files
app.py
CHANGED
|
@@ -418,17 +418,18 @@ def generate_mmaudio(video_file, prompt, negative_prompt, seed_val,
|
|
| 418 |
|
| 419 |
print(f"[MMAudio] Sample {sample_idx+1} | duration={actual_dur:.2f}s | prompt='{prompt}'")
|
| 420 |
|
| 421 |
-
|
| 422 |
-
|
| 423 |
-
|
| 424 |
-
|
| 425 |
-
|
| 426 |
-
|
| 427 |
-
|
| 428 |
-
|
| 429 |
-
|
| 430 |
-
|
| 431 |
-
|
|
|
|
| 432 |
audio = audios.float().cpu()[0] # (C, T)
|
| 433 |
|
| 434 |
audio_path = os.path.join(tmp_dir, f"mmaudio_{sample_idx}.flac")
|
|
@@ -485,12 +486,12 @@ def generate_hunyuan(video_file, prompt, negative_prompt, seed_val,
|
|
| 485 |
}
|
| 486 |
config_path = config_map.get(model_size, config_map["xxl"])
|
| 487 |
|
| 488 |
-
|
| 489 |
-
#
|
| 490 |
-
|
| 491 |
-
|
| 492 |
model_dict, cfg = load_model(
|
| 493 |
-
|
| 494 |
config_path,
|
| 495 |
device,
|
| 496 |
enable_offload=False,
|
|
|
|
| 418 |
|
| 419 |
print(f"[MMAudio] Sample {sample_idx+1} | duration={actual_dur:.2f}s | prompt='{prompt}'")
|
| 420 |
|
| 421 |
+
with torch.no_grad():
|
| 422 |
+
audios = generate(
|
| 423 |
+
clip_frames,
|
| 424 |
+
sync_frames,
|
| 425 |
+
[prompt],
|
| 426 |
+
negative_text=[negative_prompt] if negative_prompt else None,
|
| 427 |
+
feature_utils=feature_utils,
|
| 428 |
+
net=net,
|
| 429 |
+
fm=fm,
|
| 430 |
+
rng=rng,
|
| 431 |
+
cfg_strength=float(cfg_strength),
|
| 432 |
+
)
|
| 433 |
audio = audios.float().cpu()[0] # (C, T)
|
| 434 |
|
| 435 |
audio_path = os.path.join(tmp_dir, f"mmaudio_{sample_idx}.flac")
|
|
|
|
| 486 |
}
|
| 487 |
config_path = config_map.get(model_size, config_map["xxl"])
|
| 488 |
|
| 489 |
+
# hf_hub_download preserves the repo subfolder, so weights land in
|
| 490 |
+
# HUNYUAN_MODEL_DIR/HunyuanVideo-Foley/ — pass that as the weights dir.
|
| 491 |
+
hunyuan_weights_dir = str(HUNYUAN_MODEL_DIR / "HunyuanVideo-Foley")
|
| 492 |
+
print(f"[HunyuanFoley] Loading {model_size.upper()} model from {hunyuan_weights_dir}")
|
| 493 |
model_dict, cfg = load_model(
|
| 494 |
+
hunyuan_weights_dir,
|
| 495 |
config_path,
|
| 496 |
device,
|
| 497 |
enable_offload=False,
|