msrcam commited on
Commit
114554e
·
verified ·
1 Parent(s): d07571c

Fix line endings: setup_flux2_full.sh

Browse files
Files changed (1) hide show
  1. scripts/setup_flux2_full.sh +88 -108
scripts/setup_flux2_full.sh CHANGED
@@ -1,108 +1,88 @@
1
- #!/bin/bash
2
- # Dataset-Prep v3 Flux2 Dev Full setup
3
- # Includes ALL 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
- # Download and run base setup from HF
14
- python3 -c "
15
- from huggingface_hub import hf_hub_download
16
- path = hf_hub_download('msrcam/ds-prep-backend', 'scripts/setup_base.sh', repo_type='dataset')
17
- print(path)
18
- " > /tmp/base_path.txt
19
- bash "$(cat /tmp/base_path.txt)"
20
- fi
21
-
22
- echo "Installing ComfyUI..."
23
- if [ ! -d /workspace/ComfyUI ]; then
24
- cd /workspace
25
- git clone --depth 1 https://github.com/comfyanonymous/ComfyUI.git
26
- cd ComfyUI
27
- uv pip install --system -q -r requirements.txt > /dev/null 2>&1
28
- cd custom_nodes
29
- git clone --depth 1 https://github.com/city96/ComfyUI-GGUF.git 2>/dev/null || true
30
- if [ -d ComfyUI-GGUF ] && [ -f ComfyUI-GGUF/requirements.txt ]; then
31
- uv pip install --system -q -r ComfyUI-GGUF/requirements.txt > /dev/null 2>&1
32
- fi
33
- cd /workspace/ComfyUI
34
- mkdir -p models/unet models/clip models/vae
35
- echo "ComfyUI installed."
36
- else
37
- echo "ComfyUI already installed."
38
- fi
39
-
40
- # Start ComfyUI
41
- cd /workspace/ComfyUI
42
- nohup python main.py --listen 0.0.0.0 --port 8188 --preview-method auto > /tmp/comfyui.log 2>&1 &
43
- echo $! > /tmp/comfyui.pid
44
- echo "ComfyUI starting on port 8188..."
45
-
46
- # Login to HF for gated repos
47
- if [ -n "$HF_TOKEN" ]; then
48
- python3 -c "from huggingface_hub import login; login(token='$HF_TOKEN', add_to_git_credential=False)" 2>/dev/null || true
49
- fi
50
-
51
- # Download Flux2 models
52
- echo "Downloading Flux2 models (this takes a while)..."
53
- python3 << 'PYEOF'
54
- from huggingface_hub import hf_hub_download
55
- import os
56
-
57
- models_dir = "/workspace/ComfyUI/models"
58
-
59
- downloads = [
60
- # UNET — flux2-dev bf16 (~64.5GB)
61
- {
62
- "repo": "black-forest-labs/FLUX.2-dev",
63
- "file": "flux2-dev.safetensors",
64
- "dest": f"{models_dir}/unet",
65
- "hf_file": "flux1-dev.safetensors",
66
- },
67
- # VAE
68
- {
69
- "repo": "msrcam/ds-prep-models",
70
- "file": "flux2-vae.safetensors",
71
- "dest": f"{models_dir}/vae",
72
- "hf_file": "flux2-vae.safetensors",
73
- },
74
- # CLIP Qwen3 8B abliterated fp8
75
- {
76
- "repo": "msrcam/ds-prep-models",
77
- "file": "qwen3_8b_abliterated_v2-fp8mixed.safetensors",
78
- "dest": f"{models_dir}/clip",
79
- "hf_file": "qwen3_8b_abliterated_v2-fp8mixed.safetensors",
80
- },
81
- ]
82
-
83
- for dl in downloads:
84
- dest_path = os.path.join(dl["dest"], dl["file"])
85
- if os.path.exists(dest_path):
86
- print(f" {dl['file']} already exists, skipping")
87
- continue
88
- print(f" Downloading {dl['file']}...")
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 ==="