adbrasi commited on
Commit
1e85b93
·
verified ·
1 Parent(s): 08d578f

Upload image_StudioM.sh

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