Update api/seedvr_server.py
Browse files- api/seedvr_server.py +23 -30
api/seedvr_server.py
CHANGED
|
@@ -22,22 +22,31 @@ if str(SEEDVR_REPO_PATH) not in sys.path:
|
|
| 22 |
# Tenta importar as funções necessárias APÓS a modificação do path.
|
| 23 |
# Se falhar, a aplicação não pode continuar.
|
| 24 |
try:
|
| 25 |
-
from inference_cli import run_inference_logic,
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
-
|
| 28 |
-
self
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
|
| 39 |
-
|
| 40 |
-
|
| 41 |
|
| 42 |
def setup_dependencies(self):
|
| 43 |
""" Garante que o repositório e os modelos estão presentes. """
|
|
@@ -69,22 +78,6 @@ try:
|
|
| 69 |
)
|
| 70 |
print("[SeedVRServer] Checkpoints (FP16) estão no local correto.")
|
| 71 |
|
| 72 |
-
except ImportError as e:
|
| 73 |
-
print(f"ERRO FATAL: Não foi possível importar de 'inference_cli.py'.")
|
| 74 |
-
print(f"Verifique se o repositório em '{SEEDVR_REPO_PATH}' está correto e completo.")
|
| 75 |
-
raise e
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
class SeedVRServer:
|
| 82 |
-
def __init__(self, **kwargs):
|
| 83 |
-
"""
|
| 84 |
-
Inicializa o servidor, define os caminhos e prepara o ambiente.
|
| 85 |
-
"""
|
| 86 |
-
|
| 87 |
-
|
| 88 |
def run_inference_direct(
|
| 89 |
self,
|
| 90 |
file_path: str, *,
|
|
@@ -110,7 +103,7 @@ class SeedVRServer:
|
|
| 110 |
batch_size=sp_size,
|
| 111 |
model="seedvr2_ema_7b_sharp_fp16.safetensors",
|
| 112 |
preserve_vram=True,
|
| 113 |
-
debug=
|
| 114 |
cuda_device=",".join(map(str, range(self.NUM_GPUS_TOTAL))),
|
| 115 |
skip_first_frames=0,
|
| 116 |
load_cap=0,
|
|
|
|
| 22 |
# Tenta importar as funções necessárias APÓS a modificação do path.
|
| 23 |
# Se falhar, a aplicação não pode continuar.
|
| 24 |
try:
|
| 25 |
+
from inference_cli import run_inference_logic, save_frames_to_video
|
| 26 |
+
except ImportError as e:
|
| 27 |
+
print(f"ERRO FATAL: Não foi possível importar de 'inference_cli.py'.")
|
| 28 |
+
print(f"Verifique se o repositório em '{SEEDVR_REPO_PATH}' está correto e completo.")
|
| 29 |
+
raise e
|
| 30 |
|
| 31 |
+
class SeedVRServer:
|
| 32 |
+
def __init__(self, **kwargs):
|
| 33 |
+
"""
|
| 34 |
+
Inicializa o servidor, define os caminhos e prepara o ambiente.
|
| 35 |
+
"""
|
| 36 |
+
self.SEEDVR_ROOT = SEEDVR_REPO_PATH
|
| 37 |
+
self.CKPTS_ROOT = Path("/data/seedvr_models_fp16")
|
| 38 |
+
self.OUTPUT_ROOT = Path(os.getenv("OUTPUT_ROOT", "/app/outputs"))
|
| 39 |
+
self.INPUT_ROOT = Path(os.getenv("INPUT_ROOT", "/app/inputs"))
|
| 40 |
+
self.HF_HOME_CACHE = Path(os.getenv("HF_HOME", "/data/.cache/huggingface"))
|
| 41 |
+
self.REPO_URL = os.getenv("SEEDVR_GIT_URL", "https://github.com/numz/ComfyUI-SeedVR2_VideoUpscaler")
|
| 42 |
+
self.NUM_GPUS_TOTAL = int(os.getenv("NUM_GPUS", "8"))
|
| 43 |
|
| 44 |
+
print("🚀 SeedVRServer (Modo de Chamada Direta) inicializando...")
|
| 45 |
+
for p in [self.CKPTS_ROOT, self.OUTPUT_ROOT, self.INPUT_ROOT, self.HF_HOME_CACHE]:
|
| 46 |
+
p.mkdir(parents=True, exist_ok=True)
|
| 47 |
|
| 48 |
+
self.setup_dependencies()
|
| 49 |
+
print("✅ SeedVRServer (Modo de Chamada Direta) pronto.")
|
| 50 |
|
| 51 |
def setup_dependencies(self):
|
| 52 |
""" Garante que o repositório e os modelos estão presentes. """
|
|
|
|
| 78 |
)
|
| 79 |
print("[SeedVRServer] Checkpoints (FP16) estão no local correto.")
|
| 80 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 81 |
def run_inference_direct(
|
| 82 |
self,
|
| 83 |
file_path: str, *,
|
|
|
|
| 103 |
batch_size=sp_size,
|
| 104 |
model="seedvr2_ema_7b_sharp_fp16.safetensors",
|
| 105 |
preserve_vram=True,
|
| 106 |
+
debug=False, # Mantém o debug ativo para logs detalhados.
|
| 107 |
cuda_device=",".join(map(str, range(self.NUM_GPUS_TOTAL))),
|
| 108 |
skip_first_frames=0,
|
| 109 |
load_cap=0,
|