BoxOfColors commited on
Commit
15ab81a
·
1 Parent(s): 1044cda

Fix MMAudio inference_mode error (torch.no_grad); fix Hunyuan weights subdir path

Browse files
Files changed (1) hide show
  1. app.py +17 -16
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
- audios = generate(
422
- clip_frames,
423
- sync_frames,
424
- [prompt],
425
- negative_text=[negative_prompt] if negative_prompt else None,
426
- feature_utils=feature_utils,
427
- net=net,
428
- fm=fm,
429
- rng=rng,
430
- cfg_strength=float(cfg_strength),
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
- print(f"[HunyuanFoley] Loading {model_size.upper()} model from {HUNYUAN_MODEL_DIR}")
489
- # load_model() handles: HunyuanVideoFoley main model, DAC-VAE, SigLIP2, CLAP, Synchformer
490
- # CLAP (laion/larger_clap_general) and SigLIP2 (google/siglip2-base-patch16-512) are
491
- # downloaded from HuggingFace Hub automatically by load_model().
492
  model_dict, cfg = load_model(
493
- str(HUNYUAN_MODEL_DIR),
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,