adbrasi commited on
Commit
338d069
·
verified ·
1 Parent(s): 8ce1798

Update setup_comfy_wan222.sh

Browse files
Files changed (1) hide show
  1. setup_comfy_wan222.sh +26 -56
setup_comfy_wan222.sh CHANGED
@@ -26,6 +26,7 @@ MODELS_DIR="$COMFY_DIR/models"
26
  COMFY_HOST="${COMFY_HOST:-0.0.0.0}"
27
  COMFY_PORT="${COMFY_PORT:-8818}"
28
  CIVITAI_TOKEN="${CIVITAI_TOKEN:-4fcb2834969399006a736ee402b061e5}"
 
29
 
30
  # Configurações de performance
31
  export MAX_JOBS=32
@@ -89,7 +90,7 @@ add_civitai_token() {
89
  fi
90
  }
91
 
92
- # Download HuggingFace usando novo comando hf
93
  download_hf() {
94
  local repo="$1"
95
  local file_path="$2"
@@ -111,53 +112,27 @@ download_hf() {
111
 
112
  log_info "Baixando de HF: $filename"
113
 
114
- # Criar diretório temporário para download
115
- local temp_dir=$(mktemp -d)
116
-
117
- # Usar novo comando hf com HF Transfer habilitado
118
- if HF_HUB_ENABLE_HF_TRANSFER=1 hf download "$repo" "$file_path" \
119
- --local-dir "$temp_dir" \
120
  --local-dir-use-symlinks False \
121
  --resume-download 2>/dev/null; then
122
 
123
- # Encontrar o arquivo baixado (pode estar em subdiretório)
124
- local downloaded_file=$(find "$temp_dir" -name "$filename" -type f 2>/dev/null | head -1)
125
-
126
- if [ -z "$downloaded_file" ]; then
127
- # Tentar encontrar qualquer arquivo .safetensors
128
- downloaded_file=$(find "$temp_dir" -name "*.safetensors" -type f 2>/dev/null | head -1)
129
- fi
130
-
131
- if [ -n "$downloaded_file" ]; then
132
- mv "$downloaded_file" "$target_file"
133
- rm -rf "$temp_dir"
134
  log_success "Download concluído: $filename"
135
  return 0
136
  fi
137
- fi
138
-
139
- # Fallback para huggingface-cli se hf falhar
140
- if huggingface-cli download "$repo" "$file_path" \
141
- --local-dir "$temp_dir" \
142
- --local-dir-use-symlinks False \
143
- --resume-download 2>/dev/null; then
144
-
145
- # Procurar arquivo baixado
146
- local downloaded_file=$(find "$temp_dir" -name "$filename" -type f 2>/dev/null | head -1)
147
-
148
- if [ -z "$downloaded_file" ]; then
149
- downloaded_file=$(find "$temp_dir" -name "*.safetensors" -type f 2>/dev/null | head -1)
150
- fi
151
 
152
- if [ -n "$downloaded_file" ]; then
 
 
153
  mv "$downloaded_file" "$target_file"
154
- rm -rf "$temp_dir"
155
- log_success "Download concluído (fallback): $filename"
156
  return 0
157
  fi
158
  fi
159
 
160
- rm -rf "$temp_dir"
161
  log_error "Falha ao baixar: $filename"
162
  return 1
163
  }
@@ -336,12 +311,21 @@ log_success "Dependências OK"
336
  log_info "[2/8] Preparando ferramentas Python..."
337
  python3 -m pip install --upgrade pip wheel setuptools -q
338
 
339
- # Instalar huggingface_hub com hf_transfer
340
- python3 -m pip install --upgrade "huggingface_hub[hf_transfer]>=0.26.0" comfy-cli -q
 
 
 
 
 
 
 
341
 
342
  # Verificar se hf está disponível
343
- if ! command_exists hf; then
344
- log_warn "Comando 'hf' não encontrado, usando huggingface-cli como fallback"
 
 
345
  fi
346
 
347
  log_success "Ferramentas instaladas"
@@ -405,26 +389,12 @@ log_info "[7/8] Instalando custom nodes..."
405
  CN_DIR="$COMFY_DIR/custom_nodes"
406
  mkdir -p "$CN_DIR"
407
 
408
- # Instalar nodes em paralelo mas com limite
409
- MAX_PARALLEL=4
410
- count=0
411
-
412
  for repo_url in "${CUSTOM_NODES[@]}"; do
413
  node_name=$(basename "$repo_url")
414
-
415
- # Executar em background
416
- (clone_or_update "$repo_url" "$CN_DIR/$node_name") &
417
-
418
- # Limitar número de processos paralelos
419
- ((count++))
420
- if [ $((count % MAX_PARALLEL)) -eq 0 ]; then
421
- wait # Aguardar batch atual terminar
422
- fi
423
  done
424
 
425
- # Aguardar últimos processos
426
- wait
427
-
428
  log_success "Custom nodes instalados"
429
 
430
  # [8] Verificação final
 
26
  COMFY_HOST="${COMFY_HOST:-0.0.0.0}"
27
  COMFY_PORT="${COMFY_PORT:-8818}"
28
  CIVITAI_TOKEN="${CIVITAI_TOKEN:-4fcb2834969399006a736ee402b061e5}"
29
+ HF_TOKEN="${HF_TOKEN:-}" # Token opcional do HuggingFace para login
30
 
31
  # Configurações de performance
32
  export MAX_JOBS=32
 
90
  fi
91
  }
