Spaces:
Paused
Paused
Update api/ltx_server_refactored_complete.py
Browse files
api/ltx_server_refactored_complete.py
CHANGED
|
@@ -254,7 +254,7 @@ class VideoService:
|
|
| 254 |
|
| 255 |
first_pass_config = self.config.get("first_pass", {}).copy()
|
| 256 |
if kwargs.get("ltx_configs_override"):
|
| 257 |
-
self._apply_ui_overrides(first_pass_config
|
| 258 |
|
| 259 |
pipeline_kwargs = {
|
| 260 |
"prompt": kwargs['prompt'], "negative_prompt": kwargs['negative_prompt'],
|
|
@@ -308,7 +308,7 @@ class VideoService:
|
|
| 308 |
conditioning_items.append(ConditioningItem(tensor, safe_frame, float(weight)))
|
| 309 |
return conditioning_items
|
| 310 |
|
| 311 |
-
def _apply_ui_overrides(self, config_dict: Dict
|
| 312 |
"""Applies advanced settings from the UI to a config dictionary."""
|
| 313 |
# Override step counts
|
| 314 |
for key in ["num_inference_steps", "skip_initial_inference_steps", "skip_final_inference_steps"]:
|
|
@@ -317,24 +317,6 @@ class VideoService:
|
|
| 317 |
config_dict[key] = ui_value
|
| 318 |
logging.info(f"Override: '{key}' set to {ui_value} by UI.")
|
| 319 |
|
| 320 |
-
# Override guidance settings
|
| 321 |
-
preset = overrides.get("guidance_preset", "Padrão (Recomendado)")
|
| 322 |
-
guidance_overrides = {}
|
| 323 |
-
if preset == "Agressivo":
|
| 324 |
-
guidance_overrides = {"guidance_scale": [1, 2, 8, 12, 8, 2, 1], "stg_scale": [0, 0, 5, 6, 5, 3, 2]}
|
| 325 |
-
elif preset == "Suave":
|
| 326 |
-
guidance_overrides = {"guidance_scale": [1, 1, 4, 5, 4, 1, 1], "stg_scale": [0, 0, 2, 2, 2, 1, 0]}
|
| 327 |
-
elif preset == "Customizado":
|
| 328 |
-
try:
|
| 329 |
-
guidance_overrides["guidance_scale"] = json.loads(overrides["guidance_scale_list"])
|
| 330 |
-
guidance_overrides["stg_scale"] = json.loads(overrides["stg_scale_list"])
|
| 331 |
-
except Exception as e:
|
| 332 |
-
logging.warning(f"Failed to parse custom guidance values: {e}. Using defaults.")
|
| 333 |
-
|
| 334 |
-
if guidance_overrides:
|
| 335 |
-
config_dict.update(guidance_overrides)
|
| 336 |
-
logging.info(f"Applying '{preset}' guidance preset overrides.")
|
| 337 |
-
|
| 338 |
def _save_and_log_video(self, pixel_tensor: torch.Tensor, base_filename: str) -> Path:
|
| 339 |
with tempfile.TemporaryDirectory() as temp_dir:
|
| 340 |
temp_path = os.path.join(temp_dir, f"{base_filename}.mp4")
|
|
|
|
| 254 |
|
| 255 |
first_pass_config = self.config.get("first_pass", {}).copy()
|
| 256 |
if kwargs.get("ltx_configs_override"):
|
| 257 |
+
self._apply_ui_overrides(first_pass_config)
|
| 258 |
|
| 259 |
pipeline_kwargs = {
|
| 260 |
"prompt": kwargs['prompt'], "negative_prompt": kwargs['negative_prompt'],
|
|
|
|
| 308 |
conditioning_items.append(ConditioningItem(tensor, safe_frame, float(weight)))
|
| 309 |
return conditioning_items
|
| 310 |
|
| 311 |
+
def _apply_ui_overrides(self, config_dict: Dict):
|
| 312 |
"""Applies advanced settings from the UI to a config dictionary."""
|
| 313 |
# Override step counts
|
| 314 |
for key in ["num_inference_steps", "skip_initial_inference_steps", "skip_final_inference_steps"]:
|
|
|
|
| 317 |
config_dict[key] = ui_value
|
| 318 |
logging.info(f"Override: '{key}' set to {ui_value} by UI.")
|
| 319 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 320 |
def _save_and_log_video(self, pixel_tensor: torch.Tensor, base_filename: str) -> Path:
|
| 321 |
with tempfile.TemporaryDirectory() as temp_dir:
|
| 322 |
temp_path = os.path.join(temp_dir, f"{base_filename}.mp4")
|