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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env bash
|
| 2 |
+
# setup_comfyui_combined.sh
|
| 3 |
+
# Script combinado para instalação do ComfyUI com Wan 2.2
|
| 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 NVCC_APPEND_FLAGS="--threads 8"
|
| 29 |
+
export UV_SYSTEM_PYTHON=1
|
| 30 |
+
export PYTORCH_CUDA_ALLOC_CONF="expandable_segments:True"
|
| 31 |
+
export HF_HUB_ENABLE_HF_TRANSFER=1
|
| 32 |
+
export HF_TRANSFER_CONCURRENCY=16
|
| 33 |
+
export EXT_PARALLEL=4
|
| 34 |
+
|
| 35 |
+
# Lista de downloads - Formato: "URL|TIPO|NOME_OPCIONAL"
|
| 36 |
+
DOWNLOAD_FILES=(
|
| 37 |
+
# Wan 2.2 models
|
| 38 |
+
"hf://Kijai/WanVideo_comfy/Wan22-Lightning/Wan2.2-Lightning_T2V-v1.1-A14B-4steps-lora_HIGH_fp16.safetensors|loras|Wan2.2-Lightning_T2V-v1.1-A14B-4steps-lora_HIGH_fp16.safetensors"
|
| 39 |
+
"hf://Kijai/WanVideo_comfy/Wan22-Lightning/Wan2.2-Lightning_T2V-v1.1-A14B-4steps-lora_LOW_fp16.safetensors|loras|Wan2.2-Lightning_T2V-v1.1-A14B-4steps-lora_LOW_fp16.safetensors"
|
| 40 |
+
"hf://Kijai/WanVideo_comfy_fp8_scaled/I2V/Wan2_2-I2V-A14B-HIGH_fp8_e5m2_scaled_KJ.safetensors|diffusion_models|Wan2_2-I2V-A14B-HIGH_fp8_e5m2_scaled_KJ.safetensors"
|
| 41 |
+
"hf://Kijai/WanVideo_comfy_fp8_scaled/I2V/Wan2_2-I2V-A14B-LOW_fp8_e5m2_scaled_KJ.safetensors|diffusion_models|Wan2_2-I2V-A14B-LOW_fp8_e5m2_scaled_KJ.safetensors"
|
| 42 |
+
"hf://Kijai/WanVideo_comfy/Wan22-Lightning/Wan2.2-Lightning_I2V-A14B-4steps-lora_HIGH_fp16.safetensors|loras|Wan2.2-Lightning_I2V-A14B-4steps-lora_HIGH_fp16.safetensors"
|
| 43 |
+
"hf://Kijai/WanVideo_comfy/Wan22-Lightning/Wan2.2-Lightning_I2V-A14B-4steps-lora_LOW_fp16.safetensors|loras|Wan2.2-Lightning_I2V-A14B-4steps-lora_LOW_fp16.safetensors"
|
| 44 |
+
"hf://Kijai/WanVideo_comfy/Wan2_1_VAE_fp32.safetensors|vae|Wan2_1_VAE_fp32.safetensors"
|
| 45 |
+
"hf://Kijai/WanVideo_comfy/umt5-xxl-enc-bf16.safetensors|text_encoders|umt5-xxl-enc-bf16.safetensors"
|
| 46 |
+
|
| 47 |
+
# Wan 2.1 models
|
| 48 |
+
"hf://Kijai/WanVideo_comfy/Lightx2v/lightx2v_I2V_14B_480p_cfg_step_distill_rank256_bf16.safetensors|loras|lightx2v_I2V_14B_480p_cfg_step_distill_rank256_bf16.safetensors"
|
| 49 |
+
"hf://Comfy-Org/Wan_2.2_ComfyUI_Repackaged/split_files/vae/wan_2.1_vae.safetensors|vae|wan_2.1_vae.safetensors"
|
| 50 |
+
"hf://Comfy-Org/Wan_2.2_ComfyUI_Repackaged/split_files/text_encoders/umt5_xxl_fp16.safetensors|text_encoders|umt5_xxl_fp16.safetensors"
|
| 51 |
+
|
| 52 |
+
# Wan 2.1 clip vision
|
| 53 |
+
"hf://Kijai/WanVideo_comfy/open-clip-xlm-roberta-large-vit-huge-14_visual_fp32.safetensors|clip_vision|open-clip-xlm-roberta-large-vit-huge-14_visual_fp32.safetensors"
|
| 54 |
+
"hf://Comfy-Org/Wan_2.1_ComfyUI_repackaged/split_files/clip_vision/clip_vision_h.safetensors|clip_vision|clip_vision_h.safetensors"
|
| 55 |
+
|
| 56 |
+
# Upscaler extra
|
| 57 |
+
"https://huggingface.co/ABDALLALSWAITI/Upscalers/resolve/main/anime/2x-AnimeSharpV2_MoSR_Soft.pth|upscale_models|2x-AnimeSharpV2_MoSR_Soft.pth"
|
| 58 |
+
)
|
| 59 |
+
|
| 60 |
+
# Mega downloads
|
| 61 |
+
MEGA_LORAS=(
|
| 62 |
+
"https://mega.nz/file/QFxREJpZ#0dge8TyRgb52lMFKdsk-Ac-rwcoG49hvBHvaqNsZkuk"
|
| 63 |
+
"https://mega.nz/file/lIhQETjT#nKlQ01Euw6fUxo8P5bfwlQrxAkWEedXQQOqHv5u4yrM"
|
| 64 |
+
"https://mega.nz/file/UIAESACY#Qlei1Pj5Nwno3Sz-wsTekvD-YgCkN1A5QbFKoRHXG9E"
|
| 65 |
+
"https://mega.nz/file/cdAg1Q7D#tQVrer2sB-M7XdYiKAqr7kRRfJw4pXCdliOg2aPJUGE"
|
| 66 |
+
"https://mega.nz/file/5RQFiAAJ#QCWrHkuJjXlFufR18g5R9YXJGqJ1pQp7xbqNRgSYUjc"
|
| 67 |
+
"https://mega.nz/file/tABgxLTS#NNlPV8NPc7R52MIjABMFUb41EOFDxFoszBxOrPMN13Q"
|
| 68 |
+
"https://mega.nz/file/4MxBgJ5Y#R8OSby0u-t-QFBnpnOtdjN3xuiVRvHa4_OEzTwWoGKQ"
|
| 69 |
+
"https://mega.nz/file/dJJxiSRR#o3XsYfSvb04xg7gNVdfHb3XTVHgvx0ZyXe9N8VQ9Lfw"
|
| 70 |
+
"https://mega.nz/file/wcAFhRJZ#ifZcckts0wPq1FG693tYLkpFrvjXvab1ZQeL6DuL1T8"
|
| 71 |
+
"https://mega.nz/file/wNIgmRwb#vn6rKM3QuTDpWVTLEBDsKjIkNkaX2wLKeauKNeVkcFs"
|
| 72 |
+
"https://mega.nz/file/hZhhhCQS#4je0Im2g1kEvTCuPotjVWkA-g6XICkqMb-mKxMt6R3Y"
|
| 73 |
+
)
|
| 74 |
+
|
| 75 |
+
MEGA_UPSCALE=(
|
| 76 |
+
"https://mega.nz/file/qdQwAJSC#rPY2Hg4x-_RbHiHUBFW-YU8xZUqPpq5Gpl1uPFiJvW4"
|
| 77 |
+
"https://mega.nz/file/KIh2marA#CehVNXxQhGfp1bqUL0K1YPWNqrCUoLPCZGq2W6XqmWo"
|
| 78 |
+
)
|
| 79 |
+
|
| 80 |
+
# Custom nodes do CODE2
|
| 81 |
+
CUSTOM_NODES=(
|
| 82 |
+
"https://github.com/kijai/ComfyUI-Florence2"
|
| 83 |
+
"https://github.com/adbrasi/groqrouter"
|
| 84 |
+
"https://github.com/kijai/ComfyUI-WanVideoWrapper"
|
| 85 |
+
"https://github.com/Fannovel16/ComfyUI-Frame-Interpolation"
|
| 86 |
+
"https://github.com/kijai/ComfyUI-GIMM-VFI"
|
| 87 |
+
"https://github.com/Kosinkadink/ComfyUI-VideoHelperSuite"
|
| 88 |
+
"https://github.com/kijai/ComfyUI-KJNodes"
|
| 89 |
+
"https://github.com/Fannovel16/comfyui_controlnet_aux"
|
| 90 |
+
"https://github.com/Artificial-Sweetener/comfyui-WhiteRabbit"
|
| 91 |
+
"https://github.com/shiimizu/ComfyUI_smZNodes"
|
| 92 |
+
"https://github.com/CoreyCorza/ComfyUI-CRZnodes"
|
| 93 |
+
"https://github.com/pythongosssss/ComfyUI-Custom-Scripts"
|
| 94 |
+
"https://github.com/pythongosssss/ComfyUI-WD14-Tagger"
|
| 95 |
+
"https://github.com/WASasquatch/was-node-suite-comfyui"
|
| 96 |
+
"https://github.com/justUmen/Bjornulf_custom_nodes"
|
| 97 |
+
"https://github.com/mingsky-ai/ComfyUI-MingNodes"
|
| 98 |
+
"https://github.com/numz/ComfyUI-SeedVR2_VideoUpscaler"
|
| 99 |
+
"https://github.com/1038lab/ComfyUI-RMBG"
|
| 100 |
+
"https://github.com/wallish77/wlsh_nodes"
|
| 101 |
+
"https://github.com/yuvraj108c/ComfyUI-Upscaler-Tensorrt"
|
| 102 |
+
"https://github.com/raindrop313/ComfyUI-WanVideoStartEndFrames"
|
| 103 |
+
"https://github.com/MushroomFleet/DJZ-Nodes"
|
| 104 |
+
"https://github.com/Suzie1/ComfyUI_Comfyroll_CustomNodes"
|
| 105 |
+
"https://github.com/grmchn/ComfyUI-ProportionChanger"
|
| 106 |
+
)
|
| 107 |
+
|
| 108 |
+
# Download HuggingFace
|
| 109 |
+
download_hf() {
|
| 110 |
+
local url="$1"
|
| 111 |
+
local target_dir="$2"
|
| 112 |
+
local filename="$3"
|
| 113 |
+
|
| 114 |
+
# Extrair repo e file_path da URL hf://
|
| 115 |
+
url="${url#hf://}"
|
| 116 |
+
local repo="$(echo "$url" | cut -d'/' -f1-2)"
|
| 117 |
+
local file_path="$(echo "$url" | cut -d'/' -f3-)"
|
| 118 |
+
|
| 119 |
+
if [ -n "$filename" ] && [ -f "$target_dir/$filename" ]; then
|
| 120 |
+
log_success "Já existe: $filename"
|
| 121 |
+
return 0
|
| 122 |
+
fi
|
| 123 |
+
|
| 124 |
+
log_info "Baixando HF: $filename"
|
| 125 |
+
|
| 126 |
+
local temp_dir
|
| 127 |
+
temp_dir="$(mktemp -d)"
|
| 128 |
+
|
| 129 |
+
if command -v hf >/dev/null 2>&1; then
|
| 130 |
+
HF_HUB_ENABLE_HF_TRANSFER=1 hf download "$repo" "$file_path" \
|
| 131 |
+
--local-dir "$temp_dir" --local-dir-use-symlinks False 2>/dev/null || {
|
| 132 |
+
rm -rf "$temp_dir"
|
| 133 |
+
log_error "Falha ao baixar: $filename"
|
| 134 |
+
return 1
|
| 135 |
+
}
|
| 136 |
+
elif command -v huggingface-cli >/dev/null 2>&1; then
|
| 137 |
+
HF_HUB_ENABLE_HF_TRANSFER=1 huggingface-cli download "$repo" "$file_path" \
|
| 138 |
+
--local-dir "$temp_dir" --local-dir-use-symlinks False 2>/dev/null || {
|
| 139 |
+
rm -rf "$temp_dir"
|
| 140 |
+
log_error "Falha ao baixar: $filename"
|
| 141 |
+
return 1
|
| 142 |
+
}
|
| 143 |
+
else
|
| 144 |
+
wget -q --show-progress -c -O "$target_dir/$filename" "https://huggingface.co/$url"
|
| 145 |
+
rm -rf "$temp_dir"
|
| 146 |
+
return $?
|
| 147 |
+
fi
|
| 148 |
+
|
| 149 |
+
# Mover arquivo baixado para destino
|
| 150 |
+
local downloaded_file
|
| 151 |
+
downloaded_file="$(find "$temp_dir" -type f \( -name "*.safetensors" -o -name "*.pth" -o -name "*.pt" -o -name "*.bin" \) | head -1)"
|
| 152 |
+
if [ -n "$downloaded_file" ]; then
|
| 153 |
+
mv "$downloaded_file" "$target_dir/$filename"
|
| 154 |
+
rm -rf "$temp_dir"
|
| 155 |
+
log_success "Download concluído: $filename"
|
| 156 |
+
return 0
|
| 157 |
+
else
|
| 158 |
+
rm -rf "$temp_dir"
|
| 159 |
+
log_error "Arquivo não encontrado após download: $filename"
|
| 160 |
+
return 1
|
| 161 |
+
fi
|
| 162 |
+
}
|
| 163 |
+
|
| 164 |
+
# Download Mega
|
| 165 |
+
download_mega() {
|
| 166 |
+
local url="$1"
|
| 167 |
+
local target_dir="$2"
|
| 168 |
+
|
| 169 |
+
log_info "Baixando do Mega..."
|
| 170 |
+
|
| 171 |
+
cd "$target_dir"
|
| 172 |
+
if megadl "$url" 2>/dev/null; then
|
| 173 |
+
log_success "Mega download OK"
|
| 174 |
+
else
|
| 175 |
+
log_warn "Mega download falhou"
|
| 176 |
+
fi
|
| 177 |
+
cd - >/dev/null
|
| 178 |
+
}
|
| 179 |
+
|
| 180 |
+
# Download normal
|
| 181 |
+
download_file() {
|
| 182 |
+
local url="$1"
|
| 183 |
+
local target_dir="$2"
|
| 184 |
+
local filename="$3"
|
| 185 |
+
|
| 186 |
+
# Adicionar token Civitai se necessário
|
| 187 |
+
if [[ "$url" == *"civitai.com"* ]] && [[ "$url" != *"token="* ]]; then
|
| 188 |
+
url="${url}&token=${CIVITAI_TOKEN}"
|
| 189 |
+
fi
|
| 190 |
+
|
| 191 |
+
if [ -n "$filename" ] && [ -f "$target_dir/$filename" ]; then
|
| 192 |
+
log_success "Já existe: $filename"
|
| 193 |
+
return 0
|
| 194 |
+
fi
|
| 195 |
+
|
| 196 |
+
log_info "Baixando: ${filename:-arquivo}"
|
| 197 |
+
|
| 198 |
+
# Tentar com aria2c primeiro
|
| 199 |
+
if command -v aria2c >/dev/null 2>&1; then
|
| 200 |
+
if [ -n "$filename" ]; then
|
| 201 |
+
aria2c -c -x 16 -s 16 -k 1M --console-log-level=warn --dir="$target_dir" --out="$filename" "$url" || \
|
| 202 |
+
wget -q --show-progress -c -O "$target_dir/$filename" "$url" || \
|
| 203 |
+
log_error "Download falhou: $filename"
|
| 204 |
+
else
|
| 205 |
+
aria2c -c -x 16 -s 16 -k 1M --console-log-level=warn --dir="$target_dir" "$url" || \
|
| 206 |
+
(cd "$target_dir" && wget -q --show-progress -c "$url") || \
|
| 207 |
+
log_error "Download falhou: $url"
|
| 208 |
+
fi
|
| 209 |
+
elif [ -n "$filename" ]; then
|
| 210 |
+
wget -q --show-progress -c -O "$target_dir/$filename" "$url" || \
|
| 211 |
+
log_error "Download falhou: $filename"
|
| 212 |
+
else
|
| 213 |
+
(cd "$target_dir" && wget -q --show-progress -c "$url") || \
|
| 214 |
+
log_error "Download falhou: $url"
|
| 215 |
+
fi
|
| 216 |
+
}
|
| 217 |
+
|
| 218 |
+
# Processar downloads
|
| 219 |
+
process_downloads() {
|
| 220 |
+
for entry in "${DOWNLOAD_FILES[@]}"; do
|
| 221 |
+
IFS='|' read -r url type filename <<< "$entry"
|
| 222 |
+
|
| 223 |
+
# Criar diretório
|
| 224 |
+
local target_dir="$MODELS_DIR/$type"
|
| 225 |
+
mkdir -p "$target_dir"
|
| 226 |
+
|
| 227 |
+
# Baixar arquivo
|
| 228 |
+
if [[ "$url" == hf://* ]]; then
|
| 229 |
+
download_hf "$url" "$target_dir" "$filename"
|
| 230 |
+
else
|
| 231 |
+
download_file "$url" "$target_dir" "$filename"
|
| 232 |
+
fi
|
| 233 |
+
done
|
| 234 |
+
}
|
| 235 |
+
|
| 236 |
+
# Clone git repo
|
| 237 |
+
clone_repo() {
|
| 238 |
+
local url="$1"
|
| 239 |
+
local dest="$2"
|
| 240 |
+
|
| 241 |
+
if [ -d "$dest/.git" ]; then
|
| 242 |
+
git -C "$dest" pull --ff-only 2>/dev/null || true
|
| 243 |
+
else
|
| 244 |
+
git clone --depth 1 "$url" "$dest" 2>/dev/null || true
|
| 245 |
+
fi
|
| 246 |
+
|
| 247 |
+
# Instalar requirements se existir
|
| 248 |
+
if [ -f "$dest/requirements.txt" ]; then
|
| 249 |
+
pip install -q -r "$dest/requirements.txt" 2>/dev/null || true
|
| 250 |
+
fi
|
| 251 |
+
}
|
| 252 |
+
|
| 253 |
+
# ========== INSTALAÇÃO ==========
|
| 254 |
+
|
| 255 |
+
log_info "========================================="
|
| 256 |
+
log_info " ComfyUI + Wan 2.2 Setup"
|
| 257 |
+
log_info "========================================="
|
| 258 |
+
|
| 259 |
+
# 1. Instalar dependências
|
| 260 |
+
log_info "[1/7] Instalando dependências..."
|
| 261 |
+
|
| 262 |
+
apt-get update -qq
|
| 263 |
+
apt-get install -y -qq aria2 megatools git wget curl 2>/dev/null
|
| 264 |
+
|
| 265 |
+
pip install --upgrade pip wheel setuptools -q
|
| 266 |
+
pip install --upgrade "huggingface_hub[cli,hf_transfer]>=0.26.0" comfy-cli -q
|
| 267 |
+
|
| 268 |
+
log_success "Dependências instaladas"
|
| 269 |
+
|
| 270 |
+
# 2. Instalar ComfyUI
|
| 271 |
+
log_info "[2/7] Instalando ComfyUI..."
|
| 272 |
+
|
| 273 |
+
if [ -f "$COMFY_DIR/main.py" ]; then
|
| 274 |
+
log_warn "ComfyUI já existe"
|
| 275 |
+
else
|
| 276 |
+
comfy --skip-prompt install --fast-deps --nvidia
|
| 277 |
+
fi
|
| 278 |
+
|
| 279 |
+
log_success "ComfyUI instalado"
|
| 280 |
+
|
| 281 |
+
# 3. Instalar PyTorch com CUDA 12.8
|
| 282 |
+
log_info "[3/7] Instalando PyTorch com CUDA 12.8..."
|
| 283 |
+
pip install --upgrade torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu128
|
| 284 |
+
log_success "PyTorch com CUDA 12.8 instalado"
|
| 285 |
+
|
| 286 |
+
# 4. Instalar SageAttention
|
| 287 |
+
log_info "[4/7] Instalando SageAttention..."
|
| 288 |
+
if python3 -c "import torch; print(torch.cuda.is_available())" 2>/dev/null | grep -q True; then
|
| 289 |
+
pip install "https://huggingface.co/adbrasi/comfywheel/resolve/main/sageattention-2.2.0-cp311-cp311-linux_x86_64.whl" -q || log_warn "Falha ao instalar SageAttention"
|
| 290 |
+
python3 -c "import sageattention" >/dev/null 2>&1 || log_warn "SageAttention não pôde ser importado"
|
| 291 |
+
log_success "SageAttention instalado"
|
| 292 |
+
else
|
| 293 |
+
log_warn "CUDA não detectado, pulando SageAttention"
|
| 294 |
+
fi
|
| 295 |
+
|
| 296 |
+
# 5. Baixar modelos
|
| 297 |
+
log_info "[5/7] Baixando modelos..."
|
| 298 |
+
|
| 299 |
+
# Criar diretórios
|
| 300 |
+
mkdir -p "$MODELS_DIR"/{diffusion_models,loras,vae,vae_approx,text_encoders,clip_vision,controlnet,upscale_models,checkpoints}
|
| 301 |
+
|
| 302 |
+
# Processar downloads principais
|
| 303 |
+
process_downloads
|
| 304 |
+
|
| 305 |
+
# Baixar Mega LoRAs
|
| 306 |
+
LORA_DIR="$MODELS_DIR/loras"
|
| 307 |
+
for mega_url in "${MEGA_LORAS[@]}"; do
|
| 308 |
+
download_mega "$mega_url" "$LORA_DIR"
|
| 309 |
+
done
|
| 310 |
+
|
| 311 |
+
# Baixar Mega Upscale
|
| 312 |
+
UPSCALE_DIR="$MODELS_DIR/upscale_models"
|
| 313 |
+
for mega_url in "${MEGA_UPSCALE[@]}"; do
|
| 314 |
+
download_mega "$mega_url" "$UPSCALE_DIR"
|
| 315 |
+
done
|
| 316 |
+
|
| 317 |
+
log_success "Downloads processados"
|
| 318 |
+
|
| 319 |
+
# 6. Instalar custom nodes
|
| 320 |
+
log_info "[6/7] Instalando custom nodes..."
|
| 321 |
+
|
| 322 |
+
CN_DIR="$COMFY_DIR/custom_nodes"
|
| 323 |
+
mkdir -p "$CN_DIR"
|
| 324 |
+
|
| 325 |
+
total_nodes=${#CUSTOM_NODES[@]}
|
| 326 |
+
current_node=0
|
| 327 |
+
|
| 328 |
+
for repo in "${CUSTOM_NODES[@]}"; do
|
| 329 |
+
((current_node++))
|
| 330 |
+
node_name=$(basename "$repo")
|
| 331 |
+
log_info "[$current_node/$total_nodes] Instalando: $node_name"
|
| 332 |
+
clone_repo "$repo" "$CN_DIR/$node_name"
|
| 333 |
+
done
|
| 334 |
+
|
| 335 |
+
log_success "Custom nodes instalados"
|
| 336 |
+
|
| 337 |
+
# 7. Verificação final
|
| 338 |
+
log_info "[7/7] Verificando instalação..."
|
| 339 |
+
|
| 340 |
+
echo ""
|
| 341 |
+
log_info "Modelos disponíveis:"
|
| 342 |
+
for dir in diffusion_models loras vae vae_approx text_encoders clip_vision controlnet upscale_models checkpoints; do
|
| 343 |
+
if [ -d "$MODELS_DIR/$dir" ]; then
|
| 344 |
+
local count
|
| 345 |
+
count=$(find "$MODELS_DIR/$dir" -type f \( -name "*.safetensors" -o -name "*.pth" -o -name "*.pt" -o -name "*.bin" \) 2>/dev/null | wc -l)
|
| 346 |
+
if [ "$count" -gt 0 ]; then
|
| 347 |
+
log_success " $dir: $count arquivo(s)"
|
| 348 |
+
fi
|
| 349 |
+
fi
|
| 350 |
+
done
|
| 351 |
+
|
| 352 |
+
# Verificar e iniciar com SageAttention se disponível
|
| 353 |
+
log_info "========================================="
|
| 354 |
+
log_success "Instalação concluída!"
|
| 355 |
+
log_info "Iniciando ComfyUI..."
|
| 356 |
+
log_info "URL: http://localhost:$COMFY_PORT"
|
| 357 |
+
log_info "========================================="
|
| 358 |
+
|
| 359 |
+
SAGE_FLAG=""
|
| 360 |
+
python3 -c "import sageattention" >/dev/null 2>&1 && SAGE_FLAG="--use-sage-attention" || true
|
| 361 |
+
|
| 362 |
+
cd "$COMFY_DIR"
|
| 363 |
+
exec comfy launch -- ${SAGE_FLAG:+$SAGE_FLAG} --listen "$COMFY_HOST" --port "$COMFY_PORT"
|