Eueuiaa commited on
Commit
f736eae
verified
1 Parent(s): cc85702

Update api/ltx_server.py

Browse files
Files changed (1) hide show
  1. api/ltx_server.py +47 -45
api/ltx_server.py CHANGED
@@ -254,51 +254,7 @@ class LatentConditioningItem:
254
  media_frame_number: int
255
  conditioning_strength: float
256
 
257
-
258
- # --- 5. CLASSE PRINCIPAL DO SERVI脟O ---
259
- class VideoService:
260
- def __init__(self):
261
- t0 = time.perf_counter()
262
- print("[DEBUG] Inicializando VideoService...")
263
- self.debug = os.getenv("LTXV_DEBUG", "1") == "1"
264
- self.frame_log_every = int(os.getenv("LTXV_FRAME_LOG_EVERY", "8"))
265
- self.config = self._load_config()
266
- print(f"[DEBUG] Config carregada (precision={self.config.get('precision')}, sampler={self.config.get('sampler')})")
267
- self.device = "cuda" if torch.cuda.is_available() else "cpu"
268
- print(f"[DEBUG] Device selecionado: {self.device}")
269
- self.last_memory_reserved_mb = 0.0
270
- self._tmp_dirs = set(); self._tmp_files = set(); self._last_outputs = []
271
-
272
-
273
- self.pipeline, self.latent_upsampler = self._load_models()
274
- print(f"[DEBUG] Pipeline e Upsampler carregados. Upsampler ativo? {bool(self.latent_upsampler)}")
275
-
276
- self._apply_ltx_pipeline_patches()
277
-
278
- print(f"[DEBUG] Movendo modelos para {self.device}...")
279
- self.pipeline.to(self.device)
280
- if self.latent_upsampler:
281
- self.latent_upsampler.to(self.device)
282
-
283
- self._apply_precision_policy()
284
- print(f"[DEBUG] runtime_autocast_dtype = {getattr(self, 'runtime_autocast_dtype', None)}")
285
-
286
- # Injeta pipeline/vae no manager (impede vae=None)
287
- vae_manager_singleton.attach_pipeline(
288
- self.pipeline,
289
- device=self.device,
290
- autocast_dtype=self.runtime_autocast_dtype
291
- )
292
- print(f"[DEBUG] VAE manager conectado: has_vae={hasattr(self.pipeline, 'vae')} device={self.device}")
293
-
294
- if self.device == "cuda":
295
- torch.cuda.empty_cache()
296
- self._log_gpu_memory("Ap贸s carregar modelos")
297
-
298
- print(f"[DEBUG] VideoService pronto. boot_time={time.perf_counter()-t0:.3f}s")
299
-
300
-
301
- def _aduc_prepare_conditioning_patch(
302
  self: "LTXVideoPipeline",
303
  conditioning_items: Optional[List[Union["ConditioningItem", "LatentConditioningItem"]]],
304
  init_latents: torch.Tensor,
@@ -353,6 +309,52 @@ class VideoService:
353
 
354
  return init_latents, init_pixel_coords, init_conditioning_mask, extra_conditioning_num_latents
355
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
356
 
357
  # Em ltx_server.py
358
  def _apply_ltx_pipeline_patches(self):
 
254
  media_frame_number: int
255
  conditioning_strength: float
256
 
257
+ def _aduc_prepare_conditioning_patch(
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
258
  self: "LTXVideoPipeline",
259
  conditioning_items: Optional[List[Union["ConditioningItem", "LatentConditioningItem"]]],
260
  init_latents: torch.Tensor,
 
309
 
310
  return init_latents, init_pixel_coords, init_conditioning_mask, extra_conditioning_num_latents
311
 
312
+
313
+
314
+ # --- 5. CLASSE PRINCIPAL DO SERVI脟O ---
315
+ class VideoService:
316
+ def __init__(self):
317
+ t0 = time.perf_counter()
318
+ print("[DEBUG] Inicializando VideoService...")
319
+ self.debug = os.getenv("LTXV_DEBUG", "1") == "1"
320
+ self.frame_log_every = int(os.getenv("LTXV_FRAME_LOG_EVERY", "8"))
321
+ self.config = self._load_config()
322
+ print(f"[DEBUG] Config carregada (precision={self.config.get('precision')}, sampler={self.config.get('sampler')})")
323
+ self.device = "cuda" if torch.cuda.is_available() else "cpu"
324
+ print(f"[DEBUG] Device selecionado: {self.device}")
325
+ self.last_memory_reserved_mb = 0.0
326
+ self._tmp_dirs = set(); self._tmp_files = set(); self._last_outputs = []
327
+
328
+
329
+ self.pipeline, self.latent_upsampler = self._load_models()
330
+ print(f"[DEBUG] Pipeline e Upsampler carregados. Upsampler ativo? {bool(self.latent_upsampler)}")
331
+
332
+ self._apply_ltx_pipeline_patches()
333
+
334
+ print(f"[DEBUG] Movendo modelos para {self.device}...")
335
+ self.pipeline.to(self.device)
336
+ if self.latent_upsampler:
337
+ self.latent_upsampler.to(self.device)
338
+
339
+ self._apply_precision_policy()
340
+ print(f"[DEBUG] runtime_autocast_dtype = {getattr(self, 'runtime_autocast_dtype', None)}")
341
+
342
+ # Injeta pipeline/vae no manager (impede vae=None)
343
+ vae_manager_singleton.attach_pipeline(
344
+ self.pipeline,
345
+ device=self.device,
346
+ autocast_dtype=self.runtime_autocast_dtype
347
+ )
348
+ print(f"[DEBUG] VAE manager conectado: has_vae={hasattr(self.pipeline, 'vae')} device={self.device}")
349
+
350
+ if self.device == "cuda":
351
+ torch.cuda.empty_cache()
352
+ self._log_gpu_memory("Ap贸s carregar modelos")
353
+
354
+ print(f"[DEBUG] VideoService pronto. boot_time={time.perf_counter()-t0:.3f}s")
355
+
356
+
357
+
358
 
359
  # Em ltx_server.py
360
  def _apply_ltx_pipeline_patches(self):