Update api/ltx_server_refactored.py
Browse files- api/ltx_server_refactored.py +14 -15
api/ltx_server_refactored.py
CHANGED
|
@@ -303,7 +303,6 @@ class VideoService:
|
|
| 303 |
self.finalize(keep_paths=[])
|
| 304 |
|
| 305 |
def generate_upscale_denoise(self, latents_path, prompt, negative_prompt, guidance_scale, seed):
|
| 306 |
-
try:
|
| 307 |
used_seed = random.randint(0, 2**32 - 1) if seed is None else int(seed)
|
| 308 |
seed_everething(used_seed)
|
| 309 |
temp_dir = tempfile.mkdtemp(prefix="ltxv_up_"); self._register_tmp_dir(temp_dir)
|
|
@@ -340,21 +339,21 @@ class VideoService:
|
|
| 340 |
else:
|
| 341 |
final_latents_list.append(refined_chunk)
|
| 342 |
|
| 343 |
-
|
| 344 |
-
|
| 345 |
|
| 346 |
-
|
| 347 |
-
|
| 348 |
-
|
| 349 |
-
|
| 350 |
-
|
| 351 |
-
|
| 352 |
-
|
| 353 |
-
|
| 354 |
-
|
| 355 |
-
|
| 356 |
-
|
| 357 |
-
|
| 358 |
|
| 359 |
def encode_mp4(self, latents_path: str, fps: int = 24):
|
| 360 |
latents = torch.load(latents_path)
|
|
|
|
| 303 |
self.finalize(keep_paths=[])
|
| 304 |
|
| 305 |
def generate_upscale_denoise(self, latents_path, prompt, negative_prompt, guidance_scale, seed):
|
|
|
|
| 306 |
used_seed = random.randint(0, 2**32 - 1) if seed is None else int(seed)
|
| 307 |
seed_everething(used_seed)
|
| 308 |
temp_dir = tempfile.mkdtemp(prefix="ltxv_up_"); self._register_tmp_dir(temp_dir)
|
|
|
|
| 339 |
else:
|
| 340 |
final_latents_list.append(refined_chunk)
|
| 341 |
|
| 342 |
+
final_latents = torch.cat(final_latents_list, dim=2)
|
| 343 |
+
log_tensor_info(final_latents, "Latentes Upscaled/Refinados Finais")
|
| 344 |
|
| 345 |
+
latents_cpu = final_latents.detach().to("cpu")
|
| 346 |
+
tensor_path = os.path.join(results_dir, f"latents_refined_{used_seed}.pt")
|
| 347 |
+
torch.save(latents_cpu, tensor_path)
|
| 348 |
+
pixel_tensor = vae_manager_singleton.decode(final_latents, decode_timestep=float(self.config.get("decode_timestep", 0.05)))
|
| 349 |
+
video_path = self._save_and_log_video(pixel_tensor, "refined_video", 24.0, temp_dir, results_dir, used_seed)
|
| 350 |
+
return video_path, tensor_path except Exception as e:
|
| 351 |
+
except Exception as e:
|
| 352 |
+
pass
|
| 353 |
+
finally:
|
| 354 |
+
torch.cuda.empty_cache()
|
| 355 |
+
torch.cuda.ipc_collect()
|
| 356 |
+
self.finalize(keep_paths=[])
|
| 357 |
|
| 358 |
def encode_mp4(self, latents_path: str, fps: int = 24):
|
| 359 |
latents = torch.load(latents_path)
|