Update krea.sh
Browse files
krea.sh
CHANGED
|
@@ -4,8 +4,8 @@
|
|
| 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
|
| 8 |
-
# CIVITAI_TOKEN (
|
| 9 |
# HF_TOKEN (optionnel)
|
| 10 |
# AUTO_UPDATE (optionnel, "false" pour ne pas mettre à jour ComfyUI / nodes)
|
| 11 |
# =============================================================================
|
|
@@ -13,13 +13,14 @@
|
|
| 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=(
|
|
@@ -75,32 +76,32 @@ LORA_MODELS=(
|
|
| 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
|
| 79 |
-
"https://civitai.com/api/download/models/3371956
|
| 80 |
-
"https://civitai.com/api/download/models/3278885
|
| 81 |
-
"https://civitai.com/api/download/models/3147117
|
| 82 |
-
"https://civitai.com/api/download/models/3066079
|
| 83 |
-
"https://civitai.com/api/download/models/3359022
|
| 84 |
-
"https://civitai.com/api/download/models/3141485
|
| 85 |
-
"https://civitai.com/api/download/models/3109006
|
| 86 |
-
"https://civitai.com/api/download/models/3390681
|
| 87 |
-
"https://civitai.com/api/download/models/3116175
|
| 88 |
-
"https://civitai.com/api/download/models/3221218
|
| 89 |
-
"https://civitai.com/api/download/models/2268008
|
| 90 |
-
"https://civitai.com/api/download/models/1862761
|
| 91 |
-
# --- Ta LoRA perso (model01)
|
| 92 |
"https://huggingface.co/nathanglm/sofia/resolve/main/model01.safetensors|model01.safetensors"
|
| 93 |
|
| 94 |
# --- SDXL (détailleurs SDXL du workflow Krea2 v1.5) ---
|
| 95 |
# Décommente si tu utilises les détailleurs SDXL, sinon bypass-les dans le workflow.
|
| 96 |
-
#"https://civitai.com/api/download/models/368603
|
| 97 |
-
#"https://civitai.com/api/download/models/712004
|
| 98 |
-
#"https://civitai.com/api/download/models/216946
|
| 99 |
)
|
| 100 |
|
| 101 |
# SDXL (Pre-Definer). Nom forcé = celui attendu par le workflow.
|
| 102 |
CHECKPOINT_MODELS=(
|
| 103 |
-
"https://civitai.com/api/download/models/1621447
|
| 104 |
)
|
| 105 |
|
| 106 |
# GGUF : plus utilisé avec Krea 2 (le loader GGUF est en bypass dans le workflow)
|
|
@@ -146,7 +147,6 @@ function provisioning_start() {
|
|
| 146 |
provisioning_get_nodes
|
| 147 |
provisioning_get_pip_packages
|
| 148 |
provisioning_fix_flash_attn
|
| 149 |
-
provisioning_create_nanobananapro
|
| 150 |
provisioning_get_files "${COMFYUI_DIR}/models/diffusion_models" "${DIFFUSION_MODELS[@]}"
|
| 151 |
provisioning_get_files "${COMFYUI_DIR}/models/text_encoders" "${TEXT_ENCODERS[@]}"
|
| 152 |
provisioning_get_files "${COMFYUI_DIR}/models/vae" "${VAE_MODELS[@]}"
|
|
@@ -191,7 +191,7 @@ function provisioning_fix_flash_attn() {
|
|
| 191 |
}
|
| 192 |
|
| 193 |
function provisioning_report_bad_files() {
|
| 194 |
-
# Un téléchargement
|
| 195 |
printf "\nChecking for failed downloads...\n"
|
| 196 |
find "${COMFYUI_DIR}/models" -type f \( -name "*.safetensors" -o -name "*.pt" -o -name "*.pth" \) -size -100k 2>/dev/null | while read -r f; do
|
| 197 |
printf "⚠️ Fichier suspect (trop petit, probablement un échec) : %s\n" "$f"
|
|
@@ -243,583 +243,9 @@ function provisioning_get_nodes() {
|
|
| 243 |
done
|
| 244 |
}
|
| 245 |
|
| 246 |
-
function provisioning_create_nanobananapro() {
|
| 247 |
-
local NBP_DIR="${COMFYUI_DIR}/custom_nodes/NanoBananaPro"
|
| 248 |
-
printf "Creating NanoBananaPro custom nodes...\n"
|
| 249 |
-
mkdir -p "${NBP_DIR}"
|
| 250 |
-
|
| 251 |
-
# ── nano_banana_pro_node.py ────────────────────────────────────────────────
|
| 252 |
-
cat > "${NBP_DIR}/nano_banana_pro_node.py" << 'ENDOFFILE'
|
| 253 |
-
"""
|
| 254 |
-
🍌 Nano Banana Pro Node — ComfyUI
|
| 255 |
-
Supporte :
|
| 256 |
-
- Nano Banana 2 = gemini-3.1-flash-image-preview (NOUVEAU, recommandé)
|
| 257 |
-
- Nano Banana Pro = gemini-3-pro-image-preview (⚠️ déprécié le 9 mars 2026)
|
| 258 |
-
- Nano Banana = gemini-2.5-flash-image (stable, rapide)
|
| 259 |
-
Modes :
|
| 260 |
-
- generate : text-to-image pur
|
| 261 |
-
- edit : image editing (envoyer une image + prompt)
|
| 262 |
-
Résolutions : 0.5K, 1K, 2K, 4K
|
| 263 |
-
"""
|
| 264 |
-
|
| 265 |
-
import torch, numpy as np, io, random
|
| 266 |
-
from PIL import Image, ImageEnhance
|
| 267 |
-
|
| 268 |
-
def pil_to_tensor(image):
|
| 269 |
-
img = image.convert("RGB")
|
| 270 |
-
arr = np.array(img).astype(np.float32) / 255.0
|
| 271 |
-
return torch.from_numpy(arr).unsqueeze(0)
|
| 272 |
-
|
| 273 |
-
def tensor_to_pil(tensor):
|
| 274 |
-
arr = tensor.squeeze(0).numpy()
|
| 275 |
-
arr = (arr * 255).clip(0, 255).astype(np.uint8)
|
| 276 |
-
return Image.fromarray(arr)
|
| 277 |
-
|
| 278 |
-
def pil_to_bytes(image):
|
| 279 |
-
buf = io.BytesIO()
|
| 280 |
-
image.save(buf, format="PNG")
|
| 281 |
-
return buf.getvalue()
|
| 282 |
-
|
| 283 |
-
def apply_color_grade(image, brightness, contrast, saturation, temperature, sharpness):
|
| 284 |
-
img = image.convert("RGB")
|
| 285 |
-
if brightness != 1.0:
|
| 286 |
-
img = ImageEnhance.Brightness(img).enhance(brightness)
|
| 287 |
-
if contrast != 1.0:
|
| 288 |
-
img = ImageEnhance.Contrast(img).enhance(contrast)
|
| 289 |
-
if saturation != 1.0:
|
| 290 |
-
img = ImageEnhance.Color(img).enhance(saturation)
|
| 291 |
-
if temperature != 0.0:
|
| 292 |
-
r, g, b = img.split()
|
| 293 |
-
r_arr = np.array(r, dtype=np.float32)
|
| 294 |
-
b_arr = np.array(b, dtype=np.float32)
|
| 295 |
-
strength = abs(temperature) * 30
|
| 296 |
-
if temperature > 0:
|
| 297 |
-
r_arr = np.clip(r_arr + strength, 0, 255)
|
| 298 |
-
b_arr = np.clip(b_arr - strength * 0.5, 0, 255)
|
| 299 |
-
else:
|
| 300 |
-
r_arr = np.clip(r_arr - strength * 0.5, 0, 255)
|
| 301 |
-
b_arr = np.clip(b_arr + strength, 0, 255)
|
| 302 |
-
img = Image.merge("RGB", (
|
| 303 |
-
Image.fromarray(r_arr.astype(np.uint8)),
|
| 304 |
-
g,
|
| 305 |
-
Image.fromarray(b_arr.astype(np.uint8))
|
| 306 |
-
))
|
| 307 |
-
if sharpness != 1.0:
|
| 308 |
-
img = ImageEnhance.Sharpness(img).enhance(sharpness)
|
| 309 |
-
return img
|
| 310 |
-
|
| 311 |
-
|
| 312 |
-
class NanaBananaProNode:
|
| 313 |
-
MODELS = [
|
| 314 |
-
"gemini-3.1-flash-image-preview",
|
| 315 |
-
"gemini-2.5-flash-image",
|
| 316 |
-
"gemini-3-pro-image-preview",
|
| 317 |
-
]
|
| 318 |
-
MODES = ["generate", "edit"]
|
| 319 |
-
SAFETY = ["OFF", "BLOCK_ONLY_HIGH", "BLOCK_MEDIUM_AND_ABOVE", "BLOCK_LOW_AND_ABOVE"]
|
| 320 |
-
RATIOS = ["1:1", "9:16", "16:9", "2:3", "3:2", "4:3", "3:4", "21:9", "1:4", "4:1"]
|
| 321 |
-
QUALITY = ["1K", "2K", "4K", "0.5K"]
|
| 322 |
-
AFTER_GEN = ["randomize", "fixed", "increment"]
|
| 323 |
-
|
| 324 |
-
@classmethod
|
| 325 |
-
def INPUT_TYPES(cls):
|
| 326 |
-
return {
|
| 327 |
-
"required": {
|
| 328 |
-
"prompt": ("STRING", {"default": "A stunning photorealistic portrait, ultra detailed", "multiline": True}),
|
| 329 |
-
"model": (cls.MODELS,),
|
| 330 |
-
"mode": (cls.MODES,),
|
| 331 |
-
"aspect_ratio": (cls.RATIOS,),
|
| 332 |
-
"quality": (cls.QUALITY,),
|
| 333 |
-
"temperature": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 2.0, "step": 0.05}),
|
| 334 |
-
"top_p": ("FLOAT", {"default": 0.95, "min": 0.0, "max": 1.0, "step": 0.01}),
|
| 335 |
-
"top_k": ("INT", {"default": 0, "min": 0, "max": 100, "step": 1}),
|
| 336 |
-
"seed": ("INT", {"default": -1, "min": -1, "max": 2**31,"step": 1}),
|
| 337 |
-
"control_after_generate": (cls.AFTER_GEN,),
|
| 338 |
-
"safety_threshold": (cls.SAFETY,),
|
| 339 |
-
"api_key": ("STRING", {"default": "YOUR_GEMINI_API_KEY"}),
|
| 340 |
-
"cg_brightness": ("FLOAT", {"default": 1.0, "min": 0.1, "max": 3.0, "step": 0.05}),
|
| 341 |
-
"cg_contrast": ("FLOAT", {"default": 1.0, "min": 0.1, "max": 3.0, "step": 0.05}),
|
| 342 |
-
"cg_saturation": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 3.0, "step": 0.05}),
|
| 343 |
-
"cg_temperature": ("FLOAT", {"default": 0.0, "min": -1.0,"max": 1.0, "step": 0.05}),
|
| 344 |
-
"cg_sharpness": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 3.0, "step": 0.05}),
|
| 345 |
-
},
|
| 346 |
-
"optional": {
|
| 347 |
-
"edit_image": ("IMAGE",),
|
| 348 |
-
"ref_image_1": ("IMAGE",),
|
| 349 |
-
"ref_image_2": ("IMAGE",),
|
| 350 |
-
"ref_image_3": ("IMAGE",),
|
| 351 |
-
"ref_image_4": ("IMAGE",),
|
| 352 |
-
"ref_image_5": ("IMAGE",),
|
| 353 |
-
"ref_image_6": ("IMAGE",),
|
| 354 |
-
"ref_image_7": ("IMAGE",),
|
| 355 |
-
}
|
| 356 |
-
}
|
| 357 |
-
|
| 358 |
-
RETURN_TYPES = ("IMAGE", "STRING")
|
| 359 |
-
RETURN_NAMES = ("image", "metadata")
|
| 360 |
-
FUNCTION = "generate"
|
| 361 |
-
CATEGORY = "🍌 Nano Banana Pro"
|
| 362 |
-
|
| 363 |
-
def generate(self, prompt, model, mode, aspect_ratio, quality, temperature, top_p, top_k,
|
| 364 |
-
seed, control_after_generate, safety_threshold, api_key,
|
| 365 |
-
cg_brightness, cg_contrast, cg_saturation, cg_temperature, cg_sharpness,
|
| 366 |
-
edit_image=None, ref_image_1=None, ref_image_2=None, ref_image_3=None,
|
| 367 |
-
ref_image_4=None, ref_image_5=None, ref_image_6=None, ref_image_7=None):
|
| 368 |
-
try:
|
| 369 |
-
from google import genai
|
| 370 |
-
from google.genai import types
|
| 371 |
-
except ImportError:
|
| 372 |
-
raise ImportError("Lance : pip install google-genai")
|
| 373 |
-
|
| 374 |
-
if seed == -1 or control_after_generate == "randomize":
|
| 375 |
-
actual_seed = random.randint(0, 2**31)
|
| 376 |
-
elif control_after_generate == "increment":
|
| 377 |
-
actual_seed = seed + 1
|
| 378 |
-
else:
|
| 379 |
-
actual_seed = seed
|
| 380 |
-
|
| 381 |
-
client = genai.Client(api_key=api_key)
|
| 382 |
-
|
| 383 |
-
safety_settings = []
|
| 384 |
-
if safety_threshold != "OFF":
|
| 385 |
-
harm_categories = [
|
| 386 |
-
"HARM_CATEGORY_HARASSMENT",
|
| 387 |
-
"HARM_CATEGORY_HATE_SPEECH",
|
| 388 |
-
"HARM_CATEGORY_SEXUALLY_EXPLICIT",
|
| 389 |
-
"HARM_CATEGORY_DANGEROUS_CONTENT"
|
| 390 |
-
]
|
| 391 |
-
safety_settings = [types.SafetySetting(category=cat, threshold=safety_threshold) for cat in harm_categories]
|
| 392 |
-
|
| 393 |
-
parts = []
|
| 394 |
-
|
| 395 |
-
if mode == "edit" and edit_image is not None:
|
| 396 |
-
parts.append(types.Part.from_bytes(
|
| 397 |
-
data=pil_to_bytes(tensor_to_pil(edit_image)),
|
| 398 |
-
mime_type="image/png"
|
| 399 |
-
))
|
| 400 |
-
|
| 401 |
-
ref_images = [ref_image_1, ref_image_2, ref_image_3, ref_image_4,
|
| 402 |
-
ref_image_5, ref_image_6, ref_image_7]
|
| 403 |
-
for ref in ref_images:
|
| 404 |
-
if ref is not None:
|
| 405 |
-
parts.append(types.Part.from_bytes(
|
| 406 |
-
data=pil_to_bytes(tensor_to_pil(ref)),
|
| 407 |
-
mime_type="image/png"
|
| 408 |
-
))
|
| 409 |
-
|
| 410 |
-
parts.append(types.Part.from_text(text=prompt))
|
| 411 |
-
|
| 412 |
-
gen_config_kwargs = dict(
|
| 413 |
-
response_modalities=["TEXT", "IMAGE"],
|
| 414 |
-
temperature=temperature,
|
| 415 |
-
top_p=top_p,
|
| 416 |
-
image_config=types.ImageConfig(
|
| 417 |
-
aspect_ratio=aspect_ratio,
|
| 418 |
-
image_size=quality
|
| 419 |
-
),
|
| 420 |
-
)
|
| 421 |
-
if top_k > 0:
|
| 422 |
-
gen_config_kwargs["top_k"] = top_k
|
| 423 |
-
if safety_settings:
|
| 424 |
-
gen_config_kwargs["safety_settings"] = safety_settings
|
| 425 |
-
|
| 426 |
-
gen_config = types.GenerateContentConfig(**gen_config_kwargs)
|
| 427 |
-
|
| 428 |
-
print(f"[NanaBanana] -> {model} | mode:{mode} | quality:{quality} | safety:{safety_threshold}")
|
| 429 |
-
|
| 430 |
-
response = client.models.generate_content(
|
| 431 |
-
model=model,
|
| 432 |
-
contents=parts,
|
| 433 |
-
config=gen_config
|
| 434 |
-
)
|
| 435 |
-
|
| 436 |
-
if not response.candidates:
|
| 437 |
-
raise RuntimeError(f"[NanaBanana] Aucun candidat: {response}")
|
| 438 |
-
|
| 439 |
-
candidate = response.candidates[0]
|
| 440 |
-
finish_reason = str(getattr(candidate, "finish_reason", ""))
|
| 441 |
-
if "SAFETY" in finish_reason:
|
| 442 |
-
raise RuntimeError("[NanaBanana] Bloque par IMAGE_SAFETY. Reformule le prompt.")
|
| 443 |
-
|
| 444 |
-
content = getattr(candidate, "content", None)
|
| 445 |
-
if content is None or not getattr(content, "parts", None):
|
| 446 |
-
raise RuntimeError(f"[NanaBanana] Content vide. finish_reason: {finish_reason}")
|
| 447 |
-
|
| 448 |
-
result_image, info_text = None, ""
|
| 449 |
-
for part in content.parts:
|
| 450 |
-
if hasattr(part, "text") and part.text:
|
| 451 |
-
info_text += part.text + "\n"
|
| 452 |
-
elif hasattr(part, "inline_data") and part.inline_data:
|
| 453 |
-
result_image = Image.open(io.BytesIO(part.inline_data.data)).convert("RGB")
|
| 454 |
-
|
| 455 |
-
if result_image is None:
|
| 456 |
-
raise RuntimeError(f"[NanaBanana] Aucune image generee. Texte: {info_text or '(aucun)'}")
|
| 457 |
-
|
| 458 |
-
result_image = apply_color_grade(
|
| 459 |
-
result_image,
|
| 460 |
-
cg_brightness, cg_contrast, cg_saturation, cg_temperature, cg_sharpness
|
| 461 |
-
)
|
| 462 |
-
|
| 463 |
-
metadata = (
|
| 464 |
-
f"model: {model}\n"
|
| 465 |
-
f"mode: {mode}\n"
|
| 466 |
-
f"seed: {actual_seed}\n"
|
| 467 |
-
f"temperature: {temperature} | top_p: {top_p} | top_k: {top_k}\n"
|
| 468 |
-
f"aspect_ratio: {aspect_ratio} | quality: {quality}\n"
|
| 469 |
-
f"safety: {safety_threshold}\n"
|
| 470 |
-
f"{info_text.strip()}"
|
| 471 |
-
)
|
| 472 |
-
print(f"[NanaBanana] Succes ! ({quality})")
|
| 473 |
-
return (pil_to_tensor(result_image), metadata)
|
| 474 |
-
|
| 475 |
-
|
| 476 |
-
NODE_CLASS_MAPPINGS = {"NanaBananaProNode": NanaBananaProNode}
|
| 477 |
-
NODE_DISPLAY_NAME_MAPPINGS = {"NanaBananaProNode": "🍌 Nano Banana Pro"}
|
| 478 |
-
ENDOFFILE
|
| 479 |
-
|
| 480 |
-
# ── anya_prompt_extractor_node.py ──────────────────────────────────────────
|
| 481 |
-
cat > "${NBP_DIR}/anya_prompt_extractor_node.py" << 'ENDOFFILE'
|
| 482 |
-
import torch, numpy as np, io, json
|
| 483 |
-
from PIL import Image
|
| 484 |
-
|
| 485 |
-
def tensor_to_pil(tensor):
|
| 486 |
-
arr = tensor.squeeze(0).numpy()
|
| 487 |
-
arr = (arr * 255).clip(0, 255).astype(np.uint8)
|
| 488 |
-
return Image.fromarray(arr)
|
| 489 |
-
|
| 490 |
-
def pil_to_bytes(image):
|
| 491 |
-
buf = io.BytesIO()
|
| 492 |
-
image.save(buf, format="PNG")
|
| 493 |
-
return buf.getvalue()
|
| 494 |
-
|
| 495 |
-
def build_system_prompt(anya_desc, include_anya, include_l3n0v0, breast_size, style_hint, use_ref_images, num_refs, ref_descs_list):
|
| 496 |
-
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"}
|
| 497 |
-
breast_desc = breast_map.get(breast_size, "medium-sized natural breasts")
|
| 498 |
-
triggers = []
|
| 499 |
-
if include_anya: triggers.append("Anya")
|
| 500 |
-
if include_l3n0v0: triggers.append("l3n0v0")
|
| 501 |
-
triggers_str = json.dumps(triggers)
|
| 502 |
-
if include_anya:
|
| 503 |
-
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": "..."}}'
|
| 504 |
-
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."
|
| 505 |
-
else:
|
| 506 |
-
subject_block = ' "subject": {"description": "...", "pose": "...", "expression": "...", "gaze": "..."}'
|
| 507 |
-
subject_instruction = "## SUBJECT\nDescribe the subject from the reference image exactly. Reproduce face, hair, skin tone, body proportions 1:1. No changes, no beautification."
|
| 508 |
-
if use_ref_images and num_refs > 0:
|
| 509 |
-
ref_labels = ["subject_identity"] + [f"reference_image_{i}" for i in range(2, num_refs+1)]
|
| 510 |
-
ref_entries = []
|
| 511 |
-
for i in range(num_refs):
|
| 512 |
-
label = ref_labels[i] if i < len(ref_labels) else f"reference_image_{i+1}"
|
| 513 |
-
desc = ref_descs_list[i] if i < len(ref_descs_list) and ref_descs_list[i].strip() else f"uploaded_reference_image_{i+1}"
|
| 514 |
-
ref_entries.append(f' "{label}": "{desc}"')
|
| 515 |
-
ref_block = ' "reference_images": {\n' + ',\n'.join(ref_entries) + '\n },'
|
| 516 |
-
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)])
|
| 517 |
-
else:
|
| 518 |
-
ref_block = ""
|
| 519 |
-
ref_instruction = "## REFERENCE IMAGES\nNo reference images."
|
| 520 |
-
ref_section = f"\n{ref_block}" if ref_block else ""
|
| 521 |
-
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."
|
| 522 |
-
return f"""You are an expert AI image prompt engineer specializing in structured JSON prompts.
|
| 523 |
-
{subject_instruction}
|
| 524 |
-
{ref_instruction}
|
| 525 |
-
## OUTPUT RULES
|
| 526 |
-
- Return ONLY valid JSON, no markdown, no backticks, no explanation
|
| 527 |
-
- trigger_words must be exactly: {triggers_str}
|
| 528 |
-
{{
|
| 529 |
-
"trigger_words": {triggers_str},{ref_section}
|
| 530 |
-
"output_quality": {{"resolution": "4K", "definition": "ultra high resolution", "sharpness": "natural realistic detail, not overprocessed"}},
|
| 531 |
-
{subject_block},
|
| 532 |
-
"outfit": {{"description": "...", "colors": [...], "fit": "...", "fabric": "..."}},
|
| 533 |
-
"location": {{"setting": "...", "environment": [...], "time_of_day": "...", "lighting": "...", "atmosphere": "..."}},
|
| 534 |
-
"image_type": {{"orientation": "...", "aspect_ratio": "...", "style": "{style_hint}", "camera_feel": "...", "color_grading": "..."}},
|
| 535 |
-
"identity_preservation": {{"facial_identity": "...", "no_changes": ["bone_structure", "facial_proportions", "skin_tone", "hairline", "facial_features"], "no_beautification": true, "no_stylization": true}},
|
| 536 |
-
"realism_constraints": {{"no_extra_limbs": true, "no_ai_symmetry_correction": true, "natural_skin_texture": true, "natural_light_behavior": true, "no_heavy_color_grading": true}},
|
| 537 |
-
"image_feel": [...]
|
| 538 |
-
}}
|
| 539 |
-
Analyze the provided image(s): extract scene, lighting, pose, outfit, mood. {inject_note} Return ONLY the JSON."""
|
| 540 |
-
|
| 541 |
-
class AnyaPromptExtractor:
|
| 542 |
-
MODELS = ["gemini-2.5-flash-preview-05-20", "gemini-2.5-flash", "gemini-2.5-pro", "gemini-3-pro-image-preview"]
|
| 543 |
-
BREAST_SIZES = ["small", "medium", "large", "huge"]
|
| 544 |
-
NUM_REFS = ["0", "1", "2", "3", "4", "5"]
|
| 545 |
-
|
| 546 |
-
@classmethod
|
| 547 |
-
def INPUT_TYPES(cls):
|
| 548 |
-
return {
|
| 549 |
-
"required": {
|
| 550 |
-
"api_key": ("STRING", {"default": "YOUR_GEMINI_API_KEY"}),
|
| 551 |
-
"model": (cls.MODELS,),
|
| 552 |
-
"include_trigger_anya": ("BOOLEAN", {"default": True}),
|
| 553 |
-
"include_trigger_l3n0v0": ("BOOLEAN", {"default": True}),
|
| 554 |
-
"breast_size_override": (cls.BREAST_SIZES,),
|
| 555 |
-
"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}),
|
| 556 |
-
"style_hint": ("STRING", {"default": "natural high-end lifestyle, candid editorial"}),
|
| 557 |
-
"json_indent": ("INT", {"default": 4, "min": 0, "max": 8, "step": 1}),
|
| 558 |
-
"use_reference_images": ("BOOLEAN", {"default": True}),
|
| 559 |
-
"num_reference_images": (cls.NUM_REFS,),
|
| 560 |
-
"ref_1_description": ("STRING", {"default": "subject identity — main model reference"}),
|
| 561 |
-
"ref_2_description": ("STRING", {"default": "outfit reference"}),
|
| 562 |
-
"ref_3_description": ("STRING", {"default": "location or background reference"}),
|
| 563 |
-
"ref_4_description": ("STRING", {"default": "style or mood reference"}),
|
| 564 |
-
"ref_5_description": ("STRING", {"default": "additional reference"}),
|
| 565 |
-
},
|
| 566 |
-
"optional": {
|
| 567 |
-
"scene_image": ("IMAGE",),
|
| 568 |
-
"ref_image_1": ("IMAGE",),
|
| 569 |
-
"ref_image_2": ("IMAGE",),
|
| 570 |
-
"ref_image_3": ("IMAGE",),
|
| 571 |
-
"ref_image_4": ("IMAGE",),
|
| 572 |
-
"ref_image_5": ("IMAGE",),
|
| 573 |
-
}
|
| 574 |
-
}
|
| 575 |
-
|
| 576 |
-
RETURN_TYPES = ("STRING", "IMAGE", "IMAGE", "IMAGE", "IMAGE", "IMAGE", "IMAGE")
|
| 577 |
-
RETURN_NAMES = ("prompt_json", "scene_passthrough", "ref_1_passthrough", "ref_2_passthrough", "ref_3_passthrough", "ref_4_passthrough", "ref_5_passthrough")
|
| 578 |
-
FUNCTION = "extract"
|
| 579 |
-
CATEGORY = "🍌 Nano Banana Pro"
|
| 580 |
-
OUTPUT_NODE = True
|
| 581 |
-
|
| 582 |
-
def extract(self, api_key, model, include_trigger_anya, include_trigger_l3n0v0,
|
| 583 |
-
breast_size_override, anya_base_description, style_hint, json_indent,
|
| 584 |
-
use_reference_images, num_reference_images,
|
| 585 |
-
ref_1_description, ref_2_description, ref_3_description,
|
| 586 |
-
ref_4_description, ref_5_description,
|
| 587 |
-
scene_image=None, ref_image_1=None, ref_image_2=None,
|
| 588 |
-
ref_image_3=None, ref_image_4=None, ref_image_5=None):
|
| 589 |
-
try:
|
| 590 |
-
from google import genai
|
| 591 |
-
from google.genai import types
|
| 592 |
-
except ImportError:
|
| 593 |
-
raise ImportError("Lance : pip install google-genai")
|
| 594 |
-
num_refs = int(num_reference_images)
|
| 595 |
-
ref_descs_list = [ref_1_description, ref_2_description, ref_3_description, ref_4_description, ref_5_description]
|
| 596 |
-
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)
|
| 597 |
-
client = genai.Client(api_key=api_key)
|
| 598 |
-
parts = []
|
| 599 |
-
if scene_image is not None:
|
| 600 |
-
parts.append(types.Part.from_bytes(data=pil_to_bytes(tensor_to_pil(scene_image)), mime_type="image/png"))
|
| 601 |
-
if use_reference_images and num_refs > 0:
|
| 602 |
-
ref_images_list = [ref_image_1, ref_image_2, ref_image_3, ref_image_4, ref_image_5]
|
| 603 |
-
for i in range(min(num_refs, 5)):
|
| 604 |
-
ref = ref_images_list[i]
|
| 605 |
-
if ref is not None:
|
| 606 |
-
desc = ref_descs_list[i] if ref_descs_list[i].strip() else f"reference image {i+1}"
|
| 607 |
-
parts.append(types.Part.from_text(text=f"[Reference image {i+1}: {desc}]"))
|
| 608 |
-
parts.append(types.Part.from_bytes(data=pil_to_bytes(tensor_to_pil(ref)), mime_type="image/png"))
|
| 609 |
-
if not parts:
|
| 610 |
-
parts.append(types.Part.from_text(text="No image provided. Generate a generic lifestyle JSON prompt. Return ONLY the JSON."))
|
| 611 |
-
else:
|
| 612 |
-
parts.append(types.Part.from_text(text="Analyze the provided image(s) and generate the structured JSON prompt. Return ONLY the JSON."))
|
| 613 |
-
config = types.GenerateContentConfig(system_instruction=system_prompt, response_modalities=["TEXT"], temperature=0.4, top_p=0.9)
|
| 614 |
-
print(f"[AnyaExtractor] -> {model} | Anya:{include_trigger_anya} | l3n0v0:{include_trigger_l3n0v0} | refs:{num_refs if use_reference_images else 0}")
|
| 615 |
-
response = client.models.generate_content(model=model, contents=parts, config=config)
|
| 616 |
-
raw_parts = response.parts or []
|
| 617 |
-
raw_text = "".join(part.text for part in raw_parts if hasattr(part, "text") and part.text).strip()
|
| 618 |
-
if not raw_text and hasattr(response, "candidates") and response.candidates:
|
| 619 |
-
raw_text = "".join(part.text for part in (response.candidates[0].content.parts or []) if hasattr(part, "text") and part.text).strip()
|
| 620 |
-
if not raw_text:
|
| 621 |
-
raise RuntimeError(f"[AnyaExtractor] Reponse vide. Modele: {model} | Verifier la cle API ou changer de modele.")
|
| 622 |
-
if raw_text.startswith("```"):
|
| 623 |
-
lines = raw_text.split("\n")
|
| 624 |
-
raw_text = "\n".join(lines[1:-1] if lines[-1].strip() == "```" else lines[1:]).strip()
|
| 625 |
-
try:
|
| 626 |
-
parsed = json.loads(raw_text)
|
| 627 |
-
tw = parsed.get("trigger_words", [])
|
| 628 |
-
if include_trigger_anya and "Anya" not in tw: tw.insert(0, "Anya")
|
| 629 |
-
if not include_trigger_anya and "Anya" in tw: tw.remove("Anya")
|
| 630 |
-
if include_trigger_l3n0v0 and "l3n0v0" not in tw: tw.append("l3n0v0")
|
| 631 |
-
if not include_trigger_l3n0v0 and "l3n0v0" in tw: tw.remove("l3n0v0")
|
| 632 |
-
parsed["trigger_words"] = tw
|
| 633 |
-
output_json = json.dumps(parsed, indent=json_indent, ensure_ascii=False)
|
| 634 |
-
except json.JSONDecodeError as e:
|
| 635 |
-
print(f"[AnyaExtractor] JSON invalide: {e}")
|
| 636 |
-
output_json = raw_text
|
| 637 |
-
print(f"[AnyaExtractor] Succes ({len(output_json)} chars)")
|
| 638 |
-
empty = torch.zeros(1, 64, 64, 3)
|
| 639 |
-
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)
|
| 640 |
-
|
| 641 |
-
NODE_CLASS_MAPPINGS = {"AnyaPromptExtractor": AnyaPromptExtractor}
|
| 642 |
-
NODE_DISPLAY_NAME_MAPPINGS = {"AnyaPromptExtractor": "🔍 Anya Prompt Extractor"}
|
| 643 |
-
ENDOFFILE
|
| 644 |
-
|
| 645 |
-
# ── grok_prompt_extractor_node.py ──────────────────────────────────────────
|
| 646 |
-
cat > "${NBP_DIR}/grok_prompt_extractor_node.py" << 'ENDOFFILE'
|
| 647 |
-
import torch, numpy as np, io, base64
|
| 648 |
-
from PIL import Image
|
| 649 |
-
|
| 650 |
-
def tensor_to_pil(tensor):
|
| 651 |
-
arr = tensor.squeeze(0).numpy()
|
| 652 |
-
arr = (arr * 255).clip(0, 255).astype(np.uint8)
|
| 653 |
-
return Image.fromarray(arr)
|
| 654 |
-
|
| 655 |
-
def pil_to_bytes(image):
|
| 656 |
-
buf = io.BytesIO()
|
| 657 |
-
image.save(buf, format="PNG")
|
| 658 |
-
return buf.getvalue()
|
| 659 |
-
|
| 660 |
-
def image_to_base64(image):
|
| 661 |
-
return base64.b64encode(pil_to_bytes(image)).decode("utf-8")
|
| 662 |
-
|
| 663 |
-
def build_system_prompt(anya_desc, include_anya, include_l3n0v0, breast_size, style_hint, word_count):
|
| 664 |
-
breast_map = {
|
| 665 |
-
"small": "small perky breasts",
|
| 666 |
-
"medium": "medium-sized natural breasts with visible cleavage",
|
| 667 |
-
"large": "large full breasts with natural weight and deep cleavage",
|
| 668 |
-
"huge": "very large heavy breasts, extremely voluptuous silhouette"
|
| 669 |
-
}
|
| 670 |
-
breast_desc = breast_map.get(breast_size, "medium-sized natural breasts with visible cleavage")
|
| 671 |
-
triggers = []
|
| 672 |
-
if include_anya: triggers.append("Anya")
|
| 673 |
-
if include_l3n0v0: triggers.append("l3n0v0")
|
| 674 |
-
trigger_line = ", ".join(triggers)
|
| 675 |
-
if include_anya:
|
| 676 |
-
char_instruction = f"""## ANYA — FIXED PHYSICAL CHARACTER
|
| 677 |
-
{anya_desc}
|
| 678 |
-
Breast size: {breast_desc}
|
| 679 |
-
Body: wide hips, prominent round BBL-style butt, thick thighs, hourglass figure, slim waist
|
| 680 |
-
Face: full pouty lips, almond-shaped eyes with long lashes, warm tan Asian skin, high cheekbones
|
| 681 |
-
Jewelry: gold hoop earrings, gold chain necklace, gold bracelets
|
| 682 |
-
## REPLACEMENT RULE
|
| 683 |
-
Anya replaces the person in the image EXACTLY.
|
| 684 |
-
- Same pose, same expression, same gaze, same position in frame
|
| 685 |
-
- Same outfit worn on Anya's body — describe how each garment fits her curves
|
| 686 |
-
- Same location, same lighting, same background, same props
|
| 687 |
-
- Only the physical identity changes to Anya"""
|
| 688 |
-
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"
|
| 689 |
-
else:
|
| 690 |
-
char_instruction = "## SUBJECT\nDescribe the subject exactly as seen. Be extremely precise about every physical detail."
|
| 691 |
-
subject_block = "the person in the image"
|
| 692 |
-
inject = f"Replace the subject with: {subject_block}" if include_anya else "Describe the subject exactly as visible."
|
| 693 |
-
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.
|
| 694 |
-
{char_instruction}
|
| 695 |
-
## YOUR MISSION
|
| 696 |
-
Analyze the image with forensic precision. Write a single continuous text-to-image prompt of exactly {word_count} words.
|
| 697 |
-
The prompt must be so detailed that an AI image generator can reproduce the scene perfectly.
|
| 698 |
-
## TEXT-TO-IMAGE PROMPT RULES
|
| 699 |
-
- Write as comma-separated descriptive phrases, NOT sentences
|
| 700 |
-
- Start with trigger words, then subject, then body details, then outfit, then pose, then location, then lighting, then camera, then mood
|
| 701 |
-
- Use text-to-image vocabulary: "photorealistic, 8k uhd, RAW photo, sharp focus, f/1.8, 85mm lens, bokeh, cinematic lighting" etc
|
| 702 |
-
- Be EXTREMELY explicit about body proportions, clothing fit, skin exposure
|
| 703 |
-
- Describe exactly what is visible — if cleavage is showing, describe it precisely
|
| 704 |
-
- If outfit is tight/revealing, describe exactly how it fits on the body
|
| 705 |
-
- Never use euphemisms — describe body parts and clothing directly and explicitly
|
| 706 |
-
- No sentences, no paragraph structure — pure prompt style
|
| 707 |
-
## STRUCTURE TO FOLLOW
|
| 708 |
-
1. Trigger words: {trigger_line},
|
| 709 |
-
2. Subject physical description (face, hair, skin, eyes, lips, body)
|
| 710 |
-
3. Breast description and how visible/covered they are
|
| 711 |
-
4. Exact outfit — every garment, color, fabric, fit, how tight, what skin is exposed
|
| 712 |
-
5. Exact pose — body position, limb placement, weight, angles
|
| 713 |
-
6. Hands and arm positions
|
| 714 |
-
7. Expression and gaze direction
|
| 715 |
-
8. Location — exact setting, architecture, materials, colors
|
| 716 |
-
9. Background elements one by one
|
| 717 |
-
10. Lighting — source, direction, quality, color temperature, how it hits skin and clothing
|
| 718 |
-
11. Camera — shot type, angle, focal length, depth of field
|
| 719 |
-
12. Technical quality tags
|
| 720 |
-
13. Mood and atmosphere tags
|
| 721 |
-
## NSFW DESCRIPTION RULES
|
| 722 |
-
- Describe clothing tightness and fit on the body explicitly
|
| 723 |
-
- Describe visible skin areas precisely (neckline depth, leg exposure, midriff, back)
|
| 724 |
-
- Describe breast shape and how they appear in the outfit
|
| 725 |
-
- Describe butt shape and how outfit fits on it
|
| 726 |
-
- Use direct anatomical and fashion terminology
|
| 727 |
-
- If any body part is prominent or featured in the image, describe it in detail
|
| 728 |
-
## CRITICAL
|
| 729 |
-
- {word_count} words minimum
|
| 730 |
-
- Pure text-to-image prompt format — no prose, no sentences
|
| 731 |
-
- Every single visual detail from the image must be captured
|
| 732 |
-
- {inject}
|
| 733 |
-
- Return ONLY the prompt text, nothing else"""
|
| 734 |
-
|
| 735 |
-
class GrokPromptExtractor:
|
| 736 |
-
MODELS = ["grok-2-vision-1212", "grok-2-vision"]
|
| 737 |
-
BREAST_SIZES = ["small", "medium", "large", "huge"]
|
| 738 |
-
|
| 739 |
-
@classmethod
|
| 740 |
-
def INPUT_TYPES(cls):
|
| 741 |
-
return {
|
| 742 |
-
"required": {
|
| 743 |
-
"api_key": ("STRING", {"default": "YOUR_XAI_API_KEY"}),
|
| 744 |
-
"model": (cls.MODELS,),
|
| 745 |
-
"include_trigger_anya": ("BOOLEAN", {"default": True}),
|
| 746 |
-
"include_trigger_l3n0v0": ("BOOLEAN", {"default": True}),
|
| 747 |
-
"breast_size_override": (cls.BREAST_SIZES,),
|
| 748 |
-
"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}),
|
| 749 |
-
"style_hint": ("STRING", {"default": "RAW photo, photorealistic, candid shot, natural lighting, 8k uhd"}),
|
| 750 |
-
"word_count": ("INT", {"default": 450, "min": 200, "max": 800, "step": 50}),
|
| 751 |
-
},
|
| 752 |
-
"optional": {
|
| 753 |
-
"image": ("IMAGE",),
|
| 754 |
-
}
|
| 755 |
-
}
|
| 756 |
-
|
| 757 |
-
RETURN_TYPES = ("STRING", "IMAGE")
|
| 758 |
-
RETURN_NAMES = ("prompt_text", "image_passthrough")
|
| 759 |
-
FUNCTION = "extract"
|
| 760 |
-
CATEGORY = "🤖 Grok xAI"
|
| 761 |
-
OUTPUT_NODE = True
|
| 762 |
-
|
| 763 |
-
def extract(self, api_key, model, include_trigger_anya, include_trigger_l3n0v0,
|
| 764 |
-
breast_size_override, anya_base_description, style_hint, word_count,
|
| 765 |
-
image=None):
|
| 766 |
-
try:
|
| 767 |
-
from xai_sdk import Client
|
| 768 |
-
from xai_sdk.chat import system, user, image as xai_image
|
| 769 |
-
except ImportError:
|
| 770 |
-
raise ImportError("Lance : pip install xai-sdk")
|
| 771 |
-
system_prompt = build_system_prompt(anya_base_description, include_trigger_anya, include_trigger_l3n0v0, breast_size_override, style_hint, word_count)
|
| 772 |
-
client = Client(api_key=api_key)
|
| 773 |
-
chat = client.chat.create(model=model)
|
| 774 |
-
chat.append(system(system_prompt))
|
| 775 |
-
if image is not None:
|
| 776 |
-
b64 = image_to_base64(tensor_to_pil(image))
|
| 777 |
-
data_url = f"data:image/png;base64,{b64}"
|
| 778 |
-
chat.append(user(
|
| 779 |
-
f"Analyze every detail of this image. Write a {word_count}-word text-to-image prompt. "
|
| 780 |
-
f"Be extremely explicit about body proportions, outfit fit, skin exposure, clothing tightness. "
|
| 781 |
-
f"Pure prompt format — comma-separated tags and descriptors, no sentences, no explanations. "
|
| 782 |
-
f"Return ONLY the prompt.",
|
| 783 |
-
xai_image(data_url)
|
| 784 |
-
))
|
| 785 |
-
else:
|
| 786 |
-
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."))
|
| 787 |
-
print(f"[GrokExtractor] -> {model} | Anya:{include_trigger_anya} | l3n0v0:{include_trigger_l3n0v0} | words:{word_count}")
|
| 788 |
-
response = chat.sample()
|
| 789 |
-
output_text = response.content.strip()
|
| 790 |
-
print(f"[GrokExtractor] OK ({len(output_text.split())} words)")
|
| 791 |
-
empty = torch.zeros(1, 64, 64, 3)
|
| 792 |
-
return (output_text, image if image is not None else empty)
|
| 793 |
-
|
| 794 |
-
NODE_CLASS_MAPPINGS = {"GrokPromptExtractor": GrokPromptExtractor}
|
| 795 |
-
NODE_DISPLAY_NAME_MAPPINGS = {"GrokPromptExtractor": "🤖 Grok Prompt Extractor"}
|
| 796 |
-
ENDOFFILE
|
| 797 |
-
|
| 798 |
-
# ── __init__.py ────────────────────────────────────────────────────────────
|
| 799 |
-
cat > "${NBP_DIR}/__init__.py" << 'EOF'
|
| 800 |
-
from .nano_banana_pro_node import NODE_CLASS_MAPPINGS as _NM1, NODE_DISPLAY_NAME_MAPPINGS as _DN1
|
| 801 |
-
from .anya_prompt_extractor_node import NODE_CLASS_MAPPINGS as _NM2, NODE_DISPLAY_NAME_MAPPINGS as _DN2
|
| 802 |
-
from .grok_prompt_extractor_node import NODE_CLASS_MAPPINGS as _NM3, NODE_DISPLAY_NAME_MAPPINGS as _DN3
|
| 803 |
-
|
| 804 |
-
NODE_CLASS_MAPPINGS = {}
|
| 805 |
-
NODE_CLASS_MAPPINGS.update(_NM1)
|
| 806 |
-
NODE_CLASS_MAPPINGS.update(_NM2)
|
| 807 |
-
NODE_CLASS_MAPPINGS.update(_NM3)
|
| 808 |
-
|
| 809 |
-
NODE_DISPLAY_NAME_MAPPINGS = {}
|
| 810 |
-
NODE_DISPLAY_NAME_MAPPINGS.update(_DN1)
|
| 811 |
-
NODE_DISPLAY_NAME_MAPPINGS.update(_DN2)
|
| 812 |
-
NODE_DISPLAY_NAME_MAPPINGS.update(_DN3)
|
| 813 |
-
|
| 814 |
-
__all__ = ["NODE_CLASS_MAPPINGS", "NODE_DISPLAY_NAME_MAPPINGS"]
|
| 815 |
-
EOF
|
| 816 |
-
|
| 817 |
-
printf "NanoBananaPro nodes created successfully.\n"
|
| 818 |
-
}
|
| 819 |
-
|
| 820 |
function provisioning_get_files() {
|
| 821 |
if [[ -z $2 ]]; then return 1; fi
|
| 822 |
-
|
| 823 |
dir="$1"
|
| 824 |
mkdir -p "$dir"
|
| 825 |
shift
|
|
@@ -850,127 +276,51 @@ function provisioning_print_end() {
|
|
| 850 |
|
| 851 |
function provisioning_has_valid_hf_token() {
|
| 852 |
[[ -n "$HF_TOKEN" ]] || return 1
|
| 853 |
-
|
| 854 |
-
|
| 855 |
-
response=$(curl -o /dev/null -s -w "%{http_code}" -X GET "$url" \
|
| 856 |
-H "Authorization: Bearer $HF_TOKEN" \
|
| 857 |
-
|
| 858 |
-
|
| 859 |
-
if [ "$response" -eq 200 ]; then
|
| 860 |
-
return 0
|
| 861 |
-
else
|
| 862 |
-
return 1
|
| 863 |
-
fi
|
| 864 |
}
|
| 865 |
|
| 866 |
function provisioning_has_valid_civitai_token() {
|
| 867 |
-
[[ -n "
|
| 868 |
-
|
| 869 |
-
|
| 870 |
-
|
| 871 |
-
|
| 872 |
-
-H "Content-Type: application/json")
|
| 873 |
-
|
| 874 |
-
if [ "$response" -eq 200 ]; then
|
| 875 |
-
return 0
|
| 876 |
-
else
|
| 877 |
-
return 1
|
| 878 |
-
fi
|
| 879 |
}
|
| 880 |
|
| 881 |
-
#
|
| 882 |
function download_civitai_bash() {
|
| 883 |
-
local url="$1"
|
| 884 |
-
local output_dir="$2"
|
| 885 |
-
local forced_filename="$3"
|
| 886 |
local model_id=""
|
| 887 |
-
|
| 888 |
-
|
| 889 |
-
|
| 890 |
-
|
| 891 |
-
|
| 892 |
-
|
| 893 |
-
|
| 894 |
-
|
| 895 |
-
printf "Downloading CivitAI model %s...\n" "$model_id"
|
| 896 |
-
|
| 897 |
-
if [[ -n "$forced_filename" ]]; then
|
| 898 |
-
local output_file="${output_dir}/${forced_filename}"
|
| 899 |
-
if [[ -f "$output_file" ]]; then
|
| 900 |
-
printf "File already exists: %s\n" "$forced_filename"
|
| 901 |
-
return 0
|
| 902 |
-
fi
|
| 903 |
-
printf "Downloading to: %s\n" "$forced_filename"
|
| 904 |
-
if [[ -n "ee2791108127cd78eb0217b6207b4fe2" ]]; then
|
| 905 |
-
curl -fL -o "$output_file" --progress-bar -H "Authorization: Bearer ee2791108127cd78eb0217b6207b4fe2" "$url"
|
| 906 |
-
else
|
| 907 |
-
curl -fL -o "$output_file" --progress-bar "$url"
|
| 908 |
-
fi
|
| 909 |
-
if [[ $? -eq 0 ]]; then
|
| 910 |
-
printf "Download completed: %s\n" "$forced_filename"
|
| 911 |
-
return 0
|
| 912 |
-
else
|
| 913 |
-
rm -f "$output_file"
|
| 914 |
-
printf "ERROR: Download failed for model %s (token Civitai ?)\n" "$model_id"
|
| 915 |
-
return 1
|
| 916 |
-
fi
|
| 917 |
-
fi
|
| 918 |
-
|
| 919 |
-
local redirect_url=""
|
| 920 |
-
if [[ -n "ee2791108127cd78eb0217b6207b4fe2" ]]; then
|
| 921 |
-
redirect_url=$(curl -s -I -L -H "Authorization: Bearer ee2791108127cd78eb0217b6207b4fe2" "$url" | grep -i "^location:" | tail -1 | sed 's/location: //i' | tr -d '\r\n')
|
| 922 |
-
else
|
| 923 |
-
redirect_url=$(curl -s -I -L "$url" | grep -i "^location:" | tail -1 | sed 's/location: //i' | tr -d '\r\n')
|
| 924 |
-
fi
|
| 925 |
-
|
| 926 |
-
if [[ -z "$redirect_url" ]]; then
|
| 927 |
-
printf "ERROR: Could not get redirect URL for model %s\n" "$model_id"
|
| 928 |
-
return 1
|
| 929 |
-
fi
|
| 930 |
-
|
| 931 |
-
local filename=""
|
| 932 |
-
|
| 933 |
-
if [[ $redirect_url =~ response-content-disposition=attachment.*filename%3D%22([^%\"]+) ]]; then
|
| 934 |
-
filename="${BASH_REMATCH[1]}"
|
| 935 |
-
filename=$(echo "$filename" | sed 's/%20/ /g; s/%2D/-/g; s/%2E/./g; s/%5F/_/g')
|
| 936 |
-
elif [[ $redirect_url =~ filename=\"([^\"]+)\" ]]; then
|
| 937 |
-
filename="${BASH_REMATCH[1]}"
|
| 938 |
-
elif [[ $redirect_url =~ filename=([^&]+) ]]; then
|
| 939 |
-
filename="${BASH_REMATCH[1]}"
|
| 940 |
-
else
|
| 941 |
-
local path_part=$(echo "$redirect_url" | sed 's/?.*//')
|
| 942 |
-
filename=$(basename "$path_part")
|
| 943 |
-
if [[ ! "$filename" =~ \.(safetensors|pt|pth|ckpt|bin)$ ]]; then
|
| 944 |
-
filename="${filename}.safetensors"
|
| 945 |
-
fi
|
| 946 |
-
fi
|
| 947 |
-
|
| 948 |
-
filename=$(printf '%b' "${filename//%/\\x}")
|
| 949 |
-
|
| 950 |
-
if [[ -z "$filename" ]] || [[ "$filename" == "." ]] || [[ "$filename" == ".safetensors" ]]; then
|
| 951 |
-
filename="civitai_${model_id}.safetensors"
|
| 952 |
-
fi
|
| 953 |
-
|
| 954 |
-
local output_file="${output_dir}/${filename}"
|
| 955 |
-
|
| 956 |
if [[ -f "$output_file" ]]; then
|
| 957 |
-
printf "File already exists: %s\n" "$
|
| 958 |
return 0
|
| 959 |
fi
|
| 960 |
-
|
| 961 |
-
printf "Downloading to: %s\n" "$
|
| 962 |
-
|
| 963 |
-
|
| 964 |
-
if [[ $
|
| 965 |
-
|
| 966 |
-
|
| 967 |
-
|
| 968 |
-
|
| 969 |
return 1
|
| 970 |
fi
|
|
|
|
| 971 |
}
|
| 972 |
|
| 973 |
-
# Download from $1 URL to $2
|
| 974 |
function provisioning_download() {
|
| 975 |
local url="$1"
|
| 976 |
local dir="$2"
|
|
@@ -995,11 +345,6 @@ function provisioning_download() {
|
|
| 995 |
fi
|
| 996 |
}
|
| 997 |
|
| 998 |
-
# Allow user to disable provisioning if they started with a script they didn't want
|
| 999 |
-
if [[ ! -f /.noprovisioning ]]; then
|
| 1000 |
-
provisioning_start
|
| 1001 |
-
fi
|
| 1002 |
-
|
| 1003 |
# Allow user to disable provisioning if they started with a script they didn't want
|
| 1004 |
if [[ ! -f /.noprovisioning ]]; then
|
| 1005 |
provisioning_start
|
|
|
|
| 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 (optionnelles, prioritaires sur les valeurs ci-dessous) :
|
| 8 |
+
# CIVITAI_TOKEN (sinon la valeur en dur ci-dessous est utilisée)
|
| 9 |
# HF_TOKEN (optionnel)
|
| 10 |
# AUTO_UPDATE (optionnel, "false" pour ne pas mettre à jour ComfyUI / nodes)
|
| 11 |
# =============================================================================
|
|
|
|
| 13 |
source /venv/main/bin/activate
|
| 14 |
COMFYUI_DIR=${WORKSPACE}/ComfyUI
|
| 15 |
|
| 16 |
+
# Token Civitai : la variable d'env du template Vast prend le dessus si elle existe
|
| 17 |
+
CIVITAI_TOKEN="${CIVITAI_TOKEN:-4ec3d116d2d1de7a3cf02563118d8c21}"
|
| 18 |
+
|
| 19 |
APT_PACKAGES=(
|
| 20 |
"tree"
|
| 21 |
)
|
| 22 |
|
| 23 |
PIP_PACKAGES=(
|
|
|
|
|
|
|
| 24 |
)
|
| 25 |
|
| 26 |
NODES=(
|
|
|
|
| 76 |
"https://huggingface.co/Patil/Krea-2-depth-controlnet/resolve/main/depth-control-lora.safetensors|depth-control-lora.safetensors"
|
| 77 |
"https://huggingface.co/AliveAi/Krea-2-Edit-Outfit-Transfer/resolve/main/krea_outfittransfer.safetensors|krea_outfittransfer.safetensors"
|
| 78 |
|
| 79 |
+
# --- Krea 2 : LoRA Civitai ---
|
| 80 |
+
"https://civitai.com/api/download/models/3371956|K2-Casual-Snapshot-Realism-v2.safetensors"
|
| 81 |
+
"https://civitai.com/api/download/models/3278885|K2-Famegrid-Spicy.safetensors"
|
| 82 |
+
"https://civitai.com/api/download/models/3147117|K2-NSFW-v4.safetensors"
|
| 83 |
+
"https://civitai.com/api/download/models/3066079|K2-Raw-to-Turbo-r256.safetensors"
|
| 84 |
+
"https://civitai.com/api/download/models/3359022|K2-TextFusion-Refusal-Reduction-v2.safetensors"
|
| 85 |
+
"https://civitai.com/api/download/models/3141485|K2-RawGirlSpicy-v3.safetensors"
|
| 86 |
+
"https://civitai.com/api/download/models/3109006|K2-Realism-Engine-v3.safetensors"
|
| 87 |
+
"https://civitai.com/api/download/models/3390681|K2-SNOFS-v1.5.safetensors"
|
| 88 |
+
"https://civitai.com/api/download/models/3116175|K2-Mystic-XXX-v3.safetensors"
|
| 89 |
+
"https://civitai.com/api/download/models/3221218|K2-Excessive-Cum.safetensors"
|
| 90 |
+
"https://civitai.com/api/download/models/2268008|K2-Realistic-Snapshot-v1.safetensors" # ⚠️ vérifie que 2268008 est bien un ID de VERSION
|
| 91 |
+
"https://civitai.com/api/download/models/1862761|K2-NiceGirls-UltraReal-v1.safetensors" # ⚠️ vérifie que 1862761 est bien un ID de VERSION
|
| 92 |
+
# --- Ta LoRA perso (model01) ---
|
| 93 |
"https://huggingface.co/nathanglm/sofia/resolve/main/model01.safetensors|model01.safetensors"
|
| 94 |
|
| 95 |
# --- SDXL (détailleurs SDXL du workflow Krea2 v1.5) ---
|
| 96 |
# Décommente si tu utilises les détailleurs SDXL, sinon bypass-les dans le workflow.
|
| 97 |
+
#"https://civitai.com/api/download/models/368603|SDXL-Detailed-Nipples-v1.safetensors"
|
| 98 |
+
#"https://civitai.com/api/download/models/712004|SDXL-Real-Pussy-Lotte.safetensors"
|
| 99 |
+
#"https://civitai.com/api/download/models/216946|SDXL-Penis-XL-v1.safetensors"
|
| 100 |
)
|
| 101 |
|
| 102 |
# SDXL (Pre-Definer). Nom forcé = celui attendu par le workflow.
|
| 103 |
CHECKPOINT_MODELS=(
|
| 104 |
+
"https://civitai.com/api/download/models/1621447|sdxl-iniversemix.safetensors"
|
| 105 |
)
|
| 106 |
|
| 107 |
# GGUF : plus utilisé avec Krea 2 (le loader GGUF est en bypass dans le workflow)
|
|
|
|
| 147 |
provisioning_get_nodes
|
| 148 |
provisioning_get_pip_packages
|
| 149 |
provisioning_fix_flash_attn
|
|
|
|
| 150 |
provisioning_get_files "${COMFYUI_DIR}/models/diffusion_models" "${DIFFUSION_MODELS[@]}"
|
| 151 |
provisioning_get_files "${COMFYUI_DIR}/models/text_encoders" "${TEXT_ENCODERS[@]}"
|
| 152 |
provisioning_get_files "${COMFYUI_DIR}/models/vae" "${VAE_MODELS[@]}"
|
|
|
|
| 191 |
}
|
| 192 |
|
| 193 |
function provisioning_report_bad_files() {
|
| 194 |
+
# Un téléchargement refusé produit un petit fichier HTML/JSON au lieu du modèle
|
| 195 |
printf "\nChecking for failed downloads...\n"
|
| 196 |
find "${COMFYUI_DIR}/models" -type f \( -name "*.safetensors" -o -name "*.pt" -o -name "*.pth" \) -size -100k 2>/dev/null | while read -r f; do
|
| 197 |
printf "⚠️ Fichier suspect (trop petit, probablement un échec) : %s\n" "$f"
|
|
|
|
| 243 |
done
|
| 244 |
}
|
| 245 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 246 |
function provisioning_get_files() {
|
| 247 |
if [[ -z $2 ]]; then return 1; fi
|
| 248 |
+
|
| 249 |
dir="$1"
|
| 250 |
mkdir -p "$dir"
|
| 251 |
shift
|
|
|
|
| 276 |
|
| 277 |
function provisioning_has_valid_hf_token() {
|
| 278 |
[[ -n "$HF_TOKEN" ]] || return 1
|
| 279 |
+
local code
|
| 280 |
+
code=$(curl -o /dev/null -s -w "%{http_code}" \
|
|
|
|
| 281 |
-H "Authorization: Bearer $HF_TOKEN" \
|
| 282 |
+
"https://huggingface.co/api/whoami-v2")
|
| 283 |
+
[[ "$code" -eq 200 ]]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 284 |
}
|
| 285 |
|
| 286 |
function provisioning_has_valid_civitai_token() {
|
| 287 |
+
[[ -n "$CIVITAI_TOKEN" ]] || return 1
|
| 288 |
+
local code
|
| 289 |
+
code=$(curl -o /dev/null -s -w "%{http_code}" \
|
| 290 |
+
"https://civitai.com/api/v1/models?hidden=1&limit=1&token=${CIVITAI_TOKEN}")
|
| 291 |
+
[[ "$code" -eq 200 ]]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 292 |
}
|
| 293 |
|
| 294 |
+
# Téléchargement Civitai : token passé en paramètre d'URL, code HTTP affiché en cas d'échec
|
| 295 |
function download_civitai_bash() {
|
| 296 |
+
local url="$1" output_dir="$2" forced_filename="$3"
|
|
|
|
|
|
|
| 297 |
local model_id=""
|
| 298 |
+
[[ $url =~ /models/([0-9]+) ]] && model_id="${BASH_REMATCH[1]}"
|
| 299 |
+
|
| 300 |
+
local sep="?"; [[ "$url" == *"?"* ]] && sep="&"
|
| 301 |
+
local full_url="${url}${sep}token=${CIVITAI_TOKEN}"
|
| 302 |
+
local name="${forced_filename:-civitai_${model_id}.safetensors}"
|
| 303 |
+
local output_file="${output_dir}/${name}"
|
| 304 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 305 |
if [[ -f "$output_file" ]]; then
|
| 306 |
+
printf "File already exists: %s\n" "$name"
|
| 307 |
return 0
|
| 308 |
fi
|
| 309 |
+
|
| 310 |
+
printf "Downloading CivitAI model %s to: %s\n" "$model_id" "$name"
|
| 311 |
+
local code
|
| 312 |
+
code=$(curl -L --progress-bar -w "%{http_code}" -o "$output_file" "$full_url")
|
| 313 |
+
if [[ "$code" != "200" ]]; then
|
| 314 |
+
rm -f "$output_file"
|
| 315 |
+
printf "ERROR %s pour le modèle %s\n" "$code" "$model_id"
|
| 316 |
+
[[ "$code" == "404" ]] && printf " -> ID de version invalide ou fichier introuvable\n"
|
| 317 |
+
[[ "$code" == "401" || "$code" == "403" ]] && printf " -> problème de token Civitai\n"
|
| 318 |
return 1
|
| 319 |
fi
|
| 320 |
+
printf "Download completed: %s\n" "$name"
|
| 321 |
}
|
| 322 |
|
| 323 |
+
# Download from $1 URL to $2 dir, with optional $3 forced filename
|
| 324 |
function provisioning_download() {
|
| 325 |
local url="$1"
|
| 326 |
local dir="$2"
|
|
|
|
| 345 |
fi
|
| 346 |
}
|
| 347 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 348 |
# Allow user to disable provisioning if they started with a script they didn't want
|
| 349 |
if [[ ! -f /.noprovisioning ]]; then
|
| 350 |
provisioning_start
|