Update api/ltx_server.py
Browse files- api/ltx_server.py +24 -16
api/ltx_server.py
CHANGED
|
@@ -579,17 +579,13 @@ class VideoService:
|
|
| 579 |
i=0
|
| 580 |
while i < n_chunks:
|
| 581 |
start = (num_latente_por_chunk*i)
|
| 582 |
-
end = (start+num_latente_por_chunk+overlap)
|
| 583 |
if i+1 < n_chunks:
|
| 584 |
-
|
| 585 |
-
|
| 586 |
-
print(f"[DEBUG] chunk{i+1}[:, :, {start}:{end}, :, :] = {chunk.shape[2]}")
|
| 587 |
-
else:
|
| 588 |
-
chunk = latents_brutos[:, :, start:end, :, :].clone().detach()
|
| 589 |
-
print(f"[DEBUG] chunk{i+1}[:, :, {start}:{end}, :, :] = {chunk.shape[2]}")
|
| 590 |
else:
|
| 591 |
-
chunk = latents_brutos[:, :, start
|
| 592 |
-
print(f"[DEBUG] chunk{i+1}[:, :, {start
|
| 593 |
chunks.append(chunk)
|
| 594 |
i+=1
|
| 595 |
else:
|
|
@@ -873,7 +869,7 @@ class VideoService:
|
|
| 873 |
except Exception:
|
| 874 |
pass
|
| 875 |
|
| 876 |
-
latents_parts_up = self._dividir_latentes_por_tamanho(latents_cpu_up,
|
| 877 |
|
| 878 |
print("\n\n--- INICIANDO ETAPA 3: REFINAMENTO DE TEXTURA (SECOND PASS) ---")
|
| 879 |
|
|
@@ -923,21 +919,33 @@ class VideoService:
|
|
| 923 |
print("#########################################")
|
| 924 |
|
| 925 |
print("\n\n--- FIM ETAPA 3: REFINAMENTO DE TEXTURA (SECOND PASS) ---")
|
| 926 |
-
|
| 927 |
else: # Geração de etapa única
|
| 928 |
print("\n--- INICIANDO GERAÇÃO DE ETAPA ÚNICA ---")
|
| 929 |
t_single = time.perf_counter()
|
| 930 |
-
|
| 931 |
-
single_pass_kwargs.update(self.config.get("first_pass", {}))
|
| 932 |
-
single_pass_kwargs["guidance_scale"] = float(guidance_scale)
|
| 933 |
single_pass_kwargs["output_type"] = "latent"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 934 |
|
| 935 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 936 |
log_tensor_info(latents, "Latentes Finais (Etapa Única)")
|
| 937 |
print(f"[DEBUG] Etapa única concluída em {time.perf_counter() - t_single:.2f}s")
|
| 938 |
|
| 939 |
latents_list.append(latents)
|
| 940 |
-
|
| 941 |
# --- ETAPA FINAL: DECODIFICAÇÃO E CODIFICAÇÃO MP4 ---
|
| 942 |
print("\n--- INICIANDO ETAPA FINAL: DECODIFICAÇÃO E MONTAGEM ---")
|
| 943 |
|
|
|
|
| 579 |
i=0
|
| 580 |
while i < n_chunks:
|
| 581 |
start = (num_latente_por_chunk*i)
|
| 582 |
+
end = (start+num_latente_por_chunk+(overlap+1))
|
| 583 |
if i+1 < n_chunks:
|
| 584 |
+
chunk = latents_brutos[:, :, start:end, :, :].clone().detach()
|
| 585 |
+
print(f"[DEBUG] chunk{i+1}[:, :, {start}:{end}, :, :] = {chunk.shape[2]}")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 586 |
else:
|
| 587 |
+
chunk = latents_brutos[:, :, start:, :, :].clone().detach()
|
| 588 |
+
print(f"[DEBUG] chunk{i+1}[:, :, {start}:, :, :] = {chunk.shape[2]}")
|
| 589 |
chunks.append(chunk)
|
| 590 |
i+=1
|
| 591 |
else:
|
|
|
|
| 869 |
except Exception:
|
| 870 |
pass
|
| 871 |
|
| 872 |
+
latents_parts_up = self._dividir_latentes_por_tamanho(latents_cpu_up,40,1)
|
| 873 |
|
| 874 |
print("\n\n--- INICIANDO ETAPA 3: REFINAMENTO DE TEXTURA (SECOND PASS) ---")
|
| 875 |
|
|
|
|
| 919 |
print("#########################################")
|
| 920 |
|
| 921 |
print("\n\n--- FIM ETAPA 3: REFINAMENTO DE TEXTURA (SECOND PASS) ---")
|
| 922 |
+
|
| 923 |
else: # Geração de etapa única
|
| 924 |
print("\n--- INICIANDO GERAÇÃO DE ETAPA ÚNICA ---")
|
| 925 |
t_single = time.perf_counter()
|
| 926 |
+
|
|
|
|
|
|
|
| 927 |
single_pass_kwargs["output_type"] = "latent"
|
| 928 |
+
single_pass_call_kwargs = call_kwargs.copy()
|
| 929 |
+
first_pass_config_from_yaml = PIPELINE_CONFIG_YAML.get("first_pass", {})
|
| 930 |
+
|
| 931 |
+
single_pass_call_kwargs["timesteps"] = first_pass_config_from_yaml.get("timesteps")
|
| 932 |
+
single_pass_call_kwargs["guidance_scale"] = float(guidance_scale)
|
| 933 |
+
single_pass_call_kwargs["stg_scale"] = first_pass_config_from_yaml.get("stg_scale")
|
| 934 |
+
single_pass_call_kwargs["rescaling_scale"] = first_pass_config_from_yaml.get("rescaling_scale")
|
| 935 |
+
single_pass_call_kwargs["skip_block_list"] = first_pass_config_from_yaml.get("skip_block_list")
|
| 936 |
|
| 937 |
+
# Remove keys that might conflict or are not used in single pass / handled by above
|
| 938 |
+
single_pass_call_kwargs.pop("num_inference_steps", None)
|
| 939 |
+
single_pass_call_kwargs.pop("first_pass", None)
|
| 940 |
+
single_pass_call_kwargs.pop("second_pass", None)
|
| 941 |
+
single_pass_call_kwargs.pop("downscale_factor", None)
|
| 942 |
+
|
| 943 |
+
latents = self.pipeline(**single_pass_call_kwargs).images
|
| 944 |
log_tensor_info(latents, "Latentes Finais (Etapa Única)")
|
| 945 |
print(f"[DEBUG] Etapa única concluída em {time.perf_counter() - t_single:.2f}s")
|
| 946 |
|
| 947 |
latents_list.append(latents)
|
| 948 |
+
|
| 949 |
# --- ETAPA FINAL: DECODIFICAÇÃO E CODIFICAÇÃO MP4 ---
|
| 950 |
print("\n--- INICIANDO ETAPA FINAL: DECODIFICAÇÃO E MONTAGEM ---")
|
| 951 |
|