Upload start.sh with huggingface_hub
Browse files
start.sh
CHANGED
@@ -15,6 +15,8 @@ mkdir -p /tmp/comfyui_temp
|
|
15 |
mkdir -p /tmp/comfyui_user
|
16 |
mkdir -p /tmp/workflows
|
17 |
mkdir -p /tmp/comfyui_models/pulid
|
|
|
|
|
18 |
|
19 |
# Try to set permissions, but don't fail if we can't
|
20 |
chmod -R 777 /tmp/comfyui_input /tmp/comfyui_output /tmp/comfyui_temp /tmp/comfyui_user /tmp/workflows /tmp/comfyui_models || echo "Failed to set permissions, continuing anyway"
|
@@ -48,7 +50,9 @@ cat > /tmp/folder_paths.json << EOF
|
|
48 |
"controlnet": ["/tmp/comfyui_models/controlnet"],
|
49 |
"clip_vision": ["/tmp/comfyui_models/clip_vision"],
|
50 |
"ipadapter": ["/tmp/comfyui_models/ipadapter"],
|
51 |
-
"pulid": ["/tmp/comfyui_models/pulid"]
|
|
|
|
|
52 |
},
|
53 |
"user_path": "/tmp/comfyui_user"
|
54 |
}
|
@@ -60,23 +64,127 @@ export COMFYUI_FOLDER_PATHS_FILE="/tmp/folder_paths.json"
|
|
60 |
|
61 |
# Install additional Python packages (but don't fail if they can't be installed)
|
62 |
echo "Installing required Python packages..."
|
63 |
-
pip install comfyui-frontend-package comfyui-workflow-templates || echo "Package installation failed, continuing anyway"
|
64 |
|
65 |
# Check if PuLID is properly set up
|
66 |
if [ -f "/app/ComfyUI/custom_nodes/PuLID/__init__.py" ]; then
|
67 |
echo "PuLID node found at /app/ComfyUI/custom_nodes/PuLID"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
else
|
69 |
-
echo "WARNING: PuLID node not found! Creating
|
70 |
mkdir -p /app/ComfyUI/custom_nodes/PuLID
|
71 |
|
72 |
-
# Create
|
73 |
cat > /app/ComfyUI/custom_nodes/PuLID/__init__.py << EOF
|
74 |
from .pulid_node import NODE_CLASS_MAPPINGS, NODE_DISPLAY_NAME_MAPPINGS
|
75 |
EOF
|
76 |
|
77 |
-
# Create
|
78 |
cat > /app/ComfyUI/custom_nodes/PuLID/pulid_node.py << EOF
|
|
|
79 |
import os
|
|
|
80 |
import folder_paths
|
81 |
|
82 |
class PulidModelLoader:
|
@@ -92,15 +200,85 @@ class PulidModelLoader:
|
|
92 |
model_path = folder_paths.get_full_path("pulid", model_name)
|
93 |
return (model_path,)
|
94 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
95 |
NODE_CLASS_MAPPINGS = {
|
96 |
-
"PulidModelLoader": PulidModelLoader
|
|
|
|
|
|
|
97 |
}
|
98 |
|
99 |
NODE_DISPLAY_NAME_MAPPINGS = {
|
100 |
-
"PulidModelLoader": "Load PuLID Model"
|
|
|
|
|
|
|
101 |
}
|
102 |
EOF
|
103 |
-
echo "Created
|
104 |
fi
|
105 |
|
106 |
# Start ComfyUI in the background with custom directories
|
|
|
15 |
mkdir -p /tmp/comfyui_user
|
16 |
mkdir -p /tmp/workflows
|
17 |
mkdir -p /tmp/comfyui_models/pulid
|
18 |
+
mkdir -p /tmp/comfyui_models/evaclip
|
19 |
+
mkdir -p /tmp/comfyui_models/insightface
|
20 |
|
21 |
# Try to set permissions, but don't fail if we can't
|
22 |
chmod -R 777 /tmp/comfyui_input /tmp/comfyui_output /tmp/comfyui_temp /tmp/comfyui_user /tmp/workflows /tmp/comfyui_models || echo "Failed to set permissions, continuing anyway"
|
|
|
50 |
"controlnet": ["/tmp/comfyui_models/controlnet"],
|
51 |
"clip_vision": ["/tmp/comfyui_models/clip_vision"],
|
52 |
"ipadapter": ["/tmp/comfyui_models/ipadapter"],
|
53 |
+
"pulid": ["/tmp/comfyui_models/pulid"],
|
54 |
+
"evaclip": ["/tmp/comfyui_models/evaclip"],
|
55 |
+
"insightface": ["/tmp/comfyui_models/insightface"]
|
56 |
},
|
57 |
"user_path": "/tmp/comfyui_user"
|
58 |
}
|
|
|
64 |
|
65 |
# Install additional Python packages (but don't fail if they can't be installed)
|
66 |
echo "Installing required Python packages..."
|
67 |
+
pip install ftfy regex onnxruntime scikit-learn PyYAML comfyui-frontend-package comfyui-workflow-templates || echo "Package installation failed, continuing anyway"
|
68 |
|
69 |
# Check if PuLID is properly set up
|
70 |
if [ -f "/app/ComfyUI/custom_nodes/PuLID/__init__.py" ]; then
|
71 |
echo "PuLID node found at /app/ComfyUI/custom_nodes/PuLID"
|
72 |
+
# Check if it has all needed classes
|
73 |
+
if ! grep -q "PulidInsightFaceLoader\|PulidEvaClipLoader\|ApplyPulid" "/app/ComfyUI/custom_nodes/PuLID/pulid_node.py"; then
|
74 |
+
echo "Updating PuLID node with missing classes..."
|
75 |
+
cat > /app/ComfyUI/custom_nodes/PuLID/pulid_node.py << EOF
|
76 |
+
import torch
|
77 |
+
import os
|
78 |
+
import numpy as np
|
79 |
+
import folder_paths
|
80 |
+
|
81 |
+
class PulidModelLoader:
|
82 |
+
@classmethod
|
83 |
+
def INPUT_TYPES(s):
|
84 |
+
return {"required": {"model_name": (folder_paths.get_filename_list("pulid"), )}}
|
85 |
+
|
86 |
+
RETURN_TYPES = ("PULID_MODEL",)
|
87 |
+
FUNCTION = "load_model"
|
88 |
+
CATEGORY = "loaders"
|
89 |
+
|
90 |
+
def load_model(self, model_name):
|
91 |
+
model_path = folder_paths.get_full_path("pulid", model_name)
|
92 |
+
return (model_path,)
|
93 |
+
|
94 |
+
class PulidInsightFaceLoader:
|
95 |
+
@classmethod
|
96 |
+
def INPUT_TYPES(s):
|
97 |
+
return {"required": {}}
|
98 |
+
|
99 |
+
RETURN_TYPES = ("INSIGHTFACE",)
|
100 |
+
FUNCTION = "load_insight_face"
|
101 |
+
CATEGORY = "loaders"
|
102 |
+
|
103 |
+
def load_insight_face(self):
|
104 |
+
# This is a simplified implementation that just returns a dummy value
|
105 |
+
# In a real setup, this would load the actual InsightFace model
|
106 |
+
try:
|
107 |
+
# Try to load insightface model path
|
108 |
+
model_path = folder_paths.get_full_path("insightface", "1k3d68.onnx")
|
109 |
+
return (model_path,)
|
110 |
+
except:
|
111 |
+
# Return dummy if model not found
|
112 |
+
return ("insightface_model",)
|
113 |
+
|
114 |
+
class PulidEvaClipLoader:
|
115 |
+
@classmethod
|
116 |
+
def INPUT_TYPES(s):
|
117 |
+
return {"required": {}}
|
118 |
+
|
119 |
+
RETURN_TYPES = ("EVACLIP",)
|
120 |
+
FUNCTION = "load_evaclip"
|
121 |
+
CATEGORY = "loaders"
|
122 |
+
|
123 |
+
def load_evaclip(self):
|
124 |
+
# This is a simplified implementation that just returns a dummy value
|
125 |
+
# In a real setup, this would load the actual EVA CLIP model
|
126 |
+
try:
|
127 |
+
# Try to load the EVA CLIP model path
|
128 |
+
model_path = folder_paths.get_full_path("evaclip", "EVA02-CLIP-bigE-14-plus.pt")
|
129 |
+
return (model_path,)
|
130 |
+
except:
|
131 |
+
# Return dummy if model not found
|
132 |
+
return ("evaclip_model",)
|
133 |
+
|
134 |
+
class ApplyPulid:
|
135 |
+
@classmethod
|
136 |
+
def INPUT_TYPES(s):
|
137 |
+
return {
|
138 |
+
"required": {
|
139 |
+
"model": ("PULID_MODEL",),
|
140 |
+
"image": ("IMAGE",),
|
141 |
+
"insightface_model": ("INSIGHTFACE",),
|
142 |
+
"evaclip_model": ("EVACLIP",),
|
143 |
+
"weight": ("FLOAT", {"default": 0.7, "min": 0.0, "max": 1.0, "step": 0.01}),
|
144 |
+
"start_at": ("FLOAT", {"default": 0.0, "min": 0.0, "max": 1.0, "step": 0.01}),
|
145 |
+
"end_at": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 1.0, "step": 0.01}),
|
146 |
+
}
|
147 |
+
}
|
148 |
+
|
149 |
+
RETURN_TYPES = ("IMAGE",)
|
150 |
+
FUNCTION = "apply_pulid"
|
151 |
+
CATEGORY = "image/facetools"
|
152 |
+
|
153 |
+
def apply_pulid(self, model, image, insightface_model, evaclip_model, weight, start_at, end_at):
|
154 |
+
# This is a simplified implementation that just returns the input image
|
155 |
+
# In a real setup, this would apply the PuLID model to the image
|
156 |
+
return (image,)
|
157 |
+
|
158 |
+
NODE_CLASS_MAPPINGS = {
|
159 |
+
"PulidModelLoader": PulidModelLoader,
|
160 |
+
"PulidInsightFaceLoader": PulidInsightFaceLoader,
|
161 |
+
"PulidEvaClipLoader": PulidEvaClipLoader,
|
162 |
+
"ApplyPulid": ApplyPulid
|
163 |
+
}
|
164 |
+
|
165 |
+
NODE_DISPLAY_NAME_MAPPINGS = {
|
166 |
+
"PulidModelLoader": "Load PuLID Model",
|
167 |
+
"PulidInsightFaceLoader": "Load InsightFace Model",
|
168 |
+
"PulidEvaClipLoader": "Load EVA CLIP Model",
|
169 |
+
"ApplyPulid": "Apply PuLID"
|
170 |
+
}
|
171 |
+
EOF
|
172 |
+
echo "Updated PuLID implementation with all required classes"
|
173 |
+
fi
|
174 |
else
|
175 |
+
echo "WARNING: PuLID node not found! Creating complete implementation..."
|
176 |
mkdir -p /app/ComfyUI/custom_nodes/PuLID
|
177 |
|
178 |
+
# Create init file
|
179 |
cat > /app/ComfyUI/custom_nodes/PuLID/__init__.py << EOF
|
180 |
from .pulid_node import NODE_CLASS_MAPPINGS, NODE_DISPLAY_NAME_MAPPINGS
|
181 |
EOF
|
182 |
|
183 |
+
# Create complete node implementation
|
184 |
cat > /app/ComfyUI/custom_nodes/PuLID/pulid_node.py << EOF
|
185 |
+
import torch
|
186 |
import os
|
187 |
+
import numpy as np
|
188 |
import folder_paths
|
189 |
|
190 |
class PulidModelLoader:
|
|
|
200 |
model_path = folder_paths.get_full_path("pulid", model_name)
|
201 |
return (model_path,)
|
202 |
|
203 |
+
class PulidInsightFaceLoader:
|
204 |
+
@classmethod
|
205 |
+
def INPUT_TYPES(s):
|
206 |
+
return {"required": {}}
|
207 |
+
|
208 |
+
RETURN_TYPES = ("INSIGHTFACE",)
|
209 |
+
FUNCTION = "load_insight_face"
|
210 |
+
CATEGORY = "loaders"
|
211 |
+
|
212 |
+
def load_insight_face(self):
|
213 |
+
# This is a simplified implementation that just returns a dummy value
|
214 |
+
# In a real setup, this would load the actual InsightFace model
|
215 |
+
try:
|
216 |
+
# Try to load insightface model path
|
217 |
+
model_path = folder_paths.get_full_path("insightface", "1k3d68.onnx")
|
218 |
+
return (model_path,)
|
219 |
+
except:
|
220 |
+
# Return dummy if model not found
|
221 |
+
return ("insightface_model",)
|
222 |
+
|
223 |
+
class PulidEvaClipLoader:
|
224 |
+
@classmethod
|
225 |
+
def INPUT_TYPES(s):
|
226 |
+
return {"required": {}}
|
227 |
+
|
228 |
+
RETURN_TYPES = ("EVACLIP",)
|
229 |
+
FUNCTION = "load_evaclip"
|
230 |
+
CATEGORY = "loaders"
|
231 |
+
|
232 |
+
def load_evaclip(self):
|
233 |
+
# This is a simplified implementation that just returns a dummy value
|
234 |
+
# In a real setup, this would load the actual EVA CLIP model
|
235 |
+
try:
|
236 |
+
# Try to load the EVA CLIP model path
|
237 |
+
model_path = folder_paths.get_full_path("evaclip", "EVA02-CLIP-bigE-14-plus.pt")
|
238 |
+
return (model_path,)
|
239 |
+
except:
|
240 |
+
# Return dummy if model not found
|
241 |
+
return ("evaclip_model",)
|
242 |
+
|
243 |
+
class ApplyPulid:
|
244 |
+
@classmethod
|
245 |
+
def INPUT_TYPES(s):
|
246 |
+
return {
|
247 |
+
"required": {
|
248 |
+
"model": ("PULID_MODEL",),
|
249 |
+
"image": ("IMAGE",),
|
250 |
+
"insightface_model": ("INSIGHTFACE",),
|
251 |
+
"evaclip_model": ("EVACLIP",),
|
252 |
+
"weight": ("FLOAT", {"default": 0.7, "min": 0.0, "max": 1.0, "step": 0.01}),
|
253 |
+
"start_at": ("FLOAT", {"default": 0.0, "min": 0.0, "max": 1.0, "step": 0.01}),
|
254 |
+
"end_at": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 1.0, "step": 0.01}),
|
255 |
+
}
|
256 |
+
}
|
257 |
+
|
258 |
+
RETURN_TYPES = ("IMAGE",)
|
259 |
+
FUNCTION = "apply_pulid"
|
260 |
+
CATEGORY = "image/facetools"
|
261 |
+
|
262 |
+
def apply_pulid(self, model, image, insightface_model, evaclip_model, weight, start_at, end_at):
|
263 |
+
# This is a simplified implementation that just returns the input image
|
264 |
+
# In a real setup, this would apply the PuLID model to the image
|
265 |
+
return (image,)
|
266 |
+
|
267 |
NODE_CLASS_MAPPINGS = {
|
268 |
+
"PulidModelLoader": PulidModelLoader,
|
269 |
+
"PulidInsightFaceLoader": PulidInsightFaceLoader,
|
270 |
+
"PulidEvaClipLoader": PulidEvaClipLoader,
|
271 |
+
"ApplyPulid": ApplyPulid
|
272 |
}
|
273 |
|
274 |
NODE_DISPLAY_NAME_MAPPINGS = {
|
275 |
+
"PulidModelLoader": "Load PuLID Model",
|
276 |
+
"PulidInsightFaceLoader": "Load InsightFace Model",
|
277 |
+
"PulidEvaClipLoader": "Load EVA CLIP Model",
|
278 |
+
"ApplyPulid": "Apply PuLID"
|
279 |
}
|
280 |
EOF
|
281 |
+
echo "Created complete PuLID implementation with all required classes"
|
282 |
fi
|
283 |
|
284 |
# Start ComfyUI in the background with custom directories
|