File size: 3,098 Bytes
114554e
48d83aa
 
114554e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48d83aa
114554e
 
 
48d83aa
114554e
 
 
 
 
 
 
 
 
 
 
 
 
 
48d83aa
114554e
 
 
 
48d83aa
 
114554e
 
 
 
 
 
 
 
 
48d83aa
 
 
114554e
48d83aa
114554e
 
 
 
 
 
 
 
 
 
 
48d83aa
114554e
 
 
 
 
 
 
 
 
 
 
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
#!/bin/bash
# Dataset-Prep v3 — Flux2 Dev Full setup
# Base deps + ComfyUI + Flux2-dev models
set -e

echo "=== Dataset-Prep v3: Flux2 Dev Full Setup ==="

# Run base setup first
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
if [ -f "$SCRIPT_DIR/setup_base.sh" ]; then
    bash "$SCRIPT_DIR/setup_base.sh"
else
    python3 -c "
from huggingface_hub import hf_hub_download
path = hf_hub_download('msrcam/ds-prep-backend', 'scripts/setup_base.sh', repo_type='dataset')
print(path)
" > /tmp/base_path.txt
    bash "$(cat /tmp/base_path.txt)"
fi

echo "Installing ComfyUI..."
if [ ! -d /workspace/ComfyUI ]; then
    cd /workspace
    git clone --depth 1 https://github.com/comfyanonymous/ComfyUI.git
    cd ComfyUI
    uv pip install --system -q -r requirements.txt 2>&1 | tail -3
    cd custom_nodes
    git clone --depth 1 https://github.com/city96/ComfyUI-GGUF.git 2>/dev/null || true
    if [ -d ComfyUI-GGUF ] && [ -f ComfyUI-GGUF/requirements.txt ]; then
        uv pip install --system -q -r ComfyUI-GGUF/requirements.txt 2>&1 | tail -3
    fi
    cd /workspace/ComfyUI
    mkdir -p models/unet models/clip models/vae
    echo "ComfyUI installed."
else
    echo "ComfyUI already installed."
fi

# Start ComfyUI
cd /workspace/ComfyUI
nohup python main.py --listen 0.0.0.0 --port 8188 --preview-method auto > /tmp/comfyui.log 2>&1 &
echo $! > /tmp/comfyui.pid
echo "ComfyUI starting on port 8188..."

# Login to HF
if [ -n "$HF_TOKEN" ]; then
    python3 -c "from huggingface_hub import login; login(token='$HF_TOKEN', add_to_git_credential=False)" 2>/dev/null || true
fi

# Download ALL models from msrcam/klein-fleet ONLY
echo "Downloading Flux2 models from msrcam/klein-fleet..."
python3 << 'PYEOF'
from huggingface_hub import hf_hub_download
import os

unet_dir = "/workspace/ComfyUI/models/unet"
clip_dir = "/workspace/ComfyUI/models/clip"
vae_dir  = "/workspace/ComfyUI/models/vae"

downloads = [
    # FLUX.2-dev UNET (~9.1GB fp8)
    ("msrcam/klein-fleet", "unet/bigLove_klein1_fp8.safetensors", unet_dir, "bigLove_klein1_fp8.safetensors"),
    # Qwen3 8B CLIP encoder (fp8, ~8.5GB)
    ("msrcam/klein-fleet", "clip/qwen3_8b_abliterated_v2-fp8mixed.safetensors", clip_dir, "qwen3_8b_abliterated_v2-fp8mixed.safetensors"),
    # Flux2 VAE (~0.3GB)
    ("msrcam/klein-fleet", "vae/flux2-vae.safetensors", vae_dir, "flux2-vae.safetensors"),
]

for repo, hf_file, dest_dir, local_name in downloads:
    dest = os.path.join(dest_dir, local_name)
    if os.path.exists(dest) and os.path.getsize(dest) > 0:
        print(f"  {local_name} exists, skipping")
        continue
    print(f"  Downloading {local_name} from {repo}...")
    try:
        os.makedirs(dest_dir, exist_ok=True)
        path = hf_hub_download(repo_id=repo, filename=hf_file, local_dir=dest_dir)
        # Flatten if hf put it in a subfolder
        if os.path.exists(path) and path != dest:
            os.rename(path, dest)
        print(f"  OK: {local_name}")
    except Exception as e:
        print(f"  FAILED: {local_name}: {e}")

print("Model downloads complete.")
PYEOF

echo "=== Flux2 Dev Full setup complete ==="