Defter77 commited on
Commit
c1ec482
·
verified ·
1 Parent(s): 656c239

Upload start.sh with huggingface_hub

Browse files
Files changed (1) hide show
  1. start.sh +50 -22
start.sh CHANGED
@@ -39,28 +39,24 @@ echo "Downloading models and PuLID code..."
39
  cd /app
40
  python3 download_models.py
41
 
42
- # Setup folder paths for ComfyUI
43
- cat > /tmp/folder_paths.json << EOF
44
- {
45
- "input_path": "/tmp/comfyui_input",
46
- "output_path": "/tmp/comfyui_output",
47
- "temp_path": "/tmp/comfyui_temp",
48
- "models_path": {
49
- "checkpoints": ["/tmp/comfyui_models/checkpoints"],
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
- }
59
- EOF
60
 
61
- # Set environment variables to ensure we find all modules
62
- export PYTHONPATH="${PYTHONPATH}:/app/ComfyUI:/app/ComfyUI/custom_nodes"
63
- export COMFYUI_FOLDER_PATHS_FILE="/tmp/folder_paths.json"
 
 
 
 
 
 
 
 
64
 
65
  # Install additional Python packages (but don't fail if they can't be installed)
66
  echo "Installing required Python packages..."
@@ -284,7 +280,39 @@ fi
284
  # Start ComfyUI in the background with custom directories
285
  cd /app/ComfyUI
286
  echo "Starting ComfyUI server..."
287
- python3 main.py --listen 0.0.0.0 --port 8188 \
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
288
  --input-directory /tmp/comfyui_input \
289
  --output-directory /tmp/comfyui_output \
290
  --temp-directory /tmp/comfyui_temp \
 
39
  cd /app
40
  python3 download_models.py
41
 
42
+ # Setup folder paths for ComfyUI directly in Python code
43
+ # Instead of relying on a YAML file that might have formatting issues
44
+ echo "Setting up model paths in Python code..."
45
+ cat > /tmp/setup_paths.py << EOF
46
+ import os
47
+ import folder_paths
 
 
 
 
 
 
 
 
 
 
 
 
48
 
49
+ # Setup base folders (even if they already exist in folder_paths)
50
+ folder_paths.folder_names_and_paths["checkpoints"] = (["/tmp/comfyui_models/checkpoints"], folder_paths.supported_pt_extensions)
51
+ folder_paths.folder_names_and_paths["controlnet"] = (["/tmp/comfyui_models/controlnet"], folder_paths.supported_pt_extensions)
52
+ folder_paths.folder_names_and_paths["clip_vision"] = (["/tmp/comfyui_models/clip_vision"], folder_paths.supported_pt_extensions)
53
+ folder_paths.folder_names_and_paths["ipadapter"] = (["/tmp/comfyui_models/ipadapter"], folder_paths.supported_pt_extensions)
54
+ folder_paths.folder_names_and_paths["pulid"] = (["/tmp/comfyui_models/pulid"], folder_paths.supported_pt_extensions)
55
+ folder_paths.folder_names_and_paths["evaclip"] = (["/tmp/comfyui_models/evaclip"], folder_paths.supported_pt_extensions + [".pt"])
56
+ folder_paths.folder_names_and_paths["insightface"] = (["/tmp/comfyui_models/insightface"], [".onnx"])
57
+
58
+ print("Model paths set up successfully")
59
+ EOF
60
 
61
  # Install additional Python packages (but don't fail if they can't be installed)
62
  echo "Installing required Python packages..."
 
280
  # Start ComfyUI in the background with custom directories
281
  cd /app/ComfyUI
282
  echo "Starting ComfyUI server..."
283
+
284
+ # Create a simple startup script for ComfyUI that imports our path setup
285
+ cat > /tmp/comfyui_starter.py << EOF
286
+ # Import folder path setup first
287
+ import sys
288
+ import os
289
+
290
+ # Add the temp directory to Python path so we can import setup_paths
291
+ sys.path.append('/tmp')
292
+
293
+ # Try to set up folder paths - ignore errors
294
+ try:
295
+ import setup_paths
296
+ except Exception as e:
297
+ print(f"Warning: Failed to import setup_paths: {e}")
298
+ print("Continuing anyway with default paths")
299
+
300
+ # Now run the main ComfyUI script
301
+ sys.path.append('/app/ComfyUI')
302
+
303
+ # Set environment variables
304
+ os.environ['PYTHONPATH'] = f"{os.environ.get('PYTHONPATH', '')}:/app/ComfyUI:/app/ComfyUI/custom_nodes"
305
+
306
+ # Import and run ComfyUI
307
+ try:
308
+ import main
309
+ except Exception as e:
310
+ print(f"Error starting ComfyUI: {e}")
311
+ print("ComfyUI failed to start, but we'll continue with the Gradio interface")
312
+ EOF
313
+
314
+ # Run ComfyUI with our custom starter script
315
+ python3 /tmp/comfyui_starter.py --listen 0.0.0.0 --port 8188 \
316
  --input-directory /tmp/comfyui_input \
317
  --output-directory /tmp/comfyui_output \
318
  --temp-directory /tmp/comfyui_temp \