Spaces:
Running
on
Zero
Running
on
Zero
Rishi Desai
commited on
Commit
Β·
6d85bdf
1
Parent(s):
6d974e6
formatting
Browse files- .gitignore +1 -0
- install.py +16 -14
- run.py +4 -1
.gitignore
CHANGED
@@ -1,3 +1,4 @@
|
|
1 |
venv
|
2 |
.env
|
|
|
3 |
ComfyUI
|
|
|
1 |
venv
|
2 |
.env
|
3 |
+
.idea/
|
4 |
ComfyUI
|
install.py
CHANGED
@@ -31,7 +31,7 @@ def manage_git_repo(repo_url, install_path, requirements=False, submodules=False
|
|
31 |
"""
|
32 |
# Save the original directory
|
33 |
original_dir = os.getcwd()
|
34 |
-
|
35 |
if not os.path.exists(install_path) or not os.path.isdir(install_path) or not os.path.exists(
|
36 |
os.path.join(install_path, ".git")):
|
37 |
print(f"π Cloning {os.path.basename(install_path)}...")
|
@@ -50,7 +50,7 @@ def manage_git_repo(repo_url, install_path, requirements=False, submodules=False
|
|
50 |
run_command("python -m pip install -r requirements.txt")
|
51 |
|
52 |
print(f"β
{os.path.basename(install_path)} installed and updated.")
|
53 |
-
|
54 |
# Change back to the original directory
|
55 |
os.chdir(original_dir)
|
56 |
|
@@ -63,6 +63,7 @@ def install_comfyui():
|
|
63 |
requirements=True
|
64 |
)
|
65 |
|
|
|
66 |
def download_huggingface_models():
|
67 |
"""Download required models from Hugging Face and symlink to ComfyUI models directory."""
|
68 |
from huggingface_hub import hf_hub_download
|
@@ -72,7 +73,8 @@ def download_huggingface_models():
|
|
72 |
{"repo_id": "Shakker-Labs/FLUX.1-dev-ControlNet-Union-Pro", "filename": "diffusion_pytorch_model.safetensors",
|
73 |
"folder": "controlnet"},
|
74 |
{"repo_id": "guozinan/PuLID", "filename": "pulid_flux_v0.9.1.safetensors", "folder": "pulid"},
|
75 |
-
{"repo_id": "comfyanonymous/flux_text_encoders", "filename": "t5xxl_fp16.safetensors",
|
|
|
76 |
{"repo_id": "comfyanonymous/flux_text_encoders", "filename": "clip_l.safetensors", "folder": "text_encoders"},
|
77 |
]
|
78 |
|
@@ -84,7 +86,7 @@ def download_huggingface_models():
|
|
84 |
for model in hf_models:
|
85 |
try:
|
86 |
model_path = hf_hub_download(
|
87 |
-
repo_id=model["repo_id"],
|
88 |
filename=model["filename"],
|
89 |
cache_dir=CACHE_PATH,
|
90 |
repo_type=model.get("repo_type", "model")
|
@@ -108,20 +110,20 @@ def download_huggingface_models():
|
|
108 |
def download_and_extract_antelopev2():
|
109 |
"""Download and extract AntelopeV2 model for insightface."""
|
110 |
import zipfile, requests, shutil
|
111 |
-
|
112 |
base_path = os.path.join(MODEL_PATH, "insightface/models")
|
113 |
model_target_path = os.path.join(base_path, "antelopev2")
|
114 |
download_url = "https://huggingface.co/MonsterMMORPG/tools/resolve/main/antelopev2.zip"
|
115 |
zip_path = os.path.join(base_path, "antelopev2.zip")
|
116 |
temp_extract_path = os.path.join(base_path, "temp_antelopev2")
|
117 |
-
|
118 |
os.makedirs(base_path, exist_ok=True)
|
119 |
|
120 |
if not os.path.exists(model_target_path) or not os.listdir(model_target_path):
|
121 |
# First, remove any existing problematic directories
|
122 |
if os.path.exists(model_target_path):
|
123 |
shutil.rmtree(model_target_path)
|
124 |
-
|
125 |
print(f"π₯ Downloading AntelopeV2 model...")
|
126 |
try:
|
127 |
response = requests.get(download_url, stream=True)
|
@@ -133,15 +135,15 @@ def download_and_extract_antelopev2():
|
|
133 |
|
134 |
# Create a temporary extraction directory
|
135 |
os.makedirs(temp_extract_path, exist_ok=True)
|
136 |
-
|
137 |
print("π Extracting AntelopeV2 model...")
|
138 |
with zipfile.ZipFile(zip_path, "r") as zip_ref:
|
139 |
zip_ref.extractall(temp_extract_path)
|
140 |
print("β
Extraction complete.")
|
141 |
-
|
142 |
# Create the target directory
|
143 |
os.makedirs(model_target_path, exist_ok=True)
|
144 |
-
|
145 |
# Move the model files to the correct location
|
146 |
# The ZIP contains a nested antelopev2 directory we need to move files from
|
147 |
nested_model_dir = os.path.join(temp_extract_path, "antelopev2")
|
@@ -150,16 +152,16 @@ def download_and_extract_antelopev2():
|
|
150 |
source = os.path.join(nested_model_dir, item)
|
151 |
target = os.path.join(model_target_path, item)
|
152 |
shutil.move(source, target)
|
153 |
-
|
154 |
# Clean up
|
155 |
if os.path.exists(temp_extract_path):
|
156 |
shutil.rmtree(temp_extract_path)
|
157 |
if os.path.exists(zip_path):
|
158 |
os.remove(zip_path)
|
159 |
-
|
160 |
print("ποΈ Cleaned up temporary files.")
|
161 |
print("β
AntelopeV2 model installed correctly.")
|
162 |
-
|
163 |
except Exception as e:
|
164 |
print(f"β Failed to download/extract AntelopeV2: {e}")
|
165 |
else:
|
@@ -185,7 +187,7 @@ def install_custom_nodes():
|
|
185 |
"name": "rgthree-comfy",
|
186 |
"requirements": True
|
187 |
},
|
188 |
-
{
|
189 |
"repo": "https://github.com/cubiq/ComfyUI_FaceAnalysis",
|
190 |
"name": "ComfyUI_FaceAnalysis",
|
191 |
"requirements": False
|
|
|
31 |
"""
|
32 |
# Save the original directory
|
33 |
original_dir = os.getcwd()
|
34 |
+
|
35 |
if not os.path.exists(install_path) or not os.path.isdir(install_path) or not os.path.exists(
|
36 |
os.path.join(install_path, ".git")):
|
37 |
print(f"π Cloning {os.path.basename(install_path)}...")
|
|
|
50 |
run_command("python -m pip install -r requirements.txt")
|
51 |
|
52 |
print(f"β
{os.path.basename(install_path)} installed and updated.")
|
53 |
+
|
54 |
# Change back to the original directory
|
55 |
os.chdir(original_dir)
|
56 |
|
|
|
63 |
requirements=True
|
64 |
)
|
65 |
|
66 |
+
|
67 |
def download_huggingface_models():
|
68 |
"""Download required models from Hugging Face and symlink to ComfyUI models directory."""
|
69 |
from huggingface_hub import hf_hub_download
|
|
|
73 |
{"repo_id": "Shakker-Labs/FLUX.1-dev-ControlNet-Union-Pro", "filename": "diffusion_pytorch_model.safetensors",
|
74 |
"folder": "controlnet"},
|
75 |
{"repo_id": "guozinan/PuLID", "filename": "pulid_flux_v0.9.1.safetensors", "folder": "pulid"},
|
76 |
+
{"repo_id": "comfyanonymous/flux_text_encoders", "filename": "t5xxl_fp16.safetensors",
|
77 |
+
"folder": "text_encoders"},
|
78 |
{"repo_id": "comfyanonymous/flux_text_encoders", "filename": "clip_l.safetensors", "folder": "text_encoders"},
|
79 |
]
|
80 |
|
|
|
86 |
for model in hf_models:
|
87 |
try:
|
88 |
model_path = hf_hub_download(
|
89 |
+
repo_id=model["repo_id"],
|
90 |
filename=model["filename"],
|
91 |
cache_dir=CACHE_PATH,
|
92 |
repo_type=model.get("repo_type", "model")
|
|
|
110 |
def download_and_extract_antelopev2():
|
111 |
"""Download and extract AntelopeV2 model for insightface."""
|
112 |
import zipfile, requests, shutil
|
113 |
+
|
114 |
base_path = os.path.join(MODEL_PATH, "insightface/models")
|
115 |
model_target_path = os.path.join(base_path, "antelopev2")
|
116 |
download_url = "https://huggingface.co/MonsterMMORPG/tools/resolve/main/antelopev2.zip"
|
117 |
zip_path = os.path.join(base_path, "antelopev2.zip")
|
118 |
temp_extract_path = os.path.join(base_path, "temp_antelopev2")
|
119 |
+
|
120 |
os.makedirs(base_path, exist_ok=True)
|
121 |
|
122 |
if not os.path.exists(model_target_path) or not os.listdir(model_target_path):
|
123 |
# First, remove any existing problematic directories
|
124 |
if os.path.exists(model_target_path):
|
125 |
shutil.rmtree(model_target_path)
|
126 |
+
|
127 |
print(f"π₯ Downloading AntelopeV2 model...")
|
128 |
try:
|
129 |
response = requests.get(download_url, stream=True)
|
|
|
135 |
|
136 |
# Create a temporary extraction directory
|
137 |
os.makedirs(temp_extract_path, exist_ok=True)
|
138 |
+
|
139 |
print("π Extracting AntelopeV2 model...")
|
140 |
with zipfile.ZipFile(zip_path, "r") as zip_ref:
|
141 |
zip_ref.extractall(temp_extract_path)
|
142 |
print("β
Extraction complete.")
|
143 |
+
|
144 |
# Create the target directory
|
145 |
os.makedirs(model_target_path, exist_ok=True)
|
146 |
+
|
147 |
# Move the model files to the correct location
|
148 |
# The ZIP contains a nested antelopev2 directory we need to move files from
|
149 |
nested_model_dir = os.path.join(temp_extract_path, "antelopev2")
|
|
|
152 |
source = os.path.join(nested_model_dir, item)
|
153 |
target = os.path.join(model_target_path, item)
|
154 |
shutil.move(source, target)
|
155 |
+
|
156 |
# Clean up
|
157 |
if os.path.exists(temp_extract_path):
|
158 |
shutil.rmtree(temp_extract_path)
|
159 |
if os.path.exists(zip_path):
|
160 |
os.remove(zip_path)
|
161 |
+
|
162 |
print("ποΈ Cleaned up temporary files.")
|
163 |
print("β
AntelopeV2 model installed correctly.")
|
164 |
+
|
165 |
except Exception as e:
|
166 |
print(f"β Failed to download/extract AntelopeV2: {e}")
|
167 |
else:
|
|
|
187 |
"name": "rgthree-comfy",
|
188 |
"requirements": True
|
189 |
},
|
190 |
+
{ # we already have insightface so don't need requirements (for dlib)
|
191 |
"repo": "https://github.com/cubiq/ComfyUI_FaceAnalysis",
|
192 |
"name": "ComfyUI_FaceAnalysis",
|
193 |
"requirements": False
|
run.py
CHANGED
@@ -4,6 +4,7 @@ import subprocess
|
|
4 |
COMFYUI_PATH = "./ComfyUI"
|
5 |
PORT = 8000
|
6 |
|
|
|
7 |
def run_comfyui():
|
8 |
"""Launch ComfyUI with external access."""
|
9 |
os.chdir(COMFYUI_PATH)
|
@@ -11,6 +12,8 @@ def run_comfyui():
|
|
11 |
|
12 |
subprocess.run(f"python main.py --listen 0.0.0.0 --port {PORT} --disable-auto-launch", shell=True)
|
13 |
|
|
|
14 |
if __name__ == "__main__":
|
15 |
run_comfyui()
|
16 |
-
print(
|
|
|
|
4 |
COMFYUI_PATH = "./ComfyUI"
|
5 |
PORT = 8000
|
6 |
|
7 |
+
|
8 |
def run_comfyui():
|
9 |
"""Launch ComfyUI with external access."""
|
10 |
os.chdir(COMFYUI_PATH)
|
|
|
12 |
|
13 |
subprocess.run(f"python main.py --listen 0.0.0.0 --port {PORT} --disable-auto-launch", shell=True)
|
14 |
|
15 |
+
|
16 |
if __name__ == "__main__":
|
17 |
run_comfyui()
|
18 |
+
print(
|
19 |
+
f"Now run port-forwarding\nssh -L {PORT}:localhost:{PORT} root@[IP_ADDRESS] -p [RUNPOD_PORT] -i ~/.ssh/[PRIVATE_KEY_NAME]")
|