adbrasi commited on
Commit
7393a03
·
verified ·
1 Parent(s): a3b3a20

Upload ImageStudioAlternativo.sh

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