Defter77 commited on
Commit
0e4c91f
·
verified ·
1 Parent(s): 916fa4d

Upload start.sh with huggingface_hub

Browse files
Files changed (1) hide show
  1. start.sh +67 -10
start.sh CHANGED
@@ -14,10 +14,10 @@ mkdir -p /tmp/comfyui_output
14
  mkdir -p /tmp/comfyui_temp
15
  mkdir -p /tmp/comfyui_user
16
  mkdir -p /tmp/workflows
17
- mkdir -p /tmp/comfyui_models
18
 
19
- # Set proper permissions
20
- chmod -R 777 /tmp/comfyui_input /tmp/comfyui_output /tmp/comfyui_temp /tmp/comfyui_user /tmp/workflows /tmp/comfyui_models
21
 
22
  # Download files from the dataset repository
23
  echo "Downloading images from dataset repository..."
@@ -32,19 +32,77 @@ echo "Verifying downloaded files:"
32
  ls -la /tmp/comfyui_input/
33
  ls -la /tmp/workflows/
34
 
35
- # Run model downloader
36
- echo "Downloading models..."
37
  cd /app
38
  python3 download_models.py
39
 
40
- # Set environment variables
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
  export PYTHONPATH="${PYTHONPATH}:/app/ComfyUI:/app/ComfyUI/custom_nodes"
 
42
 
43
- # Install additional Python packages
44
  echo "Installing required Python packages..."
45
- pip install -e /app/ComfyUI/custom_nodes/PuLID || echo "Failed to install PuLID, continuing anyway"
46
  pip install comfyui-frontend-package comfyui-workflow-templates || echo "Package installation failed, continuing anyway"
47
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48
  # Start ComfyUI in the background with custom directories
49
  cd /app/ComfyUI
50
  echo "Starting ComfyUI server..."
@@ -52,8 +110,7 @@ python3 main.py --listen 0.0.0.0 --port 8188 \
52
  --input-directory /tmp/comfyui_input \
53
  --output-directory /tmp/comfyui_output \
54
  --temp-directory /tmp/comfyui_temp \
55
- --user-dir /tmp/comfyui_user \
56
- --models-directory /tmp/comfyui_models &
57
  COMFY_PID=$!
58
 
59
  # Wait for ComfyUI to start
 
14
  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"
21
 
22
  # Download files from the dataset repository
23
  echo "Downloading images from dataset repository..."
 
32
  ls -la /tmp/comfyui_input/
33
  ls -la /tmp/workflows/
34
 
35
+ # Run model downloader to get models and PuLID
36
+ echo "Downloading models and PuLID code..."
37
  cd /app
38
  python3 download_models.py
39
 
40
+ # Setup folder paths for ComfyUI
41
+ cat > /tmp/folder_paths.json << EOF
42
+ {
43
+ "input_path": "/tmp/comfyui_input",
44
+ "output_path": "/tmp/comfyui_output",
45
+ "temp_path": "/tmp/comfyui_temp",
46
+ "models_path": {
47
+ "checkpoints": ["/tmp/comfyui_models/checkpoints"],
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
+ }
55
+ EOF
56
+
57
+ # Set environment variables to ensure we find all modules
58
  export PYTHONPATH="${PYTHONPATH}:/app/ComfyUI:/app/ComfyUI/custom_nodes"
59
+ 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 minimal implementation..."
70
+ mkdir -p /app/ComfyUI/custom_nodes/PuLID
71
+
72
+ # Create minimal init file
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 minimal node implementation
78
+ cat > /app/ComfyUI/custom_nodes/PuLID/pulid_node.py << EOF
79
+ import os
80
+ import folder_paths
81
+
82
+ class PulidModelLoader:
83
+ @classmethod
84
+ def INPUT_TYPES(s):
85
+ return {"required": {"model_name": (folder_paths.get_filename_list("pulid"), )}}
86
+
87
+ RETURN_TYPES = ("PULID_MODEL",)
88
+ FUNCTION = "load_model"
89
+ CATEGORY = "loaders"
90
+
91
+ def load_model(self, model_name):
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 minimal PuLID implementation"
104
+ fi
105
+
106
  # Start ComfyUI in the background with custom directories
107
  cd /app/ComfyUI
108
  echo "Starting ComfyUI server..."
 
110
  --input-directory /tmp/comfyui_input \
111
  --output-directory /tmp/comfyui_output \
112
  --temp-directory /tmp/comfyui_temp \
113
+ --user-dir /tmp/comfyui_user &
 
114
  COMFY_PID=$!
115
 
116
  # Wait for ComfyUI to start