Update image_Studio.sh
Browse files- image_Studio.sh +189 -414
image_Studio.sh
CHANGED
|
@@ -1,107 +1,60 @@
|
|
| 1 |
#!/usr/bin/env bash
|
| 2 |
-
#
|
| 3 |
-
#
|
| 4 |
-
# + timeouts/retries em downloads, headers p/ Civitai, estado robusto
|
| 5 |
-
# + Blackwell (5090/5080) com torch/vision nightly via --pre --upgrade --no-cache-dir
|
| 6 |
-
# + comfy-cli mantido para instalar/rodar/instalar nodes
|
| 7 |
|
| 8 |
set -euo pipefail
|
| 9 |
|
| 10 |
-
#
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
|
|
|
|
|
|
| 14 |
|
| 15 |
-
|
| 16 |
-
# Cores/logs
|
| 17 |
-
# --------------------------------
|
| 18 |
-
RED='\033[0;31m'; GREEN='\033[0;32m'; YELLOW='\033[1;33m'; BLUE='\033[0;34m'; CYAN='\033[0;36m'; NC='\033[0m'
|
| 19 |
-
log_info() { echo -e "${BLUE}[INFO]${NC} $1"; }
|
| 20 |
log_success() { echo -e "${GREEN}[✓]${NC} $1"; }
|
| 21 |
-
log_warn()
|
| 22 |
-
log_error()
|
| 23 |
-
log_progress(){ echo -e "${CYAN}[→]${NC} $1"; }
|
| 24 |
|
| 25 |
-
#
|
| 26 |
-
# Config
|
| 27 |
-
# --------------------------------
|
| 28 |
COMFY_DIR="/root/comfy/ComfyUI"
|
| 29 |
MODELS_DIR="$COMFY_DIR/models"
|
| 30 |
-
COMFY_HOST="
|
| 31 |
-
COMFY_PORT="
|
| 32 |
-
|
| 33 |
-
# Mantemos as keys hardcoded (pedido do usuário)
|
| 34 |
-
CIVITAI_TOKEN="${CIVITAI_TOKEN:-4fcb2834969399006a736ee402b061e5}"
|
| 35 |
-
HF_TOKEN="${HF_TOKEN:-}"
|
| 36 |
-
|
| 37 |
-
STATE_DIR="/root/.comfyui_setup_state"
|
| 38 |
-
STATE_FILE="$STATE_DIR/installation_state.txt"
|
| 39 |
-
COMPLETED_DOWNLOADS="$STATE_DIR/completed_downloads.txt"
|
| 40 |
-
COMPLETED_NODES="$STATE_DIR/completed_nodes.txt"
|
| 41 |
|
| 42 |
# Performance
|
| 43 |
export MAX_JOBS=32
|
| 44 |
-
export NVCC_APPEND_FLAGS="--threads 8"
|
| 45 |
-
export UV_SYSTEM_PYTHON=1
|
| 46 |
-
export PYTORCH_CUDA_ALLOC_CONF="expandable_segments:True"
|
| 47 |
export HF_HUB_ENABLE_HF_TRANSFER=1
|
| 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 |
-
mark_download_complete(){ echo "$1" >> "$COMPLETED_DOWNLOADS"; }
|
| 74 |
-
is_download_complete(){ [[ -f "$COMPLETED_DOWNLOADS" ]] && grep -Fxq "$1" "$COMPLETED_DOWNLOADS"; }
|
| 75 |
-
mark_node_complete(){ echo "$1" >> "$COMPLETED_NODES"; }
|
| 76 |
-
is_node_complete(){ [[ -f "$COMPLETED_NODES" ]] && grep -Fxq "$1" "$COMPLETED_NODES"; }
|
| 77 |
-
|
| 78 |
-
# --------------------------------
|
| 79 |
-
# Downloads (lista)
|
| 80 |
-
# --------------------------------
|
| 81 |
-
readonly DOWNLOAD_FILES=(
|
| 82 |
-
"mega://https://mega.nz/file/gIRTFQSQ#no6Ay3JLE9LVRi7ib9O-Jc0CW7XmG046kCgpCzDg1tY|loras|"
|
| 83 |
-
|
| 84 |
-
"https://civitai.com/api/download/models/2122278?type=Model&format=SafeTensor&size=pruned&fp=fp16|checkpoints|raehoshiIllustXL_v60.safetensors"
|
| 85 |
-
|
| 86 |
-
"https://civitai.com/api/download/models/1268294?type=Model&format=SafeTensor|loras|"
|
| 87 |
-
"https://civitai.com/api/download/models/1715330?type=Model&format=SafeTensor|loras|"
|
| 88 |
-
"https://civitai.com/api/download/models/1499397?type=Model&format=SafeTensor|loras|"
|
| 89 |
-
"https://civitai.com/api/download/models/1779002?type=Model&format=SafeTensor|loras|"
|
| 90 |
-
"https://civitai.com/api/download/models/1114313?type=Model&format=SafeTensor|loras|"
|
| 91 |
-
"https://civitai.com/api/download/models/1780244?type=Model&format=SafeTensor|loras|"
|
| 92 |
-
|
| 93 |
-
"https://huggingface.co/Kim2091/AnimeSharp/resolve/main/4x-AnimeSharp.pth|upscale_models|4x-AnimeSharp.pth"
|
| 94 |
-
"https://huggingface.co/Kim2091/AnimeSharpV3/resolve/main/2x-AnimeSharpV3.pth|upscale_models|2x-AnimeSharpV3.pth"
|
| 95 |
-
"https://huggingface.co/ABDALLALSWAITI/Upscalers/resolve/main/anime/2x-AnimeSharpV2_MoSR_Soft.pth|upscale_models|2x-AnimeSharpV2_MoSR_Soft.pth"
|
| 96 |
-
"https://huggingface.co/Kim2091/UltraSharpV2/resolve/main/4x-UltraSharpV2.pth|upscale_models|4x-UltraSharpV2.pth"
|
| 97 |
-
"https://huggingface.co/Kim2091/UltraSharpV2/resolve/main/4x-UltraSharpV2_Lite.pth|upscale_models|4x-UltraSharpV2_Lite.pth"
|
| 98 |
-
"https://huggingface.co/Kim2091/UltraSharpV2/resolve/main/4x-UltraSharpV2_fp32_op17.onnx|upscale_models|4x-UltraSharpV2_fp32_op17.onnx"
|
| 99 |
-
|
| 100 |
-
"https://huggingface.co/adbrasi/testedownload/resolve/main/99coins_anime_girl_face_m_seg.pt|ultralytics/bbox|99coins_anime_girl_face_m_seg.pt"
|
| 101 |
)
|
| 102 |
|
| 103 |
# Custom nodes
|
| 104 |
-
|
| 105 |
"https://github.com/adbrasi/huggpackreator"
|
| 106 |
"https://github.com/adbrasi/packreator_processor"
|
| 107 |
"https://github.com/adbrasi/Packreator_manager"
|
|
@@ -143,361 +96,183 @@ readonly CUSTOM_NODES=(
|
|
| 143 |
"https://github.com/CoreyCorza/ComfyUI-CRZnodes"
|
| 144 |
)
|
| 145 |
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
echo "$url"
|
| 167 |
-
fi
|
| 168 |
}
|
| 169 |
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
if $ok; then
|
| 190 |
-
local f; f="$(find "$tmp" -type f \( -name "*.safetensors" -o -name "*.pth" -o -name "*.pt" -o -name "*.bin" -o -name "*.onnx" \) | head -1)"
|
| 191 |
-
if [[ -n "$f" ]]; then mv "$f" "$out"; rm -rf "$tmp"; log_success "HF OK: $filename"; return 0; fi
|
| 192 |
-
fi
|
| 193 |
-
rm -rf "$tmp"; log_error "HF falhou: $filename"; return 1
|
| 194 |
}
|
| 195 |
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 203 |
}
|
| 204 |
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
|
| 209 |
-
|
| 210 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 211 |
}
|
| 212 |
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
log_success "Arquivo já existe: $filename"; return 0
|
| 221 |
-
fi
|
| 222 |
-
|
| 223 |
-
log_info "HTTP: ${filename} -> $target_dir"
|
| 224 |
-
|
| 225 |
-
if command_exists curl; then
|
| 226 |
-
if timeout "$DOWNLOAD_TIMEOUT" curl -fL -4 -A "$UA" -e "$CIVITAI_REF" \
|
| 227 |
-
--connect-timeout "$CONNECT_TIMEOUT" --retry "$RETRY_COUNT" --retry-delay "$RETRY_WAIT" \
|
| 228 |
-
-C - -o "$out" "$url"; then
|
| 229 |
-
log_success "CURL OK: $filename"; return 0
|
| 230 |
else
|
| 231 |
-
|
| 232 |
fi
|
| 233 |
-
|
| 234 |
-
|
| 235 |
-
|
| 236 |
-
|
| 237 |
-
--timeout="$CONNECT_TIMEOUT" --tries="$RETRY_COUNT" -c -O "$out" "$url"; then
|
| 238 |
-
log_success "WGET OK: $filename"; return 0
|
| 239 |
-
else
|
| 240 |
-
log_warn "WGET falhou para $filename"
|
| 241 |
fi
|
| 242 |
-
|
| 243 |
|
| 244 |
-
|
| 245 |
-
local aria_opts="-c -s 16 -x 16 -k 1M --file-allocation=none --allow-overwrite=true --auto-file-renaming=false \
|
| 246 |
-
--summary-interval=10 --console-log-level=warn --timeout=$CONNECT_TIMEOUT --retry-wait=$RETRY_WAIT --max-tries=$RETRY_COUNT --referer=$CIVITAI_REF --user-agent=$UA"
|
| 247 |
-
if timeout "$DOWNLOAD_TIMEOUT" aria2c $aria_opts --dir="$target_dir" --out="$filename" "$url"; then
|
| 248 |
-
log_success "ARIA2C OK: $filename"; return 0
|
| 249 |
-
else
|
| 250 |
-
log_warn "ARIA2C falhou para $filename"
|
| 251 |
-
fi
|
| 252 |
-
fi
|
| 253 |
|
| 254 |
-
|
| 255 |
-
|
| 256 |
-
|
| 257 |
|
| 258 |
-
|
| 259 |
-
|
| 260 |
-
log_info "Total de downloads: $total"
|
| 261 |
-
log_info "Iniciando loop de downloads..."
|
| 262 |
|
| 263 |
-
|
| 264 |
-
|
| 265 |
-
IFS='|' read -r url type filename <<< "$raw"
|
| 266 |
-
url="$(echo -n "$url" | xargs)"; type="$(echo -n "$type" | xargs)"; filename="$(echo -n "${filename:-}" | xargs)"
|
| 267 |
-
local key; key="$(normalize_entry "$url" "$type" "$filename")"
|
| 268 |
|
| 269 |
-
|
| 270 |
-
|
| 271 |
-
fi
|
| 272 |
|
| 273 |
-
|
| 274 |
-
case "$type" in
|
| 275 |
-
checkpoints) target_dir="$MODELS_DIR/checkpoints" ;;
|
| 276 |
-
loras) target_dir="$MODELS_DIR/loras" ;;
|
| 277 |
-
upscale_models) target_dir="$MODELS_DIR/upscale_models" ;;
|
| 278 |
-
ultralytics/bbox) target_dir="$MODELS_DIR/ultralytics/bbox" ;;
|
| 279 |
-
*) target_dir="$MODELS_DIR/$type" ;;
|
| 280 |
-
esac
|
| 281 |
-
mkdir -p "$target_dir"
|
| 282 |
-
|
| 283 |
-
log_info "[$current/$total] $type :: $(basename "${filename:-$url}")"
|
| 284 |
-
|
| 285 |
-
local ok=1
|
| 286 |
-
if [[ "$url" == mega://* ]]; then
|
| 287 |
-
download_mega "$url" "$target_dir" && ok=0
|
| 288 |
-
elif [[ "$url" == hf://* ]]; then
|
| 289 |
-
url="${url#hf://}"
|
| 290 |
-
local repo="$(echo "$url" | cut -d'/' -f1-2)"
|
| 291 |
-
local file_path="$(echo "$url" | cut -d'/' -f3-)"
|
| 292 |
-
download_hf "$repo" "$file_path" "$target_dir" "$filename" && ok=0
|
| 293 |
-
elif [[ "$url" == https://huggingface.co/*/resolve/* ]]; then
|
| 294 |
-
download_file "$url" "$target_dir" "$filename" && ok=0
|
| 295 |
-
else
|
| 296 |
-
download_file "$url" "$target_dir" "$filename" && ok=0
|
| 297 |
-
fi
|
| 298 |
|
| 299 |
-
|
| 300 |
-
|
| 301 |
-
else
|
| 302 |
-
((failed++)); log_warn "[$current/$total] Falhou, segue..."
|
| 303 |
-
fi
|
| 304 |
-
done
|
| 305 |
-
|
| 306 |
-
if [[ $failed -gt 0 ]]; then
|
| 307 |
-
log_warn "Downloads: $((total - failed))/$total OK ($failed falharam)"
|
| 308 |
-
else
|
| 309 |
-
log_success "Todos os $total downloads completados!"
|
| 310 |
-
fi
|
| 311 |
-
return 0
|
| 312 |
-
}
|
| 313 |
|
| 314 |
-
|
| 315 |
-
|
| 316 |
-
|
|
|
|
|
|
|
| 317 |
|
| 318 |
-
|
| 319 |
-
# sanity: garante que é o repo esperado
|
| 320 |
-
if ! git -C "$dest" remote -v | grep -qiE 'comfy|comfyui|github\.com'; then
|
| 321 |
-
log_warn "$node_name tem git estranho; removendo..."
|
| 322 |
-
rm -rf "$dest"
|
| 323 |
-
fi
|
| 324 |
-
fi
|
| 325 |
-
|
| 326 |
-
if [[ -d "$dest/.git" ]]; then
|
| 327 |
-
log_info "Atualizando $node_name..."
|
| 328 |
-
timeout 180 git -C "$dest" pull --ff-only >/dev/null 2>&1 || log_warn "Timeout/erro ao atualizar $node_name"
|
| 329 |
-
else
|
| 330 |
-
log_info "Clonando $node_name..."
|
| 331 |
-
timeout 300 git clone --recursive --depth 1 "$url" "$dest" >/dev/null 2>&1 || { log_warn "Falha ao clonar $node_name"; return 0; }
|
| 332 |
-
fi
|
| 333 |
-
|
| 334 |
-
if [[ -f "$dest/requirements.txt" ]]; then
|
| 335 |
-
timeout 300 python3 -m pip install --no-warn-script-location -q -r "$dest/requirements.txt" >/dev/null 2>&1 || \
|
| 336 |
-
log_warn "Falha em requirements de $node_name"
|
| 337 |
-
fi
|
| 338 |
-
|
| 339 |
-
mark_node_complete "$url"
|
| 340 |
-
return 0
|
| 341 |
-
}
|
| 342 |
|
| 343 |
-
#
|
| 344 |
-
|
| 345 |
-
# --------------------------------
|
| 346 |
-
show_menu(){
|
| 347 |
-
echo ""; log_info "========================================="; log_info " ComfyUI Custom Setup v2.0"; log_info "========================================="; echo ""
|
| 348 |
-
local s; s="$(get_state)"
|
| 349 |
-
|
| 350 |
-
if [[ -z "$s" || ! "$s" =~ ^[0-9]+$ ]]; then log_info "Iniciando nova instalação..."; reset_state; return 0; fi
|
| 351 |
-
|
| 352 |
-
if [[ "$INTERACTIVE" = false ]]; then
|
| 353 |
-
if [[ "$s" != "0" && "$s" -lt "8" ]]; then log_info "Modo não-interativo: continuando (Step: $s)"; else log_info "Modo não-interativo: nova instalação"; fi
|
| 354 |
-
return 0
|
| 355 |
-
fi
|
| 356 |
-
|
| 357 |
-
if [[ "$s" != "0" && "$s" -lt "8" ]]; then
|
| 358 |
-
log_warn "Instalação anterior detectada (Step: $s)"
|
| 359 |
-
echo -e "\nOpções:\n 1) Continuar\n 2) Reiniciar\n 3) Sair\n"
|
| 360 |
-
read -t 10 -p "Escolha [1-3] (padrão 1): " choice || choice="1"
|
| 361 |
-
case "$choice" in
|
| 362 |
-
1|"") return 0 ;;
|
| 363 |
-
2) reset_state; return 0 ;;
|
| 364 |
-
3) exit 0 ;;
|
| 365 |
-
*) log_warn "Opção inválida, continuando..."; return 0 ;;
|
| 366 |
-
esac
|
| 367 |
-
fi
|
| 368 |
-
}
|
| 369 |
|
| 370 |
-
|
| 371 |
-
# Main
|
| 372 |
-
# --------------------------------
|
| 373 |
-
main(){
|
| 374 |
-
init_state
|
| 375 |
-
show_menu
|
| 376 |
-
local s; s="$(get_state)"
|
| 377 |
-
|
| 378 |
-
# STEP 1: deps
|
| 379 |
-
if [[ "$s" -lt "1" ]]; then
|
| 380 |
-
log_info "[1/6] Dependências..."
|
| 381 |
-
if ! command_exists aria2c; then apt-get update -qq && apt-get install -y -qq aria2 >/dev/null 2>&1 || true; fi
|
| 382 |
-
install_megatools
|
| 383 |
-
for cmd in python3 git wget curl; do command_exists "$cmd" || { log_error "Falta: $cmd"; exit 1; }; done
|
| 384 |
-
log_success "Dependências OK"; save_state "1"
|
| 385 |
-
fi
|
| 386 |
-
|
| 387 |
-
# STEP 2: pip tools
|
| 388 |
-
if [[ "$s" -lt "2" ]]; then
|
| 389 |
-
log_info "[2/6] Ferramentas Python..."
|
| 390 |
-
python3 -m pip install --upgrade --no-cache-dir pip wheel setuptools >/dev/null 2>&1
|
| 391 |
-
python3 -m pip install --upgrade --no-cache-dir "huggingface_hub[cli,hf_transfer]>=0.26.0" comfy-cli >/dev/null 2>&1
|
| 392 |
-
if [[ -n "$HF_TOKEN" ]]; then huggingface-cli login --token "$HF_TOKEN" >/dev/null 2>&1 || log_warn "Login HF falhou"; fi
|
| 393 |
-
log_success "Ferramentas OK"; save_state "2"
|
| 394 |
-
fi
|
| 395 |
-
|
| 396 |
-
# STEP 3: ComfyUI via comfy-cli (sem pré-criar $COMFY_DIR)
|
| 397 |
-
if [[ "$s" -lt "3" ]]; then
|
| 398 |
-
log_info "[3/6] Instalando ComfyUI (comfy-cli)..."
|
| 399 |
-
|
| 400 |
-
if [[ -d "$COMFY_DIR" ]]; then
|
| 401 |
-
if [[ -d "$COMFY_DIR/.git" || -f "$COMFY_DIR/main.py" ]]; then
|
| 402 |
-
log_warn "ComfyUI já parece instalado em $COMFY_DIR"
|
| 403 |
-
else
|
| 404 |
-
log_warn "Diretório $COMFY_DIR existe porém não é ComfyUI válido. Removendo..."
|
| 405 |
-
rm -rf "$COMFY_DIR"
|
| 406 |
-
fi
|
| 407 |
-
fi
|
| 408 |
|
| 409 |
-
|
| 410 |
-
|
| 411 |
-
|
| 412 |
-
|
| 413 |
-
|
| 414 |
-
|
| 415 |
-
fi
|
| 416 |
|
| 417 |
-
|
| 418 |
-
comfy --workspace "$COMFY_DIR" --skip-prompt install --nvidia --fast-deps || {
|
| 419 |
-
log_error "ComfyUI não instalou (comfy-cli erro)"; exit 1; }
|
| 420 |
-
fi
|
| 421 |
|
| 422 |
-
|
| 423 |
-
|
| 424 |
-
save_state "3"
|
| 425 |
-
fi
|
| 426 |
-
|
| 427 |
-
# STEP 4: Blackwell nightly (5090/5080)
|
| 428 |
-
if [[ "$s" -lt "4" ]]; then
|
| 429 |
-
log_info "[4/6] Verificando GPU..."
|
| 430 |
-
local gpu_info; gpu_info="$(nvidia-smi --query-gpu=name --format=csv,noheader 2>/dev/null || echo "")"
|
| 431 |
-
if [[ "$gpu_info" == *"5090"* || "$gpu_info" == *"5080"* ]]; then
|
| 432 |
-
log_warn "RTX ${gpu_info:-Blackwell} detectada - aplicando PyTorch nightly (pedido do usuário)"
|
| 433 |
-
python3 -m pip install --pre --upgrade --no-cache-dir torch --extra-index-url https://download.pytorch.org/whl/nightly/cu128
|
| 434 |
-
python3 -m pip install --pre --upgrade --no-cache-dir torchvision --extra-index-url https://download.pytorch.org/whl/nightly/cu128
|
| 435 |
-
log_success "PyTorch nightly (cu128) pronto"
|
| 436 |
-
else
|
| 437 |
-
log_info "GPU: ${gpu_info:-Não detectada} - mantendo PyTorch padrão"
|
| 438 |
-
fi
|
| 439 |
-
save_state "4"
|
| 440 |
-
fi
|
| 441 |
-
|
| 442 |
-
# STEP 5: modelos (só agora criamos $MODELS_DIR)
|
| 443 |
-
if [[ "$s" -lt "5" ]]; then
|
| 444 |
-
log_info "[5/6] Baixando modelos..."
|
| 445 |
-
mkdir -p "$MODELS_DIR"/{loras,upscale_models,checkpoints,ultralytics/bbox}
|
| 446 |
-
process_downloads
|
| 447 |
-
log_success "Downloads processados"; save_state "5"
|
| 448 |
-
fi
|
| 449 |
-
|
| 450 |
-
# STEP 6: custom nodes
|
| 451 |
-
if [[ "$s" -lt "6" ]]; then
|
| 452 |
-
log_info "[6/6] Instalando custom nodes..."
|
| 453 |
-
local CN_DIR="$COMFY_DIR/custom_nodes"; mkdir -p "$CN_DIR"
|
| 454 |
-
for repo_url in "${CUSTOM_NODES[@]}"; do clone_or_update "$repo_url" "$CN_DIR/$(basename "$repo_url")"; done
|
| 455 |
-
for node_name in "${SPECIAL_NODES[@]}"; do
|
| 456 |
-
if ! is_node_complete "special:$node_name"; then
|
| 457 |
-
log_info "Instalando $node_name via comfy-cli..."
|
| 458 |
-
comfy node install "$node_name" >/dev/null 2>&1 && mark_node_complete "special:$node_name" || log_warn "Falha: $node_name"
|
| 459 |
-
fi
|
| 460 |
-
done
|
| 461 |
-
log_success "Custom nodes instalados"; save_state "6"
|
| 462 |
-
fi
|
| 463 |
-
|
| 464 |
-
# Verificação final
|
| 465 |
-
log_info "Verificando instalação..."
|
| 466 |
-
[[ -f "$COMFY_DIR/main.py" ]] && log_success "✓ ComfyUI instalado" || log_error "✗ ComfyUI não encontrado"
|
| 467 |
-
|
| 468 |
-
echo ""; log_info "Modelos instalados:"
|
| 469 |
-
for dir in checkpoints loras vae vae_approx text_encoders clip_vision upscale_models ultralytics; do
|
| 470 |
-
if [[ -d "$MODELS_DIR/$dir" ]]; then
|
| 471 |
-
local c; c="$(find "$MODELS_DIR/$dir" -type f \( -name "*.safetensors" -o -name "*.pth" -o -name "*.pt" -o -name "*.ckpt" -o -name "*.onnx" \) 2>/dev/null | wc -l)"
|
| 472 |
-
[[ "$c" -gt 0 ]] && log_success " $dir: $c arquivo(s)"
|
| 473 |
-
fi
|
| 474 |
-
done
|
| 475 |
|
| 476 |
-
|
| 477 |
-
log_success "Custom nodes: $((node_count - 1)) instalados"
|
| 478 |
|
| 479 |
-
|
| 480 |
-
log_info "GPU: $gpu_info"
|
| 481 |
|
| 482 |
-
|
|
|
|
| 483 |
|
| 484 |
-
|
|
|
|
| 485 |
|
| 486 |
-
|
| 487 |
-
|
| 488 |
-
|
| 489 |
-
|
| 490 |
-
exec comfy launch -- --listen "$COMFY_HOST" --port "$COMFY_PORT"
|
| 491 |
-
fi
|
| 492 |
|
| 493 |
-
|
| 494 |
-
|
| 495 |
-
|
| 496 |
-
|
| 497 |
-
|
| 498 |
-
|
| 499 |
-
|
| 500 |
-
|
| 501 |
-
}
|
| 502 |
|
| 503 |
-
|
|
|
|
|
|
| 1 |
#!/usr/bin/env bash
|
| 2 |
+
# setup_comfyui_simple.sh
|
| 3 |
+
# Script simples para instalação do ComfyUI
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
set -euo pipefail
|
| 6 |
|
| 7 |
+
# Cores
|
| 8 |
+
RED='\033[0;31m'
|
| 9 |
+
GREEN='\033[0;32m'
|
| 10 |
+
YELLOW='\033[1;33m'
|
| 11 |
+
BLUE='\033[0;34m'
|
| 12 |
+
NC='\033[0m'
|
| 13 |
|
| 14 |
+
log_info() { echo -e "${BLUE}[INFO]${NC} $1"; }
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
log_success() { echo -e "${GREEN}[✓]${NC} $1"; }
|
| 16 |
+
log_warn() { echo -e "${YELLOW}[!]${NC} $1"; }
|
| 17 |
+
log_error() { echo -e "${RED}[✗]${NC} $1"; }
|
|
|
|
| 18 |
|
| 19 |
+
# Configuração
|
|
|
|
|
|
|
| 20 |
COMFY_DIR="/root/comfy/ComfyUI"
|
| 21 |
MODELS_DIR="$COMFY_DIR/models"
|
| 22 |
+
COMFY_HOST="0.0.0.0"
|
| 23 |
+
COMFY_PORT="8818"
|
| 24 |
+
CIVITAI_TOKEN="4fcb2834969399006a736ee402b061e5"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
# Performance
|
| 27 |
export MAX_JOBS=32
|
|
|
|
|
|
|
|
|
|
| 28 |
export HF_HUB_ENABLE_HF_TRANSFER=1
|
| 29 |
+
|
| 30 |
+
# Lista de downloads - Formato: "URL|TIPO|NOME_OPCIONAL"
|
| 31 |
+
DOWNLOAD_FILES=(
|
| 32 |
+
# Mega primeiro (sem nome forçado - usar nome original)
|
| 33 |
+
"mega://https://mega.nz/file/gIRTFQSQ#no6Ay3JLE9LVRi7ib9O-Jc0CW7XmG046kCgpCzDg1tY|loras|"
|
| 34 |
+
|
| 35 |
+
# Checkpoints
|
| 36 |
+
"https://civitai.com/api/download/models/2122278?type=Model&format=SafeTensor&size=pruned&fp=fp16|checkpoints|raehoshiIllustXL_v60.safetensors"
|
| 37 |
+
|
| 38 |
+
# LoRAs Civitai
|
| 39 |
+
"https://civitai.com/api/download/models/1268294?type=Model&format=SafeTensor|loras|"
|
| 40 |
+
"https://civitai.com/api/download/models/1715330?type=Model&format=SafeTensor|loras|"
|
| 41 |
+
"https://civitai.com/api/download/models/1499397?type=Model&format=SafeTensor|loras|"
|
| 42 |
+
"https://civitai.com/api/download/models/1779002?type=Model&format=SafeTensor|loras|"
|
| 43 |
+
"https://civitai.com/api/download/models/1114313?type=Model&format=SafeTensor|loras|"
|
| 44 |
+
"https://civitai.com/api/download/models/1780244?type=Model&format=SafeTensor|loras|"
|
| 45 |
+
|
| 46 |
+
# Upscalers
|
| 47 |
+
"https://huggingface.co/Kim2091/AnimeSharp/resolve/main/4x-AnimeSharp.pth|upscale_models|4x-AnimeSharp.pth"
|
| 48 |
+
"https://huggingface.co/Kim2091/AnimeSharpV3/resolve/main/2x-AnimeSharpV3.pth|upscale_models|2x-AnimeSharpV3.pth"
|
| 49 |
+
"https://huggingface.co/Kim2091/UltraSharpV2/resolve/main/4x-UltraSharpV2.pth|upscale_models|4x-UltraSharpV2.pth"
|
| 50 |
+
"https://huggingface.co/Kim2091/UltraSharpV2/resolve/main/4x-UltraSharpV2_Lite.pth|upscale_models|4x-UltraSharpV2_Lite.pth"
|
| 51 |
+
|
| 52 |
+
# Ultralytics
|
| 53 |
+
"https://huggingface.co/adbrasi/testedownload/resolve/main/99coins_anime_girl_face_m_seg.pt|ultralytics/bbox|99coins_anime_girl_face_m_seg.pt"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
)
|
| 55 |
|
| 56 |
# Custom nodes
|
| 57 |
+
CUSTOM_NODES=(
|
| 58 |
"https://github.com/adbrasi/huggpackreator"
|
| 59 |
"https://github.com/adbrasi/packreator_processor"
|
| 60 |
"https://github.com/adbrasi/Packreator_manager"
|
|
|
|
| 96 |
"https://github.com/CoreyCorza/ComfyUI-CRZnodes"
|
| 97 |
)
|
| 98 |
|
| 99 |
+
# Download HuggingFace
|
| 100 |
+
download_hf() {
|
| 101 |
+
local url="$1"
|
| 102 |
+
local target_dir="$2"
|
| 103 |
+
local filename="$3"
|
| 104 |
+
|
| 105 |
+
if [ -n "$filename" ] && [ -f "$target_dir/$filename" ]; then
|
| 106 |
+
log_success "Já existe: $filename"
|
| 107 |
+
return 0
|
| 108 |
+
fi
|
| 109 |
+
|
| 110 |
+
log_info "Baixando HF: $filename"
|
| 111 |
+
|
| 112 |
+
if command -v hf >/dev/null 2>&1; then
|
| 113 |
+
cd "$target_dir"
|
| 114 |
+
hf download "$(dirname "$url")" "$(basename "$url")" --local-dir . 2>/dev/null
|
| 115 |
+
cd - >/dev/null
|
| 116 |
+
else
|
| 117 |
+
wget -q --show-progress -c -O "$target_dir/$filename" "https://huggingface.co/$url"
|
| 118 |
+
fi
|
|
|
|
|
|
|
| 119 |
}
|
| 120 |
|
| 121 |
+
# Download Mega
|
| 122 |
+
download_mega() {
|
| 123 |
+
local url="$1"
|
| 124 |
+
local target_dir="$2"
|
| 125 |
+
|
| 126 |
+
# Remover prefixo mega://
|
| 127 |
+
url="${url#mega://}"
|
| 128 |
+
|
| 129 |
+
log_info "Baixando do Mega..."
|
| 130 |
+
|
| 131 |
+
cd "$target_dir"
|
| 132 |
+
# Usar megadl simples sem forçar nome
|
| 133 |
+
if megadl "$url" 2>/dev/null; then
|
| 134 |
+
log_success "Mega download OK"
|
| 135 |
+
else
|
| 136 |
+
log_warn "Mega download falhou"
|
| 137 |
+
fi
|
| 138 |
+
cd - >/dev/null
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 139 |
}
|
| 140 |
|
| 141 |
+
# Download normal
|
| 142 |
+
download_file() {
|
| 143 |
+
local url="$1"
|
| 144 |
+
local target_dir="$2"
|
| 145 |
+
local filename="$3"
|
| 146 |
+
|
| 147 |
+
# Adicionar token Civitai se necessário
|
| 148 |
+
if [[ "$url" == *"civitai.com"* ]]; then
|
| 149 |
+
url="${url}&token=${CIVITAI_TOKEN}"
|
| 150 |
+
fi
|
| 151 |
+
|
| 152 |
+
if [ -n "$filename" ] && [ -f "$target_dir/$filename" ]; then
|
| 153 |
+
log_success "Já existe: $filename"
|
| 154 |
+
return 0
|
| 155 |
+
fi
|
| 156 |
+
|
| 157 |
+
log_info "Baixando: ${filename:-arquivo}"
|
| 158 |
+
|
| 159 |
+
if command -v aria2c >/dev/null 2>&1; then
|
| 160 |
+
aria2c -c -x 4 -s 4 --console-log-level=warn --dir="$target_dir" --out="$filename" "$url"
|
| 161 |
+
elif [ -n "$filename" ]; then
|
| 162 |
+
wget -q --show-progress -c -O "$target_dir/$filename" "$url"
|
| 163 |
+
else
|
| 164 |
+
cd "$target_dir"
|
| 165 |
+
wget -q --show-progress -c "$url"
|
| 166 |
+
cd - >/dev/null
|
| 167 |
+
fi
|
| 168 |
}
|
| 169 |
|
| 170 |
+
# Processar downloads
|
| 171 |
+
process_downloads() {
|
| 172 |
+
for entry in "${DOWNLOAD_FILES[@]}"; do
|
| 173 |
+
IFS='|' read -r url type filename <<< "$entry"
|
| 174 |
+
|
| 175 |
+
# Criar diretório
|
| 176 |
+
local target_dir="$MODELS_DIR/$type"
|
| 177 |
+
mkdir -p "$target_dir"
|
| 178 |
+
|
| 179 |
+
# Baixar arquivo
|
| 180 |
+
if [[ "$url" == mega://* ]]; then
|
| 181 |
+
download_mega "$url" "$target_dir"
|
| 182 |
+
elif [[ "$url" == *.huggingface.co/* ]]; then
|
| 183 |
+
local hf_path="${url#*huggingface.co/}"
|
| 184 |
+
download_hf "$hf_path" "$target_dir" "$filename"
|
| 185 |
+
else
|
| 186 |
+
download_file "$url" "$target_dir" "$filename"
|
| 187 |
+
fi
|
| 188 |
+
done
|
| 189 |
}
|
| 190 |
|
| 191 |
+
# Clone git repo
|
| 192 |
+
clone_repo() {
|
| 193 |
+
local url="$1"
|
| 194 |
+
local dest="$2"
|
| 195 |
+
|
| 196 |
+
if [ -d "$dest/.git" ]; then
|
| 197 |
+
git -C "$dest" pull --ff-only 2>/dev/null || true
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 198 |
else
|
| 199 |
+
git clone --depth 1 "$url" "$dest" 2>/dev/null || true
|
| 200 |
fi
|
| 201 |
+
|
| 202 |
+
# Instalar requirements se existir
|
| 203 |
+
if [ -f "$dest/requirements.txt" ]; then
|
| 204 |
+
pip install -q -r "$dest/requirements.txt" 2>/dev/null || true
|
|
|
|
|
|
|
|
|
|
|
|
|
| 205 |
fi
|
| 206 |
+
}
|
| 207 |
|
| 208 |
+
# ========== INSTALAÇÃO ==========
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 209 |
|
| 210 |
+
log_info "========================================="
|
| 211 |
+
log_info " ComfyUI Setup"
|
| 212 |
+
log_info "========================================="
|
| 213 |
|
| 214 |
+
# 1. Instalar dependências
|
| 215 |
+
log_info "[1/5] Instalando dependências..."
|
|
|
|
|
|
|
| 216 |
|
| 217 |
+
apt-get update -qq
|
| 218 |
+
apt-get install -y -qq aria2 megatools git wget curl 2>/dev/null
|
|
|
|
|
|
|
|
|
|
| 219 |
|
| 220 |
+
pip install --upgrade pip wheel setuptools -q
|
| 221 |
+
pip install --upgrade "huggingface_hub[cli,hf_transfer]" comfy-cli -q
|
|
|
|
| 222 |
|
| 223 |
+
log_success "Dependências instaladas"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 224 |
|
| 225 |
+
# 2. Instalar ComfyUI
|
| 226 |
+
log_info "[2/5] Instalando ComfyUI..."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 227 |
|
| 228 |
+
if [ -f "$COMFY_DIR/main.py" ]; then
|
| 229 |
+
log_warn "ComfyUI já existe"
|
| 230 |
+
else
|
| 231 |
+
comfy --skip-prompt install --fast-deps --nvidia
|
| 232 |
+
fi
|
| 233 |
|
| 234 |
+
log_success "ComfyUI instalado"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 235 |
|
| 236 |
+
# 3. Corrigir PyTorch para RTX 5090 se detectado
|
| 237 |
+
log_info "[3/5] Verificando GPU..."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 238 |
|
| 239 |
+
GPU_INFO=$(nvidia-smi --query-gpu=name --format=csv,noheader 2>/dev/null || echo "")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 240 |
|
| 241 |
+
if [[ "$GPU_INFO" == *"5090"* ]] || [[ "$GPU_INFO" == *"5080"* ]]; then
|
| 242 |
+
log_warn "RTX 5090/5080 detectada - instalando PyTorch nightly"
|
| 243 |
+
pip install --force-reinstall --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/cu128
|
| 244 |
+
else
|
| 245 |
+
log_info "GPU: ${GPU_INFO:-Não detectada}"
|
| 246 |
+
fi
|
|
|
|
| 247 |
|
| 248 |
+
log_success "PyTorch configurado"
|
|
|
|
|
|
|
|
|
|
| 249 |
|
| 250 |
+
# 4. Baixar modelos
|
| 251 |
+
log_info "[4/5] Baixando modelos..."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 252 |
|
| 253 |
+
process_downloads
|
|
|
|
| 254 |
|
| 255 |
+
log_success "Downloads processados"
|
|
|
|
| 256 |
|
| 257 |
+
# 5. Instalar custom nodes
|
| 258 |
+
log_info "[5/5] Instalando custom nodes..."
|
| 259 |
|
| 260 |
+
CN_DIR="$COMFY_DIR/custom_nodes"
|
| 261 |
+
mkdir -p "$CN_DIR"
|
| 262 |
|
| 263 |
+
for repo in "${CUSTOM_NODES[@]}"; do
|
| 264 |
+
node_name=$(basename "$repo")
|
| 265 |
+
clone_repo "$repo" "$CN_DIR/$node_name"
|
| 266 |
+
done
|
|
|
|
|
|
|
| 267 |
|
| 268 |
+
log_success "Custom nodes instalados"
|
| 269 |
+
|
| 270 |
+
# Verificar e iniciar
|
| 271 |
+
log_info "========================================="
|
| 272 |
+
log_success "Instalação concluída!"
|
| 273 |
+
log_info "Iniciando ComfyUI..."
|
| 274 |
+
log_info "URL: http://localhost:$COMFY_PORT"
|
| 275 |
+
log_info "========================================="
|
|
|
|
| 276 |
|
| 277 |
+
cd "$COMFY_DIR"
|
| 278 |
+
exec comfy launch -- --listen "$COMFY_HOST" --port "$COMFY_PORT"
|