Spaces:
Running
Running
Update start.sh
Browse files
start.sh
CHANGED
|
@@ -6,6 +6,8 @@ COMFY="${COMFYUI_PATH:-/app/ComfyUI}"
|
|
| 6 |
# ------------------------------------------------------------
|
| 7 |
# Runtime directories
|
| 8 |
# ------------------------------------------------------------
|
|
|
|
|
|
|
| 9 |
mkdir -p \
|
| 10 |
"$COMFY/user" \
|
| 11 |
"$COMFY/input" \
|
|
@@ -13,33 +15,69 @@ mkdir -p \
|
|
| 13 |
"$COMFY/temp" \
|
| 14 |
"$COMFY/workflows" \
|
| 15 |
"$COMFY/models/unet" \
|
|
|
|
|
|
|
| 16 |
"$COMFY/models/text_encoders" \
|
| 17 |
"$COMFY/models/vae"
|
| 18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
# ------------------------------------------------------------
|
| 20 |
# Persistent storage
|
| 21 |
# ------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
| 22 |
PERSIST_ROOT="/data/comfyui"
|
| 23 |
|
| 24 |
if [ -d "/data" ] && [ -w "/data" ]; then
|
| 25 |
mkdir -p "$PERSIST_ROOT/models"
|
| 26 |
-
mkdir -p "$PERSIST_ROOT/output"
|
| 27 |
-
mkdir -p "$PERSIST_ROOT/input"
|
| 28 |
-
mkdir -p "$PERSIST_ROOT/temp"
|
| 29 |
-
mkdir -p "$PERSIST_ROOT/workflows"
|
| 30 |
else
|
| 31 |
PERSIST_ROOT="$COMFY"
|
| 32 |
fi
|
| 33 |
|
| 34 |
MODEL_ROOT="$PERSIST_ROOT/models"
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
|
| 40 |
# ------------------------------------------------------------
|
| 41 |
# Model directory links
|
| 42 |
# ------------------------------------------------------------
|
|
|
|
|
|
|
| 43 |
link_model_dir() {
|
| 44 |
local name="$1"
|
| 45 |
local target="$COMFY/models/$name"
|
|
@@ -65,67 +103,12 @@ link_model_dir() {
|
|
| 65 |
fi
|
| 66 |
}
|
| 67 |
|
| 68 |
-
#
|
| 69 |
-
# Output/Input/Temp/Workflow directory links
|
| 70 |
-
# ------------------------------------------------------------
|
| 71 |
-
# Link output, input, temp, workflows to persistent storage
|
| 72 |
-
# This ensures files survive restarts and are shared across sessions
|
| 73 |
-
link_runtime_dir() {
|
| 74 |
-
local name="$1"
|
| 75 |
-
local target="$COMFY/$name"
|
| 76 |
-
local source="$PERSIST_ROOT/$name"
|
| 77 |
-
|
| 78 |
-
mkdir -p "$source"
|
| 79 |
-
|
| 80 |
-
if [ "$source" = "$target" ]; then
|
| 81 |
-
return
|
| 82 |
-
fi
|
| 83 |
-
|
| 84 |
-
if [ -L "$target" ]; then
|
| 85 |
-
return
|
| 86 |
-
fi
|
| 87 |
-
|
| 88 |
-
if [ -d "$target" ]; then
|
| 89 |
-
if [ -z "$(find "$target" -mindepth 1 -maxdepth 1 -print -quit 2>/dev/null)" ]; then
|
| 90 |
-
rmdir "$target"
|
| 91 |
-
ln -s "$source" "$target"
|
| 92 |
-
echo "[INFO] Linked $target -> $source"
|
| 93 |
-
else
|
| 94 |
-
echo "[INFO] Keeping non-empty directory: $target"
|
| 95 |
-
fi
|
| 96 |
-
fi
|
| 97 |
-
}
|
| 98 |
-
|
| 99 |
-
# ------------------------------------------------------------
|
| 100 |
-
# Model configuration
|
| 101 |
-
# ------------------------------------------------------------
|
| 102 |
-
if [ -n "${MODELS_TO_DOWNLOAD:-}" ]; then
|
| 103 |
-
IFS=';' read -r -a MODEL_LIST <<< "$MODELS_TO_DOWNLOAD"
|
| 104 |
-
else
|
| 105 |
-
MODEL_LIST=(
|
| 106 |
-
"realrebelai/KREA-2_GGUFs|TURBO/Krea-2-Turbo-Q3_K_S.gguf|unet"
|
| 107 |
-
"Comfy-Org/Qwen3-VL|text_encoders/qwen3vl_4b_fp8_scaled.safetensors|text_encoders"
|
| 108 |
-
"Comfy-Org/Qwen-Image_ComfyUI|split_files/vae/qwen_image_vae.safetensors|vae"
|
| 109 |
-
"realrebelai/KREA-2_GGUFs|Rebels KREA-2-TURBO.json|workflows"
|
| 110 |
-
"Comfy-Org/YuE2|checkpoints/yue2_3b_int8_convrot.safetensors|checkpoints"
|
| 111 |
-
"Comfy-Org/YuE2|audio_encoders/sheetsage2_bf16.safetensors|audio_encoders"
|
| 112 |
-
# เพิ่มโมเดลอื่นๆ ได้ที่นี่ เช่น:
|
| 113 |
-
# "some-repo/some-model|path/to/model.safetensors|loras"audio_encoders
|
| 114 |
-
)
|
| 115 |
-
fi
|
| 116 |
-
|
| 117 |
-
# Dynamically link model directories
|
| 118 |
UNIQUE_SUBDIRS=$(printf "%s\n" "${MODEL_LIST[@]}" | awk -F'|' '$3 != "" {print $3}' | grep -v "^workflows$" | sort -u)
|
| 119 |
for subdir in $UNIQUE_SUBDIRS; do
|
| 120 |
link_model_dir "$subdir"
|
| 121 |
done
|
| 122 |
|
| 123 |
-
# Link runtime directories to persistent storage
|
| 124 |
-
link_runtime_dir "output"
|
| 125 |
-
link_runtime_dir "input"
|
| 126 |
-
link_runtime_dir "temp"
|
| 127 |
-
link_runtime_dir "workflows"
|
| 128 |
-
|
| 129 |
echo "============================================================"
|
| 130 |
echo "ComfyUI Krea2 - Hugging Face CPU"
|
| 131 |
echo "============================================================"
|
|
@@ -216,8 +199,6 @@ cd "$COMFY"
|
|
| 216 |
echo "============================================================"
|
| 217 |
echo "Starting ComfyUI"
|
| 218 |
echo "============================================================"
|
| 219 |
-
echo "Output directory: $COMFY/output (linked to $OUTPUT_ROOT)"
|
| 220 |
-
echo "============================================================"
|
| 221 |
|
| 222 |
exec python -u main.py \
|
| 223 |
--cpu \
|
|
|
|
| 6 |
# ------------------------------------------------------------
|
| 7 |
# Runtime directories
|
| 8 |
# ------------------------------------------------------------
|
| 9 |
+
# This is intentionally done before ComfyUI starts.
|
| 10 |
+
# ComfyUI 0.35.x creates /app/ComfyUI/user itself.
|
| 11 |
mkdir -p \
|
| 12 |
"$COMFY/user" \
|
| 13 |
"$COMFY/input" \
|
|
|
|
| 15 |
"$COMFY/temp" \
|
| 16 |
"$COMFY/workflows" \
|
| 17 |
"$COMFY/models/unet" \
|
| 18 |
+
"$COMFY/models/checkpoints" \
|
| 19 |
+
"$COMFY/models/audio_encoders" \
|
| 20 |
"$COMFY/models/text_encoders" \
|
| 21 |
"$COMFY/models/vae"
|
| 22 |
|
| 23 |
+
# ------------------------------------------------------------
|
| 24 |
+
# ComfyUI Manager Security Setup
|
| 25 |
+
# ------------------------------------------------------------
|
| 26 |
+
MANAGER_CONFIG_DIR="$COMFY/user/default/ComfyUI-Manager"
|
| 27 |
+
# mkdir -p "$MANAGER_CONFIG_DIR"
|
| 28 |
+
# cat << 'EOF' > "$MANAGER_CONFIG_DIR/config.ini"
|
| 29 |
+
# [ComfyUI-Manager]
|
| 30 |
+
# security_level = weak
|
| 31 |
+
# privacy_mode = false
|
| 32 |
+
# EOF
|
| 33 |
+
# echo "[INFO] ComfyUI Manager security level set to weak."
|
| 34 |
+
|
| 35 |
# ------------------------------------------------------------
|
| 36 |
# Persistent storage
|
| 37 |
# ------------------------------------------------------------
|
| 38 |
+
# If HF Storage is mounted at /data, models survive Space restarts.
|
| 39 |
+
# Without persistent storage, downloaded models live in the container
|
| 40 |
+
# filesystem and may have to be downloaded again after a rebuild/restart.
|
| 41 |
PERSIST_ROOT="/data/comfyui"
|
| 42 |
|
| 43 |
if [ -d "/data" ] && [ -w "/data" ]; then
|
| 44 |
mkdir -p "$PERSIST_ROOT/models"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
else
|
| 46 |
PERSIST_ROOT="$COMFY"
|
| 47 |
fi
|
| 48 |
|
| 49 |
MODEL_ROOT="$PERSIST_ROOT/models"
|
| 50 |
+
|
| 51 |
+
# ------------------------------------------------------------
|
| 52 |
+
# Model configuration
|
| 53 |
+
# ------------------------------------------------------------
|
| 54 |
+
# Define models to download.
|
| 55 |
+
# Format: "repo_id|filename|dest_subdir"
|
| 56 |
+
# dest_subdir should be one of: unet, text_encoders, vae, loras, controlnet, workflows, etc.
|
| 57 |
+
#
|
| 58 |
+
# You can override this list by setting the MODELS_TO_DOWNLOAD environment variable.
|
| 59 |
+
# Example: export MODELS_TO_DOWNLOAD="repo1|file1|unet;repo2|file2|vae"
|
| 60 |
+
|
| 61 |
+
if [ -n "${MODELS_TO_DOWNLOAD:-}" ]; then
|
| 62 |
+
IFS=';' read -r -a MODEL_LIST <<< "$MODELS_TO_DOWNLOAD"
|
| 63 |
+
else
|
| 64 |
+
MODEL_LIST=(
|
| 65 |
+
"realrebelai/KREA-2_GGUFs|TURBO/Krea-2-Turbo-Q3_K_S.gguf|unet"
|
| 66 |
+
"Comfy-Org/Qwen3-VL|text_encoders/qwen3vl_4b_fp8_scaled.safetensors|text_encoders"
|
| 67 |
+
"Comfy-Org/Qwen-Image_ComfyUI|split_files/vae/qwen_image_vae.safetensors|vae"
|
| 68 |
+
"realrebelai/KREA-2_GGUFs|Rebels KREA-2-TURBO.json|workflows"
|
| 69 |
+
"Comfy-Org/YuE2|checkpoints/yue2_3b_int8_convrot.safetensors|checkpoints"
|
| 70 |
+
"Comfy-Org/YuE2|audio_encoders/sheetsage2_bf16.safetensors|audio_encoders"
|
| 71 |
+
# เพิ่มโมเดลอื่นๆ ได้ที่นี่ เช่น:
|
| 72 |
+
# "some-repo/some-model|path/to/model.safetensors|loras"audio_encoders
|
| 73 |
+
)
|
| 74 |
+
fi
|
| 75 |
|
| 76 |
# ------------------------------------------------------------
|
| 77 |
# Model directory links
|
| 78 |
# ------------------------------------------------------------
|
| 79 |
+
# Only replace an empty ComfyUI model directory.
|
| 80 |
+
# This avoids deleting any models supplied in the Space image.
|
| 81 |
link_model_dir() {
|
| 82 |
local name="$1"
|
| 83 |
local target="$COMFY/models/$name"
|
|
|
|
| 103 |
fi
|
| 104 |
}
|
| 105 |
|
| 106 |
+
# Dynamically link model directories based on MODEL_LIST
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 107 |
UNIQUE_SUBDIRS=$(printf "%s\n" "${MODEL_LIST[@]}" | awk -F'|' '$3 != "" {print $3}' | grep -v "^workflows$" | sort -u)
|
| 108 |
for subdir in $UNIQUE_SUBDIRS; do
|
| 109 |
link_model_dir "$subdir"
|
| 110 |
done
|
| 111 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 112 |
echo "============================================================"
|
| 113 |
echo "ComfyUI Krea2 - Hugging Face CPU"
|
| 114 |
echo "============================================================"
|
|
|
|
| 199 |
echo "============================================================"
|
| 200 |
echo "Starting ComfyUI"
|
| 201 |
echo "============================================================"
|
|
|
|
|
|
|
| 202 |
|
| 203 |
exec python -u main.py \
|
| 204 |
--cpu \
|