Carlos s
commited on
Update api/ltx_server.py
Browse files- api/ltx_server.py +28 -25
api/ltx_server.py
CHANGED
|
@@ -671,7 +671,7 @@ class VideoService:
|
|
| 671 |
multi_scale_pipeline = None
|
| 672 |
|
| 673 |
try:
|
| 674 |
-
if improve_texture:
|
| 675 |
if not self.latent_upsampler:
|
| 676 |
raise ValueError("Upscaler espacial não carregado.")
|
| 677 |
print("[DEBUG] Multi-escala: construindo pipeline...")
|
|
@@ -686,7 +686,7 @@ class VideoService:
|
|
| 686 |
{
|
| 687 |
"downscale_factor": self.config["downscale_factor"],
|
| 688 |
"first_pass": first_pass_args,
|
| 689 |
-
"second_pass":
|
| 690 |
}
|
| 691 |
)
|
| 692 |
print("[DEBUG] Chamando multi_scale_pipeline...")
|
|
@@ -703,7 +703,8 @@ class VideoService:
|
|
| 703 |
else:
|
| 704 |
latents = result
|
| 705 |
print(f"[DEBUG] Latentes (multi-escala): shape={tuple(latents.shape)}")
|
| 706 |
-
|
|
|
|
| 707 |
single_pass_kwargs = call_kwargs.copy()
|
| 708 |
first_pass_config = self.config.get("first_pass", {}).copy()
|
| 709 |
|
|
@@ -726,7 +727,9 @@ class VideoService:
|
|
| 726 |
#"skip_block_list": first_pass_config.get("skip_block_list"),
|
| 727 |
}
|
| 728 |
)
|
| 729 |
-
#schedule =
|
|
|
|
|
|
|
| 730 |
#if mode == "video-to-video":
|
| 731 |
# schedule = [0.7]; print("[INFO] Modo video-to-video (etapa única): timesteps=[0.7]")
|
| 732 |
#if isinstance(schedule, (list, tuple)) and len(schedule) > 0:
|
|
@@ -734,20 +737,20 @@ class VideoService:
|
|
| 734 |
# single_pass_kwargs["guidance_timesteps"] = schedule
|
| 735 |
#print(f"[DEBUG] Single-pass: timesteps_len={len(schedule) if schedule else 0}")
|
| 736 |
|
| 737 |
-
print("\n[INFO] Executando pipeline de etapa única...")
|
| 738 |
-
t_sp = time.perf_counter()
|
| 739 |
-
ctx = torch.autocast(device_type="cuda", dtype=self.runtime_autocast_dtype) if self.device == "cuda" else contextlib.nullcontext()
|
| 740 |
-
with ctx:
|
| 741 |
-
|
| 742 |
-
print(f"[DEBUG] single-pass tempo={time.perf_counter()-t_sp:.3f}s")
|
| 743 |
-
|
| 744 |
-
if hasattr(result, "latents"):
|
| 745 |
-
|
| 746 |
-
elif hasattr(result, "images") and isinstance(result.images, torch.Tensor):
|
| 747 |
-
|
| 748 |
-
else:
|
| 749 |
-
|
| 750 |
-
print(f"[DEBUG] Latentes (single-pass) first : shape={tuple(latents.shape)}")
|
| 751 |
|
| 752 |
single_pass_kwargs = call_kwargs.copy()
|
| 753 |
first_pass_config = self.config.get("first_pass", {}).copy()
|
|
@@ -764,7 +767,7 @@ class VideoService:
|
|
| 764 |
"guidance_timesteps": second_pass.get("guidance_timesteps"),
|
| 765 |
"skip_block_list": second_pass.get("skip_block_list"),
|
| 766 |
"num_inference_steps": second_pass.get("num_inference_steps"),
|
| 767 |
-
"skip_final_inference_steps":
|
| 768 |
"skip_initial_inference_steps": 16# second_pass.get("skip_initial_inference_steps"),
|
| 769 |
"cfg_star_rescale": second_pass.get("cfg_star_rescale"),
|
| 770 |
"downscale_factor": self.config["downscale_factor"],
|
|
@@ -775,15 +778,15 @@ class VideoService:
|
|
| 775 |
#"skip_block_list": first_pass_config.get("skip_block_list"),
|
| 776 |
}
|
| 777 |
)
|
| 778 |
-
|
| 779 |
#if mode == "video-to-video":
|
| 780 |
# schedule = [0.7]; print("[INFO] Modo video-to-video (etapa única): timesteps=[0.7]")
|
| 781 |
-
|
| 782 |
-
|
| 783 |
-
|
| 784 |
-
|
| 785 |
|
| 786 |
-
|
| 787 |
t_sp = time.perf_counter()
|
| 788 |
ctx = torch.autocast(device_type="cuda", dtype=self.runtime_autocast_dtype) if self.device == "cuda" else contextlib.nullcontext()
|
| 789 |
with ctx:
|
|
|
|
| 671 |
multi_scale_pipeline = None
|
| 672 |
|
| 673 |
try:
|
| 674 |
+
if true: #improve_texture:
|
| 675 |
if not self.latent_upsampler:
|
| 676 |
raise ValueError("Upscaler espacial não carregado.")
|
| 677 |
print("[DEBUG] Multi-escala: construindo pipeline...")
|
|
|
|
| 686 |
{
|
| 687 |
"downscale_factor": self.config["downscale_factor"],
|
| 688 |
"first_pass": first_pass_args,
|
| 689 |
+
"second_pass": first_pass_args,
|
| 690 |
}
|
| 691 |
)
|
| 692 |
print("[DEBUG] Chamando multi_scale_pipeline...")
|
|
|
|
| 703 |
else:
|
| 704 |
latents = result
|
| 705 |
print(f"[DEBUG] Latentes (multi-escala): shape={tuple(latents.shape)}")
|
| 706 |
+
|
| 707 |
+
#if true:
|
| 708 |
single_pass_kwargs = call_kwargs.copy()
|
| 709 |
first_pass_config = self.config.get("first_pass", {}).copy()
|
| 710 |
|
|
|
|
| 727 |
#"skip_block_list": first_pass_config.get("skip_block_list"),
|
| 728 |
}
|
| 729 |
)
|
| 730 |
+
#schedule =
|
| 731 |
+
#first_pass_config.get("timesteps") or
|
| 732 |
+
#first_pass_config.get("guidance_timesteps")
|
| 733 |
#if mode == "video-to-video":
|
| 734 |
# schedule = [0.7]; print("[INFO] Modo video-to-video (etapa única): timesteps=[0.7]")
|
| 735 |
#if isinstance(schedule, (list, tuple)) and len(schedule) > 0:
|
|
|
|
| 737 |
# single_pass_kwargs["guidance_timesteps"] = schedule
|
| 738 |
#print(f"[DEBUG] Single-pass: timesteps_len={len(schedule) if schedule else 0}")
|
| 739 |
|
| 740 |
+
#print("\n[INFO] Executando pipeline de etapa única...")
|
| 741 |
+
#t_sp = time.perf_counter()
|
| 742 |
+
#ctx = torch.autocast(device_type="cuda", dtype=self.runtime_autocast_dtype) if self.device == "cuda" else contextlib.nullcontext()
|
| 743 |
+
#with ctx:
|
| 744 |
+
# result = self.pipeline(**single_pass_kwargs)
|
| 745 |
+
#print(f"[DEBUG] single-pass tempo={time.perf_counter()-t_sp:.3f}s")
|
| 746 |
+
|
| 747 |
+
#if hasattr(result, "latents"):
|
| 748 |
+
# latents = result.latents
|
| 749 |
+
#elif hasattr(result, "images") and isinstance(result.images, torch.Tensor):
|
| 750 |
+
# latents = result.images
|
| 751 |
+
#else:
|
| 752 |
+
# latents = result
|
| 753 |
+
#print(f"[DEBUG] Latentes (single-pass) first : shape={tuple(latents.shape)}")
|
| 754 |
|
| 755 |
single_pass_kwargs = call_kwargs.copy()
|
| 756 |
first_pass_config = self.config.get("first_pass", {}).copy()
|
|
|
|
| 767 |
"guidance_timesteps": second_pass.get("guidance_timesteps"),
|
| 768 |
"skip_block_list": second_pass.get("skip_block_list"),
|
| 769 |
"num_inference_steps": second_pass.get("num_inference_steps"),
|
| 770 |
+
"skip_final_inference_steps": 0 #first_pass_config.get("skip_final_inference_steps"),
|
| 771 |
"skip_initial_inference_steps": 16# second_pass.get("skip_initial_inference_steps"),
|
| 772 |
"cfg_star_rescale": second_pass.get("cfg_star_rescale"),
|
| 773 |
"downscale_factor": self.config["downscale_factor"],
|
|
|
|
| 778 |
#"skip_block_list": first_pass_config.get("skip_block_list"),
|
| 779 |
}
|
| 780 |
)
|
| 781 |
+
schedule = second_pass.get("guidance_timesteps")
|
| 782 |
#if mode == "video-to-video":
|
| 783 |
# schedule = [0.7]; print("[INFO] Modo video-to-video (etapa única): timesteps=[0.7]")
|
| 784 |
+
if isinstance(schedule, (list, tuple)) and len(schedule) > 0:
|
| 785 |
+
single_pass_kwargs["timesteps"] = schedule
|
| 786 |
+
single_pass_kwargs["guidance_timesteps"] = schedule
|
| 787 |
+
print(f"[DEBUG] Single-pass: timesteps_len={len(schedule) if schedule else 0}")
|
| 788 |
|
| 789 |
+
print("\n[INFO] Executando pipeline de etapa única...")
|
| 790 |
t_sp = time.perf_counter()
|
| 791 |
ctx = torch.autocast(device_type="cuda", dtype=self.runtime_autocast_dtype) if self.device == "cuda" else contextlib.nullcontext()
|
| 792 |
with ctx:
|