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

Upload ImageStudioArrakis2.sh

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