adbrasi commited on
Commit
8ded0be
·
verified ·
1 Parent(s): 75c9a38

Update wanForProduction.sh

Browse files
Files changed (1) hide show
  1. wanForProduction.sh +76 -19
wanForProduction.sh CHANGED
@@ -37,7 +37,15 @@ export PYTORCH_CUDA_ALLOC_CONF="expandable_segments:True"
37
 
38
  # Lista de downloads (formato: URL|TIPO|NOME_OPCIONAL)
39
  DOWNLOAD_FILES=(
40
- # Wan 2.2 principais (HF)
 
 
 
 
 
 
 
 
41
  "mega://https://mega.nz/file/QFxREJpZ#0dge8TyRgb52lMFKdsk-Ac-rwcoG49hvBHvaqNsZkuk|loras|"
42
  "mega://https://mega.nz/file/lIhQETjT#nKlQ01Euw6fUxo8P5bfwlQrxAkWEedXQQOqHv5u4yrM|loras|"
43
  "mega://https://mega.nz/file/UIAESACY#Qlei1Pj5Nwno3Sz-wsTekvD-YgCkN1A5QbFKoRHXG9E|loras|"
@@ -51,15 +59,6 @@ DOWNLOAD_FILES=(
51
  "mega://https://mega.nz/file/hZhhhCQS#4je0Im2g1kEvTCuPotjVWkA-g6XICkqMb-mKxMt6R3Y|loras|"
52
  "mega://https://mega.nz/file/qdQwAJSC#rPY2Hg4x-_RbHiHUBFW-YU8xZUqPpq5Gpl1uPFiJvW4|upscale_models|"
53
  "mega://https://mega.nz/file/KIh2marA#CehVNXxQhGfp1bqUL0K1YPWNqrCUoLPCZGq2W6XqmWo|upscale_models|"
54
- "https://huggingface.co/Kijai/WanVideo_comfy_fp8_scaled/resolve/main/I2V/Wan2_2-I2V-A14B-LOW_fp8_e4m3fn_scaled_KJ.safetensors|diffusion_models|"
55
- "https://huggingface.co/Kijai/WanVideo_comfy_fp8_scaled/resolve/main/I2V/Wan2_2-I2V-A14B-HIGH_fp8_e4m3fn_scaled_KJ.safetensors|diffusion_models|"
56
- "https://huggingface.co/Kijai/WanVideo_comfy/resolve/main/LoRAs/Wan22-Lightning/Wan22_A14B_T2V_HIGH_Lightning_4steps_lora_250928_rank128_fp16.safetensors|loras|"
57
- "https://huggingface.co/Kijai/WanVideo_comfy/resolve/main/LoRAs/Wan22-Lightning/Wan22_A14B_T2V_LOW_Lightning_4steps_lora_250928_rank64_fp16.safetensors|loras|"
58
- "https://huggingface.co/Kijai/WanVideo_comfy/resolve/main/LoRAs/AniSora/Wan2_2_I2V_AniSora_3_2_HIGH_rank_64_fp16.safetensors|loras|"
59
- "https://huggingface.co/Kijai/WanVideo_comfy/resolve/main/Wan2_1_VAE_bf16.safetensors|vae|"
60
- "https://huggingface.co/Kijai/WanVideo_comfy/resolve/main/open-clip-xlm-roberta-large-vit-huge-14_visual_fp16.safetensors|clip_vision|"
61
- "https://huggingface.co/Kijai/WanVideo_comfy/resolve/main/umt5-xxl-enc-bf16.safetensors|text_encoders|"
62
- "https://huggingface.co/ABDALLALSWAITI/Upscalers/resolve/main/general/Swin2SR_ClassicalSR_X2_64.pth|upscale_models|"
63
  )
64
 
65
  # Custom nodes (do CODE2)
@@ -95,9 +94,10 @@ download_hf() {
95
  local hf_path="$1"
96
  local target_dir="$2"
97
  local filename="$3"
 
98
 
99
  if [[ -z "$filename" ]]; then
100
- filename="$(basename "$hf_path")"
101
  fi
102
 
103
  mkdir -p "$target_dir"
@@ -112,28 +112,54 @@ download_hf() {
112
 
113
  local owner="${hf_path%%/*}"
114
  local remainder="${hf_path#*/}"
115
- local repo="${remainder%%/*}"
116
- local file_path="${remainder#*/}"
117
-
118
- if [[ -z "$owner" || -z "$repo" || -z "$file_path" || "$file_path" == "$remainder" ]]; then
119
  log_error "Caminho HuggingFace inválido: $hf_path"
120
  return 1
121
  fi
122
 
123
- local repo_id="$owner/$repo"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
124
  local attempt success temp_dir
125
  for attempt in 1 2 3; do
126
  temp_dir="$(mktemp -d)"
127
  success=false
128
 
129
  if command -v hf >/dev/null 2>&1; then
130
- if HF_HUB_ENABLE_HF_TRANSFER=1 hf download "$repo_id" "$file_path" --local-dir "$temp_dir" --quiet; then
 
 
 
 
 
 
 
 
131
  success=true
132
  fi
133
  fi
134
 
135
  if [[ "$success" == false ]]; then
136
- local direct_url="https://huggingface.co/${repo_id}/resolve/main/${file_path}"
 
137
  if command -v aria2c >/dev/null 2>&1; then
138
  local aria_cmd=(aria2c -c -s 16 -x 16 -k 1M --console-log-level=warn --summary-interval=10 --dir "$temp_dir" --out "$filename")
139
  if [[ -n "$HF_TOKEN" ]]; then
@@ -294,6 +320,37 @@ process_downloads() {
294
  if ! download_hf "$hf_path" "$target_dir" "$filename"; then
295
  ((failed++))
296
  fi
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
297
  else
298
  if ! download_file "$raw_url" "$target_dir" "$filename"; then
299
  ((failed++))
@@ -436,4 +493,4 @@ log_info "Iniciando ComfyUI em http://${COMFY_HOST}:${COMFY_PORT}"
436
  log_info "========================================="
437
 
438
  cd "$COMFY_DIR"
439
- exec comfy launch -- ${SAGE_FLAG:+$SAGE_FLAG} --listen "$COMFY_HOST" --port "$COMFY_PORT"
 
37
 
38
  # Lista de downloads (formato: URL|TIPO|NOME_OPCIONAL)
39
  DOWNLOAD_FILES=(
40
+ "https://huggingface.co/Kijai/WanVideo_comfy_fp8_scaled/resolve/main/I2V/Wan2_2-I2V-A14B-LOW_fp8_e4m3fn_scaled_KJ.safetensors|diffusion_models|"
41
+ "https://huggingface.co/Kijai/WanVideo_comfy_fp8_scaled/resolve/main/I2V/Wan2_2-I2V-A14B-HIGH_fp8_e4m3fn_scaled_KJ.safetensors|diffusion_models|"
42
+ "https://huggingface.co/Kijai/WanVideo_comfy/resolve/main/LoRAs/Wan22-Lightning/Wan22_A14B_T2V_HIGH_Lightning_4steps_lora_250928_rank128_fp16.safetensors|loras|"
43
+ "https://huggingface.co/Kijai/WanVideo_comfy/resolve/main/LoRAs/Wan22-Lightning/Wan22_A14B_T2V_LOW_Lightning_4steps_lora_250928_rank64_fp16.safetensors|loras|"
44
+ "https://huggingface.co/Kijai/WanVideo_comfy/resolve/main/LoRAs/AniSora/Wan2_2_I2V_AniSora_3_2_HIGH_rank_64_fp16.safetensors|loras|"
45
+ "https://huggingface.co/Kijai/WanVideo_comfy/resolve/main/Wan2_1_VAE_bf16.safetensors|vae|"
46
+ "https://huggingface.co/Kijai/WanVideo_comfy/resolve/main/open-clip-xlm-roberta-large-vit-huge-14_visual_fp16.safetensors|clip_vision|"
47
+ "https://huggingface.co/Kijai/WanVideo_comfy/resolve/main/umt5-xxl-enc-bf16.safetensors|text_encoders|"
48
+ "https://huggingface.co/ABDALLALSWAITI/Upscalers/resolve/main/general/Swin2SR_ClassicalSR_X2_64.pth|upscale_models|"
49
  "mega://https://mega.nz/file/QFxREJpZ#0dge8TyRgb52lMFKdsk-Ac-rwcoG49hvBHvaqNsZkuk|loras|"
50
  "mega://https://mega.nz/file/lIhQETjT#nKlQ01Euw6fUxo8P5bfwlQrxAkWEedXQQOqHv5u4yrM|loras|"
51
  "mega://https://mega.nz/file/UIAESACY#Qlei1Pj5Nwno3Sz-wsTekvD-YgCkN1A5QbFKoRHXG9E|loras|"
 
59
  "mega://https://mega.nz/file/hZhhhCQS#4je0Im2g1kEvTCuPotjVWkA-g6XICkqMb-mKxMt6R3Y|loras|"
60
  "mega://https://mega.nz/file/qdQwAJSC#rPY2Hg4x-_RbHiHUBFW-YU8xZUqPpq5Gpl1uPFiJvW4|upscale_models|"
61
  "mega://https://mega.nz/file/KIh2marA#CehVNXxQhGfp1bqUL0K1YPWNqrCUoLPCZGq2W6XqmWo|upscale_models|"
 
 
 
 
 
 
 
 
 
62
  )
63
 
64
  # Custom nodes (do CODE2)
 
94
  local hf_path="$1"
95
  local target_dir="$2"
96
  local filename="$3"
97
+ local revision="${4:-}"
98
 
99
  if [[ -z "$filename" ]]; then
100
+ filename="$(basename "${hf_path%%\?*}")"
101
  fi
102
 
103
  mkdir -p "$target_dir"
 
112
 
113
  local owner="${hf_path%%/*}"
114
  local remainder="${hf_path#*/}"
115
+ if [[ "$owner" == "$hf_path" ]]; then
 
 
 
116
  log_error "Caminho HuggingFace inválido: $hf_path"
117
  return 1
118
  fi
119
 
120
+ local repo_segment="${remainder%%/*}"
121
+ if [[ "$repo_segment" == "$remainder" ]]; then
122
+ log_error "Arquivo não especificado no caminho: $hf_path"
123
+ return 1
124
+ fi
125
+
126
+ remainder="${remainder#*/}"
127
+ if [[ -z "$remainder" ]]; then
128
+ log_error "Arquivo não especificado no caminho: $hf_path"
129
+ return 1
130
+ fi
131
+
132
+ if [[ "$repo_segment" == *@* ]]; then
133
+ if [[ -z "$revision" ]]; then
134
+ revision="${repo_segment#*@}"
135
+ fi
136
+ repo_segment="${repo_segment%@*}"
137
+ fi
138
+
139
+ local repo_id="$owner/$repo_segment"
140
+ local file_path="$remainder"
141
  local attempt success temp_dir
142
  for attempt in 1 2 3; do
143
  temp_dir="$(mktemp -d)"
144
  success=false
145
 
146
  if command -v hf >/dev/null 2>&1; then
147
+ local hf_cmd=(hf download "$repo_id" "$file_path")
148
+ if [[ -n "$revision" ]]; then
149
+ hf_cmd+=(--revision "$revision")
150
+ fi
151
+ hf_cmd+=(--local-dir "$temp_dir" --quiet)
152
+ if [[ -n "$HF_TOKEN" ]]; then
153
+ hf_cmd+=(--token "$HF_TOKEN")
154
+ fi
155
+ if HF_HUB_ENABLE_HF_TRANSFER=1 "${hf_cmd[@]}"; then
156
  success=true
157
  fi
158
  fi
159
 
160
  if [[ "$success" == false ]]; then
161
+ local fallback_revision="${revision:-main}"
162
+ local direct_url="https://huggingface.co/${repo_id}/resolve/${fallback_revision}/${file_path}"
163
  if command -v aria2c >/dev/null 2>&1; then
164
  local aria_cmd=(aria2c -c -s 16 -x 16 -k 1M --console-log-level=warn --summary-interval=10 --dir "$temp_dir" --out "$filename")
165
  if [[ -n "$HF_TOKEN" ]]; then
 
320
  if ! download_hf "$hf_path" "$target_dir" "$filename"; then
321
  ((failed++))
322
  fi
323
+ elif [[ "$raw_url" == https://huggingface.co/* ]]; then
324
+ local sanitized_url="${raw_url%%\?*}"
325
+ local hf_relative="${sanitized_url#https://huggingface.co/}"
326
+ IFS='/' read -ra hf_parts <<< "$hf_relative"
327
+ if (( ${#hf_parts[@]} >= 4 )) && [[ "${hf_parts[2]}" == "resolve" || "${hf_parts[2]}" == "blob" || "${hf_parts[2]}" == "raw" ]]; then
328
+ local hf_owner="${hf_parts[0]}"
329
+ local hf_repo="${hf_parts[1]}"
330
+ local hf_revision="${hf_parts[3]}"
331
+ local start_index=4
332
+ local hf_file_path=""
333
+ for ((i=start_index; i<${#hf_parts[@]}; i++)); do
334
+ if [[ -n "$hf_file_path" ]]; then
335
+ hf_file_path+='/'
336
+ fi
337
+ hf_file_path+="${hf_parts[i]}"
338
+ done
339
+ if [[ -n "$hf_file_path" ]]; then
340
+ local hf_path_combined="${hf_owner}/${hf_repo}/${hf_file_path}"
341
+ if ! download_hf "$hf_path_combined" "$target_dir" "$filename" "$hf_revision"; then
342
+ ((failed++))
343
+ fi
344
+ else
345
+ if ! download_file "$raw_url" "$target_dir" "$filename"; then
346
+ ((failed++))
347
+ fi
348
+ fi
349
+ else
350
+ if ! download_file "$raw_url" "$target_dir" "$filename"; then
351
+ ((failed++))
352
+ fi
353
+ fi
354
  else
355
  if ! download_file "$raw_url" "$target_dir" "$filename"; then
356
  ((failed++))
 
493
  log_info "========================================="
494
 
495
  cd "$COMFY_DIR"
496
+ exec comfy launch -- ${SAGE_FLAG:+$SAGE_FLAG} --listen "$COMFY_HOST" --port "$COMFY_PORT"