ford442 commited on
Commit
213a98f
·
verified ·
1 Parent(s): c5900cd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -7
app.py CHANGED
@@ -668,15 +668,25 @@ def generate(prompt, negative_prompt, clips_list, input_image_filepath, input_vi
668
  output_video_path = os.path.join(tempfile.mkdtemp(), f"output_{random.randint(10000,99999)}.mp4")
669
  if WORKER_CLIENT:
670
  print("📡 Sending Video Latents to Worker for Decode...")
671
- latents = pipeline_output.images # These are raw transformer outputs (Unit Variance)
672
 
673
- # DEBUG B: What did the Transformer produce?
674
- # If Std is 0.0 or NaN here, the Transformer failed.
675
- print(f"--- DEBUG: MAIN APP OUTPUT ---")
676
- print(f"B. OUTPUT Latents | Mean: {latents.mean().item():.4f} | Std: {latents.std().item():.4f}")
677
 
678
- # Simple package, no stats needed now
679
- pkg = { "latents": latents.cpu() }
 
 
 
 
 
 
 
 
 
 
 
680
 
681
  temp_path = "/tmp/temp_video_pkg.pt"
682
  torch.save(pkg, temp_path)
 
668
  output_video_path = os.path.join(tempfile.mkdtemp(), f"output_{random.randint(10000,99999)}.mp4")
669
  if WORKER_CLIENT:
670
  print("📡 Sending Video Latents to Worker for Decode...")
671
+ latents = pipeline_output.images
672
 
673
+ # LOGIC:
674
+ # For I2V, we want to match the input image's contrast.
675
+ # For T2V, we use the "Natural" LTX stats (Std ~0.25).
 
676
 
677
+ target_mean = torch.tensor(0.0)
678
+ target_std = torch.tensor(0.25) # Default LTX "Natural" Std
679
+
680
+ # If we have stats from the Input Image (I2V), use those!
681
+ if mode == "image-to-video" and "mean" in image_stats and "std" in image_stats:
682
+ target_mean = image_stats["mean"].cpu()
683
+ target_std = image_stats["std"].cpu()
684
+
685
+ pkg = {
686
+ "latents": latents.cpu(),
687
+ "mean": target_mean,
688
+ "std": target_std
689
+ }
690
 
691
  temp_path = "/tmp/temp_video_pkg.pt"
692
  torch.save(pkg, temp_path)