File size: 6,733 Bytes
75db9a9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14b202b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
75db9a9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
cd /workspace/madapps
cat > install_comfyui.sh << 'EOF'
#!/usr/bin/env bash
#!/usr/bin/env bash
# ---------------------------------------------------------------------------
# ComfyUI one‑shot installer for RunPod (rev‑2)
# ---------------------------------------------------------------------------
#  • Activates your virtualenv
#  • Installs official **system** CMake & tool‑chain first (avoids dlib build bug)
#  • Removes any pip‑provided cmake that might shadow /usr/bin/cmake
#  • Installs Python deps and downloads model weights (idempotent)
# ---------------------------------------------------------------------------
set -euo pipefail
COMFY_DIR="${COMFY_DIR:-/workspace/madapps/ComfyUI}"
VENV="${VENV:-$COMFY_DIR/.venv}"
info() { echo -e "\033[1;32m[INFO]\033[0m $*"; }
warn() { echo -e "\033[1;33m[WARN]\033[0m $*"; }
# ---------------------------------------------------------------------------
# Sanity checks
# ---------------------------------------------------------------------------
if [[ ! -d "$COMFY_DIR" ]]; then
  warn "ComfyUI directory '$COMFY_DIR' does not exist. Set COMFY_DIR or clone ComfyUI first."; exit 1; fi
if [[ ! -d "$VENV" ]]; then
  warn "Python venv '$VENV' not found. Create it with 'python -m venv $VENV' first."; exit 1; fi
# ---------------------------------------------------------------------------
# Activate env & upgrade pip
# ---------------------------------------------------------------------------
info "Activating virtualenv…"; source "$VENV/bin/activate"
info "Upgrading pip & wheel…"; pip install --upgrade pip wheel
# ---------------------------------------------------------------------------
# System build deps **first** so dlib finds a real /usr/bin/cmake
# ---------------------------------------------------------------------------
APT_CMD="apt-get"; [[ $(id -u) -ne 0 && $(command -v sudo) ]] && APT_CMD="sudo $APT_CMD"
if [[ -n "$APT_CMD" ]]; then
  info "Installing system CMake & tool‑chain…"
  $APT_CMD update -y && $APT_CMD install -y cmake build-essential python3-dev git wget
fi
# ---------------------------------------------------------------------------
# Ensure pip’s cmake, if present, doesn’t shadow the system one
# ---------------------------------------------------------------------------
if pip show cmake >/dev/null 2>&1; then
  warn "Removing pip‑installed cmake to avoid conflicts…"; pip uninstall -y cmake; fi
# ---------------------------------------------------------------------------
# Python packages that need the compiler tool‑chain
# ---------------------------------------------------------------------------
info "Installing Python deps (dlib, insightface)…"
pip install --no-cache-dir dlib insightface
info "Pinning transformers==4.52…"
if pip show transformers >/dev/null 2>&1; then pip uninstall -y transformers; fi
pip install --no-cache-dir transformers==4.52
# ---------------------------------------------------------------------------
# ---------------------------------------------------------------------------
# Custom node: Crystools
# ---------------------------------------------------------------------------
# Installs crystian/ComfyUI-Crystools into ComfyUI/custom_nodes and its Python deps
CRYSTOOLS_DIR="$COMFY_DIR/custom_nodes/comfyui-crystools"
info "Installing/Updating Crystools custom node…"

if [[ -d "$CRYSTOOLS_DIR/.git" ]]; then
  info "Updating existing Crystools repo…"
  git -C "$CRYSTOOLS_DIR" pull --rebase --autostash
else
  info "Cloning Crystools into custom_nodes…"
  git clone --depth 1 https://github.com/crystian/ComfyUI-Crystools.git "$CRYSTOOLS_DIR"
fi

if [[ -f "$CRYSTOOLS_DIR/requirements.txt" ]]; then
  info "Installing Crystools Python requirements…"
  pip install --no-cache-dir -r "$CRYSTOOLS_DIR/requirements.txt"
fi
# Helper for idempotent downloads
# ---------------------------------------------------------------------------
download() {
  local url="$1" dst="$2";
  if [[ -f "$dst" ]]; then info "✓ $(basename "$dst") already exists"; else
    info "↓ $(basename "$dst")"; wget -q --show-progress -O "$dst" "$url"; fi }
# Create dirs
mkdir -p "$COMFY_DIR/models/"{checkpoints,unet,clip,vae,loras,controlnet}
# ---------------------------------------------------------------------------
# Model weights
# ---------------------------------------------------------------------------
info "Downloading model weights (skip if already present)…"
# Checkpoint
download "https://huggingface.co/stabletable25/lustifyxl/resolve/main/lustifySDXLNSFW_oltFIXEDTEXTURES.safetensors?download=true" \
         "$COMFY_DIR/models/checkpoints/lustifySDXLNSFW_oltFIXEDTEXTURES.safetensors"
# UNet
download "https://huggingface.co/stabletable25/lustifyxl/resolve/main/flux1-dev-fp8.safetensors?download=true" \
         "$COMFY_DIR/models/unet/flux1-dev-fp8.safetensors"
download "https://huggingface.co/6chan/flux1-kontext-dev-fp8/resolve/main/flux1-kontext-dev-fp8-e4m3fn.safetensors?download=true" \
         "$COMFY_DIR/models/unet/flux1-kontext-dev-fp8-e4m3fn.safetensors"
download "https://huggingface.co/stabletable25/lustifyxl/resolve/main/realDream_flux1V1.safetensors?download=true" \
         "$COMFY_DIR/models/unet/realDream_flux1V1.safetensors"
# CLIP
download "https://huggingface.co/GraydientPlatformAPI/flux-clip/resolve/main/clip_l.safetensors?download=true" \
         "$COMFY_DIR/models/clip/clip_l.safetensors"
download "https://huggingface.co/GraydientPlatformAPI/flux-clip/resolve/main/t5xxl_fp8_e4m3fn.safetensors?download=true" \
         "$COMFY_DIR/models/clip/t5xxl_fp8_e4m3fn.safetensors"
# VAE
download "https://huggingface.co/stabletable25/lustifyxl/resolve/main/ae.safetensors?download=true" \
         "$COMFY_DIR/models/vae/ae.safetensors"
# Lora
download "https://huggingface.co/XLabs-AI/flux-RealismLora/resolve/main/lora.safetensors?download=true" \
         "$COMFY_DIR/models/loras/flux-RealismLora.safetensors"
download "https://huggingface.co/stabletable25/lustifyxl/resolve/main/MysticXXX-v7.safetensors?download=true" \
         "$COMFY_DIR/models/loras/MysticXXX-v7.safetensors"
# ControlNet
download "https://huggingface.co/jasperai/Flux.1-dev-Controlnet-Depth/resolve/main/diffusion_pytorch_model.safetensors?download=true" \
         "$COMFY_DIR/models/controlnet/jasparaidepth.safetensors"
download "https://huggingface.co/Shakker-Labs/FLUX.1-dev-ControlNet-Union-Pro-2.0/resolve/main/diffusion_pytorch_model.safetensors?download=true" \
         "$COMFY_DIR/models/controlnet/controlnetunionpro2.safetensors"
# ---------------------------------------------------------------------------
info "✔ Setup finished. Launch ComfyUI with:\n   cd $COMFY_DIR && bash run.sh"
EOF
chmod +x install_comfyui.sh