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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# =============================================================================
|
| 3 |
+
# Krea 2 v1.5 — Provisioning (Vast.ai)
|
| 4 |
+
# Base : Krea 2 Turbo BF16 + ControlNet depth + Outfit edit + SDXL detailers
|
| 5 |
+
# + SeedVR2. Remplace l'ancien setup Z-Image Turbo.
|
| 6 |
+
#
|
| 7 |
+
# Variables d'environnement à définir dans le template Vast :
|
| 8 |
+
# CIVITAI_TOKEN (obligatoire : la plupart des modèles Civitai NSFW demandent un compte)
|
| 9 |
+
# HF_TOKEN (optionnel)
|
| 10 |
+
# AUTO_UPDATE (optionnel, "false" pour ne pas mettre à jour ComfyUI / nodes)
|
| 11 |
+
# =============================================================================
|
| 12 |
+
|
| 13 |
+
source /venv/main/bin/activate
|
| 14 |
+
COMFYUI_DIR=${WORKSPACE}/ComfyUI
|
| 15 |
+
|
| 16 |
+
APT_PACKAGES=(
|
| 17 |
+
"tree"
|
| 18 |
+
)
|
| 19 |
+
|
| 20 |
+
PIP_PACKAGES=(
|
| 21 |
+
"google-genai"
|
| 22 |
+
"xai-sdk"
|
| 23 |
+
)
|
| 24 |
+
|
| 25 |
+
NODES=(
|
| 26 |
+
"https://github.com/ltdrdata/ComfyUI-Manager"
|
| 27 |
+
"https://github.com/rgthree/rgthree-comfy"
|
| 28 |
+
"https://github.com/ltdrdata/ComfyUI-Impact-Pack"
|
| 29 |
+
"https://github.com/ltdrdata/ComfyUI-Impact-Subpack"
|
| 30 |
+
"https://github.com/yolain/ComfyUI-Easy-Use"
|
| 31 |
+
"https://github.com/ssitu/ComfyUI_UltimateSDUpscale"
|
| 32 |
+
"https://github.com/sipherxyz/comfyui-art-venture"
|
| 33 |
+
"https://github.com/moonwhaler/comfyui-moonpack"
|
| 34 |
+
"https://github.com/gseth/ControlAltAI-Nodes"
|
| 35 |
+
"https://github.com/vrgamegirl19/comfyui-vrgamedevgirl"
|
| 36 |
+
"https://github.com/numz/ComfyUI-SeedVR2_VideoUpscaler"
|
| 37 |
+
"https://github.com/robertvoy/ComfyUI-Flux-Continuum"
|
| 38 |
+
"https://github.com/ltdrdata/was-node-suite-comfyui"
|
| 39 |
+
"https://github.com/ChangeTheConstants/SeedVarianceEnhancer"
|
| 40 |
+
"https://github.com/city96/ComfyUI-GGUF"
|
| 41 |
+
"https://github.com/kijai/ComfyUI-KJNodes"
|
| 42 |
+
"https://github.com/Suzie1/ComfyUI_Comfyroll_CustomNodes"
|
| 43 |
+
"https://github.com/pythongosssss/ComfyUI-Custom-Scripts"
|
| 44 |
+
"https://github.com/sypex6/ComfyUI_InstaRAW_Nodes"
|
| 45 |
+
# --- Krea 2 ---
|
| 46 |
+
"https://github.com/facok/comfyui-krea2-controlnet"
|
| 47 |
+
"https://github.com/lbouaraba/comfyui-krea2edit"
|
| 48 |
+
"https://github.com/Fannovel16/comfyui_controlnet_aux"
|
| 49 |
+
)
|
| 50 |
+
|
| 51 |
+
# Workflows : uploade d'abord Krea2_v1.5.json dans ton repo HF nathanglm/sofia
|
| 52 |
+
WORKFLOWS=(
|
| 53 |
+
)
|
| 54 |
+
|
| 55 |
+
# ---------------- Krea 2 (base) ----------------
|
| 56 |
+
DIFFUSION_MODELS=(
|
| 57 |
+
"https://huggingface.co/Comfy-Org/Krea-2/resolve/main/diffusion_models/krea2_turbo_bf16.safetensors"
|
| 58 |
+
# Repli si OOM :
|
| 59 |
+
#"https://huggingface.co/Comfy-Org/Krea-2/resolve/main/diffusion_models/krea2_turbo_fp8_scaled.safetensors"
|
| 60 |
+
# Pour entraîner tes LoRA (pas pour générer) :
|
| 61 |
+
#"https://huggingface.co/Comfy-Org/Krea-2/resolve/main/diffusion_models/krea2_raw_bf16.safetensors"
|
| 62 |
+
)
|
| 63 |
+
|
| 64 |
+
TEXT_ENCODERS=(
|
| 65 |
+
"https://huggingface.co/Comfy-Org/Krea-2/resolve/main/text_encoders/qwen3vl_4b_bf16.safetensors"
|
| 66 |
+
)
|
| 67 |
+
|
| 68 |
+
VAE_MODELS=(
|
| 69 |
+
"https://huggingface.co/Comfy-Org/Krea-2/resolve/main/vae/qwen_image_vae.safetensors"
|
| 70 |
+
)
|
| 71 |
+
|
| 72 |
+
# Format: "URL|filename.safetensors"
|
| 73 |
+
LORA_MODELS=(
|
| 74 |
+
# --- Krea 2 : ControlNet + Outfit ---
|
| 75 |
+
"https://huggingface.co/Patil/Krea-2-depth-controlnet/resolve/main/depth-control-lora.safetensors|depth-control-lora.safetensors"
|
| 76 |
+
"https://huggingface.co/AliveAi/Krea-2-Edit-Outfit-Transfer/resolve/main/krea_outfittransfer.safetensors|krea_outfittransfer.safetensors"
|
| 77 |
+
|
| 78 |
+
# --- Krea 2 : LoRA Civitai (CIVITAI_TOKEN requis) ---
|
| 79 |
+
"https://civitai.com/api/download/models/2790570?type=Model&format=SafeTensor&size=full&fp=fp16|K2-Casual-Snapshot-Realism-v2.safetensors"
|
| 80 |
+
"https://civitai.com/api/download/models/2088956?type=Model&format=SafeTensor&size=full&fp=fp16|K2-Famegrid-Spicy.safetensors"
|
| 81 |
+
"https://civitai.com/api/download/models/2725430?type=Model&format=SafeTensor&size=full&fp=fp16|K2-NSFW-v4.safetensors"
|
| 82 |
+
"https://civitai.com/api/download/models/1138698?type=Model&format=SafeTensor&size=full&fp=fp16|K2-Raw-to-Turbo-r256.safetensors"
|
| 83 |
+
"https://civitai.com/api/download/models/2775340?type=Model&format=SafeTensor&size=full&fp=fp16|K2-TextFusion-Refusal-Reduction-v2.safetensors"
|
| 84 |
+
"https://civitai.com/api/download/models/2766540?type=Model&format=SafeTensor&size=full&fp=fp16|K2-RawGirlSpicy-v3.safetensors"
|
| 85 |
+
"https://civitai.com/api/download/models/2688234?type=Model&format=SafeTensor&size=full&fp=fp16|K2-Realism-Engine-v3.safetensors"
|
| 86 |
+
"https://civitai.com/api/download/models/1972981?type=Model&format=SafeTensor&size=full&fp=fp16|K2-SNOFS-v1.5.safetensors"x
|
| 87 |
+
"https://civitai.com/api/download/models/2728644?type=Model&format=SafeTensor&size=full&fp=fp16|K2-Mystic-XXX-v3.safetensors"
|
| 88 |
+
"https://civitai.com/api/download/models/2512358?type=Model&format=SafeTensor&size=full&fp=fp16|K2-Excessive-Cum.safetensors"x
|
| 89 |
+
"https://civitai.com/api/download/models/2268008?type=Model&format=SafeTensor&size=full&fp=fp16|K2-Realistic-Snapshot-v1.safetensors"x
|
| 90 |
+
"https://civitai.com/api/download/models/1862761?type=Model&format=SafeTensor&size=full&fp=fp16|K2-NiceGirls-UltraReal-v1.safetensors"x
|
| 91 |
+
|
| 92 |
+
# --- Ta LoRA perso (model01) : uploade-la dans ton repo HF puis décommente ---
|
| 93 |
+
"https://huggingface.co/nathanglm/sofia/resolve/main/model01.safetensors|model01.safetensors"
|
| 94 |
+
|
| 95 |
+
# --- SDXL (Pre-Definer + détailleurs SDXL du workflow) ---
|
| 96 |
+
)
|
| 97 |
+
|
| 98 |
+
# SDXL (Pre-Definer). Nom forcé = celui attendu par le workflow.
|
| 99 |
+
CHECKPOINT_MODELS=(
|
| 100 |
+
"https://civitai.com/api/download/models/1621447?type=Model&format=SafeTensor&size=full&fp=fp16|sdxl-iniversemix.safetensors"
|
| 101 |
+
)
|
| 102 |
+
|
| 103 |
+
# GGUF : plus utilisé avec Krea 2 (le loader GGUF est en bypass dans le workflow)
|
| 104 |
+
UNET_MODELS=(
|
| 105 |
+
)
|
| 106 |
+
|
| 107 |
+
SAMS=(
|
| 108 |
+
"https://huggingface.co/datasets/Gourieff/ReActor/resolve/main/models/sams/sam_vit_b_01ec64.pth"
|
| 109 |
+
)
|
| 110 |
+
|
| 111 |
+
BBOX=(
|
| 112 |
+
"https://huggingface.co/nathanglm/sofia/resolve/main/Eyes.pt"
|
| 113 |
+
"https://huggingface.co/nathanglm/sofia/resolve/main/Face.pt"
|
| 114 |
+
"https://huggingface.co/nathanglm/sofia/resolve/main/Foot.pt"
|
| 115 |
+
"https://huggingface.co/nathanglm/sofia/resolve/main/Hands.pt"
|
| 116 |
+
"https://huggingface.co/nathanglm/sofia/resolve/main/Nipples.pt"
|
| 117 |
+
"https://huggingface.co/nathanglm/sofia/resolve/main/Pussy.pt"
|
| 118 |
+
"https://huggingface.co/nathanglm/sofia/resolve/main/Pussy2.pt"
|
| 119 |
+
"https://huggingface.co/nathanglm/sofia/resolve/main/Penis.pt"
|
| 120 |
+
"https://huggingface.co/Bingsu/adetailer/resolve/main/face_yolov8m.pt"
|
| 121 |
+
"https://huggingface.co/Bingsu/adetailer/resolve/main/hand_yolov8s.pt"
|
| 122 |
+
)
|
| 123 |
+
|
| 124 |
+
SEGM=(
|
| 125 |
+
"https://huggingface.co/Bingsu/adetailer/resolve/main/person_yolov8m-seg.pt"
|
| 126 |
+
)
|
| 127 |
+
|
| 128 |
+
# SeedVR2 et Depth Anything V2 : téléchargés automatiquement par leurs nodes au premier lancement.
|
| 129 |
+
|
| 130 |
+
ESRGAN_MODELS=(
|
| 131 |
+
)
|
| 132 |
+
|
| 133 |
+
CONTROLNET_MODELS=(
|
| 134 |
+
)
|
| 135 |
+
|
| 136 |
+
### DO NOT EDIT BELOW HERE UNLESS YOU KNOW WHAT YOU ARE DOING ###
|
| 137 |
+
|
| 138 |
+
function provisioning_start() {
|
| 139 |
+
provisioning_print_header
|
| 140 |
+
provisioning_check_tokens
|
| 141 |
+
provisioning_get_apt_packages
|
| 142 |
+
provisioning_update_comfyui
|
| 143 |
+
provisioning_get_nodes
|
| 144 |
+
provisioning_get_pip_packages
|
| 145 |
+
provisioning_fix_flash_attn
|
| 146 |
+
provisioning_create_nanobananapro
|
| 147 |
+
provisioning_get_files "${COMFYUI_DIR}/models/diffusion_models" "${DIFFUSION_MODELS[@]}"
|
| 148 |
+
provisioning_get_files "${COMFYUI_DIR}/models/text_encoders" "${TEXT_ENCODERS[@]}"
|
| 149 |
+
provisioning_get_files "${COMFYUI_DIR}/models/vae" "${VAE_MODELS[@]}"
|
| 150 |
+
provisioning_get_files "${COMFYUI_DIR}/models/loras" "${LORA_MODELS[@]}"
|
| 151 |
+
provisioning_get_files "${COMFYUI_DIR}/models/checkpoints" "${CHECKPOINT_MODELS[@]}"
|
| 152 |
+
provisioning_get_files "${COMFYUI_DIR}/models/unet" "${UNET_MODELS[@]}"
|
| 153 |
+
provisioning_get_files "${COMFYUI_DIR}/models/sams" "${SAMS[@]}"
|
| 154 |
+
provisioning_get_files "${COMFYUI_DIR}/models/ultralytics/bbox" "${BBOX[@]}"
|
| 155 |
+
provisioning_get_files "${COMFYUI_DIR}/models/ultralytics/segm" "${SEGM[@]}"
|
| 156 |
+
provisioning_get_files "${COMFYUI_DIR}/models/controlnet" "${CONTROLNET_MODELS[@]}"
|
| 157 |
+
provisioning_get_files "${COMFYUI_DIR}/models/upscale_models" "${ESRGAN_MODELS[@]}"
|
| 158 |
+
provisioning_get_files "${COMFYUI_DIR}/user/default/workflows" "${WORKFLOWS[@]}"
|
| 159 |
+
provisioning_report_bad_files
|
| 160 |
+
provisioning_print_end
|
| 161 |
+
}
|
| 162 |
+
|
| 163 |
+
function provisioning_check_tokens() {
|
| 164 |
+
if provisioning_has_valid_civitai_token; then
|
| 165 |
+
printf "CIVITAI_TOKEN : OK\n"
|
| 166 |
+
else
|
| 167 |
+
printf "\n⚠️ CIVITAI_TOKEN absent ou invalide : les modèles Civitai (LoRA NSFW, SDXL) vont échouer.\n\n"
|
| 168 |
+
fi
|
| 169 |
+
}
|
| 170 |
+
|
| 171 |
+
function provisioning_update_comfyui() {
|
| 172 |
+
# Krea 2 demande ComfyUI >= 0.26
|
| 173 |
+
if [[ ${AUTO_UPDATE,,} != "false" ]]; then
|
| 174 |
+
printf "Updating ComfyUI...\n"
|
| 175 |
+
( cd "${COMFYUI_DIR}" && git pull ) && pip install --no-cache-dir -r "${COMFYUI_DIR}/requirements.txt"
|
| 176 |
+
fi
|
| 177 |
+
}
|
| 178 |
+
|
| 179 |
+
function provisioning_fix_flash_attn() {
|
| 180 |
+
# Un flash_attn cassé fait planter xformers -> SeedVR2 ne se charge plus
|
| 181 |
+
if python -c "import flash_attn" >/dev/null 2>&1 || ls /venv/main/lib/python3*/site-packages/ 2>/dev/null | grep -qi "^flash_attn"; then
|
| 182 |
+
if ! python -c "import flash_attn.flash_attn_interface" >/dev/null 2>&1; then
|
| 183 |
+
printf "Removing broken flash_attn...\n"
|
| 184 |
+
pip uninstall -y flash-attn flash_attn >/dev/null 2>&1
|
| 185 |
+
rm -rf /venv/main/lib/python3*/site-packages/flash_attn*
|
| 186 |
+
fi
|
| 187 |
+
fi
|
| 188 |
+
}
|
| 189 |
+
|
| 190 |
+
function provisioning_report_bad_files() {
|
| 191 |
+
# Un téléchargement Civitai refusé produit un petit fichier HTML/JSON au lieu du modèle
|
| 192 |
+
printf "\nChecking for failed downloads...\n"
|
| 193 |
+
find "${COMFYUI_DIR}/models" -type f \( -name "*.safetensors" -o -name "*.pt" -o -name "*.pth" \) -size -100k 2>/dev/null | while read -r f; do
|
| 194 |
+
printf "⚠️ Fichier suspect (trop petit, probablement un échec) : %s\n" "$f"
|
| 195 |
+
done
|
| 196 |
+
}
|
| 197 |
+
|
| 198 |
+
function provisioning_get_apt_packages() {
|
| 199 |
+
if [[ -n $APT_PACKAGES ]]; then
|
| 200 |
+
sudo $APT_INSTALL ${APT_PACKAGES[@]}
|
| 201 |
+
fi
|
| 202 |
+
}
|
| 203 |
+
|
| 204 |
+
function provisioning_get_pip_packages() {
|
| 205 |
+
if [[ -n $PIP_PACKAGES ]]; then
|
| 206 |
+
pip install --no-cache-dir ${PIP_PACKAGES[@]}
|
| 207 |
+
fi
|
| 208 |
+
}
|
| 209 |
+
|
| 210 |
+
function provisioning_get_nodes() {
|
| 211 |
+
for repo in "${NODES[@]}"; do
|
| 212 |
+
dir="${repo##*/}"
|
| 213 |
+
path="${COMFYUI_DIR}/custom_nodes/${dir}"
|
| 214 |
+
requirements="${path}/requirements.txt"
|
| 215 |
+
if [[ -d $path ]]; then
|
| 216 |
+
if [[ ${AUTO_UPDATE,,} != "false" ]]; then
|
| 217 |
+
printf "Updating node: %s...\n" "${repo}"
|
| 218 |
+
( cd "$path" && git pull )
|
| 219 |
+
if [[ -e $requirements ]]; then
|
| 220 |
+
pip install --no-cache-dir -r "$requirements"
|
| 221 |
+
fi
|
| 222 |
+
fi
|
| 223 |
+
else
|
| 224 |
+
printf "Downloading node: %s...\n" "${repo}"
|
| 225 |
+
git clone "${repo}" "${path}" --recursive
|
| 226 |
+
if [[ -e $requirements ]]; then
|
| 227 |
+
pip install --no-cache-dir -r "${requirements}"
|
| 228 |
+
fi
|
| 229 |
+
fi
|
| 230 |
+
done
|
| 231 |
+
}
|
| 232 |
+
|
| 233 |
+
function provisioning_create_nanobananapro() {
|
| 234 |
+
local NBP_DIR="${COMFYUI_DIR}/custom_nodes/NanoBananaPro"
|
| 235 |
+
printf "Creating NanoBananaPro custom nodes...\n"
|
| 236 |
+
mkdir -p "${NBP_DIR}"
|
| 237 |
+
|
| 238 |
+
# ── nano_banana_pro_node.py ────────────────────────────────────────────────
|
| 239 |
+
cat > "${NBP_DIR}/nano_banana_pro_node.py" << 'ENDOFFILE'
|
| 240 |
+
"""
|
| 241 |
+
🍌 Nano Banana Pro Node — ComfyUI
|
| 242 |
+
Supporte :
|
| 243 |
+
- Nano Banana 2 = gemini-3.1-flash-image-preview (NOUVEAU, recommandé)
|
| 244 |
+
- Nano Banana Pro = gemini-3-pro-image-preview (⚠️ déprécié le 9 mars 2026)
|
| 245 |
+
- Nano Banana = gemini-2.5-flash-image (stable, rapide)
|
| 246 |
+
Modes :
|
| 247 |
+
- generate : text-to-image pur
|
| 248 |
+
- edit : image editing (envoyer une image + prompt)
|
| 249 |
+
Résolutions : 0.5K, 1K, 2K, 4K
|
| 250 |
+
"""
|
| 251 |
+
|
| 252 |
+
import torch, numpy as np, io, random
|
| 253 |
+
from PIL import Image, ImageEnhance
|
| 254 |
+
|
| 255 |
+
def pil_to_tensor(image):
|
| 256 |
+
img = image.convert("RGB")
|
| 257 |
+
arr = np.array(img).astype(np.float32) / 255.0
|
| 258 |
+
return torch.from_numpy(arr).unsqueeze(0)
|
| 259 |
+
|
| 260 |
+
def tensor_to_pil(tensor):
|
| 261 |
+
arr = tensor.squeeze(0).numpy()
|
| 262 |
+
arr = (arr * 255).clip(0, 255).astype(np.uint8)
|
| 263 |
+
return Image.fromarray(arr)
|
| 264 |
+
|
| 265 |
+
def pil_to_bytes(image):
|
| 266 |
+
buf = io.BytesIO()
|
| 267 |
+
image.save(buf, format="PNG")
|
| 268 |
+
return buf.getvalue()
|
| 269 |
+
|
| 270 |
+
def apply_color_grade(image, brightness, contrast, saturation, temperature, sharpness):
|
| 271 |
+
img = image.convert("RGB")
|
| 272 |
+
if brightness != 1.0:
|
| 273 |
+
img = ImageEnhance.Brightness(img).enhance(brightness)
|
| 274 |
+
if contrast != 1.0:
|
| 275 |
+
img = ImageEnhance.Contrast(img).enhance(contrast)
|
| 276 |
+
if saturation != 1.0:
|
| 277 |
+
img = ImageEnhance.Color(img).enhance(saturation)
|
| 278 |
+
if temperature != 0.0:
|
| 279 |
+
r, g, b = img.split()
|
| 280 |
+
r_arr = np.array(r, dtype=np.float32)
|
| 281 |
+
b_arr = np.array(b, dtype=np.float32)
|
| 282 |
+
strength = abs(temperature) * 30
|
| 283 |
+
if temperature > 0:
|
| 284 |
+
r_arr = np.clip(r_arr + strength, 0, 255)
|
| 285 |
+
b_arr = np.clip(b_arr - strength * 0.5, 0, 255)
|
| 286 |
+
else:
|
| 287 |
+
r_arr = np.clip(r_arr - strength * 0.5, 0, 255)
|
| 288 |
+
b_arr = np.clip(b_arr + strength, 0, 255)
|
| 289 |
+
img = Image.merge("RGB", (
|
| 290 |
+
Image.fromarray(r_arr.astype(np.uint8)),
|
| 291 |
+
g,
|
| 292 |
+
Image.fromarray(b_arr.astype(np.uint8))
|
| 293 |
+
))
|
| 294 |
+
if sharpness != 1.0:
|
| 295 |
+
img = ImageEnhance.Sharpness(img).enhance(sharpness)
|
| 296 |
+
return img
|
| 297 |
+
|
| 298 |
+
|
| 299 |
+
class NanaBananaProNode:
|
| 300 |
+
MODELS = [
|
| 301 |
+
"gemini-3.1-flash-image-preview",
|
| 302 |
+
"gemini-2.5-flash-image",
|
| 303 |
+
"gemini-3-pro-image-preview",
|
| 304 |
+
]
|
| 305 |
+
MODES = ["generate", "edit"]
|
| 306 |
+
SAFETY = ["OFF", "BLOCK_ONLY_HIGH", "BLOCK_MEDIUM_AND_ABOVE", "BLOCK_LOW_AND_ABOVE"]
|
| 307 |
+
RATIOS = ["1:1", "9:16", "16:9", "2:3", "3:2", "4:3", "3:4", "21:9", "1:4", "4:1"]
|
| 308 |
+
QUALITY = ["1K", "2K", "4K", "0.5K"]
|
| 309 |
+
AFTER_GEN = ["randomize", "fixed", "increment"]
|
| 310 |
+
|
| 311 |
+
@classmethod
|
| 312 |
+
def INPUT_TYPES(cls):
|
| 313 |
+
return {
|
| 314 |
+
"required": {
|
| 315 |
+
"prompt": ("STRING", {"default": "A stunning photorealistic portrait, ultra detailed", "multiline": True}),
|
| 316 |
+
"model": (cls.MODELS,),
|
| 317 |
+
"mode": (cls.MODES,),
|
| 318 |
+
"aspect_ratio": (cls.RATIOS,),
|
| 319 |
+
"quality": (cls.QUALITY,),
|
| 320 |
+
"temperature": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 2.0, "step": 0.05}),
|
| 321 |
+
"top_p": ("FLOAT", {"default": 0.95, "min": 0.0, "max": 1.0, "step": 0.01}),
|
| 322 |
+
"top_k": ("INT", {"default": 0, "min": 0, "max": 100, "step": 1}),
|
| 323 |
+
"seed": ("INT", {"default": -1, "min": -1, "max": 2**31,"step": 1}),
|
| 324 |
+
"control_after_generate": (cls.AFTER_GEN,),
|
| 325 |
+
"safety_threshold": (cls.SAFETY,),
|
| 326 |
+
"api_key": ("STRING", {"default": "YOUR_GEMINI_API_KEY"}),
|
| 327 |
+
"cg_brightness": ("FLOAT", {"default": 1.0, "min": 0.1, "max": 3.0, "step": 0.05}),
|
| 328 |
+
"cg_contrast": ("FLOAT", {"default": 1.0, "min": 0.1, "max": 3.0, "step": 0.05}),
|
| 329 |
+
"cg_saturation": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 3.0, "step": 0.05}),
|
| 330 |
+
"cg_temperature": ("FLOAT", {"default": 0.0, "min": -1.0,"max": 1.0, "step": 0.05}),
|
| 331 |
+
"cg_sharpness": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 3.0, "step": 0.05}),
|
| 332 |
+
},
|
| 333 |
+
"optional": {
|
| 334 |
+
"edit_image": ("IMAGE",),
|
| 335 |
+
"ref_image_1": ("IMAGE",),
|
| 336 |
+
"ref_image_2": ("IMAGE",),
|
| 337 |
+
"ref_image_3": ("IMAGE",),
|
| 338 |
+
"ref_image_4": ("IMAGE",),
|
| 339 |
+
"ref_image_5": ("IMAGE",),
|
| 340 |
+
"ref_image_6": ("IMAGE",),
|
| 341 |
+
"ref_image_7": ("IMAGE",),
|
| 342 |
+
}
|
| 343 |
+
}
|
| 344 |
+
|
| 345 |
+
RETURN_TYPES = ("IMAGE", "STRING")
|
| 346 |
+
RETURN_NAMES = ("image", "metadata")
|
| 347 |
+
FUNCTION = "generate"
|
| 348 |
+
CATEGORY = "🍌 Nano Banana Pro"
|
| 349 |
+
|
| 350 |
+
def generate(self, prompt, model, mode, aspect_ratio, quality, temperature, top_p, top_k,
|
| 351 |
+
seed, control_after_generate, safety_threshold, api_key,
|
| 352 |
+
cg_brightness, cg_contrast, cg_saturation, cg_temperature, cg_sharpness,
|
| 353 |
+
edit_image=None, ref_image_1=None, ref_image_2=None, ref_image_3=None,
|
| 354 |
+
ref_image_4=None, ref_image_5=None, ref_image_6=None, ref_image_7=None):
|
| 355 |
+
try:
|
| 356 |
+
from google import genai
|
| 357 |
+
from google.genai import types
|
| 358 |
+
except ImportError:
|
| 359 |
+
raise ImportError("Lance : pip install google-genai")
|
| 360 |
+
|
| 361 |
+
if seed == -1 or control_after_generate == "randomize":
|
| 362 |
+
actual_seed = random.randint(0, 2**31)
|
| 363 |
+
elif control_after_generate == "increment":
|
| 364 |
+
actual_seed = seed + 1
|
| 365 |
+
else:
|
| 366 |
+
actual_seed = seed
|
| 367 |
+
|
| 368 |
+
client = genai.Client(api_key=api_key)
|
| 369 |
+
|
| 370 |
+
safety_settings = []
|
| 371 |
+
if safety_threshold != "OFF":
|
| 372 |
+
harm_categories = [
|
| 373 |
+
"HARM_CATEGORY_HARASSMENT",
|
| 374 |
+
"HARM_CATEGORY_HATE_SPEECH",
|
| 375 |
+
"HARM_CATEGORY_SEXUALLY_EXPLICIT",
|
| 376 |
+
"HARM_CATEGORY_DANGEROUS_CONTENT"
|
| 377 |
+
]
|
| 378 |
+
safety_settings = [types.SafetySetting(category=cat, threshold=safety_threshold) for cat in harm_categories]
|
| 379 |
+
|
| 380 |
+
parts = []
|
| 381 |
+
|
| 382 |
+
if mode == "edit" and edit_image is not None:
|
| 383 |
+
parts.append(types.Part.from_bytes(
|
| 384 |
+
data=pil_to_bytes(tensor_to_pil(edit_image)),
|
| 385 |
+
mime_type="image/png"
|
| 386 |
+
))
|
| 387 |
+
|
| 388 |
+
ref_images = [ref_image_1, ref_image_2, ref_image_3, ref_image_4,
|
| 389 |
+
ref_image_5, ref_image_6, ref_image_7]
|
| 390 |
+
for ref in ref_images:
|
| 391 |
+
if ref is not None:
|
| 392 |
+
parts.append(types.Part.from_bytes(
|
| 393 |
+
data=pil_to_bytes(tensor_to_pil(ref)),
|
| 394 |
+
mime_type="image/png"
|
| 395 |
+
))
|
| 396 |
+
|
| 397 |
+
parts.append(types.Part.from_text(text=prompt))
|
| 398 |
+
|
| 399 |
+
gen_config_kwargs = dict(
|
| 400 |
+
response_modalities=["TEXT", "IMAGE"],
|
| 401 |
+
temperature=temperature,
|
| 402 |
+
top_p=top_p,
|
| 403 |
+
image_config=types.ImageConfig(
|
| 404 |
+
aspect_ratio=aspect_ratio,
|
| 405 |
+
image_size=quality
|
| 406 |
+
),
|
| 407 |
+
)
|
| 408 |
+
if top_k > 0:
|
| 409 |
+
gen_config_kwargs["top_k"] = top_k
|
| 410 |
+
if safety_settings:
|
| 411 |
+
gen_config_kwargs["safety_settings"] = safety_settings
|
| 412 |
+
|
| 413 |
+
gen_config = types.GenerateContentConfig(**gen_config_kwargs)
|
| 414 |
+
|
| 415 |
+
print(f"[NanaBanana] -> {model} | mode:{mode} | quality:{quality} | safety:{safety_threshold}")
|
| 416 |
+
|
| 417 |
+
response = client.models.generate_content(
|
| 418 |
+
model=model,
|
| 419 |
+
contents=parts,
|
| 420 |
+
config=gen_config
|
| 421 |
+
)
|
| 422 |
+
|
| 423 |
+
if not response.candidates:
|
| 424 |
+
raise RuntimeError(f"[NanaBanana] Aucun candidat: {response}")
|
| 425 |
+
|
| 426 |
+
candidate = response.candidates[0]
|
| 427 |
+
finish_reason = str(getattr(candidate, "finish_reason", ""))
|
| 428 |
+
if "SAFETY" in finish_reason:
|
| 429 |
+
raise RuntimeError("[NanaBanana] Bloque par IMAGE_SAFETY. Reformule le prompt.")
|
| 430 |
+
|
| 431 |
+
content = getattr(candidate, "content", None)
|
| 432 |
+
if content is None or not getattr(content, "parts", None):
|
| 433 |
+
raise RuntimeError(f"[NanaBanana] Content vide. finish_reason: {finish_reason}")
|
| 434 |
+
|
| 435 |
+
result_image, info_text = None, ""
|
| 436 |
+
for part in content.parts:
|
| 437 |
+
if hasattr(part, "text") and part.text:
|
| 438 |
+
info_text += part.text + "\n"
|
| 439 |
+
elif hasattr(part, "inline_data") and part.inline_data:
|
| 440 |
+
result_image = Image.open(io.BytesIO(part.inline_data.data)).convert("RGB")
|
| 441 |
+
|
| 442 |
+
if result_image is None:
|
| 443 |
+
raise RuntimeError(f"[NanaBanana] Aucune image generee. Texte: {info_text or '(aucun)'}")
|
| 444 |
+
|
| 445 |
+
result_image = apply_color_grade(
|
| 446 |
+
result_image,
|
| 447 |
+
cg_brightness, cg_contrast, cg_saturation, cg_temperature, cg_sharpness
|
| 448 |
+
)
|
| 449 |
+
|
| 450 |
+
metadata = (
|
| 451 |
+
f"model: {model}\n"
|
| 452 |
+
f"mode: {mode}\n"
|
| 453 |
+
f"seed: {actual_seed}\n"
|
| 454 |
+
f"temperature: {temperature} | top_p: {top_p} | top_k: {top_k}\n"
|
| 455 |
+
f"aspect_ratio: {aspect_ratio} | quality: {quality}\n"
|
| 456 |
+
f"safety: {safety_threshold}\n"
|
| 457 |
+
f"{info_text.strip()}"
|
| 458 |
+
)
|
| 459 |
+
print(f"[NanaBanana] Succes ! ({quality})")
|
| 460 |
+
return (pil_to_tensor(result_image), metadata)
|
| 461 |
+
|
| 462 |
+
|
| 463 |
+
NODE_CLASS_MAPPINGS = {"NanaBananaProNode": NanaBananaProNode}
|
| 464 |
+
NODE_DISPLAY_NAME_MAPPINGS = {"NanaBananaProNode": "🍌 Nano Banana Pro"}
|
| 465 |
+
ENDOFFILE
|
| 466 |
+
|
| 467 |
+
# ── anya_prompt_extractor_node.py ──────────────────────────────────────────
|
| 468 |
+
cat > "${NBP_DIR}/anya_prompt_extractor_node.py" << 'ENDOFFILE'
|
| 469 |
+
import torch, numpy as np, io, json
|
| 470 |
+
from PIL import Image
|
| 471 |
+
|
| 472 |
+
def tensor_to_pil(tensor):
|
| 473 |
+
arr = tensor.squeeze(0).numpy()
|
| 474 |
+
arr = (arr * 255).clip(0, 255).astype(np.uint8)
|
| 475 |
+
return Image.fromarray(arr)
|
| 476 |
+
|
| 477 |
+
def pil_to_bytes(image):
|
| 478 |
+
buf = io.BytesIO()
|
| 479 |
+
image.save(buf, format="PNG")
|
| 480 |
+
return buf.getvalue()
|
| 481 |
+
|
| 482 |
+
def build_system_prompt(anya_desc, include_anya, include_l3n0v0, breast_size, style_hint, use_ref_images, num_refs, ref_descs_list):
|
| 483 |
+
breast_map = {"small": "small perky breasts", "medium": "medium-sized natural breasts, visible cleavage", "large": "large full breasts with natural weight", "huge": "very large breasts, voluptuous silhouette"}
|
| 484 |
+
breast_desc = breast_map.get(breast_size, "medium-sized natural breasts")
|
| 485 |
+
triggers = []
|
| 486 |
+
if include_anya: triggers.append("Anya")
|
| 487 |
+
if include_l3n0v0: triggers.append("l3n0v0")
|
| 488 |
+
triggers_str = json.dumps(triggers)
|
| 489 |
+
if include_anya:
|
| 490 |
+
subject_block = f' "subject": {{"name": "Anya", "ethnicity": "Asian", "hair": "...", "skin_tone": "...", "breast_size": "{breast_desc}", "body": "wide hips, prominent round BBL-style butt, thick thighs, hourglass figure", "face": "full lips, almond-shaped eyes, long lashes, natural makeup", "jewelry": "...", "pose": "...", "expression": "...", "gaze": "..."}}'
|
| 491 |
+
subject_instruction = f"## ANYA FIXED CHARACTER\n{anya_desc}\nBreast size: {breast_desc}\nHips: wide hips, prominent round BBL-style butt, thick thighs\nInject into subject section, never modify physical traits."
|
| 492 |
+
else:
|
| 493 |
+
subject_block = ' "subject": {"description": "...", "pose": "...", "expression": "...", "gaze": "..."}'
|
| 494 |
+
subject_instruction = "## SUBJECT\nDescribe the subject from the reference image exactly. Reproduce face, hair, skin tone, body proportions 1:1. No changes, no beautification."
|
| 495 |
+
if use_ref_images and num_refs > 0:
|
| 496 |
+
ref_labels = ["subject_identity"] + [f"reference_image_{i}" for i in range(2, num_refs+1)]
|
| 497 |
+
ref_entries = []
|
| 498 |
+
for i in range(num_refs):
|
| 499 |
+
label = ref_labels[i] if i < len(ref_labels) else f"reference_image_{i+1}"
|
| 500 |
+
desc = ref_descs_list[i] if i < len(ref_descs_list) and ref_descs_list[i].strip() else f"uploaded_reference_image_{i+1}"
|
| 501 |
+
ref_entries.append(f' "{label}": "{desc}"')
|
| 502 |
+
ref_block = ' "reference_images": {\n' + ',\n'.join(ref_entries) + '\n },'
|
| 503 |
+
ref_instruction = f"## REFERENCE IMAGES\n{num_refs} reference image(s):\n" + "\n".join([f"- Image {i+1}: {ref_descs_list[i] if i < len(ref_descs_list) else 'reference'}" for i in range(num_refs)])
|
| 504 |
+
else:
|
| 505 |
+
ref_block = ""
|
| 506 |
+
ref_instruction = "## REFERENCE IMAGES\nNo reference images."
|
| 507 |
+
ref_section = f"\n{ref_block}" if ref_block else ""
|
| 508 |
+
inject_note = "Inject the fixed Anya character description into subject." if include_anya else "Describe subject exactly as seen in the reference image, 1:1 accuracy."
|
| 509 |
+
return f"""You are an expert AI image prompt engineer specializing in structured JSON prompts.
|
| 510 |
+
{subject_instruction}
|
| 511 |
+
{ref_instruction}
|
| 512 |
+
## OUTPUT RULES
|
| 513 |
+
- Return ONLY valid JSON, no markdown, no backticks, no explanation
|
| 514 |
+
- trigger_words must be exactly: {triggers_str}
|
| 515 |
+
{{
|
| 516 |
+
"trigger_words": {triggers_str},{ref_section}
|
| 517 |
+
"output_quality": {{"resolution": "4K", "definition": "ultra high resolution", "sharpness": "natural realistic detail, not overprocessed"}},
|
| 518 |
+
{subject_block},
|
| 519 |
+
"outfit": {{"description": "...", "colors": [...], "fit": "...", "fabric": "..."}},
|
| 520 |
+
"location": {{"setting": "...", "environment": [...], "time_of_day": "...", "lighting": "...", "atmosphere": "..."}},
|
| 521 |
+
"image_type": {{"orientation": "...", "aspect_ratio": "...", "style": "{style_hint}", "camera_feel": "...", "color_grading": "..."}},
|
| 522 |
+
"identity_preservation": {{"facial_identity": "...", "no_changes": ["bone_structure", "facial_proportions", "skin_tone", "hairline", "facial_features"], "no_beautification": true, "no_stylization": true}},
|
| 523 |
+
"realism_constraints": {{"no_extra_limbs": true, "no_ai_symmetry_correction": true, "natural_skin_texture": true, "natural_light_behavior": true, "no_heavy_color_grading": true}},
|
| 524 |
+
"image_feel": [...]
|
| 525 |
+
}}
|
| 526 |
+
Analyze the provided image(s): extract scene, lighting, pose, outfit, mood. {inject_note} Return ONLY the JSON."""
|
| 527 |
+
|
| 528 |
+
class AnyaPromptExtractor:
|
| 529 |
+
MODELS = ["gemini-2.5-flash-preview-05-20", "gemini-2.5-flash", "gemini-2.5-pro", "gemini-3-pro-image-preview"]
|
| 530 |
+
BREAST_SIZES = ["small", "medium", "large", "huge"]
|
| 531 |
+
NUM_REFS = ["0", "1", "2", "3", "4", "5"]
|
| 532 |
+
|
| 533 |
+
@classmethod
|
| 534 |
+
def INPUT_TYPES(cls):
|
| 535 |
+
return {
|
| 536 |
+
"required": {
|
| 537 |
+
"api_key": ("STRING", {"default": "YOUR_GEMINI_API_KEY"}),
|
| 538 |
+
"model": (cls.MODELS,),
|
| 539 |
+
"include_trigger_anya": ("BOOLEAN", {"default": True}),
|
| 540 |
+
"include_trigger_l3n0v0": ("BOOLEAN", {"default": True}),
|
| 541 |
+
"breast_size_override": (cls.BREAST_SIZES,),
|
| 542 |
+
"anya_base_description": ("STRING", {"default": "Anya is an Asian woman with long straight black hair, medium-sized natural breasts, wide hips and a prominent BBL-style butt, thick thighs. She has full lips, almond-shaped eyes with long lashes, tan warm skin tone, and usually wears gold jewelry.", "multiline": True}),
|
| 543 |
+
"style_hint": ("STRING", {"default": "natural high-end lifestyle, candid editorial"}),
|
| 544 |
+
"json_indent": ("INT", {"default": 4, "min": 0, "max": 8, "step": 1}),
|
| 545 |
+
"use_reference_images": ("BOOLEAN", {"default": True}),
|
| 546 |
+
"num_reference_images": (cls.NUM_REFS,),
|
| 547 |
+
"ref_1_description": ("STRING", {"default": "subject identity — main model reference"}),
|
| 548 |
+
"ref_2_description": ("STRING", {"default": "outfit reference"}),
|
| 549 |
+
"ref_3_description": ("STRING", {"default": "location or background reference"}),
|
| 550 |
+
"ref_4_description": ("STRING", {"default": "style or mood reference"}),
|
| 551 |
+
"ref_5_description": ("STRING", {"default": "additional reference"}),
|
| 552 |
+
},
|
| 553 |
+
"optional": {
|
| 554 |
+
"scene_image": ("IMAGE",),
|
| 555 |
+
"ref_image_1": ("IMAGE",),
|
| 556 |
+
"ref_image_2": ("IMAGE",),
|
| 557 |
+
"ref_image_3": ("IMAGE",),
|
| 558 |
+
"ref_image_4": ("IMAGE",),
|
| 559 |
+
"ref_image_5": ("IMAGE",),
|
| 560 |
+
}
|
| 561 |
+
}
|
| 562 |
+
|
| 563 |
+
RETURN_TYPES = ("STRING", "IMAGE", "IMAGE", "IMAGE", "IMAGE", "IMAGE", "IMAGE")
|
| 564 |
+
RETURN_NAMES = ("prompt_json", "scene_passthrough", "ref_1_passthrough", "ref_2_passthrough", "ref_3_passthrough", "ref_4_passthrough", "ref_5_passthrough")
|
| 565 |
+
FUNCTION = "extract"
|
| 566 |
+
CATEGORY = "🍌 Nano Banana Pro"
|
| 567 |
+
OUTPUT_NODE = True
|
| 568 |
+
|
| 569 |
+
def extract(self, api_key, model, include_trigger_anya, include_trigger_l3n0v0,
|
| 570 |
+
breast_size_override, anya_base_description, style_hint, json_indent,
|
| 571 |
+
use_reference_images, num_reference_images,
|
| 572 |
+
ref_1_description, ref_2_description, ref_3_description,
|
| 573 |
+
ref_4_description, ref_5_description,
|
| 574 |
+
scene_image=None, ref_image_1=None, ref_image_2=None,
|
| 575 |
+
ref_image_3=None, ref_image_4=None, ref_image_5=None):
|
| 576 |
+
try:
|
| 577 |
+
from google import genai
|
| 578 |
+
from google.genai import types
|
| 579 |
+
except ImportError:
|
| 580 |
+
raise ImportError("Lance : pip install google-genai")
|
| 581 |
+
num_refs = int(num_reference_images)
|
| 582 |
+
ref_descs_list = [ref_1_description, ref_2_description, ref_3_description, ref_4_description, ref_5_description]
|
| 583 |
+
system_prompt = build_system_prompt(anya_base_description, include_trigger_anya, include_trigger_l3n0v0, breast_size_override, style_hint, use_reference_images, num_refs, ref_descs_list)
|
| 584 |
+
client = genai.Client(api_key=api_key)
|
| 585 |
+
parts = []
|
| 586 |
+
if scene_image is not None:
|
| 587 |
+
parts.append(types.Part.from_bytes(data=pil_to_bytes(tensor_to_pil(scene_image)), mime_type="image/png"))
|
| 588 |
+
if use_reference_images and num_refs > 0:
|
| 589 |
+
ref_images_list = [ref_image_1, ref_image_2, ref_image_3, ref_image_4, ref_image_5]
|
| 590 |
+
for i in range(min(num_refs, 5)):
|
| 591 |
+
ref = ref_images_list[i]
|
| 592 |
+
if ref is not None:
|
| 593 |
+
desc = ref_descs_list[i] if ref_descs_list[i].strip() else f"reference image {i+1}"
|
| 594 |
+
parts.append(types.Part.from_text(text=f"[Reference image {i+1}: {desc}]"))
|
| 595 |
+
parts.append(types.Part.from_bytes(data=pil_to_bytes(tensor_to_pil(ref)), mime_type="image/png"))
|
| 596 |
+
if not parts:
|
| 597 |
+
parts.append(types.Part.from_text(text="No image provided. Generate a generic lifestyle JSON prompt. Return ONLY the JSON."))
|
| 598 |
+
else:
|
| 599 |
+
parts.append(types.Part.from_text(text="Analyze the provided image(s) and generate the structured JSON prompt. Return ONLY the JSON."))
|
| 600 |
+
config = types.GenerateContentConfig(system_instruction=system_prompt, response_modalities=["TEXT"], temperature=0.4, top_p=0.9)
|
| 601 |
+
print(f"[AnyaExtractor] -> {model} | Anya:{include_trigger_anya} | l3n0v0:{include_trigger_l3n0v0} | refs:{num_refs if use_reference_images else 0}")
|
| 602 |
+
response = client.models.generate_content(model=model, contents=parts, config=config)
|
| 603 |
+
raw_parts = response.parts or []
|
| 604 |
+
raw_text = "".join(part.text for part in raw_parts if hasattr(part, "text") and part.text).strip()
|
| 605 |
+
if not raw_text and hasattr(response, "candidates") and response.candidates:
|
| 606 |
+
raw_text = "".join(part.text for part in (response.candidates[0].content.parts or []) if hasattr(part, "text") and part.text).strip()
|
| 607 |
+
if not raw_text:
|
| 608 |
+
raise RuntimeError(f"[AnyaExtractor] Reponse vide. Modele: {model} | Verifier la cle API ou changer de modele.")
|
| 609 |
+
if raw_text.startswith("```"):
|
| 610 |
+
lines = raw_text.split("\n")
|
| 611 |
+
raw_text = "\n".join(lines[1:-1] if lines[-1].strip() == "```" else lines[1:]).strip()
|
| 612 |
+
try:
|
| 613 |
+
parsed = json.loads(raw_text)
|
| 614 |
+
tw = parsed.get("trigger_words", [])
|
| 615 |
+
if include_trigger_anya and "Anya" not in tw: tw.insert(0, "Anya")
|
| 616 |
+
if not include_trigger_anya and "Anya" in tw: tw.remove("Anya")
|
| 617 |
+
if include_trigger_l3n0v0 and "l3n0v0" not in tw: tw.append("l3n0v0")
|
| 618 |
+
if not include_trigger_l3n0v0 and "l3n0v0" in tw: tw.remove("l3n0v0")
|
| 619 |
+
parsed["trigger_words"] = tw
|
| 620 |
+
output_json = json.dumps(parsed, indent=json_indent, ensure_ascii=False)
|
| 621 |
+
except json.JSONDecodeError as e:
|
| 622 |
+
print(f"[AnyaExtractor] JSON invalide: {e}")
|
| 623 |
+
output_json = raw_text
|
| 624 |
+
print(f"[AnyaExtractor] Succes ({len(output_json)} chars)")
|
| 625 |
+
empty = torch.zeros(1, 64, 64, 3)
|
| 626 |
+
return (output_json, scene_image if scene_image is not None else empty, ref_image_1 if ref_image_1 is not None else empty, ref_image_2 if ref_image_2 is not None else empty, ref_image_3 if ref_image_3 is not None else empty, ref_image_4 if ref_image_4 is not None else empty, ref_image_5 if ref_image_5 is not None else empty)
|
| 627 |
+
|
| 628 |
+
NODE_CLASS_MAPPINGS = {"AnyaPromptExtractor": AnyaPromptExtractor}
|
| 629 |
+
NODE_DISPLAY_NAME_MAPPINGS = {"AnyaPromptExtractor": "🔍 Anya Prompt Extractor"}
|
| 630 |
+
ENDOFFILE
|
| 631 |
+
|
| 632 |
+
# ── grok_prompt_extractor_node.py ──────────────────────────────────────────
|
| 633 |
+
cat > "${NBP_DIR}/grok_prompt_extractor_node.py" << 'ENDOFFILE'
|
| 634 |
+
import torch, numpy as np, io, base64
|
| 635 |
+
from PIL import Image
|
| 636 |
+
|
| 637 |
+
def tensor_to_pil(tensor):
|
| 638 |
+
arr = tensor.squeeze(0).numpy()
|
| 639 |
+
arr = (arr * 255).clip(0, 255).astype(np.uint8)
|
| 640 |
+
return Image.fromarray(arr)
|
| 641 |
+
|
| 642 |
+
def pil_to_bytes(image):
|
| 643 |
+
buf = io.BytesIO()
|
| 644 |
+
image.save(buf, format="PNG")
|
| 645 |
+
return buf.getvalue()
|
| 646 |
+
|
| 647 |
+
def image_to_base64(image):
|
| 648 |
+
return base64.b64encode(pil_to_bytes(image)).decode("utf-8")
|
| 649 |
+
|
| 650 |
+
def build_system_prompt(anya_desc, include_anya, include_l3n0v0, breast_size, style_hint, word_count):
|
| 651 |
+
breast_map = {
|
| 652 |
+
"small": "small perky breasts",
|
| 653 |
+
"medium": "medium-sized natural breasts with visible cleavage",
|
| 654 |
+
"large": "large full breasts with natural weight and deep cleavage",
|
| 655 |
+
"huge": "very large heavy breasts, extremely voluptuous silhouette"
|
| 656 |
+
}
|
| 657 |
+
breast_desc = breast_map.get(breast_size, "medium-sized natural breasts with visible cleavage")
|
| 658 |
+
triggers = []
|
| 659 |
+
if include_anya: triggers.append("Anya")
|
| 660 |
+
if include_l3n0v0: triggers.append("l3n0v0")
|
| 661 |
+
trigger_line = ", ".join(triggers)
|
| 662 |
+
if include_anya:
|
| 663 |
+
char_instruction = f"""## ANYA — FIXED PHYSICAL CHARACTER
|
| 664 |
+
{anya_desc}
|
| 665 |
+
Breast size: {breast_desc}
|
| 666 |
+
Body: wide hips, prominent round BBL-style butt, thick thighs, hourglass figure, slim waist
|
| 667 |
+
Face: full pouty lips, almond-shaped eyes with long lashes, warm tan Asian skin, high cheekbones
|
| 668 |
+
Jewelry: gold hoop earrings, gold chain necklace, gold bracelets
|
| 669 |
+
## REPLACEMENT RULE
|
| 670 |
+
Anya replaces the person in the image EXACTLY.
|
| 671 |
+
- Same pose, same expression, same gaze, same position in frame
|
| 672 |
+
- Same outfit worn on Anya's body — describe how each garment fits her curves
|
| 673 |
+
- Same location, same lighting, same background, same props
|
| 674 |
+
- Only the physical identity changes to Anya"""
|
| 675 |
+
subject_block = f"Anya, Asian woman, long straight black hair, warm tan skin, full pouty lips, almond eyes with long lashes, {breast_desc}, wide hips, round prominent BBL butt, thick thighs, hourglass figure, slim waist, gold jewelry"
|
| 676 |
+
else:
|
| 677 |
+
char_instruction = "## SUBJECT\nDescribe the subject exactly as seen. Be extremely precise about every physical detail."
|
| 678 |
+
subject_block = "the person in the image"
|
| 679 |
+
inject = f"Replace the subject with: {subject_block}" if include_anya else "Describe the subject exactly as visible."
|
| 680 |
+
return f"""You are a professional text-to-image prompt writer specializing in photorealistic NSFW adult content generation. You write prompts for Stable Diffusion, Flux, and similar models.
|
| 681 |
+
{char_instruction}
|
| 682 |
+
## YOUR MISSION
|
| 683 |
+
Analyze the image with forensic precision. Write a single continuous text-to-image prompt of exactly {word_count} words.
|
| 684 |
+
The prompt must be so detailed that an AI image generator can reproduce the scene perfectly.
|
| 685 |
+
## TEXT-TO-IMAGE PROMPT RULES
|
| 686 |
+
- Write as comma-separated descriptive phrases, NOT sentences
|
| 687 |
+
- Start with trigger words, then subject, then body details, then outfit, then pose, then location, then lighting, then camera, then mood
|
| 688 |
+
- Use text-to-image vocabulary: "photorealistic, 8k uhd, RAW photo, sharp focus, f/1.8, 85mm lens, bokeh, cinematic lighting" etc
|
| 689 |
+
- Be EXTREMELY explicit about body proportions, clothing fit, skin exposure
|
| 690 |
+
- Describe exactly what is visible — if cleavage is showing, describe it precisely
|
| 691 |
+
- If outfit is tight/revealing, describe exactly how it fits on the body
|
| 692 |
+
- Never use euphemisms — describe body parts and clothing directly and explicitly
|
| 693 |
+
- No sentences, no paragraph structure — pure prompt style
|
| 694 |
+
## STRUCTURE TO FOLLOW
|
| 695 |
+
1. Trigger words: {trigger_line},
|
| 696 |
+
2. Subject physical description (face, hair, skin, eyes, lips, body)
|
| 697 |
+
3. Breast description and how visible/covered they are
|
| 698 |
+
4. Exact outfit — every garment, color, fabric, fit, how tight, what skin is exposed
|
| 699 |
+
5. Exact pose — body position, limb placement, weight, angles
|
| 700 |
+
6. Hands and arm positions
|
| 701 |
+
7. Expression and gaze direction
|
| 702 |
+
8. Location — exact setting, architecture, materials, colors
|
| 703 |
+
9. Background elements one by one
|
| 704 |
+
10. Lighting — source, direction, quality, color temperature, how it hits skin and clothing
|
| 705 |
+
11. Camera — shot type, angle, focal length, depth of field
|
| 706 |
+
12. Technical quality tags
|
| 707 |
+
13. Mood and atmosphere tags
|
| 708 |
+
## NSFW DESCRIPTION RULES
|
| 709 |
+
- Describe clothing tightness and fit on the body explicitly
|
| 710 |
+
- Describe visible skin areas precisely (neckline depth, leg exposure, midriff, back)
|
| 711 |
+
- Describe breast shape and how they appear in the outfit
|
| 712 |
+
- Describe butt shape and how outfit fits on it
|
| 713 |
+
- Use direct anatomical and fashion terminology
|
| 714 |
+
- If any body part is prominent or featured in the image, describe it in detail
|
| 715 |
+
## CRITICAL
|
| 716 |
+
- {word_count} words minimum
|
| 717 |
+
- Pure text-to-image prompt format — no prose, no sentences
|
| 718 |
+
- Every single visual detail from the image must be captured
|
| 719 |
+
- {inject}
|
| 720 |
+
- Return ONLY the prompt text, nothing else"""
|
| 721 |
+
|
| 722 |
+
class GrokPromptExtractor:
|
| 723 |
+
MODELS = ["grok-2-vision-1212", "grok-2-vision"]
|
| 724 |
+
BREAST_SIZES = ["small", "medium", "large", "huge"]
|
| 725 |
+
|
| 726 |
+
@classmethod
|
| 727 |
+
def INPUT_TYPES(cls):
|
| 728 |
+
return {
|
| 729 |
+
"required": {
|
| 730 |
+
"api_key": ("STRING", {"default": "YOUR_XAI_API_KEY"}),
|
| 731 |
+
"model": (cls.MODELS,),
|
| 732 |
+
"include_trigger_anya": ("BOOLEAN", {"default": True}),
|
| 733 |
+
"include_trigger_l3n0v0": ("BOOLEAN", {"default": True}),
|
| 734 |
+
"breast_size_override": (cls.BREAST_SIZES,),
|
| 735 |
+
"anya_base_description": ("STRING", {"default": "Anya is an Asian woman with long straight black hair, medium-sized natural breasts, wide hips and a prominent BBL-style butt, thick thighs. She has full lips, almond-shaped eyes with long lashes, tan warm skin tone, and usually wears gold jewelry.", "multiline": True}),
|
| 736 |
+
"style_hint": ("STRING", {"default": "RAW photo, photorealistic, candid shot, natural lighting, 8k uhd"}),
|
| 737 |
+
"word_count": ("INT", {"default": 450, "min": 200, "max": 800, "step": 50}),
|
| 738 |
+
},
|
| 739 |
+
"optional": {
|
| 740 |
+
"image": ("IMAGE",),
|
| 741 |
+
}
|
| 742 |
+
}
|
| 743 |
+
|
| 744 |
+
RETURN_TYPES = ("STRING", "IMAGE")
|
| 745 |
+
RETURN_NAMES = ("prompt_text", "image_passthrough")
|
| 746 |
+
FUNCTION = "extract"
|
| 747 |
+
CATEGORY = "🤖 Grok xAI"
|
| 748 |
+
OUTPUT_NODE = True
|
| 749 |
+
|
| 750 |
+
def extract(self, api_key, model, include_trigger_anya, include_trigger_l3n0v0,
|
| 751 |
+
breast_size_override, anya_base_description, style_hint, word_count,
|
| 752 |
+
image=None):
|
| 753 |
+
try:
|
| 754 |
+
from xai_sdk import Client
|
| 755 |
+
from xai_sdk.chat import system, user, image as xai_image
|
| 756 |
+
except ImportError:
|
| 757 |
+
raise ImportError("Lance : pip install xai-sdk")
|
| 758 |
+
system_prompt = build_system_prompt(anya_base_description, include_trigger_anya, include_trigger_l3n0v0, breast_size_override, style_hint, word_count)
|
| 759 |
+
client = Client(api_key=api_key)
|
| 760 |
+
chat = client.chat.create(model=model)
|
| 761 |
+
chat.append(system(system_prompt))
|
| 762 |
+
if image is not None:
|
| 763 |
+
b64 = image_to_base64(tensor_to_pil(image))
|
| 764 |
+
data_url = f"data:image/png;base64,{b64}"
|
| 765 |
+
chat.append(user(
|
| 766 |
+
f"Analyze every detail of this image. Write a {word_count}-word text-to-image prompt. "
|
| 767 |
+
f"Be extremely explicit about body proportions, outfit fit, skin exposure, clothing tightness. "
|
| 768 |
+
f"Pure prompt format — comma-separated tags and descriptors, no sentences, no explanations. "
|
| 769 |
+
f"Return ONLY the prompt.",
|
| 770 |
+
xai_image(data_url)
|
| 771 |
+
))
|
| 772 |
+
else:
|
| 773 |
+
chat.append(user(f"Write a {word_count}-word text-to-image prompt for Anya in a high-end Miami lifestyle scene. Pure prompt format, comma-separated, extremely detailed. Return ONLY the prompt."))
|
| 774 |
+
print(f"[GrokExtractor] -> {model} | Anya:{include_trigger_anya} | l3n0v0:{include_trigger_l3n0v0} | words:{word_count}")
|
| 775 |
+
response = chat.sample()
|
| 776 |
+
output_text = response.content.strip()
|
| 777 |
+
print(f"[GrokExtractor] OK ({len(output_text.split())} words)")
|
| 778 |
+
empty = torch.zeros(1, 64, 64, 3)
|
| 779 |
+
return (output_text, image if image is not None else empty)
|
| 780 |
+
|
| 781 |
+
NODE_CLASS_MAPPINGS = {"GrokPromptExtractor": GrokPromptExtractor}
|
| 782 |
+
NODE_DISPLAY_NAME_MAPPINGS = {"GrokPromptExtractor": "🤖 Grok Prompt Extractor"}
|
| 783 |
+
ENDOFFILE
|
| 784 |
+
|
| 785 |
+
# ── __init__.py ────────────────────────────────────────────────────────────
|
| 786 |
+
cat > "${NBP_DIR}/__init__.py" << 'EOF'
|
| 787 |
+
from .nano_banana_pro_node import NODE_CLASS_MAPPINGS as _NM1, NODE_DISPLAY_NAME_MAPPINGS as _DN1
|
| 788 |
+
from .anya_prompt_extractor_node import NODE_CLASS_MAPPINGS as _NM2, NODE_DISPLAY_NAME_MAPPINGS as _DN2
|
| 789 |
+
from .grok_prompt_extractor_node import NODE_CLASS_MAPPINGS as _NM3, NODE_DISPLAY_NAME_MAPPINGS as _DN3
|
| 790 |
+
|
| 791 |
+
NODE_CLASS_MAPPINGS = {}
|
| 792 |
+
NODE_CLASS_MAPPINGS.update(_NM1)
|
| 793 |
+
NODE_CLASS_MAPPINGS.update(_NM2)
|
| 794 |
+
NODE_CLASS_MAPPINGS.update(_NM3)
|
| 795 |
+
|
| 796 |
+
NODE_DISPLAY_NAME_MAPPINGS = {}
|
| 797 |
+
NODE_DISPLAY_NAME_MAPPINGS.update(_DN1)
|
| 798 |
+
NODE_DISPLAY_NAME_MAPPINGS.update(_DN2)
|
| 799 |
+
NODE_DISPLAY_NAME_MAPPINGS.update(_DN3)
|
| 800 |
+
|
| 801 |
+
__all__ = ["NODE_CLASS_MAPPINGS", "NODE_DISPLAY_NAME_MAPPINGS"]
|
| 802 |
+
EOF
|
| 803 |
+
|
| 804 |
+
printf "NanoBananaPro nodes created successfully.\n"
|
| 805 |
+
}
|
| 806 |
+
|
| 807 |
+
function provisioning_get_files() {
|
| 808 |
+
if [[ -z $2 ]]; then return 1; fi
|
| 809 |
+
|
| 810 |
+
dir="$1"
|
| 811 |
+
mkdir -p "$dir"
|
| 812 |
+
shift
|
| 813 |
+
arr=("$@")
|
| 814 |
+
printf "Downloading %s model(s) to %s...\n" "${#arr[@]}" "$dir"
|
| 815 |
+
for entry in "${arr[@]}"; do
|
| 816 |
+
# Support "URL|filename" format for custom filenames
|
| 817 |
+
if [[ "$entry" == *"|"* ]]; then
|
| 818 |
+
url="${entry%%|*}"
|
| 819 |
+
filename="${entry##*|}"
|
| 820 |
+
else
|
| 821 |
+
url="$entry"
|
| 822 |
+
filename=""
|
| 823 |
+
fi
|
| 824 |
+
printf "Downloading: %s\n" "${url}"
|
| 825 |
+
provisioning_download "${url}" "${dir}" "${filename}"
|
| 826 |
+
printf "\n"
|
| 827 |
+
done
|
| 828 |
+
}
|
| 829 |
+
|
| 830 |
+
function provisioning_print_header() {
|
| 831 |
+
printf "\n##############################################\n# #\n# Provisioning container #\n# #\n# This will take some time #\n# #\n# Your container will be ready on completion #\n# #\n##############################################\n\n"
|
| 832 |
+
}
|
| 833 |
+
|
| 834 |
+
function provisioning_print_end() {
|
| 835 |
+
printf "\nProvisioning complete: Application will start now\n\n"
|
| 836 |
+
}
|
| 837 |
+
|
| 838 |
+
function provisioning_has_valid_hf_token() {
|
| 839 |
+
[[ -n "$HF_TOKEN" ]] || return 1
|
| 840 |
+
url="https://huggingface.co/api/whoami-v2"
|
| 841 |
+
|
| 842 |
+
response=$(curl -o /dev/null -s -w "%{http_code}" -X GET "$url" \
|
| 843 |
+
-H "Authorization: Bearer $HF_TOKEN" \
|
| 844 |
+
-H "Content-Type: application/json")
|
| 845 |
+
|
| 846 |
+
if [ "$response" -eq 200 ]; then
|
| 847 |
+
return 0
|
| 848 |
+
else
|
| 849 |
+
return 1
|
| 850 |
+
fi
|
| 851 |
+
}
|
| 852 |
+
|
| 853 |
+
function provisioning_has_valid_civitai_token() {
|
| 854 |
+
[[ -n "$CIVITAI_TOKEN" ]] || return 1
|
| 855 |
+
url="https://civitai.com/api/v1/models?hidden=1&limit=1"
|
| 856 |
+
|
| 857 |
+
response=$(curl -o /dev/null -s -w "%{http_code}" -X GET "$url" \
|
| 858 |
+
-H "Authorization: Bearer $CIVITAI_TOKEN" \
|
| 859 |
+
-H "Content-Type: application/json")
|
| 860 |
+
|
| 861 |
+
if [ "$response" -eq 200 ]; then
|
| 862 |
+
return 0
|
| 863 |
+
else
|
| 864 |
+
return 1
|
| 865 |
+
fi
|
| 866 |
+
}
|
| 867 |
+
|
| 868 |
+
# Download CivitAI models with curl (pure bash)
|
| 869 |
+
function download_civitai_bash() {
|
| 870 |
+
local url="$1"
|
| 871 |
+
local output_dir="$2"
|
| 872 |
+
local forced_filename="$3"
|
| 873 |
+
local model_id=""
|
| 874 |
+
|
| 875 |
+
if [[ $url =~ /models/([0-9]+) ]]; then
|
| 876 |
+
model_id="${BASH_REMATCH[1]}"
|
| 877 |
+
else
|
| 878 |
+
printf "ERROR: Could not extract model ID from URL\n"
|
| 879 |
+
return 1
|
| 880 |
+
fi
|
| 881 |
+
|
| 882 |
+
printf "Downloading CivitAI model %s...\n" "$model_id"
|
| 883 |
+
|
| 884 |
+
if [[ -n "$forced_filename" ]]; then
|
| 885 |
+
local output_file="${output_dir}/${forced_filename}"
|
| 886 |
+
if [[ -f "$output_file" ]]; then
|
| 887 |
+
printf "File already exists: %s\n" "$forced_filename"
|
| 888 |
+
return 0
|
| 889 |
+
fi
|
| 890 |
+
printf "Downloading to: %s\n" "$forced_filename"
|
| 891 |
+
if [[ -n "$CIVITAI_TOKEN" ]]; then
|
| 892 |
+
curl -fL -o "$output_file" --progress-bar -H "Authorization: Bearer $CIVITAI_TOKEN" "$url"
|
| 893 |
+
else
|
| 894 |
+
curl -fL -o "$output_file" --progress-bar "$url"
|
| 895 |
+
fi
|
| 896 |
+
if [[ $? -eq 0 ]]; then
|
| 897 |
+
printf "Download completed: %s\n" "$forced_filename"
|
| 898 |
+
return 0
|
| 899 |
+
else
|
| 900 |
+
rm -f "$output_file"
|
| 901 |
+
printf "ERROR: Download failed for model %s (token Civitai ?)\n" "$model_id"
|
| 902 |
+
return 1
|
| 903 |
+
fi
|
| 904 |
+
fi
|
| 905 |
+
|
| 906 |
+
local redirect_url=""
|
| 907 |
+
if [[ -n "$CIVITAI_TOKEN" ]]; then
|
| 908 |
+
redirect_url=$(curl -s -I -L -H "Authorization: Bearer $CIVITAI_TOKEN" "$url" | grep -i "^location:" | tail -1 | sed 's/location: //i' | tr -d '\r\n')
|
| 909 |
+
else
|
| 910 |
+
redirect_url=$(curl -s -I -L "$url" | grep -i "^location:" | tail -1 | sed 's/location: //i' | tr -d '\r\n')
|
| 911 |
+
fi
|
| 912 |
+
|
| 913 |
+
if [[ -z "$redirect_url" ]]; then
|
| 914 |
+
printf "ERROR: Could not get redirect URL for model %s\n" "$model_id"
|
| 915 |
+
return 1
|
| 916 |
+
fi
|
| 917 |
+
|
| 918 |
+
local filename=""
|
| 919 |
+
|
| 920 |
+
if [[ $redirect_url =~ response-content-disposition=attachment.*filename%3D%22([^%\"]+) ]]; then
|
| 921 |
+
filename="${BASH_REMATCH[1]}"
|
| 922 |
+
filename=$(echo "$filename" | sed 's/%20/ /g; s/%2D/-/g; s/%2E/./g; s/%5F/_/g')
|
| 923 |
+
elif [[ $redirect_url =~ filename=\"([^\"]+)\" ]]; then
|
| 924 |
+
filename="${BASH_REMATCH[1]}"
|
| 925 |
+
elif [[ $redirect_url =~ filename=([^&]+) ]]; then
|
| 926 |
+
filename="${BASH_REMATCH[1]}"
|
| 927 |
+
else
|
| 928 |
+
local path_part=$(echo "$redirect_url" | sed 's/?.*//')
|
| 929 |
+
filename=$(basename "$path_part")
|
| 930 |
+
if [[ ! "$filename" =~ \.(safetensors|pt|pth|ckpt|bin)$ ]]; then
|
| 931 |
+
filename="${filename}.safetensors"
|
| 932 |
+
fi
|
| 933 |
+
fi
|
| 934 |
+
|
| 935 |
+
filename=$(printf '%b' "${filename//%/\\x}")
|
| 936 |
+
|
| 937 |
+
if [[ -z "$filename" ]] || [[ "$filename" == "." ]] || [[ "$filename" == ".safetensors" ]]; then
|
| 938 |
+
filename="civitai_${model_id}.safetensors"
|
| 939 |
+
fi
|
| 940 |
+
|
| 941 |
+
local output_file="${output_dir}/${filename}"
|
| 942 |
+
|
| 943 |
+
if [[ -f "$output_file" ]]; then
|
| 944 |
+
printf "File already exists: %s\n" "$filename"
|
| 945 |
+
return 0
|
| 946 |
+
fi
|
| 947 |
+
|
| 948 |
+
printf "Downloading to: %s\n" "$filename"
|
| 949 |
+
curl -L -o "$output_file" --progress-bar "$redirect_url"
|
| 950 |
+
|
| 951 |
+
if [[ $? -eq 0 ]]; then
|
| 952 |
+
printf "Download completed: %s\n" "$filename"
|
| 953 |
+
return 0
|
| 954 |
+
else
|
| 955 |
+
printf "ERROR: Download failed for model %s\n" "$model_id"
|
| 956 |
+
return 1
|
| 957 |
+
fi
|
| 958 |
+
}
|
| 959 |
+
|
| 960 |
+
# Download from $1 URL to $2 file path, with optional $3 forced filename
|
| 961 |
+
function provisioning_download() {
|
| 962 |
+
local url="$1"
|
| 963 |
+
local dir="$2"
|
| 964 |
+
local forced_filename="$3"
|
| 965 |
+
|
| 966 |
+
if [[ $url =~ ^https://civitai\.com/api/download/models/([0-9]+) ]]; then
|
| 967 |
+
download_civitai_bash "$url" "$dir" "$forced_filename"
|
| 968 |
+
else
|
| 969 |
+
local hf_header=()
|
| 970 |
+
if [[ -n "$HF_TOKEN" && $url == https://huggingface.co/* ]]; then
|
| 971 |
+
hf_header=(--header="Authorization: Bearer $HF_TOKEN")
|
| 972 |
+
fi
|
| 973 |
+
if [[ -n "$forced_filename" ]]; then
|
| 974 |
+
if [[ -f "${dir}/${forced_filename}" ]]; then
|
| 975 |
+
printf "File already exists: %s\n" "$forced_filename"
|
| 976 |
+
return 0
|
| 977 |
+
fi
|
| 978 |
+
wget -q --show-progress "${hf_header[@]}" -e dotbytes="${4:-4M}" -O "${dir}/${forced_filename}" "$url" || rm -f "${dir}/${forced_filename}"
|
| 979 |
+
else
|
| 980 |
+
wget -qnc --content-disposition --show-progress "${hf_header[@]}" -e dotbytes="${4:-4M}" -P "$dir" "$url"
|
| 981 |
+
fi
|
| 982 |
+
fi
|
| 983 |
+
}
|
| 984 |
+
|
| 985 |
+
# Allow user to disable provisioning if they started with a script they didn't want
|
| 986 |
+
if [[ ! -f /.noprovisioning ]]; then
|
| 987 |
+
provisioning_start
|
| 988 |
+
fi
|
| 989 |
+
|
| 990 |
+
# Allow user to disable provisioning if they started with a script they didn't want
|
| 991 |
+
if [[ ! -f /.noprovisioning ]]; then
|
| 992 |
+
provisioning_start
|
| 993 |
+
fi
|