Upload ltx_server.py
Browse files- api/ltx_server.py +7 -7
api/ltx_server.py
CHANGED
|
@@ -71,9 +71,9 @@ def _query_gpu_processes_via_nvidiasmi(device_index: int) -> List[Dict]:
|
|
| 71 |
parts = [p.strip() for p in line.split(",")]
|
| 72 |
if len(parts) >= 3:
|
| 73 |
try:
|
| 74 |
-
pid = int(parts[
|
| 75 |
-
name = parts[
|
| 76 |
-
used_mb = int(parts[
|
| 77 |
user = "unknown"
|
| 78 |
try:
|
| 79 |
import psutil
|
|
@@ -389,7 +389,7 @@ class VideoService:
|
|
| 389 |
padding_values, progress_callback=None):
|
| 390 |
print(f"[DEBUG] Decodificando latentes → vídeo: {output_video_path}")
|
| 391 |
pad_left, pad_right, pad_top, pad_bottom = padding_values
|
| 392 |
-
T = latents.shape[
|
| 393 |
print(f"[DEBUG] Latentes shape={tuple(latents.shape)} frames={T}")
|
| 394 |
start = time.perf_counter()
|
| 395 |
with imageio.get_writer(output_video_path, fps=frame_rate, codec="libx264", quality=8) as writer:
|
|
@@ -407,12 +407,12 @@ class VideoService:
|
|
| 407 |
print(f"[DEBUG] vae.decode frame={i}")
|
| 408 |
else:
|
| 409 |
raise RuntimeError("Pipeline não possui decode_latents/vae.decode.")
|
| 410 |
-
pixel_chw = pixel_bchw[
|
| 411 |
if pixel_chw.min() < 0:
|
| 412 |
pixel_chw = (pixel_chw.clamp(-1, 1) + 1.0) / 2.0
|
| 413 |
else:
|
| 414 |
pixel_chw = pixel_chw.clamp(0, 1)
|
| 415 |
-
H, W = pixel_chw.shape[
|
| 416 |
h_end = H - pad_bottom if pad_bottom > 0 else H
|
| 417 |
w_end = W - pad_right if pad_right > 0 else W
|
| 418 |
pixel_chw = pixel_chw[:, pad_top:h_end, pad_left:w_end]
|
|
@@ -632,7 +632,7 @@ class VideoService:
|
|
| 632 |
else:
|
| 633 |
print("[DEBUG] Escrevendo vídeo a partir de pixels (sem latentes)...")
|
| 634 |
with imageio.get_writer(output_video_path, fps=call_kwargs["frame_rate"], codec="libx264", quality=8) as writer:
|
| 635 |
-
T = result_tensor.shape[
|
| 636 |
for i in range(T):
|
| 637 |
frame_chw = result_tensor[0, :, i]
|
| 638 |
frame_hwc_u8 = (frame_chw.permute(1, 2, 0)
|
|
|
|
| 71 |
parts = [p.strip() for p in line.split(",")]
|
| 72 |
if len(parts) >= 3:
|
| 73 |
try:
|
| 74 |
+
pid = int(parts[0])
|
| 75 |
+
name = parts[1]
|
| 76 |
+
used_mb = int(parts[2])
|
| 77 |
user = "unknown"
|
| 78 |
try:
|
| 79 |
import psutil
|
|
|
|
| 389 |
padding_values, progress_callback=None):
|
| 390 |
print(f"[DEBUG] Decodificando latentes → vídeo: {output_video_path}")
|
| 391 |
pad_left, pad_right, pad_top, pad_bottom = padding_values
|
| 392 |
+
T = latents.shape[2]
|
| 393 |
print(f"[DEBUG] Latentes shape={tuple(latents.shape)} frames={T}")
|
| 394 |
start = time.perf_counter()
|
| 395 |
with imageio.get_writer(output_video_path, fps=frame_rate, codec="libx264", quality=8) as writer:
|
|
|
|
| 407 |
print(f"[DEBUG] vae.decode frame={i}")
|
| 408 |
else:
|
| 409 |
raise RuntimeError("Pipeline não possui decode_latents/vae.decode.")
|
| 410 |
+
pixel_chw = pixel_bchw[0]
|
| 411 |
if pixel_chw.min() < 0:
|
| 412 |
pixel_chw = (pixel_chw.clamp(-1, 1) + 1.0) / 2.0
|
| 413 |
else:
|
| 414 |
pixel_chw = pixel_chw.clamp(0, 1)
|
| 415 |
+
H, W = pixel_chw.shape[2]
|
| 416 |
h_end = H - pad_bottom if pad_bottom > 0 else H
|
| 417 |
w_end = W - pad_right if pad_right > 0 else W
|
| 418 |
pixel_chw = pixel_chw[:, pad_top:h_end, pad_left:w_end]
|
|
|
|
| 632 |
else:
|
| 633 |
print("[DEBUG] Escrevendo vídeo a partir de pixels (sem latentes)...")
|
| 634 |
with imageio.get_writer(output_video_path, fps=call_kwargs["frame_rate"], codec="libx264", quality=8) as writer:
|
| 635 |
+
T = result_tensor.shape[2]
|
| 636 |
for i in range(T):
|
| 637 |
frame_chw = result_tensor[0, :, i]
|
| 638 |
frame_hwc_u8 = (frame_chw.permute(1, 2, 0)
|