Spaces:
Running
Running
Clean up logs and install performance optimizations
Browse filesImprovements:
- Install SageAttention & Flash Attention for faster processing
- Suppress unnecessary warnings (Python warnings, TensorFlow logs)
- Hide verbose git clone output (capture_output=True)
- Cleaner model download progress (numbered list)
- Remove time estimates and excessive status messages
Result: Much cleaner, quieter output with better performance.
app.py
CHANGED
|
@@ -11,6 +11,10 @@ from huggingface_hub import hf_hub_download
|
|
| 11 |
|
| 12 |
os.environ["HF_HUB_ENABLE_HF_TRANSFER"] = "1"
|
| 13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
# Configuration
|
| 15 |
REPO_URL = "https://github.com/00quebec/Synthid-Bypass"
|
| 16 |
COMFYUI_URL = "https://github.com/comfyanonymous/ComfyUI"
|
|
@@ -26,12 +30,12 @@ def setup():
|
|
| 26 |
if os.path.exists(os.path.join(COMFYUI_DIR, "models/vae/ae.safetensors")):
|
| 27 |
print("--- ENVIRONMENT ALREADY INITIALIZED ---")
|
| 28 |
return
|
| 29 |
-
|
| 30 |
-
print("--- FIRST TIME SETUP STARTING
|
| 31 |
-
|
| 32 |
# 1. Clone Repos
|
| 33 |
-
subprocess.run(["git", "clone", COMFYUI_URL, COMFYUI_DIR], check=True)
|
| 34 |
-
subprocess.run(["git", "clone", REPO_URL, BYPASS_REPO_DIR], check=True)
|
| 35 |
|
| 36 |
# 2. Setup Custom Nodes
|
| 37 |
nodes = [
|
|
@@ -55,14 +59,21 @@ def setup():
|
|
| 55 |
name = url.split("/")[-1]
|
| 56 |
node_dest = os.path.join(custom_nodes_path, name)
|
| 57 |
if not os.path.exists(node_dest):
|
| 58 |
-
subprocess.run(["git", "clone", url, node_dest], check=True)
|
| 59 |
# Checkout specific versions for Impact packs to match reference workflow
|
| 60 |
if name == "ComfyUI-Impact-Pack":
|
| 61 |
-
subprocess.run(["git", "checkout", IMPACT_PACK_COMMIT], cwd=node_dest, check=True)
|
| 62 |
-
print(f"Pinned Impact Pack to commit {IMPACT_PACK_COMMIT}")
|
| 63 |
elif name == "ComfyUI-Impact-Subpack":
|
| 64 |
-
subprocess.run(["git", "checkout", IMPACT_SUBPACK_VERSION], cwd=node_dest, check=True)
|
| 65 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
|
| 67 |
# 3. Models Download logic (Using hf_transfer for speed)
|
| 68 |
model_configs = [
|
|
@@ -77,27 +88,23 @@ def setup():
|
|
| 77 |
{"repo": "numz/SeedVR2_comfyUI", "file": "ema_vae_fp16.safetensors", "dest": "models/SEEDVR2/ema_vae_fp16.safetensors"}
|
| 78 |
]
|
| 79 |
|
| 80 |
-
print("
|
| 81 |
-
for cfg in model_configs:
|
| 82 |
out_path = os.path.join(COMFYUI_DIR, cfg['dest'])
|
| 83 |
if not os.path.exists(out_path):
|
| 84 |
os.makedirs(os.path.dirname(out_path), exist_ok=True)
|
| 85 |
-
print(f"
|
| 86 |
-
# Use local_dir to avoid symlink issues in ZeroGPU workers
|
| 87 |
-
dest_dir = os.path.dirname(out_path)
|
| 88 |
hf_hub_download(
|
| 89 |
-
repo_id=cfg['repo'],
|
| 90 |
filename=cfg['file'],
|
| 91 |
local_dir=COMFYUI_DIR,
|
| 92 |
local_dir_use_symlinks=False
|
| 93 |
)
|
| 94 |
-
# hf_hub_download with local_dir might save to a different path if nested
|
| 95 |
-
# We ensure it's at the expected 'dest'
|
| 96 |
actual_downloaded_path = os.path.join(COMFYUI_DIR, cfg['file'])
|
| 97 |
if actual_downloaded_path != out_path and os.path.exists(actual_downloaded_path):
|
| 98 |
os.rename(actual_downloaded_path, out_path)
|
| 99 |
|
| 100 |
-
print("
|
| 101 |
|
| 102 |
def convert_to_api(web_workflow):
|
| 103 |
"""
|
|
|
|
| 11 |
|
| 12 |
os.environ["HF_HUB_ENABLE_HF_TRANSFER"] = "1"
|
| 13 |
|
| 14 |
+
# Suppress unnecessary warnings
|
| 15 |
+
os.environ["PYTHONWARNINGS"] = "ignore"
|
| 16 |
+
os.environ["TF_CPP_MIN_LOG_LEVEL"] = "3"
|
| 17 |
+
|
| 18 |
# Configuration
|
| 19 |
REPO_URL = "https://github.com/00quebec/Synthid-Bypass"
|
| 20 |
COMFYUI_URL = "https://github.com/comfyanonymous/ComfyUI"
|
|
|
|
| 30 |
if os.path.exists(os.path.join(COMFYUI_DIR, "models/vae/ae.safetensors")):
|
| 31 |
print("--- ENVIRONMENT ALREADY INITIALIZED ---")
|
| 32 |
return
|
| 33 |
+
|
| 34 |
+
print("--- FIRST TIME SETUP STARTING ---")
|
| 35 |
+
|
| 36 |
# 1. Clone Repos
|
| 37 |
+
subprocess.run(["git", "clone", COMFYUI_URL, COMFYUI_DIR], check=True, capture_output=True)
|
| 38 |
+
subprocess.run(["git", "clone", REPO_URL, BYPASS_REPO_DIR], check=True, capture_output=True)
|
| 39 |
|
| 40 |
# 2. Setup Custom Nodes
|
| 41 |
nodes = [
|
|
|
|
| 59 |
name = url.split("/")[-1]
|
| 60 |
node_dest = os.path.join(custom_nodes_path, name)
|
| 61 |
if not os.path.exists(node_dest):
|
| 62 |
+
subprocess.run(["git", "clone", url, node_dest], check=True, capture_output=True)
|
| 63 |
# Checkout specific versions for Impact packs to match reference workflow
|
| 64 |
if name == "ComfyUI-Impact-Pack":
|
| 65 |
+
subprocess.run(["git", "checkout", IMPACT_PACK_COMMIT], cwd=node_dest, check=True, capture_output=True)
|
|
|
|
| 66 |
elif name == "ComfyUI-Impact-Subpack":
|
| 67 |
+
subprocess.run(["git", "checkout", IMPACT_SUBPACK_VERSION], cwd=node_dest, check=True, capture_output=True)
|
| 68 |
+
|
| 69 |
+
print("✓ Custom nodes installed")
|
| 70 |
+
|
| 71 |
+
# Install performance optimizations (SageAttention, Flash Attention)
|
| 72 |
+
print("Installing performance optimizations...")
|
| 73 |
+
subprocess.run([
|
| 74 |
+
sys.executable, "-m", "pip", "install",
|
| 75 |
+
"sageattention", "flash-attn", "--no-cache-dir"
|
| 76 |
+
], capture_output=True, check=False) # Don't fail if these can't install
|
| 77 |
|
| 78 |
# 3. Models Download logic (Using hf_transfer for speed)
|
| 79 |
model_configs = [
|
|
|
|
| 88 |
{"repo": "numz/SeedVR2_comfyUI", "file": "ema_vae_fp16.safetensors", "dest": "models/SEEDVR2/ema_vae_fp16.safetensors"}
|
| 89 |
]
|
| 90 |
|
| 91 |
+
print("Downloading models (fast with HF_TRANSFER)...")
|
| 92 |
+
for i, cfg in enumerate(model_configs, 1):
|
| 93 |
out_path = os.path.join(COMFYUI_DIR, cfg['dest'])
|
| 94 |
if not os.path.exists(out_path):
|
| 95 |
os.makedirs(os.path.dirname(out_path), exist_ok=True)
|
| 96 |
+
print(f" [{i}/{len(model_configs)}] {cfg['file'].split('/')[-1]}")
|
|
|
|
|
|
|
| 97 |
hf_hub_download(
|
| 98 |
+
repo_id=cfg['repo'],
|
| 99 |
filename=cfg['file'],
|
| 100 |
local_dir=COMFYUI_DIR,
|
| 101 |
local_dir_use_symlinks=False
|
| 102 |
)
|
|
|
|
|
|
|
| 103 |
actual_downloaded_path = os.path.join(COMFYUI_DIR, cfg['file'])
|
| 104 |
if actual_downloaded_path != out_path and os.path.exists(actual_downloaded_path):
|
| 105 |
os.rename(actual_downloaded_path, out_path)
|
| 106 |
|
| 107 |
+
print("✓ Setup complete")
|
| 108 |
|
| 109 |
def convert_to_api(web_workflow):
|
| 110 |
"""
|