EuuIia commited on
Commit
a638401
·
verified ·
1 Parent(s): c2b86c8

Update api/ltx_server.py

Browse files
Files changed (1) hide show
  1. api/ltx_server.py +25 -29
api/ltx_server.py CHANGED
@@ -754,27 +754,22 @@ class VideoService:
754
  # --- ETAPA 1: GERAÇÃO BASE (FIRST PASS) ---
755
  print("\n--- INICIANDO ETAPA 1: GERAÇÃO BASE (FIRST PASS) ---")
756
  t_pass1 = time.perf_counter()
757
-
758
- first_pass_config = self.config.get("first_pass", {}).copy()
759
- downscale_factor = self.config.get("downscale_factor", 0.666)
760
 
761
- unrounded_width = width_padded * downscale_factor
762
- unrounded_height = height_padded * downscale_factor
763
-
764
- # Sanitiza as dimensões para serem divisíveis pelo fator do VAE (geralmente 8)
765
- # Usamos o mesmo divisor da UI para consistência.
766
- divisor = 8
767
- downscaled_width = int(round(unrounded_width / divisor)) * divisor
768
- downscaled_height = int(round(unrounded_height / divisor)) * divisor
769
-
770
- downscaled_width = max(divisor, downscaled_width)
771
- downscaled_height = max(divisor, downscaled_height)
772
- first_pass_kwargs.update(first_pass_config)
773
-
774
-
775
- print(f"[DEBUG] Dimensões do First Pass: Calculado ({unrounded_width:.0f}x{unrounded_height:.0f}) -> Sanitizado ({downscaled_width}x{downscaled_height})")
776
 
777
- first_pass_kwargs = call_kwargs.copy()
 
 
 
 
 
 
 
 
 
 
778
  first_pass_kwargs.update({
779
  "output_type": "latent",
780
  "width": downscaled_width,
@@ -799,22 +794,23 @@ class VideoService:
799
  del base_latents; gc.collect(); torch.cuda.empty_cache()
800
 
801
 
802
-
803
-
804
- # --- ETAPA 3: REFINAMENTO DE TEXTURA (SECOND PASS) ---
805
  print("\n--- INICIANDO ETAPA 3: REFINAMENTO DE TEXTURA (SECOND PASS) ---")
806
- t_pass2 = time.perf_counter()
807
 
808
  second_pass_config = self.config.get("second_pass", {}).copy()
809
- second_pass_kwargs.update(second_pass_config)
810
-
 
 
 
 
811
 
812
- second_pass_kwargs = call_kwargs.copy()
813
  second_pass_kwargs.update({
814
  "output_type": "latent",
815
- "width": width_padded,
816
- "height": height_padded,
817
- "latents": upsampled_latents,
818
  "guidance_scale": float(guidance_scale),
819
  **second_pass_config
820
  })
 
754
  # --- ETAPA 1: GERAÇÃO BASE (FIRST PASS) ---
755
  print("\n--- INICIANDO ETAPA 1: GERAÇÃO BASE (FIRST PASS) ---")
756
  t_pass1 = time.perf_counter()
 
 
 
757
 
758
+ first_pass_config = self.config.get("first_pass", {}).copy()
759
+ downscale_factor = self.config.get("downscale_factor", 0.6666666)
760
+ vae_scale_factor = self.pipeline.vae_scale_factor # Geralmente 8
 
 
 
 
 
 
 
 
 
 
 
 
761
 
762
+ # --- <INÍCIO DA LÓGICA DE CÁLCULO EXATA> ---
763
+ # Replica a fórmula da LTXMultiScalePipeline
764
+ x_width = int(width_padded * downscale_factor)
765
+ downscaled_width = x_width - (x_width % vae_scale_factor)
766
+ x_height = int(height_padded * downscale_factor)
767
+ downscaled_height = x_height - (x_height % vae_scale_factor)
768
+ print(f"[DEBUG] First Pass Dims: Original Pad ({width_padded}x{height_padded}) -> Downscaled ({downscaled_width}x{downscaled_height})")
769
+ # --- <FIM DA LÓGICA DE CÁLCULO EXATA> ---
770
+
771
+ first_pass_kwargs = base_call_kwargs.copy()
772
+
773
  first_pass_kwargs.update({
774
  "output_type": "latent",
775
  "width": downscaled_width,
 
794
  del base_latents; gc.collect(); torch.cuda.empty_cache()
795
 
796
 
797
+ # # --- ETAPA 3: REFINAMENTO DE TEXTURA (SECOND PASS) ---
 
 
798
  print("\n--- INICIANDO ETAPA 3: REFINAMENTO DE TEXTURA (SECOND PASS) ---")
 
799
 
800
  second_pass_config = self.config.get("second_pass", {}).copy()
801
+ # --- <INÍCIO DA LÓGICA DE CÁLCULO EXATA PARA SECOND PASS> ---
802
+ # Usa as dimensões da primeira passagem dobradas, como na pipeline original
803
+ second_pass_width = downscaled_width * 2
804
+ second_pass_height = downscaled_height * 2
805
+ print(f"[DEBUG] Second Pass Dims: Target ({second_pass_width}x{second_pass_height})")
806
+ # --- <FIM DA LÓGICA DE CÁLCULO EXATA> ---
807
 
808
+ second_pass_kwargs = base_call_kwargs.copy()
809
  second_pass_kwargs.update({
810
  "output_type": "latent",
811
+ "width": second_pass_width,
812
+ "height": second_pass_height,
813
+ "latents": upsampled_latents, # O tensor upscaled
814
  "guidance_scale": float(guidance_scale),
815
  **second_pass_config
816
  })