92
 
93
+ # Download HuggingFace usando huggingface-cli com hf_transfer
94
  download_hf() {
95
  local repo="$1"
96
  local file_path="$2"
 
112
 
113
  log_info "Baixando de HF: $filename"
114
 
115
+ # Usar huggingface-cli com hf_transfer habilitado para velocidade máxima
116
+ if HF_HUB_ENABLE_HF_TRANSFER=1 huggingface-cli download "$repo" "$file_path" \
117
+ --local-dir "$target_dir" \
 
 
 
118
  --local-dir-use-symlinks False \
119
  --resume-download 2>/dev/null; then
120
 
121
+ # Verificar se arquivo foi baixado
122
+ if [ -f "$target_file" ]; then
 
 
 
 
 
 
 
 
 
123
  log_success "Download concluído: $filename"
124
  return 0
125
  fi
 
 
 
 
 
 
 
 
 
 
 
 
 
 
126
 
127
+ # Procurar arquivo em subdiretórios se não estiver no local esperado
128
+ local downloaded_file=$(find "$target_dir" -name "$filename" -type f 2>/dev/null | head -1)
129
+ if [ -n "$downloaded_file" ] && [ "$downloaded_file" != "$target_file" ]; then
130
  mv "$downloaded_file" "$target_file"
131
+ log_success "Download concluído e movido: $filename"
 
132
  return 0
133
  fi
134
  fi
135
 
 
136
  log_error "Falha ao baixar: $filename"
137
  return 1
138
  }
 
311
  log_info "[2/8] Preparando ferramentas Python..."
312
  python3 -m pip install --upgrade pip wheel setuptools -q
313
 
314
+ # Instalar huggingface_hub com CLI e hf_transfer para velocidade máxima
315
+ python3 -m pip install --upgrade "huggingface_hub[cli]>=0.26.0" hf_transfer comfy-cli -q
316
+
317
+ # Configurar token HF se disponível (opcional)
318
+ HF_TOKEN="${HF_TOKEN:-}"
319
+ if [ -n "$HF_TOKEN" ]; then
320
+ echo "$HF_TOKEN" | huggingface-cli login --token
321
+ log_success "Login HF configurado"
322
+ fi
323
 
324
  # Verificar se hf está disponível
325
+ if command_exists huggingface-cli; then
326
+ log_success "huggingface-cli disponível"
327
+ else
328
+ log_warn "huggingface-cli não encontrado"
329
  fi
330
 
331
  log_success "Ferramentas instaladas"
 
389
  CN_DIR="$COMFY_DIR/custom_nodes"
390
  mkdir -p "$CN_DIR"
391
 
392
+ # Instalar nodes sequencialmente para evitar travamentos
 
 
 
393
  for repo_url in "${CUSTOM_NODES[@]}"; do
394
  node_name=$(basename "$repo_url")
395
+ clone_or_update "$repo_url" "$CN_DIR/$node_name"
 
 
 
 
 
 
 
 
396
  done
397
 
 
 
 
398
  log_success "Custom nodes instalados"
399
 
400
  # [8] Verificação final