adbrasi commited on
Commit
84ddefc
·
verified ·
1 Parent(s): 358187e

Upload image_Studio2.sh

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