Update installer.sh
Browse files- installer.sh +361 -3
installer.sh
CHANGED
|
@@ -11,8 +11,8 @@ APT_PACKAGES=(
|
|
| 11 |
)
|
| 12 |
|
| 13 |
PIP_PACKAGES=(
|
| 14 |
-
|
| 15 |
-
|
| 16 |
)
|
| 17 |
|
| 18 |
NODES=(
|
|
@@ -33,6 +33,7 @@ NODES=(
|
|
| 33 |
"https://github.com/city96/ComfyUI-GGUF"
|
| 34 |
"https://github.com/kijai/ComfyUI-KJNodes"
|
| 35 |
"https://github.com/Suzie1/ComfyUI_Comfyroll_CustomNodes"
|
|
|
|
| 36 |
)
|
| 37 |
|
| 38 |
WORKFLOWS=(
|
|
@@ -118,6 +119,7 @@ function provisioning_start() {
|
|
| 118 |
provisioning_get_apt_packages
|
| 119 |
provisioning_get_nodes
|
| 120 |
provisioning_get_pip_packages
|
|
|
|
| 121 |
provisioning_get_files \
|
| 122 |
"${COMFYUI_DIR}/models/sams" \
|
| 123 |
"${SAMS[@]}"
|
|
@@ -189,6 +191,362 @@ function provisioning_get_nodes() {
|
|
| 189 |
done
|
| 190 |
}
|
| 191 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 192 |
function provisioning_get_files() {
|
| 193 |
if [[ -z $2 ]]; then return 1; fi
|
| 194 |
|
|
@@ -247,7 +605,7 @@ function provisioning_has_valid_civitai_token() {
|
|
| 247 |
# Check if the token is valid
|
| 248 |
if [ "$response" -eq 200 ]; then
|
| 249 |
return 0
|
| 250 |
-
|
| 251 |
return 1
|
| 252 |
fi
|
| 253 |
}
|
|
|
|
| 11 |
)
|
| 12 |
|
| 13 |
PIP_PACKAGES=(
|
| 14 |
+
"google-genai"
|
| 15 |
+
"xai-sdk"
|
| 16 |
)
|
| 17 |
|
| 18 |
NODES=(
|
|
|
|
| 33 |
"https://github.com/city96/ComfyUI-GGUF"
|
| 34 |
"https://github.com/kijai/ComfyUI-KJNodes"
|
| 35 |
"https://github.com/Suzie1/ComfyUI_Comfyroll_CustomNodes"
|
| 36 |
+
"https://github.com/pythongosssss/ComfyUI-Custom-Scripts"
|
| 37 |
)
|
| 38 |
|
| 39 |
WORKFLOWS=(
|
|
|
|
| 119 |
provisioning_get_apt_packages
|
| 120 |
provisioning_get_nodes
|
| 121 |
provisioning_get_pip_packages
|
| 122 |
+
provisioning_create_nanobananapro
|
| 123 |
provisioning_get_files \
|
| 124 |
"${COMFYUI_DIR}/models/sams" \
|
| 125 |
"${SAMS[@]}"
|
|
|
|
| 191 |
done
|
| 192 |
}
|
| 193 |
|
| 194 |
+
function provisioning_create_nanobananapro() {
|
| 195 |
+
local NBP_DIR="${COMFYUI_DIR}/custom_nodes/NanoBananaPro"
|
| 196 |
+
printf "Creating NanoBananaPro custom nodes...\n"
|
| 197 |
+
mkdir -p "${NBP_DIR}"
|
| 198 |
+
|
| 199 |
+
# ββ anya_prompt_extractor_node.py ββββββββββββββββββββββββββββββββββββββββββ
|
| 200 |
+
cat > "${NBP_DIR}/anya_prompt_extractor_node.py" << 'ENDOFFILE'
|
| 201 |
+
import torch, numpy as np, io, json
|
| 202 |
+
from PIL import Image
|
| 203 |
+
|
| 204 |
+
def tensor_to_pil(tensor):
|
| 205 |
+
arr = tensor.squeeze(0).numpy()
|
| 206 |
+
arr = (arr * 255).clip(0, 255).astype(np.uint8)
|
| 207 |
+
return Image.fromarray(arr)
|
| 208 |
+
|
| 209 |
+
def pil_to_bytes(image):
|
| 210 |
+
buf = io.BytesIO()
|
| 211 |
+
image.save(buf, format="PNG")
|
| 212 |
+
return buf.getvalue()
|
| 213 |
+
|
| 214 |
+
def build_system_prompt(anya_desc, include_anya, include_l3n0v0, breast_size, style_hint, use_ref_images, num_refs, ref_descs_list):
|
| 215 |
+
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"}
|
| 216 |
+
breast_desc = breast_map.get(breast_size, "medium-sized natural breasts")
|
| 217 |
+
triggers = []
|
| 218 |
+
if include_anya: triggers.append("Anya")
|
| 219 |
+
if include_l3n0v0: triggers.append("l3n0v0")
|
| 220 |
+
triggers_str = json.dumps(triggers)
|
| 221 |
+
if include_anya:
|
| 222 |
+
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": "..."}}'
|
| 223 |
+
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."
|
| 224 |
+
else:
|
| 225 |
+
subject_block = ' "subject": {"description": "...", "pose": "...", "expression": "...", "gaze": "..."}'
|
| 226 |
+
subject_instruction = "## SUBJECT\nDescribe the subject from the reference image exactly. Reproduce face, hair, skin tone, body proportions 1:1. No changes, no beautification."
|
| 227 |
+
if use_ref_images and num_refs > 0:
|
| 228 |
+
ref_labels = ["subject_identity"] + [f"reference_image_{i}" for i in range(2, num_refs+1)]
|
| 229 |
+
ref_entries = []
|
| 230 |
+
for i in range(num_refs):
|
| 231 |
+
label = ref_labels[i] if i < len(ref_labels) else f"reference_image_{i+1}"
|
| 232 |
+
desc = ref_descs_list[i] if i < len(ref_descs_list) and ref_descs_list[i].strip() else f"uploaded_reference_image_{i+1}"
|
| 233 |
+
ref_entries.append(f' "{label}": "{desc}"')
|
| 234 |
+
ref_block = ' "reference_images": {\n' + ',\n'.join(ref_entries) + '\n },'
|
| 235 |
+
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)])
|
| 236 |
+
else:
|
| 237 |
+
ref_block = ""
|
| 238 |
+
ref_instruction = "## REFERENCE IMAGES\nNo reference images."
|
| 239 |
+
ref_section = f"\n{ref_block}" if ref_block else ""
|
| 240 |
+
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."
|
| 241 |
+
return f"""You are an expert AI image prompt engineer specializing in structured JSON prompts.
|
| 242 |
+
|
| 243 |
+
{subject_instruction}
|
| 244 |
+
{ref_instruction}
|
| 245 |
+
|
| 246 |
+
## OUTPUT RULES
|
| 247 |
+
- Return ONLY valid JSON, no markdown, no backticks, no explanation
|
| 248 |
+
- trigger_words must be exactly: {triggers_str}
|
| 249 |
+
|
| 250 |
+
{{
|
| 251 |
+
"trigger_words": {triggers_str},{ref_section}
|
| 252 |
+
"output_quality": {{"resolution": "4K", "definition": "ultra high resolution", "sharpness": "natural realistic detail, not overprocessed"}},
|
| 253 |
+
{subject_block},
|
| 254 |
+
"outfit": {{"description": "...", "colors": [...], "fit": "...", "fabric": "..."}},
|
| 255 |
+
"location": {{"setting": "...", "environment": [...], "time_of_day": "...", "lighting": "...", "atmosphere": "..."}},
|
| 256 |
+
"image_type": {{"orientation": "...", "aspect_ratio": "...", "style": "{style_hint}", "camera_feel": "...", "color_grading": "..."}},
|
| 257 |
+
"identity_preservation": {{"facial_identity": "...", "no_changes": ["bone_structure", "facial_proportions", "skin_tone", "hairline", "facial_features"], "no_beautification": true, "no_stylization": true}},
|
| 258 |
+
"realism_constraints": {{"no_extra_limbs": true, "no_ai_symmetry_correction": true, "natural_skin_texture": true, "natural_light_behavior": true, "no_heavy_color_grading": true}},
|
| 259 |
+
"image_feel": [...]
|
| 260 |
+
}}
|
| 261 |
+
|
| 262 |
+
Analyze the provided image(s): extract scene, lighting, pose, outfit, mood. {inject_note} Return ONLY the JSON."""
|
| 263 |
+
|
| 264 |
+
class AnyaPromptExtractor:
|
| 265 |
+
MODELS = ["gemini-2.5-flash-preview-05-20", "gemini-2.5-flash", "gemini-2.5-pro", "gemini-3-pro-image-preview"]
|
| 266 |
+
BREAST_SIZES = ["small", "medium", "large", "huge"]
|
| 267 |
+
NUM_REFS = ["0", "1", "2", "3", "4", "5"]
|
| 268 |
+
|
| 269 |
+
@classmethod
|
| 270 |
+
def INPUT_TYPES(cls):
|
| 271 |
+
return {
|
| 272 |
+
"required": {
|
| 273 |
+
"api_key": ("STRING", {"default": "YOUR_GEMINI_API_KEY"}),
|
| 274 |
+
"model": (cls.MODELS,),
|
| 275 |
+
"include_trigger_anya": ("BOOLEAN", {"default": True}),
|
| 276 |
+
"include_trigger_l3n0v0": ("BOOLEAN", {"default": True}),
|
| 277 |
+
"breast_size_override": (cls.BREAST_SIZES,),
|
| 278 |
+
"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}),
|
| 279 |
+
"style_hint": ("STRING", {"default": "natural high-end lifestyle, candid editorial"}),
|
| 280 |
+
"json_indent": ("INT", {"default": 4, "min": 0, "max": 8, "step": 1}),
|
| 281 |
+
"use_reference_images": ("BOOLEAN", {"default": True}),
|
| 282 |
+
"num_reference_images": (cls.NUM_REFS,),
|
| 283 |
+
"ref_1_description": ("STRING", {"default": "subject identity β main model reference"}),
|
| 284 |
+
"ref_2_description": ("STRING", {"default": "outfit reference"}),
|
| 285 |
+
"ref_3_description": ("STRING", {"default": "location or background reference"}),
|
| 286 |
+
"ref_4_description": ("STRING", {"default": "style or mood reference"}),
|
| 287 |
+
"ref_5_description": ("STRING", {"default": "additional reference"}),
|
| 288 |
+
},
|
| 289 |
+
"optional": {
|
| 290 |
+
"scene_image": ("IMAGE",),
|
| 291 |
+
"ref_image_1": ("IMAGE",),
|
| 292 |
+
"ref_image_2": ("IMAGE",),
|
| 293 |
+
"ref_image_3": ("IMAGE",),
|
| 294 |
+
"ref_image_4": ("IMAGE",),
|
| 295 |
+
"ref_image_5": ("IMAGE",),
|
| 296 |
+
}
|
| 297 |
+
}
|
| 298 |
+
|
| 299 |
+
RETURN_TYPES = ("STRING", "IMAGE", "IMAGE", "IMAGE", "IMAGE", "IMAGE", "IMAGE")
|
| 300 |
+
RETURN_NAMES = ("prompt_json", "scene_passthrough", "ref_1_passthrough", "ref_2_passthrough", "ref_3_passthrough", "ref_4_passthrough", "ref_5_passthrough")
|
| 301 |
+
FUNCTION = "extract"
|
| 302 |
+
CATEGORY = "π Nano Banana Pro"
|
| 303 |
+
OUTPUT_NODE = True
|
| 304 |
+
|
| 305 |
+
def extract(self, api_key, model, include_trigger_anya, include_trigger_l3n0v0,
|
| 306 |
+
breast_size_override, anya_base_description, style_hint, json_indent,
|
| 307 |
+
use_reference_images, num_reference_images,
|
| 308 |
+
ref_1_description, ref_2_description, ref_3_description,
|
| 309 |
+
ref_4_description, ref_5_description,
|
| 310 |
+
scene_image=None, ref_image_1=None, ref_image_2=None,
|
| 311 |
+
ref_image_3=None, ref_image_4=None, ref_image_5=None):
|
| 312 |
+
try:
|
| 313 |
+
from google import genai
|
| 314 |
+
from google.genai import types
|
| 315 |
+
except ImportError:
|
| 316 |
+
raise ImportError("Lance : pip install google-genai")
|
| 317 |
+
num_refs = int(num_reference_images)
|
| 318 |
+
ref_descs_list = [ref_1_description, ref_2_description, ref_3_description, ref_4_description, ref_5_description]
|
| 319 |
+
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)
|
| 320 |
+
client = genai.Client(api_key=api_key)
|
| 321 |
+
parts = []
|
| 322 |
+
if scene_image is not None:
|
| 323 |
+
parts.append(types.Part.from_bytes(data=pil_to_bytes(tensor_to_pil(scene_image)), mime_type="image/png"))
|
| 324 |
+
if use_reference_images and num_refs > 0:
|
| 325 |
+
ref_images_list = [ref_image_1, ref_image_2, ref_image_3, ref_image_4, ref_image_5]
|
| 326 |
+
for i in range(min(num_refs, 5)):
|
| 327 |
+
ref = ref_images_list[i]
|
| 328 |
+
if ref is not None:
|
| 329 |
+
desc = ref_descs_list[i] if ref_descs_list[i].strip() else f"reference image {i+1}"
|
| 330 |
+
parts.append(types.Part.from_text(text=f"[Reference image {i+1}: {desc}]"))
|
| 331 |
+
parts.append(types.Part.from_bytes(data=pil_to_bytes(tensor_to_pil(ref)), mime_type="image/png"))
|
| 332 |
+
if not parts:
|
| 333 |
+
parts.append(types.Part.from_text(text="No image provided. Generate a generic lifestyle JSON prompt. Return ONLY the JSON."))
|
| 334 |
+
else:
|
| 335 |
+
parts.append(types.Part.from_text(text="Analyze the provided image(s) and generate the structured JSON prompt. Return ONLY the JSON."))
|
| 336 |
+
config = types.GenerateContentConfig(system_instruction=system_prompt, response_modalities=["TEXT"], temperature=0.4, top_p=0.9)
|
| 337 |
+
print(f"[AnyaExtractor] -> {model} | Anya:{include_trigger_anya} | l3n0v0:{include_trigger_l3n0v0} | refs:{num_refs if use_reference_images else 0}")
|
| 338 |
+
response = client.models.generate_content(model=model, contents=parts, config=config)
|
| 339 |
+
raw_parts = response.parts or []
|
| 340 |
+
raw_text = "".join(part.text for part in raw_parts if hasattr(part, "text") and part.text).strip()
|
| 341 |
+
if not raw_text and hasattr(response, "candidates") and response.candidates:
|
| 342 |
+
raw_text = "".join(part.text for part in (response.candidates[0].content.parts or []) if hasattr(part, "text") and part.text).strip()
|
| 343 |
+
if not raw_text:
|
| 344 |
+
raise RuntimeError(f"[AnyaExtractor] Reponse vide. Modele: {model} | Verifier la cle API ou changer de modele.")
|
| 345 |
+
if raw_text.startswith("```"):
|
| 346 |
+
lines = raw_text.split("\n")
|
| 347 |
+
raw_text = "\n".join(lines[1:-1] if lines[-1].strip() == "```" else lines[1:]).strip()
|
| 348 |
+
try:
|
| 349 |
+
parsed = json.loads(raw_text)
|
| 350 |
+
tw = parsed.get("trigger_words", [])
|
| 351 |
+
if include_trigger_anya and "Anya" not in tw: tw.insert(0, "Anya")
|
| 352 |
+
if not include_trigger_anya and "Anya" in tw: tw.remove("Anya")
|
| 353 |
+
if include_trigger_l3n0v0 and "l3n0v0" not in tw: tw.append("l3n0v0")
|
| 354 |
+
if not include_trigger_l3n0v0 and "l3n0v0" in tw: tw.remove("l3n0v0")
|
| 355 |
+
parsed["trigger_words"] = tw
|
| 356 |
+
output_json = json.dumps(parsed, indent=json_indent, ensure_ascii=False)
|
| 357 |
+
except json.JSONDecodeError as e:
|
| 358 |
+
print(f"[AnyaExtractor] JSON invalide: {e}")
|
| 359 |
+
output_json = raw_text
|
| 360 |
+
print(f"[AnyaExtractor] Succes ({len(output_json)} chars)")
|
| 361 |
+
empty = torch.zeros(1, 64, 64, 3)
|
| 362 |
+
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)
|
| 363 |
+
|
| 364 |
+
NODE_CLASS_MAPPINGS = {"AnyaPromptExtractor": AnyaPromptExtractor}
|
| 365 |
+
NODE_DISPLAY_NAME_MAPPINGS = {"AnyaPromptExtractor": "π Anya Prompt Extractor"}
|
| 366 |
+
ENDOFFILE
|
| 367 |
+
|
| 368 |
+
# ββ grok_prompt_extractor_node.py ββββββββββββββββββββββββββββββββββββββββββ
|
| 369 |
+
cat > "${NBP_DIR}/grok_prompt_extractor_node.py" << 'ENDOFFILE'
|
| 370 |
+
import torch, numpy as np, io, base64
|
| 371 |
+
from PIL import Image
|
| 372 |
+
|
| 373 |
+
def tensor_to_pil(tensor):
|
| 374 |
+
arr = tensor.squeeze(0).numpy()
|
| 375 |
+
arr = (arr * 255).clip(0, 255).astype(np.uint8)
|
| 376 |
+
return Image.fromarray(arr)
|
| 377 |
+
|
| 378 |
+
def pil_to_bytes(image):
|
| 379 |
+
buf = io.BytesIO()
|
| 380 |
+
image.save(buf, format="PNG")
|
| 381 |
+
return buf.getvalue()
|
| 382 |
+
|
| 383 |
+
def image_to_base64(image):
|
| 384 |
+
return base64.b64encode(pil_to_bytes(image)).decode("utf-8")
|
| 385 |
+
|
| 386 |
+
def build_system_prompt(anya_desc, include_anya, include_l3n0v0, breast_size, style_hint, word_count):
|
| 387 |
+
breast_map = {
|
| 388 |
+
"small": "small perky breasts",
|
| 389 |
+
"medium": "medium-sized natural breasts with visible cleavage",
|
| 390 |
+
"large": "large full breasts with natural weight and deep cleavage",
|
| 391 |
+
"huge": "very large heavy breasts, extremely voluptuous silhouette"
|
| 392 |
+
}
|
| 393 |
+
breast_desc = breast_map.get(breast_size, "medium-sized natural breasts with visible cleavage")
|
| 394 |
+
triggers = []
|
| 395 |
+
if include_anya: triggers.append("Anya")
|
| 396 |
+
if include_l3n0v0: triggers.append("l3n0v0")
|
| 397 |
+
trigger_line = ", ".join(triggers)
|
| 398 |
+
if include_anya:
|
| 399 |
+
char_instruction = f"""## ANYA β FIXED PHYSICAL CHARACTER
|
| 400 |
+
{anya_desc}
|
| 401 |
+
Breast size: {breast_desc}
|
| 402 |
+
Body: wide hips, prominent round BBL-style butt, thick thighs, hourglass figure, slim waist
|
| 403 |
+
Face: full pouty lips, almond-shaped eyes with long lashes, warm tan Asian skin, high cheekbones
|
| 404 |
+
Jewelry: gold hoop earrings, gold chain necklace, gold bracelets
|
| 405 |
+
|
| 406 |
+
## REPLACEMENT RULE
|
| 407 |
+
Anya replaces the person in the image EXACTLY.
|
| 408 |
+
- Same pose, same expression, same gaze, same position in frame
|
| 409 |
+
- Same outfit worn on Anya's body β describe how each garment fits her curves
|
| 410 |
+
- Same location, same lighting, same background, same props
|
| 411 |
+
- Only the physical identity changes to Anya"""
|
| 412 |
+
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"
|
| 413 |
+
else:
|
| 414 |
+
char_instruction = "## SUBJECT\nDescribe the subject exactly as seen. Be extremely precise about every physical detail."
|
| 415 |
+
subject_block = "the person in the image"
|
| 416 |
+
inject = f"Replace the subject with: {subject_block}" if include_anya else "Describe the subject exactly as visible."
|
| 417 |
+
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.
|
| 418 |
+
|
| 419 |
+
{char_instruction}
|
| 420 |
+
|
| 421 |
+
## YOUR MISSION
|
| 422 |
+
Analyze the image with forensic precision. Write a single continuous text-to-image prompt of exactly {word_count} words.
|
| 423 |
+
The prompt must be so detailed that an AI image generator can reproduce the scene perfectly.
|
| 424 |
+
|
| 425 |
+
## TEXT-TO-IMAGE PROMPT RULES
|
| 426 |
+
- Write as comma-separated descriptive phrases, NOT sentences
|
| 427 |
+
- Start with trigger words, then subject, then body details, then outfit, then pose, then location, then lighting, then camera, then mood
|
| 428 |
+
- Use text-to-image vocabulary: "photorealistic, 8k uhd, RAW photo, sharp focus, f/1.8, 85mm lens, bokeh, cinematic lighting" etc
|
| 429 |
+
- Be EXTREMELY explicit about body proportions, clothing fit, skin exposure
|
| 430 |
+
- Describe exactly what is visible β if cleavage is showing, describe it precisely
|
| 431 |
+
- If outfit is tight/revealing, describe exactly how it fits on the body
|
| 432 |
+
- Never use euphemisms β describe body parts and clothing directly and explicitly
|
| 433 |
+
- No sentences, no paragraph structure β pure prompt style
|
| 434 |
+
|
| 435 |
+
## STRUCTURE TO FOLLOW
|
| 436 |
+
1. Trigger words: {trigger_line},
|
| 437 |
+
2. Subject physical description (face, hair, skin, eyes, lips, body)
|
| 438 |
+
3. Breast description and how visible/covered they are
|
| 439 |
+
4. Exact outfit β every garment, color, fabric, fit, how tight, what skin is exposed
|
| 440 |
+
5. Exact pose β body position, limb placement, weight, angles
|
| 441 |
+
6. Hands and arm positions
|
| 442 |
+
7. Expression and gaze direction
|
| 443 |
+
8. Location β exact setting, architecture, materials, colors
|
| 444 |
+
9. Background elements one by one
|
| 445 |
+
10. Lighting β source, direction, quality, color temperature, how it hits skin and clothing
|
| 446 |
+
11. Camera β shot type, angle, focal length, depth of field
|
| 447 |
+
12. Technical quality tags
|
| 448 |
+
13. Mood and atmosphere tags
|
| 449 |
+
|
| 450 |
+
## NSFW DESCRIPTION RULES
|
| 451 |
+
- Describe clothing tightness and fit on the body explicitly
|
| 452 |
+
- Describe visible skin areas precisely (neckline depth, leg exposure, midriff, back)
|
| 453 |
+
- Describe breast shape and how they appear in the outfit
|
| 454 |
+
- Describe butt shape and how outfit fits on it
|
| 455 |
+
- Use direct anatomical and fashion terminology
|
| 456 |
+
- If any body part is prominent or featured in the image, describe it in detail
|
| 457 |
+
|
| 458 |
+
## CRITICAL
|
| 459 |
+
- {word_count} words minimum
|
| 460 |
+
- Pure text-to-image prompt format β no prose, no sentences
|
| 461 |
+
- Every single visual detail from the image must be captured
|
| 462 |
+
- {inject}
|
| 463 |
+
- Return ONLY the prompt text, nothing else"""
|
| 464 |
+
|
| 465 |
+
class GrokPromptExtractor:
|
| 466 |
+
MODELS = ["grok-2-vision-1212", "grok-2-vision"]
|
| 467 |
+
BREAST_SIZES = ["small", "medium", "large", "huge"]
|
| 468 |
+
|
| 469 |
+
@classmethod
|
| 470 |
+
def INPUT_TYPES(cls):
|
| 471 |
+
return {
|
| 472 |
+
"required": {
|
| 473 |
+
"api_key": ("STRING", {"default": "YOUR_XAI_API_KEY"}),
|
| 474 |
+
"model": (cls.MODELS,),
|
| 475 |
+
"include_trigger_anya": ("BOOLEAN", {"default": True}),
|
| 476 |
+
"include_trigger_l3n0v0": ("BOOLEAN", {"default": True}),
|
| 477 |
+
"breast_size_override": (cls.BREAST_SIZES,),
|
| 478 |
+
"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}),
|
| 479 |
+
"style_hint": ("STRING", {"default": "RAW photo, photorealistic, candid shot, natural lighting, 8k uhd"}),
|
| 480 |
+
"word_count": ("INT", {"default": 450, "min": 200, "max": 800, "step": 50}),
|
| 481 |
+
},
|
| 482 |
+
"optional": {
|
| 483 |
+
"image": ("IMAGE",),
|
| 484 |
+
}
|
| 485 |
+
}
|
| 486 |
+
|
| 487 |
+
RETURN_TYPES = ("STRING", "IMAGE")
|
| 488 |
+
RETURN_NAMES = ("prompt_text", "image_passthrough")
|
| 489 |
+
FUNCTION = "extract"
|
| 490 |
+
CATEGORY = "π€ Grok xAI"
|
| 491 |
+
OUTPUT_NODE = True
|
| 492 |
+
|
| 493 |
+
def extract(self, api_key, model, include_trigger_anya, include_trigger_l3n0v0,
|
| 494 |
+
breast_size_override, anya_base_description, style_hint, word_count,
|
| 495 |
+
image=None):
|
| 496 |
+
try:
|
| 497 |
+
from xai_sdk import Client
|
| 498 |
+
from xai_sdk.chat import system, user, image as xai_image
|
| 499 |
+
except ImportError:
|
| 500 |
+
raise ImportError("Lance : pip install xai-sdk")
|
| 501 |
+
system_prompt = build_system_prompt(anya_base_description, include_trigger_anya, include_trigger_l3n0v0, breast_size_override, style_hint, word_count)
|
| 502 |
+
client = Client(api_key=api_key)
|
| 503 |
+
chat = client.chat.create(model=model)
|
| 504 |
+
chat.append(system(system_prompt))
|
| 505 |
+
if image is not None:
|
| 506 |
+
b64 = image_to_base64(tensor_to_pil(image))
|
| 507 |
+
data_url = f"data:image/png;base64,{b64}"
|
| 508 |
+
chat.append(user(
|
| 509 |
+
f"Analyze every detail of this image. Write a {word_count}-word text-to-image prompt. "
|
| 510 |
+
f"Be extremely explicit about body proportions, outfit fit, skin exposure, clothing tightness. "
|
| 511 |
+
f"Pure prompt format β comma-separated tags and descriptors, no sentences, no explanations. "
|
| 512 |
+
f"Return ONLY the prompt.",
|
| 513 |
+
xai_image(data_url)
|
| 514 |
+
))
|
| 515 |
+
else:
|
| 516 |
+
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."))
|
| 517 |
+
print(f"[GrokExtractor] -> {model} | Anya:{include_trigger_anya} | l3n0v0:{include_trigger_l3n0v0} | words:{word_count}")
|
| 518 |
+
response = chat.sample()
|
| 519 |
+
output_text = response.content.strip()
|
| 520 |
+
print(f"[GrokExtractor] OK ({len(output_text.split())} words)")
|
| 521 |
+
empty = torch.zeros(1, 64, 64, 3)
|
| 522 |
+
return (output_text, image if image is not None else empty)
|
| 523 |
+
|
| 524 |
+
NODE_CLASS_MAPPINGS = {"GrokPromptExtractor": GrokPromptExtractor}
|
| 525 |
+
NODE_DISPLAY_NAME_MAPPINGS = {"GrokPromptExtractor": "π€ Grok Prompt Extractor"}
|
| 526 |
+
ENDOFFILE
|
| 527 |
+
|
| 528 |
+
# ββ __init__.py (version complΓ¨te avec nano_banana_pro_node) βββββββββββββββ
|
| 529 |
+
cat > "${NBP_DIR}/__init__.py" << 'EOF'
|
| 530 |
+
from .nano_banana_pro_node import NODE_CLASS_MAPPINGS as _NM1, NODE_DISPLAY_NAME_MAPPINGS as _DN1
|
| 531 |
+
from .anya_prompt_extractor_node import NODE_CLASS_MAPPINGS as _NM2, NODE_DISPLAY_NAME_MAPPINGS as _DN2
|
| 532 |
+
from .grok_prompt_extractor_node import NODE_CLASS_MAPPINGS as _NM3, NODE_DISPLAY_NAME_MAPPINGS as _DN3
|
| 533 |
+
|
| 534 |
+
NODE_CLASS_MAPPINGS = {}
|
| 535 |
+
NODE_CLASS_MAPPINGS.update(_NM1)
|
| 536 |
+
NODE_CLASS_MAPPINGS.update(_NM2)
|
| 537 |
+
NODE_CLASS_MAPPINGS.update(_NM3)
|
| 538 |
+
|
| 539 |
+
NODE_DISPLAY_NAME_MAPPINGS = {}
|
| 540 |
+
NODE_DISPLAY_NAME_MAPPINGS.update(_DN1)
|
| 541 |
+
NODE_DISPLAY_NAME_MAPPINGS.update(_DN2)
|
| 542 |
+
NODE_DISPLAY_NAME_MAPPINGS.update(_DN3)
|
| 543 |
+
|
| 544 |
+
__all__ = ["NODE_CLASS_MAPPINGS", "NODE_DISPLAY_NAME_MAPPINGS"]
|
| 545 |
+
EOF
|
| 546 |
+
|
| 547 |
+
printf "NanoBananaPro nodes created successfully.\n"
|
| 548 |
+
}
|
| 549 |
+
|
| 550 |
function provisioning_get_files() {
|
| 551 |
if [[ -z $2 ]]; then return 1; fi
|
| 552 |
|
|
|
|
| 605 |
# Check if the token is valid
|
| 606 |
if [ "$response" -eq 200 ]; then
|
| 607 |
return 0
|
| 608 |
+
else
|
| 609 |
return 1
|
| 610 |
fi
|
| 611 |
}
|