Update api/seedvr_server.py
Browse files- api/seedvr_server.py +24 -21
api/seedvr_server.py
CHANGED
|
@@ -28,31 +28,33 @@ except ImportError as e:
|
|
| 28 |
print(f"Verifique se o repositório em '{SEEDVR_REPO_PATH}' está correto e completo.")
|
| 29 |
raise e
|
| 30 |
|
|
|
|
| 31 |
|
| 32 |
class SeedVRServer:
|
| 33 |
-
|
| 34 |
-
SEEDVR_ROOT = SEEDVR_REPO_PATH
|
| 35 |
-
CKPTS_ROOT = Path("/data/seedvr_models_fp16")
|
| 36 |
-
OUTPUT_ROOT = Path(os.getenv("OUTPUT_ROOT", "/app/outputs"))
|
| 37 |
-
INPUT_ROOT = Path(os.getenv("INPUT_ROOT", "/app/inputs"))
|
| 38 |
-
HF_HOME_CACHE = Path(os.getenv("HF_HOME", "/data/.cache/huggingface"))
|
| 39 |
-
REPO_URL = os.getenv("SEEDVR_GIT_URL", "https://github.com/numz/ComfyUI-SeedVR2_VideoUpscaler")
|
| 40 |
-
NUM_GPUS_TOTAL = 4#int(os.getenv("NUM_GPUS", "8"))
|
| 41 |
-
|
| 42 |
-
print("🚀 SeedVRServer (Modo de Chamada Direta) inicializando...")
|
| 43 |
-
for p in [CKPTS_ROOT, OUTPUT_ROOT, INPUT_ROOT, HF_HOME_CACHE]:
|
| 44 |
-
p.mkdir(parents=True, exist_ok=True)
|
| 45 |
-
|
| 46 |
-
setup_dependencies()
|
| 47 |
-
print("✅ SeedVRServer (Modo de Chamada Direta) pronto.")
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
def __init__(self, **kwargs):
|
| 52 |
"""
|
| 53 |
Inicializa o servidor, define os caminhos e prepara o ambiente.
|
| 54 |
"""
|
| 55 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
def setup_dependencies():
|
| 57 |
""" Garante que o repositório e os modelos estão presentes. """
|
| 58 |
self._ensure_repo()
|
|
@@ -118,7 +120,7 @@ class SeedVRServer:
|
|
| 118 |
try:
|
| 119 |
# Informa a UI que o processo começou.
|
| 120 |
if progress:
|
| 121 |
-
progress(0.01, "Initializing...")
|
| 122 |
|
| 123 |
# Chama a função importada do script original, passando o callback de progresso.
|
| 124 |
# Este callback será chamado de dentro da lógica de multi-processamento.
|
|
@@ -132,7 +134,7 @@ class SeedVRServer:
|
|
| 132 |
final_fps = fps if fps and fps > 0 else original_fps
|
| 133 |
save_frames_to_video(result_tensor, str(output_filepath), final_fps, args.debug)
|
| 134 |
|
| 135 |
-
print(f"
|
| 136 |
|
| 137 |
# Retorna o caminho do arquivo gerado para a UI.
|
| 138 |
return str(output_filepath)
|
|
@@ -140,6 +142,7 @@ class SeedVRServer:
|
|
| 140 |
except Exception as e:
|
| 141 |
print(f"❌ Error during direct inference execution: {e}")
|
| 142 |
import traceback
|
|
|
|
| 143 |
traceback.print_exc()
|
| 144 |
# Propaga o erro para a UI do Gradio, que o exibirá de forma amigável.
|
| 145 |
raise
|
|
|
|
| 28 |
print(f"Verifique se o repositório em '{SEEDVR_REPO_PATH}' está correto e completo.")
|
| 29 |
raise e
|
| 30 |
|
| 31 |
+
init = false
|
| 32 |
|
| 33 |
class SeedVRServer:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
def __init__(self, **kwargs):
|
| 35 |
"""
|
| 36 |
Inicializa o servidor, define os caminhos e prepara o ambiente.
|
| 37 |
"""
|
| 38 |
+
|
| 39 |
+
SEEDVR_ROOT = SEEDVR_REPO_PATH
|
| 40 |
+
CKPTS_ROOT = Path("/data/seedvr_models_fp16")
|
| 41 |
+
OUTPUT_ROOT = Path(os.getenv("OUTPUT_ROOT", "/app/outputs"))
|
| 42 |
+
INPUT_ROOT = Path(os.getenv("INPUT_ROOT", "/app/inputs"))
|
| 43 |
+
HF_HOME_CACHE = Path(os.getenv("HF_HOME", "/data/.cache/huggingface"))
|
| 44 |
+
REPO_URL = os.getenv("SEEDVR_GIT_URL", "https://github.com/numz/ComfyUI-SeedVR2_VideoUpscaler")
|
| 45 |
+
NUM_GPUS_TOTAL = 4#int(os.getenv("NUM_GPUS", "8"))
|
| 46 |
+
|
| 47 |
+
if init:
|
| 48 |
+
print(⚒️ SeedVRServer (Modo de Chamada Direta) inicializando...")
|
| 49 |
+
for p in [CKPTS_ROOT, OUTPUT_ROOT, INPUT_ROOT, HF_HOME_CACHE]:
|
| 50 |
+
p.mkdir(parents=True, exist_ok=True)
|
| 51 |
+
|
| 52 |
+
setup_dependencies()
|
| 53 |
+
print("📦 SeedVRServer (Modo de Chamada Direta) pronto.")
|
| 54 |
+
init = true
|
| 55 |
+
else:
|
| 56 |
+
print(⚙️ SeedVRServer pronto.")
|
| 57 |
+
|
| 58 |
def setup_dependencies():
|
| 59 |
""" Garante que o repositório e os modelos estão presentes. """
|
| 60 |
self._ensure_repo()
|
|
|
|
| 120 |
try:
|
| 121 |
# Informa a UI que o processo começou.
|
| 122 |
if progress:
|
| 123 |
+
progress(0.01, "⌛ Initializing...")
|
| 124 |
|
| 125 |
# Chama a função importada do script original, passando o callback de progresso.
|
| 126 |
# Este callback será chamado de dentro da lógica de multi-processamento.
|
|
|
|
| 134 |
final_fps = fps if fps and fps > 0 else original_fps
|
| 135 |
save_frames_to_video(result_tensor, str(output_filepath), final_fps, args.debug)
|
| 136 |
|
| 137 |
+
print(f"💾 Video saved successfully to: {output_filepath}")
|
| 138 |
|
| 139 |
# Retorna o caminho do arquivo gerado para a UI.
|
| 140 |
return str(output_filepath)
|
|
|
|
| 142 |
except Exception as e:
|
| 143 |
print(f"❌ Error during direct inference execution: {e}")
|
| 144 |
import traceback
|
| 145 |
+
init = false
|
| 146 |
traceback.print_exc()
|
| 147 |
# Propaga o erro para a UI do Gradio, que o exibirá de forma amigável.
|
| 148 |
raise
|