Eueuiaa commited on
Commit
1ec4b43
·
verified ·
1 Parent(s): 49750ad

Update api/ltx_server.py

Browse files
Files changed (1) hide show
  1. api/ltx_server.py +21 -33
api/ltx_server.py CHANGED
@@ -14,13 +14,9 @@ logging.set_verbosity_error()
14
  logging.set_verbosity_warning()
15
  logging.set_verbosity_info()
16
  logging.set_verbosity_debug()
17
-
18
-
19
  LTXV_DEBUG=1
20
  LTXV_FRAME_LOG_EVERY=8
21
 
22
-
23
-
24
  # --- 1. IMPORTAÇÕES ---
25
  import os, subprocess, shlex, tempfile
26
  import torch
@@ -108,8 +104,6 @@ def _query_gpu_processes_via_nvidiasmi(device_index: int) -> List[Dict]:
108
  continue
109
  return results
110
 
111
-
112
-
113
  def calculate_new_dimensions(orig_w, orig_h, divisor=8):
114
  """
115
  Calcula novas dimensões mantendo a proporção, garantindo que ambos os
@@ -144,7 +138,6 @@ def calculate_new_dimensions(orig_w, orig_h, divisor=8):
144
  print(f"[Dimension Calc] Original: {orig_w}x{orig_h} -> Calculado: {new_w:.0f}x{new_h:.0f} -> Final (divisível por {divisor}): {final_w}x{final_h}")
145
  return final_h, final_w # Retorna (altura, largura)
146
 
147
-
148
  def handle_media_upload_for_dims(filepath, current_h, current_w):
149
  """
150
  Esta função agora usará o novo cálculo robusto.
@@ -218,7 +211,6 @@ def add_deps_to_path():
218
  add_deps_to_path()
219
 
220
  # --- 3. IMPORTAÇÕES ESPECÍFICAS DO MODELO ---
221
-
222
  from ltx_video.pipelines.pipeline_ltx_video import ConditioningItem, LTXMultiScalePipeline
223
  from ltx_video.utils.skip_layer_strategy import SkipLayerStrategy
224
  from ltx_video.models.autoencoders.vae_encode import un_normalize_latents, normalize_latents
@@ -241,10 +233,6 @@ def log_tensor_info(tensor, name="Tensor"):
241
  pass
242
  print("------------------------------------------\n")
243
 
244
-
245
-
246
-
247
-
248
  # --- 5. CLASSE PRINCIPAL DO SERVIÇO ---
249
  class VideoService:
250
  def __init__(self):
@@ -367,28 +355,28 @@ class VideoService:
367
 
368
  def _load_models(self):
369
  t0 = time.perf_counter()
370
- LTX_REPO = "Lightricks/LTX-Video"
371
- print("[DEBUG] Baixando checkpoint principal...")
372
- distilled_model_path = hf_hub_download(
373
- repo_id=LTX_REPO,
374
- filename=self.config["checkpoint_path"],
375
- local_dir=os.getenv("HF_HOME"),
376
- cache_dir=os.getenv("HF_HOME_CACHE"),
377
- token=os.getenv("HF_TOKEN"),
378
- )
379
- self.config["checkpoint_path"] = distilled_model_path
380
- print(f"[DEBUG] Checkpoint em: {distilled_model_path}")
381
-
382
- print("[DEBUG] Baixando upscaler espacial...")
383
- spatial_upscaler_path = hf_hub_download(
384
- repo_id=LTX_REPO,
385
- filename=self.config["spatial_upscaler_model_path"],
386
- local_dir=os.getenv("HF_HOME"),
387
- cache_dir=os.getenv("HF_HOME_CACHE"),
388
- token=os.getenv("HF_TOKEN")
389
  )
390
- self.config["spatial_upscaler_model_path"] = spatial_upscaler_path
391
- print(f"[DEBUG] Upscaler em: {spatial_upscaler_path}")
392
 
393
  print("[DEBUG] Construindo pipeline...")
394
  pipeline = create_ltx_video_pipeline(
 
14
  logging.set_verbosity_warning()
15
  logging.set_verbosity_info()
16
  logging.set_verbosity_debug()
 
 
17
  LTXV_DEBUG=1
18
  LTXV_FRAME_LOG_EVERY=8
19
 
 
 
20
  # --- 1. IMPORTAÇÕES ---
21
  import os, subprocess, shlex, tempfile
22
  import torch
 
104
  continue
105
  return results
106
 
 
 
107
  def calculate_new_dimensions(orig_w, orig_h, divisor=8):
108
  """
109
  Calcula novas dimensões mantendo a proporção, garantindo que ambos os
 
138
  print(f"[Dimension Calc] Original: {orig_w}x{orig_h} -> Calculado: {new_w:.0f}x{new_h:.0f} -> Final (divisível por {divisor}): {final_w}x{final_h}")
139
  return final_h, final_w # Retorna (altura, largura)
140
 
 
141
  def handle_media_upload_for_dims(filepath, current_h, current_w):
142
  """
143
  Esta função agora usará o novo cálculo robusto.
 
211
  add_deps_to_path()
212
 
213
  # --- 3. IMPORTAÇÕES ESPECÍFICAS DO MODELO ---
 
214
  from ltx_video.pipelines.pipeline_ltx_video import ConditioningItem, LTXMultiScalePipeline
215
  from ltx_video.utils.skip_layer_strategy import SkipLayerStrategy
216
  from ltx_video.models.autoencoders.vae_encode import un_normalize_latents, normalize_latents
 
233
  pass
234
  print("------------------------------------------\n")
235
 
 
 
 
 
236
  # --- 5. CLASSE PRINCIPAL DO SERVIÇO ---
237
  class VideoService:
238
  def __init__(self):
 
355
 
356
  def _load_models(self):
357
  t0 = time.perf_counter()
358
+ #LTX_REPO = "Lightricks/LTX-Video"
359
+ #print("[DEBUG] Baixando checkpoint principal...")
360
+ #distilled_model_path = hf_hub_download(
361
+ # repo_id=LTX_REPO,
362
+ # filename=self.config["checkpoint_path"],
363
+ # local_dir=os.getenv("HF_HOME"),
364
+ # cache_dir=os.getenv("HF_HOME_CACHE"),
365
+ # token=os.getenv("HF_TOKEN"),
366
+ #)
367
+ #self.config["checkpoint_path"] = distilled_model_path
368
+ #print(f"[DEBUG] Checkpoint em: {distilled_model_path}")
369
+
370
+ #print("[DEBUG] Baixando upscaler espacial...")
371
+ #spatial_upscaler_path = hf_hub_download(
372
+ # repo_id=LTX_REPO,
373
+ # filename=self.config["spatial_upscaler_model_path"],
374
+ # local_dir=os.getenv("HF_HOME"),
375
+ # cache_dir=os.getenv("HF_HOME_CACHE"),
376
+ # token=os.getenv("HF_TOKEN")
377
  )
378
+ #self.config["spatial_upscaler_model_path"] = spatial_upscaler_path
379
+ #print(f"[DEBUG] Upscaler em: {spatial_upscaler_path}")
380
 
381
  print("[DEBUG] Construindo pipeline...")
382
  pipeline = create_ltx_video_pipeline(