eeuuia commited on
Commit
bb4dfa4
·
verified ·
1 Parent(s): 80792cf

Update api/ltx/ltx_aduc_manager.py

Browse files
Files changed (1) hide show
  1. api/ltx/ltx_aduc_manager.py +22 -6
api/ltx/ltx_aduc_manager.py CHANGED
@@ -13,7 +13,8 @@ from pathlib import Path
13
  from typing import List, Optional, Tuple, Union, Dict
14
  from dataclasses import dataclass
15
  import threading
16
-
 
17
  import torch
18
  from diffusers.utils.torch_utils import randn_tensor
19
  from huggingface_hub import hf_hub_download
@@ -22,12 +23,27 @@ from huggingface_hub import hf_hub_download
22
  from api.managers.gpu_manager import gpu_manager
23
  from api.ltx.ltx_utils import build_ltx_pipeline_on_cpu
24
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
  # --- Importações da biblioteca LTX-Video ---
26
- try:
27
- from ltx_video.pipelines.pipeline_ltx_video import LTXVideoPipeline
28
- from ltx_video.models.autoencoders.vae_encode import vae_encode, latent_to_pixel_coords
29
- except ImportError as e:
30
- raise ImportError(f"Could not import from LTX-Video library. Check sys.path and repo integrity. Error: {e}")
31
 
32
 
33
  # ==============================================================================
 
13
  from typing import List, Optional, Tuple, Union, Dict
14
  from dataclasses import dataclass
15
  import threading
16
+ import sys
17
+ from pathlib import Path
18
  import torch
19
  from diffusers.utils.torch_utils import randn_tensor
20
  from huggingface_hub import hf_hub_download
 
23
  from api.managers.gpu_manager import gpu_manager
24
  from api.ltx.ltx_utils import build_ltx_pipeline_on_cpu
25
 
26
+ LTX_VIDEO_REPO_DIR = Path("/data/LTX-Video")
27
+ LTX_REPO_ID = "Lightricks/LTX-Video"
28
+ CACHE_DIR = os.environ.get("HF_HOME")
29
+
30
+
31
+ def add_deps_to_path():
32
+ """
33
+ Adiciona o diretório do repositório LTX ao sys.path para garantir que suas
34
+ bibliotecas possam ser importadas.
35
+ """
36
+ repo_path = str(LTX_VIDEO_REPO_DIR.resolve())
37
+ if repo_path not in sys.path:
38
+ sys.path.insert(0, repo_path)
39
+ logging.info(f"[ltx_utils] LTX-Video repository added to sys.path: {repo_path}")
40
+
41
+ # Executa a função imediatamente para configurar o ambiente antes de qualquer importação.
42
+ add_deps_to_path()
43
+
44
  # --- Importações da biblioteca LTX-Video ---
45
+ from ltx_video.pipelines.pipeline_ltx_video import LTXVideoPipeline
46
+ from ltx_video.models.autoencoders.vae_encode import vae_encode, latent_to_pixel_coords
 
 
 
47
 
48
 
49
  # ==============================================================================