| #!/bin/bash |
| |
| |
| set -e |
|
|
| echo "=== Dataset-Prep v3: Flux2 Dev Full Setup ===" |
|
|
| |
| 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 |
|
|
| |
| 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..." |
|
|
| |
| 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 |
|
|
| |
| 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 = [ |
| |
| ("msrcam/klein-fleet", "unet/bigLove_klein1_fp8.safetensors", unet_dir, "bigLove_klein1_fp8.safetensors"), |
| |
| ("msrcam/klein-fleet", "clip/qwen3_8b_abliterated_v2-fp8mixed.safetensors", clip_dir, "qwen3_8b_abliterated_v2-fp8mixed.safetensors"), |
| |
| ("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) |
| |
| 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 ===" |
|
|