Update api/ltx_server_refactored.py
Browse files- api/ltx_server_refactored.py +43 -0
api/ltx_server_refactored.py
CHANGED
|
@@ -574,6 +574,49 @@ class VideoService:
|
|
| 574 |
|
| 575 |
print("[SUCCESS] ETAPA 1 Concluída.")
|
| 576 |
return final_video_path, final_latents_path, used_seed
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 577 |
|
| 578 |
def refine_texture_only(
|
| 579 |
self,
|
|
|
|
| 574 |
|
| 575 |
print("[SUCCESS] ETAPA 1 Concluída.")
|
| 576 |
return final_video_path, final_latents_path, used_seed
|
| 577 |
+
|
| 578 |
+
|
| 579 |
+
# Em api/ltx_server_refactored.py, dentro da classe VideoService
|
| 580 |
+
|
| 581 |
+
|
| 582 |
+
def apply_secondary_refinement(
|
| 583 |
+
self,
|
| 584 |
+
latents_path: str,
|
| 585 |
+
prompt: str,
|
| 586 |
+
negative_prompt: str,
|
| 587 |
+
guidance_scale: float,
|
| 588 |
+
seed: int
|
| 589 |
+
) -> Tuple[str, str]:
|
| 590 |
+
"""
|
| 591 |
+
Função "ponte" chamada pela UI para aplicar um segundo passo de refinamento
|
| 592 |
+
sobre latentes já existentes.
|
| 593 |
+
|
| 594 |
+
Sua principal responsabilidade é garantir que o ambiente da GPU esteja
|
| 595 |
+
corretamente configurado antes de chamar a lógica de refinamento principal.
|
| 596 |
+
"""
|
| 597 |
+
print("\n======================================================================")
|
| 598 |
+
print("====== [INFO] Iniciando ETAPA de Refinamento Secundário ======")
|
| 599 |
+
print("======================================================================\n")
|
| 600 |
+
|
| 601 |
+
# 1. PREPARAR O AMBIENTE: Garante que o Transformer, Text Encoder e VAE
|
| 602 |
+
# estejam no dispositivo correto (GPU). Este é o passo que corrige o erro.
|
| 603 |
+
print("[LOG] Preparando ambiente da GPU para o refinamento...")
|
| 604 |
+
self._set_generation_environment()
|
| 605 |
+
|
| 606 |
+
# 2. CHAMAR A LÓGICA DE REFINAMENTO PRINCIPAL: Reutiliza a função robusta
|
| 607 |
+
# que já criamos, que lida com o denoise e a decodificação adaptativa.
|
| 608 |
+
print("[LOG] Ambiente pronto. Chamando a lógica principal de 'refine_texture_only'...")
|
| 609 |
+
video_path_out, latents_path_out = self.refine_texture_only(
|
| 610 |
+
latents_path=latents_path,
|
| 611 |
+
prompt=prompt,
|
| 612 |
+
negative_prompt=negative_prompt,
|
| 613 |
+
guidance_scale=guidance_scale,
|
| 614 |
+
seed=seed,
|
| 615 |
+
conditioning_items=None # No refinamento secundário, geralmente não há novos condicionantes
|
| 616 |
+
)
|
| 617 |
+
|
| 618 |
+
return video_path_out, latents_path_out
|
| 619 |
+
|
| 620 |
|
| 621 |
def refine_texture_only(
|
| 622 |
self,
|