adbrasi commited on
Commit
014e0b1
·
verified ·
1 Parent(s): 564b420

Upload ImageStudioTESTER.sh

Browse files
Files changed (1) hide show
  1. ImageStudioTESTER.sh +336 -0
ImageStudioTESTER.sh ADDED
@@ -0,0 +1,336 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_BASE="/workspace/comfy"
21
+ COMFY_DIR="$COMFY_BASE/ComfyUI"
22
+ MODELS_DIR="$COMFY_DIR/models"
23
+ COMFY_HOST="0.0.0.0"
24
+ COMFY_PORT="8818"
25
+ VENV_DIR="$COMFY_BASE/.venv"
26
+ CIVITAI_TOKEN="4fcb2834969399006a736ee402b061e5"
27
+
28
+ # Garantir que o diretório base exista para instalar fora de /root
29
+ mkdir -p "$COMFY_BASE"
30
+
31
+ # Performance
32
+ export MAX_JOBS=32
33
+ export HF_HUB_ENABLE_HF_TRANSFER=1
34
+
35
+ # Lista de downloads - Formato: "URL|TIPO|NOME_OPCIONAL"
36
+ DOWNLOAD_FILES=(
37
+ # Mega primeiro (sem nome forçado - usar nome original)
38
+ #"mega://https://mega.nz/file/gIRTFQSQ#no6Ay3JLE9LVRi7ib9O-Jc0CW7XmG046kCgpCzDg1tY|loras|"
39
+
40
+ # Checkpoints
41
+ "https://civitai.com/api/download/models/1761560?type=Model&format=SafeTensor&size=pruned&fp=fp16|checkpoints|wai14.safetensors"
42
+
43
+ # LoRAs Civitai
44
+ "https://civitai.com/api/download/models/1268294?type=Model&format=SafeTensor|loras|"
45
+ "https://civitai.com/api/download/models/1148809?type=Model&format=SafeTensor|loras|"
46
+ "https://civitai.com/api/download/models/1715330?type=Model&format=SafeTensor|loras|"
47
+ "https://civitai.com/api/download/models/1715330?type=Model&format=SafeTensor|loras|"
48
+ "https://civitai.com/api/download/models/1499397?type=Model&format=SafeTensor|loras|"
49
+ "https://civitai.com/api/download/models/1779002?type=Model&format=SafeTensor|loras|"
50
+ "https://civitai.com/api/download/models/1114313?type=Model&format=SafeTensor|loras|"
51
+ "https://civitai.com/api/download/models/1780244?type=Model&format=SafeTensor|loras|"
52
+ "https://civitai.com/api/download/models/1613410?type=Model&format=SafeTensor|loras|"
53
+ "https://civitai.com/api/download/models/1804885?type=Model&format=SafeTensor|loras|"
54
+ "https://civitai.com/api/download/models/1809575?type=Model&format=SafeTensor|loras|"
55
+ "https://civitai.com/api/download/models/2135873?type=Model&format=SafeTensor|loras|"
56
+ "https://civitai.com/api/download/models/2332149?type=Model&format=SafeTensor|loras|"
57
+ "https://civitai.com/api/download/models/1517104?type=Model&format=SafeTensor|loras|"
58
+
59
+ "https://civitai.com/api/download/models/1833157?type=Model&format=SafeTensor|embeddings|"
60
+
61
+ "https://huggingface.co/Anzhc/Anzhcs_YOLOs/resolve/main/Anzhc%20Face%20seg%201024%20v2%20y8n.pt|ultralytics/bbox|Anzhc_Faceseg_1024_v2_y8n.pt"
62
+ "https://dl.fbaipublicfiles.com/segment_anything/sam_vit_b_01ec64.pth|sams|sam_vit_b_01ec64.pth"
63
+ "https://huggingface.co/adbrasi/wanlotest/resolve/main/Eyeful_v2-Individual.pt|ultralytics/bbox|Eyeful_v2-Paired.pt"
64
+ "https://huggingface.co/Bingsu/adetailer/resolve/main/hand_yolov8s.pt|ultralytics/bbox|hand_yolov8s.pt"
65
+ "https://huggingface.co/adbrasi/wanlotest/resolve/main/ntd11_anime_nsfw_segm_v5-variant1.pt|ultralytics/bbox|ntd11_anime_nsfw_segm_v5-variant1.pt"
66
+ "https://civitai.com/api/download/models/2121199?type=Model&format=Other|embeddings|"
67
+ "https://civitai.com/api/download/models/1195487?type=Negative&format=Other|embeddings|"
68
+ "https://civitai.com/api/download/models/1470551?type=Model&format=SafeTensor|embeddings|"
69
+ # Upscalers
70
+ "https://huggingface.co/adbrasi/wanlotest/resolve/main/2x-AnimeSharpV4_RCAN_fp16_op17.onnx|upscale_models|2x-AnimeSharpV4_RCAN_fp16_op17.onnx"
71
+ "https://huggingface.co/Kim2091/AnimeSharp/resolve/main/4x-AnimeSharp.pth|upscale_models|4x-AnimeSharp.pth"
72
+ "https://huggingface.co/adbrasi/wanlotest/resolve/main/2x-AnimeSharpV4_Fast_RCAN_PU.safetensors|upscale_models|2x-AnimeSharpV4_Fast_RCAN_PU.safetensors"
73
+ "https://huggingface.co/Kim2091/AnimeSharpV3/resolve/main/2x-AnimeSharpV3.pth|upscale_models|2x-AnimeSharpV3.pth"
74
+ "https://huggingface.co/FacehugmanIII/4x_foolhardy_Remacri/resolve/main/4x_foolhardy_Remacri.pth"
75
+ "https://huggingface.co/Kim2091/UltraSharpV2/resolve/main/4x-UltraSharpV2.pth|upscale_models|4x-UltraSharpV2.pth"
76
+ "https://huggingface.co/Kim2091/UltraSharpV2/resolve/main/4x-UltraSharpV2_Lite.pth|upscale_models|4x-UltraSharpV2_Lite.pth"
77
+
78
+ # Ultralytics
79
+ "https://huggingface.co/adbrasi/testedownload/resolve/main/99coins_anime_girl_face_m_seg.pt|ultralytics/bbox|99coins_anime_girl_face_m_seg.pt"
80
+ )
81
+
82
+ # Custom nodes
83
+ CUSTOM_NODES=(
84
+ "https://github.com/adbrasi/huggpackreator"
85
+ "https://github.com/adbrasi/packreator_processor"
86
+ "https://github.com/Cezarsaint/Packreator_managerMEita"
87
+ "https://github.com/adbrasi/cezarsave34"
88
+ "https://github.com/adbrasi/pageonetor"
89
+ "https://github.com/QuietNoise/comfyui_queue_manager"
90
+ "https://github.com/adbrasi/pakreatorio"
91
+ "https://github.com/adbrasi/WaterMark_bumbumzin"
92
+ "https://github.com/adbrasi/marcadaguita"
93
+ "https://github.com/adbrasi/randomico"
94
+ "https://github.com/kijai/ComfyUI-KJNodes"
95
+ "https://github.com/ltdrdata/ComfyUI-Inspire-Pack"
96
+ "https://github.com/Goshe-nite/comfyui-gps-supplements"
97
+ "https://github.com/adbrasi/groqrouter"
98
+ "https://github.com/adbrasi/find_charakito"
99
+ "https://github.com/adbrasi/randomsizito"
100
+ "https://github.com/adbrasi/importex"
101
+ "https://github.com/adbrasi/storitadifusita"
102
+ "https://github.com/adbrasi/attentionPPM"
103
+ "https://github.com/Suzie1/ComfyUI_Comfyroll_CustomNodes"
104
+ "https://github.com/sipherxyz/comfyui-art-venture"
105
+ "https://github.com/pamparamm/sd-perturbed-attention"
106
+ "https://github.com/KoreTeknology/ComfyUI-Universal-Styler"
107
+ "https://github.com/WASasquatch/was-node-suite-comfyui"
108
+ "https://github.com/chflame163/ComfyUI_LayerStyle"
109
+ "https://github.com/newtextdoc1111/ComfyUI-Autocomplete-Plus"
110
+ "https://github.com/pythongosssss/ComfyUI-WD14-Tagger"
111
+ "https://github.com/ltdrdata/ComfyUI-Impact-Pack"
112
+ "https://github.com/pythongosssss/ComfyUI-Custom-Scripts"
113
+ "https://github.com/rgthree/rgthree-comfy"
114
+ "https://github.com/ssitu/ComfyUI_UltimateSDUpscale"
115
+ "https://github.com/adbrasi/Importador"
116
+ "https://github.com/adbrasi/GetFirstTag"
117
+ "https://github.com/adbrasi/comfydodi"
118
+ "https://github.com/omar92/ComfyUI-QualityOfLifeSuit_Omar92"
119
+ "https://github.com/Cezarsaint/blacklisto"
120
+ "https://github.com/TinyTerra/ComfyUI_tinyterraNodes"
121
+ "https://github.com/ltdrdata/ComfyUI-Impact-Subpack"
122
+ "https://github.com/Cezarsaint/rand0micoUploaderLoven"
123
+ "https://github.com/adbrasi/pixivmosaic"
124
+ "https://github.com/adbrasi/futfilter"
125
+ "https://github.com/Artificial-Sweetener/comfyui-WhiteRabbit"
126
+ "https://github.com/shiimizu/ComfyUI_smZNodes"
127
+ "https://github.com/CoreyCorza/ComfyUI-CRZnodes"
128
+ "https://github.com/MoonGoblinDev/Civicomfy"
129
+ "https://github.com/ltdrdata/ComfyUI-Impact-Pack"
130
+ "https://github.com/ltdrdata/ComfyUI-Impact-Subpack"
131
+ "https://github.com/huchenlei/ComfyUI_DanTagGen"
132
+ "https://github.com/adbrasi/captionizador"
133
+ )
134
+
135
+ # Download HuggingFace
136
+ download_hf() {
137
+ local url="$1"
138
+ local target_dir="$2"
139
+ local filename="$3"
140
+
141
+ if [ -n "$filename" ] && [ -f "$target_dir/$filename" ]; then
142
+ log_success "Já existe: $filename"
143
+ return 0
144
+ fi
145
+
146
+ log_info "Baixando HF: $filename"
147
+
148
+ if command -v hf >/dev/null 2>&1; then
149
+ cd "$target_dir"
150
+ hf download "$(dirname "$url")" "$(basename "$url")" --local-dir . 2>/dev/null
151
+ cd - >/dev/null
152
+ else
153
+ wget -q --show-progress -c -O "$target_dir/$filename" "https://huggingface.co/$url"
154
+ fi
155
+ }
156
+
157
+ # Download Mega
158
+ download_mega() {
159
+ local url="$1"
160
+ local target_dir="$2"
161
+
162
+ # Remover prefixo mega://
163
+ url="${url#mega://}"
164
+
165
+ log_info "Baixando do Mega..."
166
+
167
+ cd "$target_dir"
168
+ # Usar megadl simples sem forçar nome
169
+ if megadl "$url" 2>/dev/null; then
170
+ log_success "Mega download OK"
171
+ else
172
+ log_warn "Mega download falhou"
173
+ fi
174
+ cd - >/dev/null
175
+ }
176
+
177
+ # Download normal
178
+ download_file() {
179
+ local url="$1"
180
+ local target_dir="$2"
181
+ local filename="$3"
182
+
183
+ # Adicionar token Civitai se necessário
184
+ if [[ "$url" == *"civitai.com"* ]] && [[ "$url" != *"token="* ]]; then
185
+ url="${url}&token=${CIVITAI_TOKEN}"
186
+ fi
187
+
188
+ if [ -n "$filename" ] && [ -f "$target_dir/$filename" ]; then
189
+ log_success "Já existe: $filename"
190
+ return 0
191
+ fi
192
+
193
+ log_info "Baixando: ${filename:-arquivo}"
194
+
195
+ # Tentar com aria2c primeiro
196
+ if command -v aria2c >/dev/null 2>&1; then
197
+ if [ -n "$filename" ]; then
198
+ aria2c -c -x 4 -s 4 --console-log-level=warn --dir="$target_dir" --out="$filename" "$url" || \
199
+ wget -q --show-progress -c -O "$target_dir/$filename" "$url" || \
200
+ log_error "Download falhou: $filename"
201
+ else
202
+ aria2c -c -x 4 -s 4 --console-log-level=warn --dir="$target_dir" "$url" || \
203
+ (cd "$target_dir" && wget -q --show-progress -c "$url") || \
204
+ log_error "Download falhou: $url"
205
+ fi
206
+ elif [ -n "$filename" ]; then
207
+ wget -q --show-progress -c -O "$target_dir/$filename" "$url" || \
208
+ log_error "Download falhou: $filename"
209
+ else
210
+ (cd "$target_dir" && wget -q --show-progress -c "$url") || \
211
+ log_error "Download falhou: $url"
212
+ fi
213
+ }
214
+
215
+ # Processar downloads
216
+ process_downloads() {
217
+ for entry in "${DOWNLOAD_FILES[@]}"; do
218
+ IFS='|' read -r url type filename <<< "$entry"
219
+
220
+ # Criar diretório
221
+ local target_dir="$MODELS_DIR/$type"
222
+ mkdir -p "$target_dir"
223
+
224
+ # Baixar arquivo
225
+ if [[ "$url" == mega://* ]]; then
226
+ download_mega "$url" "$target_dir"
227
+ elif [[ "$url" == *.huggingface.co/* ]]; then
228
+ local hf_path="${url#*huggingface.co/}"
229
+ download_hf "$hf_path" "$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
+ python -m 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 Setup"
257
+ log_info "========================================="
258
+
259
+ # 1. Instalar dependências
260
+ log_info "[1/6] Instalando dependências do sistema..."
261
+
262
+ apt-get update -qq
263
+ apt-get install -y -qq python3-venv aria2 megatools git wget curl 2>/dev/null
264
+
265
+ log_success "Dependências do sistema instaladas"
266
+
267
+ log_info "[2/6] Preparando ambiente virtual..."
268
+
269
+ if [ ! -d "$VENV_DIR/bin" ]; then
270
+ python3 -m venv "$VENV_DIR"
271
+ log_success "Ambiente virtual criado em $VENV_DIR"
272
+ else
273
+ log_info "Ambiente virtual já existe em $VENV_DIR"
274
+ fi
275
+
276
+ . "$VENV_DIR/bin/activate"
277
+
278
+ python -m pip install -U pip wheel setuptools -q
279
+ python -m pip install -U "huggingface_hub[cli,hf_transfer]" comfy-cli -q
280
+
281
+ log_success "Ambiente virtual pronto e comfy-cli instalado"
282
+
283
+ # 3. Instalar ComfyUI
284
+ log_info "[3/6] Instalando ComfyUI..."
285
+
286
+ if [ -f "$COMFY_DIR/main.py" ]; then
287
+ log_warn "ComfyUI já existe"
288
+ else
289
+ comfy --skip-prompt --workspace "$COMFY_DIR" install --fast-deps --nvidia --version "0.3.67"
290
+ fi
291
+
292
+ log_success "ComfyUI instalado"
293
+
294
+ # 4. Corrigir PyTorch para RTX 5090 se detectado
295
+ log_info "[4/6] Verificando GPU..."
296
+
297
+ GPU_INFO=$(nvidia-smi --query-gpu=name --format=csv,noheader 2>/dev/null || echo "")
298
+
299
+ if [[ "$GPU_INFO" == *"5090"* ]] || [[ "$GPU_INFO" == *"5080"* ]]; then
300
+ log_warn "RTX 5090/5080 detectada - instalando PyTorch nightly"
301
+ python -m pip install --force-reinstall --pre torch==2.8.0 torchvision==0.23.0 torchaudio==2.8.0 --index-url https://download.pytorch.org/whl/cu129
302
+ else
303
+ log_info "GPU: ${GPU_INFO:-Não detectada}"
304
+ fi
305
+
306
+ log_success "PyTorch configurado"
307
+
308
+ # 5. Baixar modelos
309
+ log_info "[5/6] Baixando modelos..."
310
+
311
+ process_downloads
312
+
313
+ log_success "Downloads processados"
314
+
315
+ # 6. Instalar custom nodes
316
+ log_info "[6/6] Instalando custom nodes..."
317
+
318
+ CN_DIR="$COMFY_DIR/custom_nodes"
319
+ mkdir -p "$CN_DIR"
320
+
321
+ for repo in "${CUSTOM_NODES[@]}"; do
322
+ node_name=$(basename "$repo")
323
+ clone_repo "$repo" "$CN_DIR/$node_name"
324
+ done
325
+
326
+ log_success "Custom nodes instalados"
327
+
328
+ # Verificar e iniciar
329
+ log_info "========================================="
330
+ log_success "Instalação concluída!"
331
+ log_info "Iniciando ComfyUI..."
332
+ log_info "URL: http://localhost:$COMFY_PORT"
333
+ log_info "========================================="
334
+
335
+ cd "$COMFY_DIR"
336
+ exec comfy --workspace "$COMFY_DIR" launch -- --listen "$COMFY_HOST" --preview-method latent2rgb --front-end-version Comfy-Org/ComfyUI_frontend@v1.28.8 --port "$COMFY_PORT"