Fix line endings: setup_flux2_full.sh
Browse files- scripts/setup_flux2_full.sh +88 -108
scripts/setup_flux2_full.sh
CHANGED
|
@@ -1,108 +1,88 @@
|
|
| 1 |
-
#!/bin/bash
|
| 2 |
-
# Dataset-Prep v3
|
| 3 |
-
#
|
| 4 |
-
set -e
|
| 5 |
-
|
| 6 |
-
echo "=== Dataset-Prep v3: Flux2 Dev Full Setup ==="
|
| 7 |
-
|
| 8 |
-
# Run base setup first
|
| 9 |
-
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
| 10 |
-
if [ -f "$SCRIPT_DIR/setup_base.sh" ]; then
|
| 11 |
-
bash "$SCRIPT_DIR/setup_base.sh"
|
| 12 |
-
else
|
| 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 |
-
echo
|
| 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 |
-
try:
|
| 90 |
-
os.makedirs(dl["dest"], exist_ok=True)
|
| 91 |
-
downloaded = hf_hub_download(
|
| 92 |
-
repo_id=dl["repo"],
|
| 93 |
-
filename=dl["hf_file"],
|
| 94 |
-
local_dir=dl["dest"],
|
| 95 |
-
local_dir_use_symlinks=False,
|
| 96 |
-
)
|
| 97 |
-
# Rename if needed
|
| 98 |
-
actual = os.path.join(dl["dest"], dl["hf_file"])
|
| 99 |
-
if os.path.exists(actual) and actual != dest_path:
|
| 100 |
-
os.rename(actual, dest_path)
|
| 101 |
-
print(f" OK: {dl['file']}")
|
| 102 |
-
except Exception as e:
|
| 103 |
-
print(f" WARNING: Failed to download {dl['file']}: {e}")
|
| 104 |
-
|
| 105 |
-
print("Model downloads complete.")
|
| 106 |
-
PYEOF
|
| 107 |
-
|
| 108 |
-
echo "=== Flux2 Dev Full setup complete ==="
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# Dataset-Prep v3 — Flux2 Dev Full setup
|
| 3 |
+
# Base deps + ComfyUI + Flux2-dev models (80GB+ VRAM needed)
|
| 4 |
+
set -e
|
| 5 |
+
|
| 6 |
+
echo "=== Dataset-Prep v3: Flux2 Dev Full Setup ==="
|
| 7 |
+
|
| 8 |
+
# Run base setup first
|
| 9 |
+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
| 10 |
+
if [ -f "$SCRIPT_DIR/setup_base.sh" ]; then
|
| 11 |
+
bash "$SCRIPT_DIR/setup_base.sh"
|
| 12 |
+
else
|
| 13 |
+
python3 -c "
|
| 14 |
+
from huggingface_hub import hf_hub_download
|
| 15 |
+
path = hf_hub_download('msrcam/ds-prep-backend', 'scripts/setup_base.sh', repo_type='dataset')
|
| 16 |
+
print(path)
|
| 17 |
+
" > /tmp/base_path.txt
|
| 18 |
+
bash "$(cat /tmp/base_path.txt)"
|
| 19 |
+
fi
|
| 20 |
+
|
| 21 |
+
echo "Installing ComfyUI..."
|
| 22 |
+
if [ ! -d /workspace/ComfyUI ]; then
|
| 23 |
+
cd /workspace
|
| 24 |
+
git clone --depth 1 https://github.com/comfyanonymous/ComfyUI.git
|
| 25 |
+
cd ComfyUI
|
| 26 |
+
uv pip install --system -q -r requirements.txt > /dev/null 2>&1
|
| 27 |
+
cd custom_nodes
|
| 28 |
+
git clone --depth 1 https://github.com/city96/ComfyUI-GGUF.git 2>/dev/null || true
|
| 29 |
+
if [ -d ComfyUI-GGUF ] && [ -f ComfyUI-GGUF/requirements.txt ]; then
|
| 30 |
+
uv pip install --system -q -r ComfyUI-GGUF/requirements.txt > /dev/null 2>&1
|
| 31 |
+
fi
|
| 32 |
+
cd /workspace/ComfyUI
|
| 33 |
+
mkdir -p models/unet models/clip models/vae
|
| 34 |
+
echo "ComfyUI installed."
|
| 35 |
+
else
|
| 36 |
+
echo "ComfyUI already installed."
|
| 37 |
+
fi
|
| 38 |
+
|
| 39 |
+
# Start ComfyUI
|
| 40 |
+
cd /workspace/ComfyUI
|
| 41 |
+
nohup python main.py --listen 0.0.0.0 --port 8188 --preview-method auto > /tmp/comfyui.log 2>&1 &
|
| 42 |
+
echo $! > /tmp/comfyui.pid
|
| 43 |
+
echo "ComfyUI starting on port 8188..."
|
| 44 |
+
|
| 45 |
+
# Login to HF for gated repos (FLUX.2-dev is gated)
|
| 46 |
+
if [ -n "$HF_TOKEN" ]; then
|
| 47 |
+
python3 -c "from huggingface_hub import login; login(token='$HF_TOKEN', add_to_git_credential=False)" 2>/dev/null || true
|
| 48 |
+
fi
|
| 49 |
+
|
| 50 |
+
# Download Flux2 models
|
| 51 |
+
echo "Downloading Flux2 models..."
|
| 52 |
+
python3 << 'PYEOF'
|
| 53 |
+
from huggingface_hub import hf_hub_download
|
| 54 |
+
import os
|
| 55 |
+
|
| 56 |
+
unet_dir = "/workspace/ComfyUI/models/unet"
|
| 57 |
+
clip_dir = "/workspace/ComfyUI/models/clip"
|
| 58 |
+
vae_dir = "/workspace/ComfyUI/models/vae"
|
| 59 |
+
|
| 60 |
+
downloads = [
|
| 61 |
+
# FLUX.2-dev UNET (gated, ~64.5GB)
|
| 62 |
+
("black-forest-labs/FLUX.2-dev", "flux2-dev.safetensors", unet_dir, "flux2-dev.safetensors"),
|
| 63 |
+
# Qwen3 8B CLIP encoder (fp8, ~8.5GB) — from msrcam/klein-fleet
|
| 64 |
+
("msrcam/klein-fleet", "clip/qwen3_8b_abliterated_v2-fp8mixed.safetensors", clip_dir, "qwen3_8b_abliterated_v2-fp8mixed.safetensors"),
|
| 65 |
+
# Flux2 VAE (~0.3GB) — from msrcam/klein-fleet
|
| 66 |
+
("msrcam/klein-fleet", "vae/flux2-vae.safetensors", vae_dir, "flux2-vae.safetensors"),
|
| 67 |
+
]
|
| 68 |
+
|
| 69 |
+
for repo, hf_file, dest_dir, local_name in downloads:
|
| 70 |
+
dest = os.path.join(dest_dir, local_name)
|
| 71 |
+
if os.path.exists(dest) and os.path.getsize(dest) > 0:
|
| 72 |
+
print(f" {local_name} exists, skipping")
|
| 73 |
+
continue
|
| 74 |
+
print(f" Downloading {local_name} from {repo}...")
|
| 75 |
+
try:
|
| 76 |
+
os.makedirs(dest_dir, exist_ok=True)
|
| 77 |
+
path = hf_hub_download(repo_id=repo, filename=hf_file, local_dir=dest_dir, local_dir_use_symlinks=False)
|
| 78 |
+
# Flatten if hf put it in a subfolder
|
| 79 |
+
if os.path.exists(path) and path != dest:
|
| 80 |
+
os.rename(path, dest)
|
| 81 |
+
print(f" OK: {local_name}")
|
| 82 |
+
except Exception as e:
|
| 83 |
+
print(f" FAILED: {local_name}: {e}")
|
| 84 |
+
|
| 85 |
+
print("Model downloads complete.")
|
| 86 |
+
PYEOF
|
| 87 |
+
|
| 88 |
+
echo "=== Flux2 Dev Full setup complete ==="
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|