File size: 4,175 Bytes
18e723a
 
 
 
 
 
 
 
 
b3eec7f
18e723a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b3eec7f
 
 
 
 
 
 
18e723a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/bin/bash
set -euo pipefail

# =============================================
# ComfyUI models on persistent /workspace + symlink /ComfyUI/models
# Adds: FLUX ControlNet Union (InstantX)
# =============================================

# Персистентный путь под модели
WORK_PATH="/workspace/runpod-slim/ComfyUI"
STORAGE_MODELS="$WORK_PATH/models"

# Подпапки моделей
CLIP_DIR="$STORAGE_MODELS/clip"
DIFF_DIR="$STORAGE_MODELS/diffusion_models"   # Flux checkpoint
VAE_DIR="$STORAGE_MODELS/vae"
LORA_DIR="$STORAGE_MODELS/loras"
CN_DIR="$STORAGE_MODELS/controlnet"           # <-- ControlNet сюда

# Создаём структуру
mkdir -p "$CLIP_DIR" "$DIFF_DIR" "$VAE_DIR" "$LORA_DIR" "$CN_DIR"

echo ">>> Using persistent storage: $STORAGE_MODELS"

# Симлинк /ComfyUI/models -> /workspace/comfyui/models
# if [ ! -L /ComfyUI/models ]; then
#   echo ">>> Linking /ComfyUI/models -> $STORAGE_MODELS"
#   rm -rf /ComfyUI/models
#   ln -s "$STORAGE_MODELS" /ComfyUI/models
# else
#   echo ">>> Symlink /ComfyUI/models already exists"
# fi

# --- TE-only encoders (FLAN-T5-XXL FP16 & ViT-L TE-only) ---
echo ">>> Downloading TE-only encoders -> $CLIP_DIR"
curl -fL -C - --retry 5 --retry-all-errors \
  "https://huggingface.co/easygoing0114/flan-t5-xxl-fused/resolve/main/flan_t5_xxl_TE-only_FP16.safetensors" \
  -o "$CLIP_DIR/flan_t5_xxl_TE-only_FP16.safetensors"

curl -fL -C - --retry 5 --retry-all-errors \
  "https://huggingface.co/zer0int/CLIP-GmP-ViT-L-14/resolve/main/ViT-L-14-TEXT-detail-improved-hiT-GmP-TE-only-HF.safetensors" \
  -o "$CLIP_DIR/vit_l_te_only.safetensors"

# --- VAE (официальный через HF_TOKEN или публичный фолбэк) ---
echo ">>> Downloading VAE -> $VAE_DIR"
if [[ -n "${HF_TOKEN:-}" ]]; then
  echo ">>> HF_TOKEN present; trying official BFL VAE"
  if curl -fL -C - --retry 5 --retry-all-errors \
       -H "Authorization: Bearer $HF_TOKEN" \
       "https://huggingface.co/black-forest-labs/FLUX.1-dev/resolve/main/ae.safetensors" \
       -o "$VAE_DIR/ae.safetensors"; then
    echo ">>> Official VAE downloaded"
  else
    echo ">>> Official VAE failed; using public mirror"
    curl -fL -C - --retry 5 --retry-all-errors \
      "https://huggingface.co/ffxvs/vae-flux/resolve/main/ae.safetensors" \
      -o "$VAE_DIR/ae.safetensors"
  fi
else
  echo ">>> No HF_TOKEN; using public mirror VAE"
  curl -fL -C - --retry 5 --retry-all-errors \
    "https://huggingface.co/ffxvs/vae-flux/resolve/main/ae.safetensors" \
    -o "$VAE_DIR/ae.safetensors"
fi

# --- Flux1-dev checkpoint (Comfy-Org, public) ---
echo ">>> Downloading flux1-dev checkpoint -> $DIFF_DIR"
curl -fL -C - --retry 5 --retry-all-errors \
  "https://huggingface.co/Comfy-Org/flux1-dev/resolve/main/flux1-dev.safetensors" \
  -o "$DIFF_DIR/flux1-dev.safetensors"

# --- ControlNet Union for FLUX.1-dev (InstantX) ---
# Файлы: diffusion_pytorch_model.safetensors (~6.6 GB) + config.json
echo ">>> Downloading FLUX ControlNet Union -> $CN_DIR"
curl -fL -C - --retry 5 --retry-all-errors \
  "https://huggingface.co/InstantX/FLUX.1-dev-Controlnet-Union/resolve/main/diffusion_pytorch_model.safetensors" \
  -o "$CN_DIR/flux1-dev-controlnet-union.safetensors"

curl -fL -C - --retry 5 --retry-all-errors \
  "https://huggingface.co/InstantX/FLUX.1-dev-Controlnet-Union/resolve/main/config.json" \
  -o "$CN_DIR/flux1-dev-controlnet-union.json"

# --- LoRAs (public) ---
echo ">>> Downloading LoRAs -> $LORA_DIR"
for f in Ernie_LoRA_FLUX Ostin_LoRA_FLUX Sheep_LoRA_FLUX; do
  curl -fL -C - --retry 5 --retry-all-errors \
    "https://huggingface.co/playrix/loras/resolve/main/${f}.safetensors" \
    -o "$LORA_DIR/${f}.safetensors"
done

echo ">>> DONE. Models stored under $STORAGE_MODELS and visible via /ComfyUI/models"
echo ">>> ComfyUI: Reload Models."
echo ">>> Load Diffusion:   models/diffusion_models/flux1-dev.safetensors"
echo ">>> Load TE-only:     models/clip/flan_t5_xxl_TE-only_FP16.safetensors + models/clip/vit_l_te_only.safetensors"
echo ">>> Load VAE:         models/vae/ae.safetensors"
echo ">>> Load ControlNet:  models/controlnet/flux1-dev-controlnet-union.safetensors"