adbrasi commited on
Commit
9c71aad
·
verified ·
1 Parent(s): f6a7dc8

Upload ImageStudioArrakis.sh

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