Spaces:
Paused
Paused
Update api/ltx_server_refactored_complete.py
Browse files
api/ltx_server_refactored_complete.py
CHANGED
|
@@ -283,31 +283,57 @@ class VideoService:
|
|
| 283 |
downscaled_height = self._align(int(height_padded * downscale_factor), vae_scale_factor)
|
| 284 |
downscaled_width = self._align(int(width_padded * downscale_factor), vae_scale_factor)
|
| 285 |
|
|
|
|
| 286 |
first_pass_config = self.config.get("first_pass", {}).copy()
|
|
|
|
|
|
|
| 287 |
if kwargs.get("ltx_configs_override"):
|
| 288 |
-
self._apply_ui_overrides(first_pass_config)
|
| 289 |
|
|
|
|
| 290 |
pipeline_kwargs = {
|
| 291 |
-
"prompt": kwargs['prompt'],
|
| 292 |
-
"
|
| 293 |
-
"
|
| 294 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 295 |
}
|
| 296 |
-
|
| 297 |
-
logging.info(f"\n[Info] pipeline_kwargs:\n {pipeline_kwargs}\n\n")
|
| 298 |
-
self._log_conditioning_items(kwargs.get['conditioning_items'])
|
| 299 |
|
| 300 |
-
|
| 301 |
-
|
| 302 |
-
|
| 303 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 304 |
|
|
|
|
|
|
|
| 305 |
|
|
|
|
| 306 |
with torch.autocast(device_type=self.main_device.type, dtype=self.runtime_autocast_dtype, enabled="cuda" in self.main_device.type):
|
| 307 |
latents_raw = self.pipeline(**pipeline_kwargs).images
|
| 308 |
|
| 309 |
return latents_raw.to(self.main_device)
|
| 310 |
|
|
|
|
| 311 |
@log_function_io
|
| 312 |
def _finalize_generation(self, temp_latent_paths: List[Path], base_filename: str, seed: int) -> Tuple[str, str, int]:
|
| 313 |
"""Consolidates latents, decodes them to video, and saves final artifacts."""
|
|
|
|
| 283 |
downscaled_height = self._align(int(height_padded * downscale_factor), vae_scale_factor)
|
| 284 |
downscaled_width = self._align(int(width_padded * downscale_factor), vae_scale_factor)
|
| 285 |
|
| 286 |
+
# 1. Começa com a configuração padrão
|
| 287 |
first_pass_config = self.config.get("first_pass", {}).copy()
|
| 288 |
+
|
| 289 |
+
# 2. Aplica os overrides da UI, se existirem
|
| 290 |
if kwargs.get("ltx_configs_override"):
|
| 291 |
+
self._apply_ui_overrides(first_pass_config, kwargs.get("ltx_configs_override"))
|
| 292 |
|
| 293 |
+
# 3. Monta o dicionário de argumentos SEM conditioning_items primeiro
|
| 294 |
pipeline_kwargs = {
|
| 295 |
+
"prompt": kwargs['prompt'],
|
| 296 |
+
"negative_prompt": kwargs['negative_prompt'],
|
| 297 |
+
"height": downscaled_height,
|
| 298 |
+
"width": downscaled_width,
|
| 299 |
+
"num_frames": kwargs['num_frames'],
|
| 300 |
+
"frame_rate": int(DEFAULT_FPS),
|
| 301 |
+
"generator": torch.Generator(device=self.main_device).manual_seed(kwargs['seed']),
|
| 302 |
+
"output_type": "latent",
|
| 303 |
+
#"conditioning_items": conditioning_items if conditioning_items else None,
|
| 304 |
+
"media_items": None,
|
| 305 |
+
"decode_timestep": self.config["decode_timestep"],
|
| 306 |
+
"decode_noise_scale": self.config["decode_noise_scale"],
|
| 307 |
+
"stochastic_sampling": self.config["stochastic_sampling"],
|
| 308 |
+
"image_cond_noise_scale": 0.01,
|
| 309 |
+
"is_video": True,
|
| 310 |
+
"vae_per_channel_normalize": True,
|
| 311 |
+
"mixed_precision": (self.config["precision"] == "mixed_precision"),
|
| 312 |
+
"offload_to_cpu": False,
|
| 313 |
+
"enhance_prompt": False,
|
| 314 |
+
#"skip_layer_strategy": SkipLayerStrategy.AttentionValues,
|
| 315 |
+
**first_pass_config
|
| 316 |
}
|
|
|
|
|
|
|
|
|
|
| 317 |
|
| 318 |
+
# --- Bloco de Logging para Depuração ---
|
| 319 |
+
# 4. Loga os argumentos do pipeline (sem os tensores de condição)
|
| 320 |
+
logging.info(f"\n[Info] Pipeline Arguments (BASE):\n {json.dumps(pipeline_kwargs, indent=2, default=str)}\n")
|
| 321 |
+
|
| 322 |
+
# Loga os conditioning_items separadamente com a nossa função helper
|
| 323 |
+
conditioning_items_list = kwargs.get('conditioning_items')
|
| 324 |
+
self._log_conditioning_items(conditioning_items_list)
|
| 325 |
+
# --- Fim do Bloco de Logging ---
|
| 326 |
|
| 327 |
+
# 5. Adiciona os conditioning_items ao dicionário
|
| 328 |
+
pipeline_kwargs['conditioning_items'] = conditioning_items_list
|
| 329 |
|
| 330 |
+
# 6. Executa o pipeline com o dicionário completo
|
| 331 |
with torch.autocast(device_type=self.main_device.type, dtype=self.runtime_autocast_dtype, enabled="cuda" in self.main_device.type):
|
| 332 |
latents_raw = self.pipeline(**pipeline_kwargs).images
|
| 333 |
|
| 334 |
return latents_raw.to(self.main_device)
|
| 335 |
|
| 336 |
+
|
| 337 |
@log_function_io
|
| 338 |
def _finalize_generation(self, temp_latent_paths: List[Path], base_filename: str, seed: int) -> Tuple[str, str, int]:
|
| 339 |
"""Consolidates latents, decodes them to video, and saves final artifacts."""
|