vicentemovil commited on
Commit
d99fa3d
·
0 Parent(s):

aether-studio mirror

Browse files
.gitattributes ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
2
+ *.gguf filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Krea 2 Turbo Image Generator
3
+ emoji: 🖌️
4
+ colorFrom: blue
5
+ colorTo: purple
6
+ sdk: gradio
7
+ sdk_version: 5.44.1
8
+ python_version: '3.12'
9
+ app_file: app.py
10
+ pinned: true
11
+ short_description: Krea 2 Turbo text2image and image editing
12
+ license: other
13
+ ---
14
+
15
+ # Krea 2 Turbo Image Generator
16
+
17
+ This Space runs Krea 2 Turbo through headless ComfyUI execution. It provides:
18
+
19
+ - Text-to-image generation.
20
+ - Instruction-based image editing with an optional second reference image.
21
+ - Krea 2 Identity Edit v1.2 conditioning for the edit mode.
22
+ - Two selectable custom Krea 2 Turbo checkpoints.
23
+ - An option to download and use a custom base checkpoint from any accessible Hugging Face repository.
24
+ - A catalog of Krea 2 LoRAs with signed weight controls and search/filtering.
25
+ - Custom LoRAs from any accessible Hugging Face repository.
26
+ - Seed, sampling, grounding, and reference-fidelity controls.
27
+ - PNG metadata and portable JSON settings profiles.
28
+
29
+ ## Models
30
+
31
+ The text encoder and VAE are downloaded from the ungated [Comfy-Org/Krea-2 mirror](https://huggingface.co/Comfy-Org/Krea-2).
32
+ The base-model selector provides both checkpoints from [mpasila/Krea-2-Models](https://huggingface.co/mpasila/Krea-2-Models):
33
+
34
+ | File | Role |
35
+ |------|------|
36
+ | `museByStableYogi_v25EXTENDEDTURBO.safetensors` | Muse By Stable Yogi Krea2 diffusion model |
37
+ | `pornmasterKrea2_v2TurboInt8.safetensors` | PornMaster Krea 2 Turbo diffusion model |
38
+ | `qwen3vl_4b_fp8_scaled.safetensors` | Krea 2 Qwen3-VL text encoder |
39
+ | `qwen_image_vae.safetensors` | Krea 2 VAE |
40
+
41
+ Choose **Custom Hugging Face base model** in the base checkpoint selector to provide a repository,
42
+ relative model filename, and optional revision. Supported files use `.safetensors`, `.ckpt`, `.pt`,
43
+ or `.bin` extensions. The checkpoint is downloaded lazily into ComfyUI's managed diffusion-model
44
+ directory and cached in a stable repository/revision namespace. Private repositories require the
45
+ `HF_TOKEN` or `HUGGINGFACE_HUB_TOKEN` environment variable.
46
+
47
+ Edit mode also downloads `krea2_identity_edit_v1_2.safetensors` from
48
+ [conradlocke/krea2-identity-edit](https://huggingface.co/conradlocke/krea2-identity-edit).
49
+ The edit nodes come from [ComfyUI-Krea2Edit](https://github.com/lbouaraba/comfyui-krea2edit).
50
+
51
+ ## LoRAs
52
+
53
+ The built-in catalog is loaded from [`krea2_loras.json`](../krea2_loras.json:1) and downloaded
54
+ lazily from [mpasila/Krea-2-LoRAs](https://huggingface.co/mpasila/Krea-2-LoRAs). A weight of zero
55
+ disables an entry. Enabled catalog entries are applied in the order listed in the catalog, then
56
+ custom rows are applied in their table order. Signed weights are supported for slider LoRAs.
57
+
58
+ Custom Hugging Face LoRAs use one table row per file:
59
+
60
+ | Column | Example |
61
+ |------|------|
62
+ | `repo_id` | `org/repository` |
63
+ | `filename` | `subfolder/style.safetensors` |
64
+ | `revision` | `main` or a commit/tag (optional) |
65
+ | `weight` | `0.8` |
66
+
67
+ Only relative model files with supported extensions are accepted. Private repositories require the
68
+ `HF_TOKEN` or `HUGGINGFACE_HUB_TOKEN` environment variable. Catalog and custom LoRAs are cached
69
+ under ComfyUI’s managed LoRA directory and are downloaded only when their weight is non-zero.
70
+ In edit mode, the mandatory Krea 2 Identity Edit adapter remains enabled before the user LoRA
71
+ chain; it is not included in the selectable catalog.
72
+
73
+ All model and adapter licenses remain applicable. Review the Krea 2 Community License Agreement
74
+ and the adapter repository’s responsible-use guidance before deploying this Space. Do not use the
75
+ identity-edit workflow for non-consensual or harmful impersonation of real people.
76
+
77
+ ## Usage
78
+
79
+ Choose **text-to-image** for a new image, or **edit** to provide a primary source image and an
80
+ optional second reference. In edit mode, image order matters: the primary image is the scene/source
81
+ and the second image is the subject or additional reference.
82
+
83
+ The edit workflow uses `fit` reference geometry. The target megapixel setting controls the output
84
+ size while preserving the primary image’s aspect ratio. Lower grounding values usually follow the
85
+ edit instruction more strongly; higher values usually preserve reference identity more strongly.
86
+
87
+ Generated PNGs include a `krea_settings` JSON object and a readable `parameters` field. Source image
88
+ bytes are never stored in exported settings profiles. Profiles also preserve the selected checkpoint,
89
+ custom base-model repository/file/revision, catalog weights, and custom Hugging Face LoRA rows.
app.py ADDED
@@ -0,0 +1,1302 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Krea 2 Turbo text-to-image and image-editing Hugging Face Space.
2
+
3
+ The supplied ComfyUI workflows are bundled as the graph references for this
4
+ Space. The runtime uses their supported first-pass/edit paths and replaces
5
+ optional UI-heavy stages with a small deterministic API graph so startup does
6
+ not depend on face, hand, detailer, or image-saver node packs.
7
+ """
8
+
9
+ from __future__ import annotations
10
+
11
+ import asyncio
12
+ import glob
13
+ import json
14
+ import os
15
+ import pathlib
16
+ import random
17
+ import re
18
+ import shutil
19
+ import subprocess
20
+ import sys
21
+ import tempfile
22
+ import traceback
23
+ import uuid
24
+ from typing import Any
25
+
26
+ import gradio as gr
27
+ from huggingface_hub import hf_hub_download
28
+ from PIL import Image
29
+
30
+ try:
31
+ import spaces
32
+ except ImportError: # pragma: no cover - lets pure unit tests import helpers.
33
+ class _SpacesFallback:
34
+ @staticmethod
35
+ def GPU(**_kwargs):
36
+ def decorate(function):
37
+ return function
38
+ return decorate
39
+
40
+ spaces = _SpacesFallback()
41
+
42
+ from settings_utils import (
43
+ APP_ID,
44
+ PROFILE_SCHEMA_VERSION,
45
+ build_settings,
46
+ extract_image_settings,
47
+ normalize_custom_loras,
48
+ parse_settings_text,
49
+ stable_custom_base_model_namespace,
50
+ stable_custom_lora_namespace,
51
+ validate_custom_base_model,
52
+ validate_custom_lora,
53
+ write_png_metadata,
54
+ )
55
+
56
+
57
+ ROOT = pathlib.Path(__file__).resolve().parent
58
+ COMFY = ROOT / "ComfyUI"
59
+ MODELS = COMFY / "models"
60
+ INPUT = COMFY / "input"
61
+ OUTPUT = COMFY / "output"
62
+ CUSTOM_NODES = COMFY / "custom_nodes"
63
+
64
+ T2I_SOURCE = ROOT / "lustifyWorkflowsKrea2_krea2.json"
65
+ EDIT_SOURCE = ROOT / "lustifyWorkflowsKrea2_krea2Edit.json"
66
+
67
+ KREA_REPO = "Comfy-Org/Krea-2"
68
+ CUSTOM_KREA_REPO = "mpasila/Krea-2-Models"
69
+ CUSTOM_KREA_FILE = "pornmasterKrea2_v2TurboInt8.safetensors"
70
+ MUSE_KREA_FILE = "museByStableYogi_v25EXTENDEDTURBO.safetensors"
71
+ DEFAULT_BASE_MODEL = CUSTOM_KREA_FILE
72
+ CUSTOM_BASE_MODEL = "__custom_huggingface_base_model__"
73
+ BASE_MODELS = {
74
+ MUSE_KREA_FILE: {
75
+ "label": "Muse By Stable Yogi Krea2",
76
+ "repo": CUSTOM_KREA_REPO,
77
+ "filename": MUSE_KREA_FILE,
78
+ },
79
+ CUSTOM_KREA_FILE: {
80
+ "label": "PornMaster 色情大師-Krea2",
81
+ "repo": CUSTOM_KREA_REPO,
82
+ "filename": CUSTOM_KREA_FILE,
83
+ },
84
+ }
85
+ IDENTITY_REPO = "conradlocke/krea2-identity-edit"
86
+ IDENTITY_FILE = "krea2_identity_edit_v1_2.safetensors"
87
+ KREA_EDIT_NODES = "https://github.com/lbouaraba/comfyui-krea2edit.git"
88
+ LORA_CATALOG_FILE = "krea2_loras.json"
89
+ LORA_HF_REPO = "mpasila/Krea-2-LoRAs"
90
+ LORA_DEST_DIR = MODELS / "loras" / "krea2"
91
+ LORA_ROOT = MODELS / "loras"
92
+ CUSTOM_LORA_DEST_DIR = LORA_ROOT / "huggingface"
93
+
94
+ DOWNLOADS = [
95
+ (KREA_REPO, "text_encoders/qwen3vl_4b_fp8_scaled.safetensors", MODELS / "text_encoders" / "qwen3vl_4b_fp8_scaled.safetensors", "Qwen3-VL text encoder"),
96
+ (KREA_REPO, "vae/qwen_image_vae.safetensors", MODELS / "vae" / "qwen_image_vae.safetensors", "Qwen image VAE"),
97
+ (IDENTITY_REPO, IDENTITY_FILE, MODELS / "loras" / "krea" / IDENTITY_FILE, "Krea 2 identity-edit adapter"),
98
+ ]
99
+
100
+ SAMPLERS = [
101
+ "euler", "euler_ancestral", "euler_a", "dpmpp_2m", "dpmpp_2m_sde",
102
+ "dpmpp_sde", "heun", "lms",
103
+ ]
104
+ SCHEDULERS = ["beta", "normal", "karras", "exponential", "sgm_uniform", "simple"]
105
+
106
+ DEFAULT_WIDTH = 1024
107
+ DEFAULT_HEIGHT = 1024
108
+ DEFAULT_TARGET_MP = 1.4
109
+ MAX_WIDTH = 2048
110
+ MAX_HEIGHT = 2048
111
+ MAX_TARGET_MP = 4.0
112
+ DEFAULT_GROUNDING = 768
113
+ DEFAULT_REF_BOOST = 1.0
114
+ DEFAULT_STEPS = 8
115
+ DEFAULT_CFG = 1.0
116
+ DEFAULT_SAMPLER = "euler"
117
+ DEFAULT_SCHEDULER = "beta"
118
+ DEFAULT_SEED = 2
119
+ MIN_GPU_SECONDS = int(os.environ.get("MIN_GPU_SECONDS", "45"))
120
+ MAX_GPU_SECONDS = int(os.environ.get("MAX_GPU_SECONDS", "300"))
121
+
122
+ _comfy_ready = False
123
+ _nodes_ready = False
124
+ _workflow_cache: dict[str, dict[str, Any]] = {}
125
+ _lora_catalog: list[dict[str, Any]] = []
126
+ _lora_by_filename: dict[str, dict[str, Any]] = {}
127
+
128
+
129
+ def _run(command: list[str], cwd: pathlib.Path | None = None, check: bool = True) -> None:
130
+ print("[setup]", " ".join(command), flush=True)
131
+ subprocess.run(command, cwd=str(cwd) if cwd else None, check=check)
132
+
133
+
134
+ def _pip_install(arguments: list[str]) -> None:
135
+ _run([sys.executable, "-m", "pip", "install", "--no-cache-dir", *arguments], check=False)
136
+
137
+
138
+ def _install_filtered_requirements(path: pathlib.Path) -> None:
139
+ """Install ComfyUI requirements without replacing Space's torch stack."""
140
+ if not path.exists():
141
+ return
142
+ blocked = {"torch", "torchvision", "torchaudio", "transformers", "huggingface-hub", "accelerate"}
143
+ requirements: list[str] = []
144
+ for raw in path.read_text(encoding="utf-8", errors="ignore").splitlines():
145
+ item = raw.strip()
146
+ if not item or item.startswith("#"):
147
+ continue
148
+ package = re.split(r"[<>=!~;\[\s]", item.lower().replace("_", "-"), maxsplit=1)[0]
149
+ if package not in blocked:
150
+ requirements.append(item)
151
+ if requirements:
152
+ _pip_install(requirements)
153
+
154
+
155
+ def _ensure_repo(path: pathlib.Path, url: str) -> None:
156
+ if not path.exists():
157
+ _run(["git", "clone", "--depth", "1", url, str(path)])
158
+
159
+
160
+ def _restore_utils_namespace() -> None:
161
+ """Undo the old root ``utils`` rename if a persistent Space has one."""
162
+ source = COMFY / "utils"
163
+ target = COMFY / "utilities"
164
+ if not source.exists() and target.exists():
165
+ target.rename(source)
166
+ if not source.exists():
167
+ return
168
+ for path in COMFY.rglob("*.py"):
169
+ if "__pycache__" in path.parts:
170
+ continue
171
+ try:
172
+ text = path.read_text(encoding="utf-8")
173
+ except UnicodeDecodeError:
174
+ continue
175
+ updated = re.sub(r"\bfrom utilities\b", "from utils", text)
176
+ updated = re.sub(r"\bimport utilities\b", "import utils", updated)
177
+ if updated != text:
178
+ path.write_text(updated, encoding="utf-8")
179
+
180
+
181
+ def _ensure_comfy() -> None:
182
+ global _comfy_ready
183
+ if _comfy_ready:
184
+ return
185
+ _ensure_repo(COMFY, "https://github.com/comfyanonymous/ComfyUI.git")
186
+ _install_filtered_requirements(COMFY / "requirements.txt")
187
+ CUSTOM_NODES.mkdir(parents=True, exist_ok=True)
188
+ _ensure_repo(CUSTOM_NODES / "comfyui-krea2edit", KREA_EDIT_NODES)
189
+ _restore_utils_namespace()
190
+ for folder in (
191
+ "diffusion_models",
192
+ "text_encoders",
193
+ "vae",
194
+ "loras/krea",
195
+ "loras/krea2",
196
+ "loras/huggingface",
197
+ ):
198
+ (MODELS / folder).mkdir(parents=True, exist_ok=True)
199
+ INPUT.mkdir(parents=True, exist_ok=True)
200
+ OUTPUT.mkdir(parents=True, exist_ok=True)
201
+ _comfy_ready = True
202
+
203
+
204
+ def _init_comfy_nodes() -> None:
205
+ global _nodes_ready
206
+ if _nodes_ready:
207
+ return
208
+ comfy_path = str(COMFY)
209
+ sys.path = [item for item in sys.path if item != comfy_path]
210
+ sys.path.insert(0, comfy_path)
211
+ for name in list(sys.modules):
212
+ if name == "utils" or name.startswith("utils."):
213
+ del sys.modules[name]
214
+ os.chdir(COMFY)
215
+ import execution
216
+ import nodes
217
+ import server
218
+
219
+ loop = asyncio.new_event_loop()
220
+ asyncio.set_event_loop(loop)
221
+
222
+ # New Comfy requires an AssetManager. Old Comfy only took the loop.
223
+ try:
224
+ from app.assets.manager import default_asset_manager
225
+ server_instance = server.PromptServer(loop, default_asset_manager())
226
+ except TypeError:
227
+ server_instance = server.PromptServer(loop)
228
+
229
+ execution.PromptQueue(server_instance)
230
+ loop.run_until_complete(nodes.init_extra_nodes())
231
+ _nodes_ready = True
232
+
233
+
234
+ def _download_to_dest(repo: str, filename: str, destination: pathlib.Path, label: str) -> None:
235
+ if destination.exists():
236
+ return
237
+ destination.parent.mkdir(parents=True, exist_ok=True)
238
+ path = pathlib.Path(filename)
239
+ token = os.environ.get("HF_TOKEN") or os.environ.get("HUGGINGFACE_HUB_TOKEN")
240
+ downloaded = pathlib.Path(
241
+ hf_hub_download(
242
+ repo_id=repo,
243
+ filename=path.name,
244
+ subfolder=None if str(path.parent) == "." else str(path.parent),
245
+ local_dir=str(destination.parent),
246
+ token=token,
247
+ )
248
+ )
249
+ if downloaded.resolve() != destination.resolve():
250
+ shutil.move(str(downloaded), str(destination))
251
+ print(f"[models] ready: {label}", flush=True)
252
+
253
+
254
+ def _load_lora_catalog() -> None:
255
+ """Load the shipped Krea LoRA catalog in its documented order."""
256
+ global _lora_catalog, _lora_by_filename
257
+ path = ROOT / LORA_CATALOG_FILE
258
+ if not path.exists():
259
+ path = ROOT.parent / LORA_CATALOG_FILE
260
+ if not path.exists():
261
+ print(f"[lora] {LORA_CATALOG_FILE} not found; catalog disabled", flush=True)
262
+ return
263
+ data = json.loads(path.read_text(encoding="utf-8"))
264
+ catalog: list[dict[str, Any]] = []
265
+ for row in data.get("loras", []):
266
+ if not isinstance(row, dict) or not row.get("hf_filename"):
267
+ continue
268
+ filename = pathlib.PurePosixPath(str(row["hf_filename"]).replace("\\", "/"))
269
+ if filename.is_absolute() or any(part in {"", ".", ".."} for part in filename.parts):
270
+ continue
271
+ catalog.append(dict(row, hf_filename=filename.as_posix()))
272
+ _lora_catalog = catalog
273
+ _lora_by_filename = {str(item["hf_filename"]): item for item in catalog}
274
+ print(f"[lora] loaded {len(_lora_catalog)} Krea LoRAs", flush=True)
275
+
276
+
277
+ def _ensure_base_model(base_model: str, progress: gr.Progress | None = None) -> str:
278
+ """Download an approved base checkpoint and return its ComfyUI name."""
279
+ if base_model not in BASE_MODELS:
280
+ raise ValueError("unsupported Krea base model")
281
+ item = BASE_MODELS[base_model]
282
+ _download_to_dest(
283
+ item["repo"],
284
+ item["filename"],
285
+ MODELS / "diffusion_models" / item["filename"],
286
+ item["label"],
287
+ )
288
+ return base_model
289
+
290
+
291
+ def _ensure_custom_base_model(value: dict[str, Any]) -> str:
292
+ """Download a validated custom HF base model into a managed ComfyUI folder."""
293
+ normalized = validate_custom_base_model(value)
294
+ namespace = stable_custom_base_model_namespace(
295
+ normalized["repo_id"], normalized["filename"], normalized["revision"]
296
+ )
297
+ diffusion_root = MODELS / "diffusion_models"
298
+ destination_dir = diffusion_root / "huggingface" / namespace
299
+ relative_file = pathlib.PurePosixPath(normalized["filename"])
300
+ destination = destination_dir.joinpath(*relative_file.parts)
301
+ if destination.exists():
302
+ relative = destination.resolve().relative_to(diffusion_root.resolve())
303
+ return pathlib.PurePosixPath(*relative.parts).as_posix()
304
+
305
+ token = os.environ.get("HF_TOKEN") or os.environ.get("HUGGINGFACE_HUB_TOKEN")
306
+ kwargs: dict[str, Any] = {
307
+ "repo_id": normalized["repo_id"],
308
+ "filename": normalized["filename"],
309
+ "local_dir": str(destination_dir),
310
+ "token": token,
311
+ }
312
+ if normalized["revision"]:
313
+ kwargs["revision"] = normalized["revision"]
314
+ try:
315
+ downloaded = pathlib.Path(hf_hub_download(**kwargs))
316
+ except Exception as exc:
317
+ raise RuntimeError(
318
+ f"failed to download custom base model "
319
+ f"{normalized['repo_id']}/{normalized['filename']}: {exc}"
320
+ ) from exc
321
+ if not downloaded.exists():
322
+ raise RuntimeError(f"HF Hub returned a missing custom base-model path: {downloaded}")
323
+ try:
324
+ relative = downloaded.resolve().relative_to(diffusion_root.resolve())
325
+ except ValueError as exc:
326
+ raise RuntimeError("custom base-model download escaped the managed model directory") from exc
327
+ print(f"[models] ready: custom base model {normalized['repo_id']}/{normalized['filename']}", flush=True)
328
+ return pathlib.PurePosixPath(*relative.parts).as_posix()
329
+
330
+
331
+ def _resolve_base_model(
332
+ base_model: str,
333
+ custom_base_model: dict[str, Any] | None = None,
334
+ ) -> str:
335
+ """Resolve the UI selection to the relative model name expected by ComfyUI."""
336
+ if base_model == CUSTOM_BASE_MODEL:
337
+ if not custom_base_model:
338
+ raise ValueError("enter a custom Hugging Face base-model repository and file")
339
+ return _ensure_custom_base_model(custom_base_model)
340
+ if base_model not in BASE_MODELS:
341
+ raise ValueError("unsupported Krea base model")
342
+ if custom_base_model:
343
+ raise ValueError("custom base-model details require the custom model option")
344
+ return _ensure_base_model(base_model)
345
+
346
+
347
+ def _ensure_models(
348
+ base_model: str = DEFAULT_BASE_MODEL,
349
+ custom_base_model: dict[str, Any] | None = None,
350
+ progress: gr.Progress | None = None,
351
+ ) -> str:
352
+ total = len(DOWNLOADS) + 1
353
+ for index, (repo, filename, destination, label) in enumerate(DOWNLOADS):
354
+ if progress:
355
+ progress(index / total, desc=f"downloading {label}")
356
+ _download_to_dest(repo, filename, destination, label)
357
+ if base_model == CUSTOM_BASE_MODEL:
358
+ if progress:
359
+ progress(len(DOWNLOADS) / total, desc="downloading custom Hugging Face checkpoint")
360
+ return _resolve_base_model(base_model, custom_base_model)
361
+ if progress:
362
+ progress(len(DOWNLOADS) / total, desc="downloading selected Krea checkpoint")
363
+ return _resolve_base_model(base_model)
364
+
365
+
366
+ def _ensure_lora(hf_filename: str) -> str:
367
+ """Lazy-download one catalog LoRA and return its ComfyUI path."""
368
+ normalized = pathlib.PurePosixPath(str(hf_filename).replace("\\", "/")).as_posix()
369
+ if normalized not in _lora_by_filename:
370
+ raise ValueError(f"catalog LoRA is not available: {hf_filename}")
371
+ destination = LORA_DEST_DIR.joinpath(*pathlib.PurePosixPath(normalized).parts)
372
+ if destination.exists():
373
+ return pathlib.PurePosixPath("krea2", normalized).as_posix()
374
+ destination.parent.mkdir(parents=True, exist_ok=True)
375
+ token = os.environ.get("HF_TOKEN") or os.environ.get("HUGGINGFACE_HUB_TOKEN")
376
+ path = pathlib.PurePosixPath(normalized)
377
+ downloaded = pathlib.Path(
378
+ hf_hub_download(
379
+ repo_id=LORA_HF_REPO,
380
+ filename=path.name,
381
+ subfolder=None if str(path.parent) == "." else str(path.parent),
382
+ local_dir=str(LORA_DEST_DIR),
383
+ token=token,
384
+ )
385
+ )
386
+ if downloaded.resolve() != destination.resolve():
387
+ destination.parent.mkdir(parents=True, exist_ok=True)
388
+ shutil.move(str(downloaded), str(destination))
389
+ return pathlib.PurePosixPath("krea2", normalized).as_posix()
390
+
391
+
392
+ def _ensure_custom_lora(row: dict[str, Any]) -> str:
393
+ """Download one validated custom HF LoRA and return its ComfyUI path."""
394
+ normalized = validate_custom_lora(row)
395
+ namespace = stable_custom_lora_namespace(
396
+ normalized["repo_id"], normalized["filename"], normalized["revision"]
397
+ )
398
+ destination_dir = CUSTOM_LORA_DEST_DIR / namespace
399
+ relative_file = pathlib.PurePosixPath(normalized["filename"])
400
+ destination = destination_dir.joinpath(*relative_file.parts)
401
+ if destination.exists():
402
+ relative = destination.resolve().relative_to(LORA_ROOT.resolve())
403
+ return pathlib.PurePosixPath(*relative.parts).as_posix()
404
+
405
+ token = os.environ.get("HF_TOKEN") or os.environ.get("HUGGINGFACE_HUB_TOKEN")
406
+ kwargs: dict[str, Any] = {
407
+ "repo_id": normalized["repo_id"],
408
+ "filename": normalized["filename"],
409
+ "local_dir": str(destination_dir),
410
+ "token": token,
411
+ }
412
+ if normalized["revision"]:
413
+ kwargs["revision"] = normalized["revision"]
414
+ try:
415
+ downloaded = pathlib.Path(hf_hub_download(**kwargs))
416
+ except Exception as exc:
417
+ raise RuntimeError(
418
+ f"failed to download custom LoRA {normalized['repo_id']}/{normalized['filename']}: {exc}"
419
+ ) from exc
420
+ if not downloaded.exists():
421
+ raise RuntimeError(f"HF Hub returned a missing custom LoRA path: {downloaded}")
422
+ try:
423
+ relative = downloaded.resolve().relative_to(LORA_ROOT.resolve())
424
+ except ValueError as exc:
425
+ raise RuntimeError("custom LoRA download escaped the managed LoRA directory") from exc
426
+ return pathlib.PurePosixPath(*relative.parts).as_posix()
427
+
428
+
429
+ def _read_source_workflow(path: pathlib.Path) -> dict[str, Any]:
430
+ """Load a bundled visual workflow and fail early if it was not shipped."""
431
+ if not path.exists():
432
+ raise FileNotFoundError(f"workflow file is missing: {path.name}")
433
+ data = json.loads(path.read_text(encoding="utf-8"))
434
+ if not data.get("nodes"):
435
+ raise ValueError(f"workflow file has no nodes: {path.name}")
436
+ return data
437
+
438
+
439
+ def _ref(node: str, output: int = 0) -> list[Any]:
440
+ return [node, output]
441
+
442
+
443
+ def _validate_model_name(model_name: str) -> str:
444
+ """Accept only a relative model name produced by the managed model loader."""
445
+ normalized = str(model_name).replace("\\", "/")
446
+ path = pathlib.PurePosixPath(normalized)
447
+ if not normalized or path.is_absolute() or any(part in {"", ".", ".."} for part in path.parts):
448
+ raise ValueError("invalid Krea base model path")
449
+ return path.as_posix()
450
+
451
+
452
+ def _t2i_workflow(base_model: str = DEFAULT_BASE_MODEL) -> dict[str, Any]:
453
+ base_model = _validate_model_name(base_model)
454
+ cache_key = f"text2image:{base_model}"
455
+ if cache_key in _workflow_cache:
456
+ return json.loads(json.dumps(_workflow_cache[cache_key]))
457
+ _read_source_workflow(T2I_SOURCE)
458
+ workflow = {
459
+ "1": {"class_type": "UNETLoader", "inputs": {"unet_name": base_model, "weight_dtype": "default"}},
460
+ "2": {"class_type": "CLIPLoader", "inputs": {"clip_name": "qwen3vl_4b_fp8_scaled.safetensors", "type": "krea2", "device": "default"}},
461
+ "3": {"class_type": "VAELoader", "inputs": {"vae_name": "qwen_image_vae.safetensors"}},
462
+ "4": {"class_type": "ModelSamplingAuraFlow", "inputs": {"model": _ref("1"), "shift": 4.0}},
463
+ "5": {"class_type": "CLIPTextEncode", "inputs": {"clip": _ref("2"), "text": ""}},
464
+ "6": {"class_type": "ConditioningZeroOut", "inputs": {"conditioning": _ref("5")}},
465
+ "7": {"class_type": "EmptyLatentImage", "inputs": {"width": DEFAULT_WIDTH, "height": DEFAULT_HEIGHT, "batch_size": 1}},
466
+ "8": {"class_type": "KSampler", "inputs": {"model": _ref("4"), "positive": _ref("5"), "negative": _ref("6"), "latent_image": _ref("7"), "seed": DEFAULT_SEED, "steps": DEFAULT_STEPS, "cfg": DEFAULT_CFG, "sampler_name": DEFAULT_SAMPLER, "scheduler": DEFAULT_SCHEDULER, "denoise": 1.0}},
467
+ "9": {"class_type": "VAEDecode", "inputs": {"samples": _ref("8"), "vae": _ref("3")}},
468
+ "10": {"class_type": "SaveImage", "inputs": {"images": _ref("9"), "filename_prefix": "krea2_turbo"}},
469
+ }
470
+ _workflow_cache[cache_key] = workflow
471
+ return json.loads(json.dumps(workflow))
472
+
473
+
474
+ def _edit_workflow(
475
+ has_second_reference: bool,
476
+ base_model: str = DEFAULT_BASE_MODEL,
477
+ ) -> dict[str, Any]:
478
+ base_model = _validate_model_name(base_model)
479
+ _read_source_workflow(EDIT_SOURCE)
480
+ workflow: dict[str, Any] = {
481
+ "1": {"class_type": "LoadImage", "inputs": {"image": ""}},
482
+ "3": {"class_type": "CLIPLoader", "inputs": {"clip_name": "qwen3vl_4b_fp8_scaled.safetensors", "type": "krea2", "device": "default"}},
483
+ "4": {"class_type": "VAELoader", "inputs": {"vae_name": "qwen_image_vae.safetensors"}},
484
+ "5": {"class_type": "UNETLoader", "inputs": {"unet_name": base_model, "weight_dtype": "default"}},
485
+ "6": {"class_type": "LoraLoaderModelOnly", "inputs": {"model": _ref("5"), "lora_name": "krea/" + IDENTITY_FILE, "strength_model": 1.0}},
486
+ "7": {"class_type": "VAEEncode", "inputs": {"pixels": _ref("1"), "vae": _ref("4")}},
487
+ "8": {"class_type": "EmptySD3LatentImage", "inputs": {"width": DEFAULT_WIDTH, "height": DEFAULT_HEIGHT, "batch_size": 1}},
488
+ "9": {"class_type": "Krea2EditModelPatch", "inputs": {"model": _ref("6"), "source_latent": _ref("7"), "vae": _ref("4"), "source_image": _ref("1"), "target_latent": _ref("8"), "ref_boost": DEFAULT_REF_BOOST, "ref_boost_a": DEFAULT_REF_BOOST, "fit_mode": "fit"}},
489
+ "10": {"class_type": "Krea2EditGroundedEncode", "inputs": {"clip": _ref("3"), "image": _ref("1"), "prompt": "", "grounding_px": DEFAULT_GROUNDING}},
490
+ "11": {"class_type": "ConditioningZeroOut", "inputs": {"conditioning": _ref("10")}},
491
+ "12": {"class_type": "ModelSamplingAuraFlow", "inputs": {"model": _ref("9"), "shift": 4.0}},
492
+ "13": {"class_type": "KSampler", "inputs": {"model": _ref("12"), "positive": _ref("10"), "negative": _ref("11"), "latent_image": _ref("8"), "seed": DEFAULT_SEED, "steps": DEFAULT_STEPS, "cfg": DEFAULT_CFG, "sampler_name": DEFAULT_SAMPLER, "scheduler": DEFAULT_SCHEDULER, "denoise": 1.0}},
493
+ "14": {"class_type": "VAEDecode", "inputs": {"samples": _ref("13"), "vae": _ref("4")}},
494
+ "15": {"class_type": "SaveImage", "inputs": {"images": _ref("14"), "filename_prefix": "krea2_edit"}},
495
+ }
496
+ if has_second_reference:
497
+ workflow["2"] = {"class_type": "LoadImage", "inputs": {"image": ""}}
498
+ workflow["16"] = {"class_type": "VAEEncode", "inputs": {"pixels": _ref("2"), "vae": _ref("4")}}
499
+ workflow["9"]["inputs"]["source_latent_b"] = _ref("16")
500
+ workflow["9"]["inputs"]["source_image_b"] = _ref("2")
501
+ workflow["10"]["inputs"]["image_b"] = _ref("2")
502
+ return workflow
503
+
504
+
505
+ def _find_node(workflow: dict[str, Any], class_type: str) -> str:
506
+ for node_id, node in workflow.items():
507
+ if node.get("class_type") == class_type:
508
+ return node_id
509
+ raise KeyError(f"workflow does not contain {class_type}")
510
+
511
+
512
+ def _inject_lora_chain(
513
+ workflow: dict[str, Any],
514
+ enabled_loras: list[tuple[str, float]],
515
+ *,
516
+ model_source: list[Any],
517
+ clip_source: list[Any],
518
+ model_consumers: list[tuple[str, str]],
519
+ clip_consumers: list[tuple[str, str]],
520
+ ) -> None:
521
+ """Append an ordered model+CLIP LoRA chain to a workflow."""
522
+ if not enabled_loras:
523
+ return
524
+ previous_model = model_source
525
+ previous_clip = clip_source
526
+ for index, (filename, strength) in enumerate(enabled_loras):
527
+ node_id = f"user_lora_{index}"
528
+ workflow[node_id] = {
529
+ "class_type": "LoraLoader",
530
+ "inputs": {
531
+ "model": previous_model,
532
+ "clip": previous_clip,
533
+ "lora_name": filename,
534
+ "strength_model": float(strength),
535
+ "strength_clip": float(strength),
536
+ },
537
+ }
538
+ previous_model = _ref(node_id)
539
+ previous_clip = _ref(node_id, 1)
540
+ for node_id, input_name in model_consumers:
541
+ workflow[node_id]["inputs"][input_name] = previous_model
542
+ for node_id, input_name in clip_consumers:
543
+ workflow[node_id]["inputs"][input_name] = previous_clip
544
+
545
+
546
+ def _prepare_edit_image(path: str, target_megapixels: float) -> tuple[str, int, int]:
547
+ """Resize the primary source to a 64-pixel grid while preserving its AR."""
548
+ with Image.open(path) as source:
549
+ image = source.convert("RGB")
550
+ megapixels = max(0.25, min(MAX_TARGET_MP, float(target_megapixels)))
551
+ scale = (megapixels * 1_000_000 / max(1, image.width * image.height)) ** 0.5
552
+ width = max(64, int(round(image.width * scale / 64) * 64))
553
+ height = max(64, int(round(image.height * scale / 64) * 64))
554
+ width = min(MAX_WIDTH, width)
555
+ height = min(MAX_HEIGHT, height)
556
+ image = image.resize((width, height), Image.Resampling.LANCZOS)
557
+ name = f"input_{uuid.uuid4().hex[:12]}.png"
558
+ image.save(INPUT / name, format="PNG")
559
+ return name, width, height
560
+
561
+
562
+ def _stage_image(path: str, prefix: str) -> str:
563
+ with Image.open(path) as source:
564
+ image = source.convert("RGB")
565
+ name = f"{prefix}_{uuid.uuid4().hex[:12]}.png"
566
+ image.save(INPUT / name, format="PNG")
567
+ return name
568
+
569
+
570
+ def _validate_request(mode: str, prompt: str, edit_prompt: str, primary: str | None) -> None:
571
+ if mode not in {"text2image", "edit"}:
572
+ raise ValueError("unsupported generation mode")
573
+ if mode == "text2image" and not (prompt or "").strip():
574
+ raise ValueError("enter a prompt")
575
+ if mode == "edit":
576
+ if not primary:
577
+ raise ValueError("upload a primary image for edit mode")
578
+ if not (edit_prompt or prompt or "").strip():
579
+ raise ValueError("enter an edit instruction in the prompt or edit instruction field")
580
+
581
+
582
+ def _inject_t2i(
583
+ workflow: dict[str, Any],
584
+ *,
585
+ prompt: str,
586
+ negative_prompt: str = "",
587
+ width: int,
588
+ height: int,
589
+ steps: int,
590
+ cfg: float,
591
+ sampler: str,
592
+ scheduler: str,
593
+ seed: int,
594
+ enabled_loras: list[tuple[str, float]] | None = None,
595
+ ) -> None:
596
+ _inject_lora_chain(
597
+ workflow,
598
+ enabled_loras or [],
599
+ model_source=_ref("1"),
600
+ clip_source=_ref("2"),
601
+ model_consumers=[("4", "model")],
602
+ clip_consumers=[("5", "clip")],
603
+ )
604
+ workflow["5"]["inputs"]["text"] = prompt.strip()
605
+ workflow["6"]["inputs"]["text"] = negative_prompt.strip()
606
+ workflow["7"]["inputs"].update(width=int(width), height=int(height))
607
+ workflow["8"]["inputs"].update(seed=int(seed), steps=int(steps), cfg=float(cfg), sampler_name=sampler, scheduler=scheduler, denoise=1.0)
608
+
609
+
610
+ def _inject_edit(
611
+ workflow: dict[str, Any],
612
+ *,
613
+ primary_name: str,
614
+ second_name: str | None,
615
+ width: int,
616
+ height: int,
617
+ edit_prompt: str,
618
+ negative_prompt: str = "",
619
+ grounding_px: int,
620
+ ref_boost: float,
621
+ ref_boost_a: float,
622
+ steps: int,
623
+ cfg: float,
624
+ sampler: str,
625
+ scheduler: str,
626
+ seed: int,
627
+ enabled_loras: list[tuple[str, float]] | None = None,
628
+ ) -> None:
629
+ _inject_lora_chain(
630
+ workflow,
631
+ enabled_loras or [],
632
+ model_source=_ref("6"),
633
+ clip_source=_ref("3"),
634
+ model_consumers=[("9", "model")],
635
+ clip_consumers=[("10", "clip")],
636
+ )
637
+ workflow["1"]["inputs"]["image"] = primary_name
638
+ workflow["8"]["inputs"].update(width=int(width), height=int(height))
639
+ workflow["9"]["inputs"].update(ref_boost=float(ref_boost), ref_boost_a=float(ref_boost_a))
640
+ workflow["10"]["inputs"].update(prompt=edit_prompt.strip(), grounding_px=int(grounding_px))
641
+ workflow["11"]["inputs"]["text"] = negative_prompt.strip()
642
+ workflow["13"]["inputs"].update(seed=int(seed), steps=int(steps), cfg=float(cfg), sampler_name=sampler, scheduler=scheduler, denoise=1.0)
643
+ if second_name:
644
+ workflow["2"]["inputs"]["image"] = second_name
645
+
646
+
647
+ def _execute_workflow(workflow: dict[str, Any]) -> list[str]:
648
+ import execution
649
+ import server
650
+
651
+ loop = asyncio.new_event_loop()
652
+ asyncio.set_event_loop(loop)
653
+
654
+ try:
655
+ from app.assets.manager import default_asset_manager
656
+ server_instance = server.PromptServer(loop, default_asset_manager())
657
+ except TypeError:
658
+ server_instance = server.PromptServer(loop)
659
+
660
+ executor = execution.PromptExecutor(
661
+ server_instance,
662
+ cache_type=execution.CacheType.RAM_PRESSURE,
663
+ cache_args={"lru": 0, "ram": 2.0, "ram_inactive": 8.0},
664
+ )
665
+ prompt_id = str(uuid.uuid4())
666
+ save_id = _find_node(workflow, "SaveImage")
667
+ executor.execute(workflow, prompt_id, extra_data={}, execute_outputs=[save_id])
668
+ if not executor.success:
669
+ message = executor.status_messages[-1] if executor.status_messages else "ComfyUI execution failed"
670
+ raise RuntimeError(str(message))
671
+ paths: list[pathlib.Path] = []
672
+ for output in executor.history_result.get("outputs", {}).values():
673
+ for items in output.values():
674
+ if not isinstance(items, list):
675
+ continue
676
+ for item in items:
677
+ if not isinstance(item, dict) or not item.get("filename"):
678
+ continue
679
+ base = OUTPUT if item.get("type", "output") == "output" else COMFY / item.get("type", "output")
680
+ candidate = base / item.get("subfolder", "") / item["filename"]
681
+ if candidate.exists():
682
+ paths.append(candidate)
683
+ if not paths:
684
+ paths = sorted(
685
+ [pathlib.Path(item) for item in glob.glob(str(OUTPUT / "**" / "*.png"), recursive=True)],
686
+ key=lambda item: item.stat().st_mtime,
687
+ reverse=True,
688
+ )
689
+ if not paths:
690
+ raise RuntimeError("ComfyUI finished without an output image")
691
+ return [str(path) for path in paths]
692
+
693
+
694
+ def _prepare_runtime(
695
+ base_model: str = DEFAULT_BASE_MODEL,
696
+ custom_base_model: dict[str, Any] | None = None,
697
+ progress: gr.Progress | None = None,
698
+ ) -> str:
699
+ _ensure_comfy()
700
+ resolved_base_model = _ensure_models(base_model, custom_base_model, progress)
701
+ _init_comfy_nodes()
702
+ return resolved_base_model
703
+
704
+
705
+ def get_gpu_duration(*args: Any, **kwargs: Any) -> int:
706
+ """Estimate GPU time for Spaces' positional or keyword callback forms."""
707
+ # spaces.zero invokes a duration callback with the complete generate()
708
+ # argument list positionally. Keep the indexes aligned with generate().
709
+ steps = kwargs.get("steps", args[12] if len(args) > 12 else DEFAULT_STEPS)
710
+ width = kwargs.get("width", args[6] if len(args) > 6 else DEFAULT_WIDTH)
711
+ height = kwargs.get("height", args[7] if len(args) > 7 else DEFAULT_HEIGHT)
712
+ gen_budget = kwargs.get("gen_budget", args[18] if len(args) > 18 else 0)
713
+ if gen_budget and int(gen_budget) > 0:
714
+ return max(MIN_GPU_SECONDS, min(MAX_GPU_SECONDS, int(gen_budget)))
715
+ lora_weights = kwargs.get("lora_weights", args[23] if len(args) > 23 else {}) or {}
716
+ custom_loras = kwargs.get("custom_loras", args[24] if len(args) > 24 else []) or []
717
+ lora_count = sum(
718
+ 1 for value in lora_weights.values()
719
+ if value and abs(float(value)) > 1e-6
720
+ )
721
+ lora_count += sum(1 for row in custom_loras if isinstance(row, (dict, list, tuple)))
722
+ estimate = int(
723
+ 35
724
+ + (int(width) * int(height) / 1_000_000)
725
+ * int(steps)
726
+ * 3.0
727
+ * (1 + 0.05 * lora_count)
728
+ )
729
+ return max(MIN_GPU_SECONDS, min(MAX_GPU_SECONDS, estimate))
730
+
731
+
732
+ @spaces.GPU(duration=get_gpu_duration)
733
+ def generate(
734
+ mode: str,
735
+ prompt: str,
736
+ negative_prompt: str,
737
+ edit_prompt: str,
738
+ primary_image: str | None,
739
+ second_image: str | None,
740
+ width: int,
741
+ height: int,
742
+ target_megapixels: float,
743
+ grounding_px: int,
744
+ ref_boost: float,
745
+ ref_boost_a: float,
746
+ steps: int,
747
+ cfg: float,
748
+ sampler: str,
749
+ scheduler: str,
750
+ seed: int,
751
+ randomize_seed: bool,
752
+ gen_budget: float,
753
+ base_model: str = DEFAULT_BASE_MODEL,
754
+ custom_base_repo: str = "",
755
+ custom_base_filename: str = "",
756
+ custom_base_revision: str = "",
757
+ lora_weights: dict[str, float] | None = None,
758
+ custom_loras: list[dict[str, Any]] | None = None,
759
+ progress: gr.Progress = gr.Progress(track_tqdm=True),
760
+ ) -> tuple[list[str], str, int]:
761
+ """Validate inputs, execute the selected Krea graph, and persist outputs."""
762
+ effective_seed = random.randint(0, 2**32 - 1) if randomize_seed or int(seed) < 0 else int(seed)
763
+ staged: list[pathlib.Path] = []
764
+ try:
765
+ _validate_request(mode, prompt, edit_prompt, primary_image)
766
+ effective_edit_prompt = (edit_prompt or prompt or "").strip()
767
+ if sampler not in SAMPLERS or scheduler not in SCHEDULERS:
768
+ raise ValueError("unsupported sampler or scheduler")
769
+ custom_base = None
770
+ if base_model == CUSTOM_BASE_MODEL:
771
+ custom_base = validate_custom_base_model({
772
+ "repo_id": custom_base_repo,
773
+ "filename": custom_base_filename,
774
+ "revision": custom_base_revision,
775
+ })
776
+ elif base_model not in BASE_MODELS:
777
+ raise ValueError("unsupported Krea base model")
778
+ resolved_base_model = _prepare_runtime(base_model, custom_base, progress)
779
+
780
+ enabled_loras: list[tuple[str, float]] = []
781
+ active_catalog: list[dict[str, Any]] = []
782
+ for filename, weight in (lora_weights or {}).items():
783
+ if filename not in _lora_by_filename:
784
+ raise ValueError(f"catalog LoRA is not available: {filename}")
785
+ numeric_weight = float(weight)
786
+ if numeric_weight < -3.0 or numeric_weight > 3.0:
787
+ raise ValueError(f"catalog LoRA weight is out of range: {filename}")
788
+ if abs(numeric_weight) > 1e-6:
789
+ enabled_loras.append((_ensure_lora(filename), numeric_weight))
790
+ active_catalog.append({"hf_filename": filename, "weight": numeric_weight})
791
+
792
+ normalized_custom, custom_warnings = normalize_custom_loras(custom_loras)
793
+ if custom_warnings:
794
+ raise ValueError("; ".join(custom_warnings))
795
+ active_custom = [
796
+ row for row in normalized_custom if abs(float(row["weight"])) > 1e-6
797
+ ]
798
+ for row in active_custom:
799
+ enabled_loras.append((_ensure_custom_lora(row), float(row["weight"])))
800
+
801
+ if mode == "text2image":
802
+ width = max(512, min(MAX_WIDTH, int(width) // 64 * 64))
803
+ height = max(512, min(MAX_HEIGHT, int(height) // 64 * 64))
804
+ workflow = _t2i_workflow(resolved_base_model)
805
+ else:
806
+ primary_name, width, height = _prepare_edit_image(primary_image, target_megapixels)
807
+ staged.append(INPUT / primary_name)
808
+ second_name = _stage_image(second_image, "reference") if second_image else None
809
+ if second_name:
810
+ staged.append(INPUT / second_name)
811
+ workflow = _edit_workflow(bool(second_name), resolved_base_model)
812
+
813
+ if mode == "text2image":
814
+ _inject_t2i(
815
+ workflow,
816
+ prompt=prompt,
817
+ negative_prompt=negative_prompt,
818
+ width=width,
819
+ height=height,
820
+ steps=int(steps),
821
+ cfg=float(cfg),
822
+ sampler=sampler,
823
+ scheduler=scheduler,
824
+ seed=effective_seed,
825
+ enabled_loras=enabled_loras,
826
+ )
827
+ else:
828
+ _inject_edit(
829
+ workflow,
830
+ primary_name=primary_name,
831
+ second_name=second_name,
832
+ width=width,
833
+ height=height,
834
+ edit_prompt=effective_edit_prompt,
835
+ negative_prompt=negative_prompt,
836
+ grounding_px=int(grounding_px),
837
+ ref_boost=float(ref_boost),
838
+ ref_boost_a=float(ref_boost_a),
839
+ steps=int(steps),
840
+ cfg=float(cfg),
841
+ sampler=sampler,
842
+ scheduler=scheduler,
843
+ seed=effective_seed,
844
+ enabled_loras=enabled_loras,
845
+ )
846
+
847
+ settings = build_settings(
848
+ mode=mode,
849
+ prompt=prompt,
850
+ edit_prompt=effective_edit_prompt,
851
+ width=width,
852
+ height=height,
853
+ target_megapixels=float(target_megapixels),
854
+ grounding_px=int(grounding_px),
855
+ ref_boost=float(ref_boost),
856
+ ref_boost_a=float(ref_boost_a),
857
+ steps=int(steps),
858
+ cfg=float(cfg),
859
+ sampler_name=sampler,
860
+ scheduler=scheduler,
861
+ seed=int(seed),
862
+ randomize_seed=bool(randomize_seed),
863
+ gen_budget=float(gen_budget),
864
+ effective_seed=effective_seed,
865
+ base_model=base_model,
866
+ custom_base_model=custom_base,
867
+ catalog_loras=active_catalog,
868
+ custom_loras=active_custom,
869
+ )
870
+ progress(0.35, desc=f"generating {mode}")
871
+ result_paths = _execute_workflow(workflow)
872
+ destination_dir = pathlib.Path(tempfile.mkdtemp(prefix="krea2_outputs_"))
873
+ output_paths: list[str] = []
874
+ for index, source in enumerate(result_paths):
875
+ destination = destination_dir / f"output_{index}.png"
876
+ write_png_metadata(source, destination, settings)
877
+ output_paths.append(str(destination))
878
+ return output_paths, f"done — {len(output_paths)} image(s), seed {effective_seed}", effective_seed
879
+ except Exception as exc:
880
+ print(traceback.format_exc(), flush=True)
881
+ raise gr.Error(f"generation failed: {str(exc)[:500]}") from exc
882
+ finally:
883
+ for path in staged:
884
+ try:
885
+ path.unlink(missing_ok=True)
886
+ except OSError:
887
+ pass
888
+
889
+
890
+ def _profile_from_values(
891
+ mode: str,
892
+ prompt: str,
893
+ edit_prompt: str,
894
+ width: int,
895
+ height: int,
896
+ target_mp: float,
897
+ grounding: int,
898
+ ref_boost: float,
899
+ ref_boost_a: float,
900
+ steps: int,
901
+ cfg: float,
902
+ sampler: str,
903
+ scheduler: str,
904
+ seed: int,
905
+ randomize: bool,
906
+ budget: float,
907
+ base_model: str = DEFAULT_BASE_MODEL,
908
+ custom_base_repo: str = "",
909
+ custom_base_filename: str = "",
910
+ custom_base_revision: str = "",
911
+ catalog_loras: list[dict[str, Any]] | None = None,
912
+ custom_loras: list[dict[str, Any]] | None = None,
913
+ ) -> dict[str, Any]:
914
+ return build_settings(
915
+ mode=mode,
916
+ prompt=prompt,
917
+ edit_prompt=edit_prompt,
918
+ width=int(width),
919
+ height=int(height),
920
+ target_megapixels=float(target_mp),
921
+ grounding_px=int(grounding),
922
+ ref_boost=float(ref_boost),
923
+ ref_boost_a=float(ref_boost_a),
924
+ steps=int(steps),
925
+ cfg=float(cfg),
926
+ sampler_name=sampler,
927
+ scheduler=scheduler,
928
+ seed=int(seed),
929
+ randomize_seed=bool(randomize),
930
+ gen_budget=float(budget),
931
+ base_model=base_model,
932
+ custom_base_model=(
933
+ validate_custom_base_model({
934
+ "repo_id": custom_base_repo,
935
+ "filename": custom_base_filename,
936
+ "revision": custom_base_revision,
937
+ })
938
+ if base_model == CUSTOM_BASE_MODEL
939
+ else None
940
+ ),
941
+ catalog_loras=catalog_loras,
942
+ custom_loras=custom_loras,
943
+ )
944
+
945
+
946
+ def create_ui() -> gr.Blocks:
947
+ with gr.Blocks(title="krea2-turbo-i2i", theme=gr.themes.Base()) as demo:
948
+ gr.Markdown("krea2-turbo-i2i")
949
+ with gr.Row(visible=False):
950
+ with gr.Column(scale=1):
951
+ mode = gr.Radio(["text2image", "edit"], value="text2image", label="mode")
952
+ base_model = gr.Dropdown(
953
+ choices=[
954
+ *[(item["label"], filename) for filename, item in BASE_MODELS.items()],
955
+ ("Custom Hugging Face base model", CUSTOM_BASE_MODEL),
956
+ ],
957
+ value=DEFAULT_BASE_MODEL,
958
+ label="base Krea checkpoint",
959
+ )
960
+ with gr.Column(visible=False) as custom_base_controls:
961
+ custom_base_repo = gr.Textbox(
962
+ label="custom base-model Hugging Face repository",
963
+ placeholder="namespace/repository",
964
+ )
965
+ custom_base_filename = gr.Textbox(
966
+ label="custom base-model filename",
967
+ placeholder="path/to/model.safetensors",
968
+ )
969
+ custom_base_revision = gr.Textbox(
970
+ label="custom base-model revision (optional)",
971
+ placeholder="main, tag, or commit hash",
972
+ )
973
+ gr.Markdown(
974
+ "Use a relative `.safetensors`, `.ckpt`, `.pt`, or `.bin` file. "
975
+ "Private repositories use `HF_TOKEN` or `HUGGINGFACE_HUB_TOKEN`."
976
+ )
977
+ with gr.Column(visible=False) as image_inputs:
978
+ primary = gr.Image(type="filepath", label="primary image / scene")
979
+ second = gr.Image(type="filepath", label="optional second reference")
980
+ prompt = gr.Textbox(value="A cinematic portrait in soft natural light", label="prompt", lines=3)
981
+ negative_prompt = gr.Textbox(label="negative prompt", lines=2, placeholder="what to avoid")
982
+ edit_prompt = gr.Textbox(label="edit instruction", lines=3, visible=False, placeholder="recolor the jacket to matte black")
983
+ with gr.Column() as t2i_resolution:
984
+ with gr.Row():
985
+ width = gr.Slider(512, MAX_WIDTH, value=DEFAULT_WIDTH, step=64, label="width")
986
+ height = gr.Slider(512, MAX_HEIGHT, value=DEFAULT_HEIGHT, step=64, label="height")
987
+ with gr.Column(visible=False) as edit_controls:
988
+ target_mp = gr.Slider(0.25, MAX_TARGET_MP, value=DEFAULT_TARGET_MP, step=0.05, label="target megapixels")
989
+ grounding = gr.Slider(384, 1536, value=DEFAULT_GROUNDING, step=32, label="grounding resolution")
990
+ ref_boost = gr.Slider(0.0, 12.0, value=DEFAULT_REF_BOOST, step=0.1, label="primary reference strength")
991
+ ref_boost_a = gr.Slider(0.0, 12.0, value=DEFAULT_REF_BOOST, step=0.1, label="second reference strength")
992
+ with gr.Accordion(f"LoRAs ({len(_lora_catalog)} available)", open=False):
993
+ gr.Markdown(
994
+ "Set a weight other than zero to enable a catalog LoRA. "
995
+ "Enabled catalog entries are stacked in catalog order, followed "
996
+ "by custom rows. Negative weights are supported for sliders."
997
+ )
998
+ with gr.Row():
999
+ lora_search = gr.Textbox(
1000
+ label="search catalog LoRAs",
1001
+ placeholder="title, trigger word, tag, or category",
1002
+ lines=1,
1003
+ )
1004
+ lora_category = gr.Dropdown(
1005
+ choices=["all"] + sorted({str(item.get("category", "uncategorized")) for item in _lora_catalog}),
1006
+ value="all",
1007
+ label="category",
1008
+ )
1009
+ lora_slider_map: dict[str, gr.Slider] = {}
1010
+ for item in _lora_catalog:
1011
+ filename = str(item.get("hf_filename", ""))
1012
+ if not filename:
1013
+ continue
1014
+ title = str(item.get("title", filename))
1015
+ category = str(item.get("category", "uncategorized"))
1016
+ triggers = ", ".join(str(value) for value in item.get("trigger_words", [])[:3])
1017
+ label = f"[{category}] {title}"
1018
+ if triggers:
1019
+ label += f" — {triggers}"
1020
+ lora_slider_map[filename] = gr.Slider(
1021
+ minimum=-3.0,
1022
+ maximum=3.0,
1023
+ value=0.0,
1024
+ step=0.05,
1025
+ label=label,
1026
+ )
1027
+ custom_loras = gr.Dataframe(
1028
+ headers=["repo_id", "filename", "revision", "weight"],
1029
+ datatype=["str", "str", "str", "number"],
1030
+ value=[],
1031
+ row_count=(0, "dynamic"),
1032
+ col_count=(4, "fixed"),
1033
+ type="array",
1034
+ label="custom Hugging Face LoRAs",
1035
+ interactive=True,
1036
+ )
1037
+ gr.Markdown(
1038
+ "Custom rows use `repo_id`, `filename`, optional `revision`, and `weight`. "
1039
+ "Private repositories use `HF_TOKEN` or `HUGGINGFACE_HUB_TOKEN`."
1040
+ )
1041
+ with gr.Accordion("sampling", open=False):
1042
+ steps = gr.Slider(4, 40, value=DEFAULT_STEPS, step=1, label="steps")
1043
+ cfg = gr.Slider(1.0, 5.0, value=DEFAULT_CFG, step=0.1, label="CFG")
1044
+ with gr.Row():
1045
+ sampler = gr.Dropdown(SAMPLERS, value=DEFAULT_SAMPLER, label="sampler")
1046
+ scheduler = gr.Dropdown(SCHEDULERS, value=DEFAULT_SCHEDULER, label="scheduler")
1047
+ with gr.Row():
1048
+ seed = gr.Number(value=DEFAULT_SEED, precision=0, label="seed")
1049
+ randomize = gr.Checkbox(value=False, label="randomize seed")
1050
+ with gr.Accordion("settings", open=False):
1051
+ profile_name = gr.Textbox(label="profile name")
1052
+ export_button = gr.Button("export settings", size="sm")
1053
+ export_file = gr.File(label="profile", visible=False)
1054
+ import_file = gr.File(label="import JSON profile", file_types=[".json"], type="filepath")
1055
+ metadata_image = gr.Image(type="filepath", label="read settings from image")
1056
+ read_metadata = gr.Button("read image metadata", size="sm")
1057
+ profile_status = gr.Textbox(label="settings status", interactive=False)
1058
+ gen_budget = gr.Slider(0, MAX_GPU_SECONDS, value=0, step=10, label="GPU budget (0 = automatic)")
1059
+ button = gr.Button("generate", variant="primary", size="lg")
1060
+
1061
+ gallery = gr.Gallery(label="output", columns=2, height=600)
1062
+ status = gr.Textbox(label="status", interactive=False)
1063
+ used_seed = gr.Number(label="used seed", interactive=False)
1064
+
1065
+ def on_mode_change(value: str):
1066
+ editing = value == "edit"
1067
+ return gr.update(visible=editing), gr.update(visible=not editing), gr.update(visible=editing), gr.update(visible=editing)
1068
+
1069
+ mode.change(on_mode_change, inputs=[mode], outputs=[image_inputs, t2i_resolution, edit_controls, edit_prompt])
1070
+
1071
+ def on_base_model_change(value: str):
1072
+ return gr.update(visible=value == CUSTOM_BASE_MODEL)
1073
+
1074
+ base_model.change(on_base_model_change, inputs=[base_model], outputs=[custom_base_controls])
1075
+
1076
+ all_lora_filenames = list(lora_slider_map.keys())
1077
+ all_lora_sliders = list(lora_slider_map.values())
1078
+
1079
+ def _filter_lora_sliders(search_text: str, category: str):
1080
+ search = (search_text or "").strip().lower()
1081
+ selected_category = (category or "all").strip()
1082
+ updates = []
1083
+ for item, filename in zip(_lora_catalog, all_lora_filenames):
1084
+ searchable = " ".join([
1085
+ str(item.get("title", "")),
1086
+ str(item.get("category", "")),
1087
+ " ".join(str(value) for value in item.get("tags", [])),
1088
+ " ".join(str(value) for value in item.get("trigger_words", [])),
1089
+ filename,
1090
+ ]).lower()
1091
+ visible = (
1092
+ (selected_category == "all" or item.get("category", "uncategorized") == selected_category)
1093
+ and (not search or search in searchable)
1094
+ )
1095
+ updates.append(gr.update(visible=visible))
1096
+ return updates
1097
+
1098
+ lora_search.change(
1099
+ _filter_lora_sliders,
1100
+ inputs=[lora_search, lora_category],
1101
+ outputs=all_lora_sliders,
1102
+ )
1103
+ lora_category.change(
1104
+ _filter_lora_sliders,
1105
+ inputs=[lora_search, lora_category],
1106
+ outputs=all_lora_sliders,
1107
+ )
1108
+
1109
+ def _catalog_weights(values: list[Any]) -> dict[str, float]:
1110
+ return {
1111
+ filename: float(weight)
1112
+ for filename, weight in zip(all_lora_filenames, values)
1113
+ if weight and abs(float(weight)) > 1e-6
1114
+ }
1115
+
1116
+ def _generate_wrapper(*values):
1117
+ base_values = values[:19]
1118
+ base_model_value = values[19]
1119
+ custom_repo = values[20]
1120
+ custom_filename = values[21]
1121
+ custom_revision = values[22]
1122
+ custom_rows = values[23]
1123
+ lora_weights = _catalog_weights(values[24:])
1124
+ return generate(
1125
+ *base_values,
1126
+ base_model=base_model_value,
1127
+ custom_base_repo=custom_repo,
1128
+ custom_base_filename=custom_filename,
1129
+ custom_base_revision=custom_revision,
1130
+ lora_weights=lora_weights,
1131
+ custom_loras=custom_rows,
1132
+ )
1133
+
1134
+ generation_inputs = [
1135
+ mode, prompt, negative_prompt, edit_prompt, primary, second, width, height, target_mp,
1136
+ grounding, ref_boost, ref_boost_a, steps, cfg, sampler, scheduler,
1137
+ seed, randomize, gen_budget, base_model, custom_base_repo, custom_base_filename,
1138
+ custom_base_revision, custom_loras, *all_lora_sliders,
1139
+ ]
1140
+ button.click(_generate_wrapper, inputs=generation_inputs, outputs=[gallery, status, used_seed], api_name="generate")
1141
+
1142
+ profile_inputs = [
1143
+ mode, prompt, edit_prompt, width, height, target_mp, grounding,
1144
+ ref_boost, ref_boost_a, steps, cfg, sampler, scheduler, seed,
1145
+ randomize, gen_budget, base_model, custom_base_repo, custom_base_filename,
1146
+ custom_base_revision, custom_loras, *all_lora_sliders,
1147
+ profile_name,
1148
+ ]
1149
+
1150
+ def export_profile(*values):
1151
+ name_value = str(values[-1] or "krea2")
1152
+ catalog = [
1153
+ {"hf_filename": filename, "weight": float(weight or 0.0)}
1154
+ for filename, weight in zip(all_lora_filenames, values[21:-1])
1155
+ if weight and abs(float(weight)) > 1e-6
1156
+ ]
1157
+ normalized_custom, warnings = normalize_custom_loras(values[20])
1158
+ if warnings:
1159
+ return None, "settings export failed — " + "; ".join(warnings)
1160
+ try:
1161
+ data = _profile_from_values(
1162
+ *values[:16],
1163
+ values[16],
1164
+ values[17],
1165
+ values[18],
1166
+ values[19],
1167
+ catalog,
1168
+ normalized_custom,
1169
+ )
1170
+ except (TypeError, ValueError) as exc:
1171
+ return None, f"settings export failed — {exc}"
1172
+ name = re.sub(r"[^A-Za-z0-9_-]", "_", name_value)[:40]
1173
+ handle = tempfile.NamedTemporaryFile(prefix=f"{name}_", suffix=".json", mode="w", encoding="utf-8", delete=False)
1174
+ json.dump(data, handle, indent=2)
1175
+ handle.close()
1176
+ return handle.name, "settings exported"
1177
+
1178
+ export_button.click(export_profile, inputs=profile_inputs, outputs=[export_file, profile_status]).then(lambda: gr.update(visible=True), outputs=[export_file])
1179
+
1180
+ settings_outputs = [
1181
+ mode, base_model, custom_base_repo, custom_base_filename, custom_base_revision,
1182
+ prompt, edit_prompt, width, height, target_mp, grounding,
1183
+ ref_boost, ref_boost_a, steps, cfg, sampler, scheduler, seed,
1184
+ randomize, gen_budget, custom_loras, *all_lora_sliders, profile_status, image_inputs,
1185
+ t2i_resolution, edit_controls, custom_base_controls,
1186
+ ]
1187
+ settings_keys = [
1188
+ "mode", "base_model", "custom_base_repo", "custom_base_filename", "custom_base_revision",
1189
+ "prompt", "edit_prompt", "width", "height",
1190
+ "target_megapixels", "grounding_px", "ref_boost", "ref_boost_a",
1191
+ "steps", "cfg", "sampler_name", "scheduler", "effective_seed",
1192
+ "randomize_seed", "gen_budget",
1193
+ ]
1194
+
1195
+ def settings_updates(data: dict[str, Any], warnings: list[str], error: str = ""):
1196
+ view_data = dict(data)
1197
+ custom_base = data.get("custom_base_model")
1198
+ if custom_base:
1199
+ try:
1200
+ normalized_base = validate_custom_base_model(custom_base)
1201
+ except ValueError as exc:
1202
+ warnings.append(f"ignored custom base model: {exc}")
1203
+ else:
1204
+ view_data.update({
1205
+ "custom_base_repo": normalized_base["repo_id"],
1206
+ "custom_base_filename": normalized_base["filename"],
1207
+ "custom_base_revision": normalized_base["revision"],
1208
+ })
1209
+ editing = view_data.get("mode") == "edit"
1210
+ custom_base_visible = view_data.get("base_model") == CUSTOM_BASE_MODEL
1211
+ updates = []
1212
+ for key in settings_keys:
1213
+ if key not in view_data:
1214
+ updates.append(gr.update())
1215
+ elif key == "base_model" and view_data[key] not in (*BASE_MODELS, CUSTOM_BASE_MODEL):
1216
+ warnings.append(f"ignored unsupported base model: {view_data[key]!r}")
1217
+ updates.append(gr.update())
1218
+ elif key == "edit_prompt" and "mode" in view_data:
1219
+ updates.append(gr.update(value=view_data[key], visible=editing))
1220
+ else:
1221
+ updates.append(gr.update(value=view_data[key]))
1222
+ custom_rows: list[list[Any]] = []
1223
+ if "custom_loras" in view_data:
1224
+ for row in view_data.get("custom_loras", []) or []:
1225
+ try:
1226
+ normalized = validate_custom_lora(row)
1227
+ except ValueError as exc:
1228
+ warnings.append(f"ignored custom LoRA: {exc}")
1229
+ continue
1230
+ custom_rows.append([
1231
+ normalized["repo_id"], normalized["filename"],
1232
+ normalized["revision"], normalized["weight"],
1233
+ ])
1234
+ updates.append(gr.update(value=custom_rows) if "custom_loras" in view_data else gr.update())
1235
+ catalog_values = {filename: 0.0 for filename in all_lora_filenames}
1236
+ for row in view_data.get("catalog_loras", []) or []:
1237
+ if not isinstance(row, dict):
1238
+ warnings.append("ignored malformed catalog LoRA entry")
1239
+ continue
1240
+ filename = str(row.get("hf_filename", ""))
1241
+ if filename not in catalog_values:
1242
+ warnings.append(f"catalog LoRA not found: {filename}")
1243
+ continue
1244
+ try:
1245
+ weight = float(row.get("weight", 0.0))
1246
+ except (TypeError, ValueError):
1247
+ warnings.append(f"ignored invalid catalog LoRA weight: {filename}")
1248
+ continue
1249
+ if not -3.0 <= weight <= 3.0:
1250
+ warnings.append(f"ignored out-of-range catalog LoRA weight: {filename}")
1251
+ continue
1252
+ catalog_values[filename] = weight
1253
+ updates.extend(gr.update(value=catalog_values[filename]) for filename in all_lora_filenames)
1254
+ message = error or ("settings loaded" if not warnings else "; ".join(warnings[:6]))
1255
+ if len(warnings) > 6:
1256
+ message += f" (+{len(warnings) - 6} more)"
1257
+ updates.extend([
1258
+ message,
1259
+ gr.update(visible=editing) if "mode" in view_data else gr.update(),
1260
+ gr.update(visible=not editing) if "mode" in view_data else gr.update(),
1261
+ gr.update(visible=editing) if "mode" in view_data else gr.update(),
1262
+ gr.update(visible=custom_base_visible) if "base_model" in view_data else gr.update(),
1263
+ ])
1264
+ return tuple(updates)
1265
+
1266
+ def import_profile(path: str | None):
1267
+ if not path:
1268
+ return settings_updates({}, [], "select a profile first")
1269
+ try:
1270
+ data, warnings = parse_settings_text(pathlib.Path(path).read_text(encoding="utf-8"))
1271
+ except Exception as exc:
1272
+ return settings_updates({}, [], f"could not read profile: {exc}")
1273
+ return settings_updates(data, warnings)
1274
+
1275
+ import_file.change(import_profile, inputs=[import_file], outputs=settings_outputs)
1276
+
1277
+ def import_metadata(path: str | None):
1278
+ if not path:
1279
+ return settings_updates({}, [], "upload an image first")
1280
+ data, warnings = extract_image_settings(path)
1281
+ return settings_updates(data, warnings)
1282
+
1283
+ read_metadata.click(import_metadata, inputs=[metadata_image], outputs=settings_outputs)
1284
+ return demo
1285
+
1286
+
1287
+ def _on_startup() -> None:
1288
+ if os.environ.get("KREA_SKIP_STARTUP") == "1":
1289
+ return
1290
+ try:
1291
+ _prepare_runtime()
1292
+ except Exception as exc:
1293
+ print(f"[startup] setup incomplete ({type(exc).__name__}: {exc}); generation will retry", flush=True)
1294
+
1295
+
1296
+ _on_startup()
1297
+ _load_lora_catalog()
1298
+ demo = create_ui()
1299
+ demo.queue()
1300
+
1301
+ if __name__ == "__main__":
1302
+ demo.launch(allowed_paths=["/tmp/krea2_outputs_", "/tmp/gradio"])
krea2_loras.json ADDED
@@ -0,0 +1,364 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "collection": "Krea-2 LoRAs",
3
+ "count": 17,
4
+ "categories": [
5
+ "anatomy",
6
+ "enhancer",
7
+ "pose",
8
+ "slider"
9
+ ],
10
+ "category_legend": {
11
+ "slider": "Weight-controllable concept sliders (-N to +N)",
12
+ "anatomy": "Body part shape, detail, and variant concepts",
13
+ "fluids": "Cum, pussy juice, precum, saliva, and related fluids",
14
+ "sex_act": "Specific sexual acts and fetish activities",
15
+ "sex_position": "Sexual position helpers and framing",
16
+ "pose": "Non-sex-specific posing and body language",
17
+ "pov": "First-person perspective composition helpers",
18
+ "body_type": "Overall physique and body-shape concepts",
19
+ "clothing": "Clothing interactions, bulges, and clothed-fetish concepts",
20
+ "extreme": "Extreme content: prolapse, gaping, hyper insertion",
21
+ "enhancer": "Detail enhancers, decensoring, and quality boosters",
22
+ "style": "Art style and aesthetic overrides",
23
+ "concept": "Scenario, meme, and niche concept LoRAs",
24
+ "face": "Facial expressions, eyes, and gaze"
25
+ },
26
+ "loras": [
27
+ {
28
+ "id": 2744291,
29
+ "title": "Innie Vagina (Puffy Labia Majora)",
30
+ "url": "https://civitai.red/models/2744291/innie-vagina-puffy-labia-majora?modelVersionId=3150334",
31
+ "download_url": "https://civitai.red/api/download/models/3150334?fileId=3030968",
32
+ "hf_filename": "Krea_2_innie_82_rank_128-0000001000.safetensors",
33
+ "category": "anatomy",
34
+ "tags": [
35
+ "pussy",
36
+ "innie",
37
+ "labia",
38
+ "female-genitals"
39
+ ],
40
+ "trigger_words": [],
41
+ "strength": "1",
42
+ "description": "VERSION 3.0 UPDATE: This is basically a hybrid of v1.0 and v2.0. Much better skin details over v1.0 without going overboard like I did with v2.0. It has a great balance with both low and high resolutions.\n\nRank 8 (v1.0) - Trained on smooth skin with no texture details (not enough skin detail, especially at lower resolutions, small file size)\n\nRank 32 (v2.0) - Trained on highly detailed skin texture (too much skin detail, especially at higher resolutions, medium file size)\n\nRank 128 (v3.0 - This LoRA) - Trained on both V1/V2 datasets (balanced skin detail, good at all resolutions, large file size)\n\nThis is a big LoRA since I trained it at rank 128, but it is very powerful and effective even with less training steps compared to prior runs. It also continues to work very well at 1.00 strength when stacking with multiple LoRA's (even when combining with other LoRA's that directly modify the vagina, such as NSFW all-in-ones).\n\nI have done a LOT of training/testing with this concept in an attempt to perfect it, and this is the one LoRA checkpoint I keep coming back to since it works so well. So I figure I would share it. Enjoy!\n\n--------------------------------------------------\n\nVERSION 2.0 UPDATE: So far the #1 complaint about version 1.0 was that it created extremely smooth skin that lacked details (very plastic/3D looking). I have to admit, I had tunnel-vision when testing that LoRA and actually thought it looked fine. It's possible I did the same here, so you be sure to let me know so I can keep fine-tuning for future updates. I appreciate any feedback, even if it is negative, harsh, or just poking fun at how bad the LoRA is, lol.\n\nAnywho, I completely overhauled the original dataset images by meticulously feeding every single one of them through an AI image editor (I used Klein 9B KV with a few good skin-texture/realism detailing LoRA's). I dialed-in each image as best I could (and to match the style of the original as best as possible) and trained at rank 32 (instead of rank 8). I trained to 3,000 steps like V1, but I actually found the 2,000 step version was much better (probably less overfitting). And that is the one I am providing here. I may train well past 3,000 to see if anything improves, and if it does, I'll do a 2.x version update.\n\nThe quality difference between V1 and V2 is night as day in terms of skin detail, but it's still not perfect. I may have gone a little too far on the skin texture detailing, as things can sometimes look a bit wrinkly or dried out (or like the character has some kind of skin condition). But hey, at least it's better than smooth non-detailed skin, right? Plus you can always adjust it down or up or mess with the samplers/schedulers to get exactly what you want. Euler/simple is the most balanced and euler/beta amps up the skin details. And if you do 12 steps on the sampler (instead of 8), it will add even more skin textures/details (usually too much, but you be the judge of that).\n\nSo while V2 is a huge improvement on realism/skin detail compared to V1, it is still not at the level of Krea 2 base quality. Maybe that is impossible, I don't know. But I did a lot of A/B testing with my V2 LoRA and the Krea 2 base, and the skin detail/realism was decently close (at least to my eyes). But my LoRA definitely does reduce the level of overall detail compared a baseline Krea 2 sample. Clothes might not be as detailed, there will be less stuff in the backgrounds etc.\n\nGive it a try and let me know what you think. I've only done a very limited amount of testing (a few hundred images/prompts), so no doubt I am unaware of a lot of potential downsides (or maybe even some unknown upsides). Either way, for those who really hated that V1 was so smooth and lacked skin details, this should get a little bit closer to what you may want.\n\n\n--------------------------------------------------\n\nOriginal Post:\n\nKrea 2 is an incredible image model, and it's looking more and more like it will be the true successor to Stable Diffusion 1.5/SDXL in terms of mass adoption and post-release training (LoRA's, model finetunes, etc). But the base model and all the other LoRA's (so far) have only focused on the, uh.... roast beef sandwich aspect of the vagina. Lots of wrinkly meat folds (very pronounced inner vulvas). And if that's your thing, I got no beef with you.\n\nBut for me, I like a cleaner look. Smooth curvy lines that are proportionally plumped up to an aesthetically pleasing degree. Simple, basic, not complex.\n\nm99's Labiaplasty LoRA's are, IMO, the golden standard for innies, and I hope they eventually release something for Krea 2. But since training this model is surprisingly fast (and very effective), I thought I would give it a try myself. And I'm honestly shocked at how well this LoRA turned out (at least with the tests I've done so far).\n\nTraining Info:\n\nMy training dataset consisted entirely of synthetic images of women that I generated using m99's Labiaplasty LoRA with Stable Diffusion 1.5 (Cyberrealistic) and Flux.2 Klein 9B models. On all the images only the lower body (crotch/butt) were cropped/used, so there should be little (ideally none) influence on character faces/hair/body or even overall model styles or compositions.\n\nThis should stack with other LoRA's very well, though it will be diluted and will compete when stacking (especially if the other LoRA is also trained on vaginas), so adjust the strength of it and others accordingly to achieve a proper innie. From what I've tried with stacking, it almost always has a positive effect on the vagina even if it doesn't make it a true innie (plumping up the outer lips and reducing the overall inner vulva size). It's actually quite nice and allows for some great vaginal customization in this regard when combining with other vagina LoRA's or all-in-ones.\n\nUsage:\n\nI did not add a trigger word or any captions to this LoRA. To make it work, just enable and set the strength to whatever works best for you. It is trained at 1.00 strength. If stacking, you may need to adjust it higher (or adjust other LoRA's lower) to get the right results."
43
+ },
44
+ {
45
+ "id": 2775340,
46
+ "title": "Krea2 TextFusion Refusal-Reduction LoRA",
47
+ "url": "https://civitai.red/models/2775340/krea2-textfusion-refusal-reduction-lora?modelVersionId=3125118",
48
+ "download_url": "https://civitai.red/api/download/models/3125118?fileId=3005583",
49
+ "hf_filename": "Krea2_TextFusion_Refusal_Reduction.safetensors",
50
+ "category": "enhancer",
51
+ "tags": [
52
+ "refusal-reduction",
53
+ "uncensored",
54
+ "textfusion"
55
+ ],
56
+ "trigger_words": [],
57
+ "strength": "1",
58
+ "description": "Buy me a coffee :)\n\n# Krea2 TextFusion Refusal-Reduction LoRA\n\nThis is a dedicated rank-64 LoRA trained with one narrow objective: reduce Krea2’s learned refusal and restriction behavior while preserving as much of the base model’s existing visual knowledge and prompt behavior as possible.\n\nThis is not a concept, character, style, anatomy, or aesthetic LoRA. It was not trained to add new visual concepts, reproduce a training-image set, or impose a preferred look. Its training objective was exclusively to push the model away from refusal behavior so that concepts already represented within the base model are less likely to be suppressed during text conditioning.\n\n## What It Changes\n\nKrea2 receives multiple hidden-state taps from its Qwen-VL text encoder and processes them through TextFusion before sending the resulting conditioning into the image transformer. This LoRA applies learned low-rank residuals only to the attention and internal MLP projections within:\n\n- txtfusion.layerwise_blocks.0\n\n- txtfusion.layerwise_blocks.1\n\n- txtfusion.refiner_blocks.0\n\n- txtfusion.refiner_blocks.1\n\nThe release version deliberately contains no adapter for:\n\n- The TextFusion 1 × 12 tap projector\n\n- The external/general txtmlp\n\n- The image-transformer blocks or any other image-generation layers\n\n## How It Works\n\nThe base checkpoint is never overwritten. For every targeted linear layer, LoRA adds a learned rank-64 residual to the original weight during inference:\n\nW_effective = W_base + strength × ΔW\n\nThis changes how existing Qwen-VL text features are routed, gated, transported, and refined through TextFusion before they reach Krea2’s untouched image transformer. In other words, the LoRA is intended to improve access to visual knowledge already present in the base model, not inject a new concept or replace the model’s learned visual representations.\n\nThis release targets the specific TextFusion route isolated through layer-by-layer ablation instead of broadly amplifying activations or directly altering the projector.\n\n## Usage\n\nUse strength of \"1.00\"\n\nResponsibility and Output Disclaimer\n\nThis LoRA modifies the model’s text-conditioning behavior but does not determine, authorize, endorse, supervise, or control the images produced by individual users, prompts, workflows, checkpoints, samplers, or third-party software.\n\nGenerated outputs remain dependent on the base model, user-provided conditioning, inference configuration, and the surrounding generation pipeline. The author assumes no responsibility or liability for what users choose to generate, how generated material is used, or whether any output complies with applicable laws, platform rules, licensing terms, or third-party rights.\n\nUsers are solely responsible for their prompts, generated outputs, distribution decisions, and use of this LoRA."
59
+ },
60
+ {
61
+ "id": 2772293,
62
+ "title": "PornMaster Krea2 Age Slider",
63
+ "url": "https://civitai.red/models/2772293/pornmaster-krea2-age-slider",
64
+ "download_url": "https://civitai.red/api/download/models/3121449?fileId=3001767",
65
+ "hf_filename": "PornMaster_Age_Slider_Krea2_V1.safetensors",
66
+ "category": "slider",
67
+ "tags": [
68
+ "age",
69
+ "body-type"
70
+ ],
71
+ "trigger_words": [],
72
+ "strength": null,
73
+ "description": "模型介紹為中英雙語,中文使用者可以關閉翻譯。\nPornMaster 色情大師-Krea2\n\n正面權重:人物變老。\n\nlora權重:+9 to -?\n\nPositive weight: Characters age.\n\nLora weight: +9 to -?\n\n我的其他檢查站和Lora。\nMy other checkpoints and Lora.\n\n--\n我已將模型上傳至runninghub。\nI have uploaded the model to runninghub.\n\nPornMaster_Age_Slider_Krea2_V1\n\nhttps://www.runninghub.ai/zh-cn/model/public/2076164439010807810?inviteCode=rh-v1304\n\n不要問我如何安裝的問題與comfyui如何使用。\n\n客製化lora:我的Telegram ID:@iamddtla0620\n\n我的微信ID:iamddtla\n\n我的line ID:iamddtla\n\n時間寶貴,請直接說明來意,例如:訂製lora.\n\nDo not ask me questions about how to install it or how to use ComfyUI.\n\nCustomized lora: My Telegram ID: @iamddtla0620\n\nMy WeChat ID: iamddtla\n\nMy Line ID: iamddtla\n\nTime is precious, please state your intention directly, for example: customized LORA."
74
+ },
75
+ {
76
+ "id": 2540631,
77
+ "title": "Skin Tone Slider - (Krea2 + ZIT)",
78
+ "url": "https://civitai.red/models/2540631/skin-tone-slider-krea2-zit?modelVersionId=3187970",
79
+ "download_url": "https://civitai.red/api/download/models/3187970?fileId=3068609",
80
+ "hf_filename": "skintone_v2_krea2_loraholic.safetensors",
81
+ "category": "slider",
82
+ "tags": [
83
+ "skin-tone",
84
+ "skin-color"
85
+ ],
86
+ "trigger_words": [],
87
+ "strength": null,
88
+ "description": "Krea2\n\nV1 was a little unstable at high values regarding ethnicity.\nThat problem is fixed on V2.\nV2:\nRecommended range: -3.0 to 5.0\n\n(try -10.0 or 10.0 to get a fun effect)\nV1:\nRecommended stable range: -1.5 to 1.5\nRecommended unstable range: -4.0 to 4.0\nZIT\n\nV2 is a huge improvement.\n\nV2 is as close to ethnicity stable as i think is possible. As long as you stay within the range, this should not change a prompted ethnicity to something else. But it may drift within the ethnicity, like east to west.\nSamples represents the LoRAs effect very well.\n\nOnly in the negative there is a tiny bit asian-bias when there is other asians in the image, as my sample with the 3 girls show.\nStable range: -3 and 3\nBut i will leave the range available wider just in case.\n\nAll my work is 100% free. The only thing that really matters to me is people leaving a review, good or bad. I will NEVER remove or block anyone for leaving a bad review, so don't be afraid to give me criticism.\n\nI'm stating this because when a creator blocks someone for leaving a bad review, that person can no longer see any of the creator's models, essentially muting their critics. This is something I'm highly critical of, and I believe it's a fundamental quality problem on this site."
89
+ },
90
+ {
91
+ "id": 2554618,
92
+ "title": "Areola Size Slider - (Krea2 + ZIT)",
93
+ "url": "https://civitai.red/models/2554618/areola-size-slider-krea2-zit?modelVersionId=3120387",
94
+ "download_url": "https://civitai.red/api/download/models/3120387?fileId=3000690",
95
+ "hf_filename": "areola_size_krea2_loraholic.safetensors",
96
+ "category": "slider",
97
+ "tags": [
98
+ "areolae",
99
+ "breasts"
100
+ ],
101
+ "trigger_words": [],
102
+ "strength": null,
103
+ "description": "There have been some breakthroughs in the Loraholic HQ Research Department the last days. Expect a lot of high quality sliders to come your way in the coming days.\nAreola Size Slider\nKrea2\nRecommended range: -10.0 to 10.0\nZIT\nRecommended range: -3.0 to 5.0\n\nAll my work is 100% free. The only thing that really matters to me is people leaving a review, good or bad. I will NEVER remove or block anyone for leaving a bad review, so don't be afraid to give me criticism.\n\nI'm stating this because when a creator blocks someone for leaving a bad review, that person can no longer see any of the creator's models, essentially muting their critics. This is something I'm highly critical of, and I believe it's a fundamental quality problem on this site."
104
+ },
105
+ {
106
+ "id": 2540187,
107
+ "title": "Breast Size Slider - (Krea-2 + ZIT)",
108
+ "url": "https://civitai.red/models/2540187/breast-size-slider-krea-2-zit?modelVersionId=3131773",
109
+ "download_url": "https://civitai.red/api/download/models/3131773?fileId=3012392",
110
+ "hf_filename": "breast_size_v2_krea2_loraholic.safetensors",
111
+ "category": "slider",
112
+ "tags": [
113
+ "breasts",
114
+ "size"
115
+ ],
116
+ "trigger_words": [],
117
+ "strength": null,
118
+ "description": "Krea-2 V2:\n\nV2 is focused on stability, and on keeping the womans body unaffected in size. Most, if not all other Breast size slider will make every woman chubby when you increase breast size, but this LoRA will keep the rest of her body lean and almost unaffected, in both directions.\nIt behaves different with and without clothes. And with different LoRA combinations etc. But in general i would stay within these values:\nRange naked: -5 to 5\nRange with clothes: -5 to 8\n\nIf you want hyper, or have problems with large breasts getting a forced bra, use V1 and V2 combined at half strength.\nKrea-2 V1:\nRecommended range: -4 to 5\n\nZIT\n\nv1.1 is v1.0 merged 50/50 with a v2.0 candidate that i didnt think would live up to a v2.0 quality.\nPros of v1.1 is that is retains the original face, light and pose better. And therefor it can also be pushed to higher values.\nI also changed the name of the LoRA to \"Breast\" instead of \"Breasts\", both here in civ and the filename.\n\nRecommended range: -3.0 to 10.0\n\nAll my work is 100% free. The only thing that really matters to me is people leaving a review, good or bad. I will NEVER remove or block anyone for leaving a bad review, so don't be afraid to give me criticism.\n\nI'm stating this because when a creator blocks someone for leaving a bad review, that person can no longer see any of the creator's models, essentially muting their critics. This is something I'm highly critical of, and I believe it's a fundamental quality problem on this site."
119
+ },
120
+ {
121
+ "id": 2554586,
122
+ "title": "Real / Fake Breast Slider - (Krea2 + ZIT)",
123
+ "url": "https://civitai.red/models/2554586/real-fake-breast-slider-krea2-zit?modelVersionId=3192618",
124
+ "download_url": "https://civitai.red/api/download/models/3192618?fileId=3073398",
125
+ "hf_filename": "breast_fake_real_krea2_loraholic.safetensors",
126
+ "category": "slider",
127
+ "tags": [
128
+ "breasts",
129
+ "fake",
130
+ "real",
131
+ "implants"
132
+ ],
133
+ "trigger_words": [],
134
+ "strength": null,
135
+ "description": "Krea2:\n\nThis was a nightmare to make, since saggy breasts drags the image towards older and unatractive subjects, while fake breasts will add a tons of shiny skin, saturation etc. I did my best to keep these things under controll, but its not perfect at values outside the recommended range.\nIf you want to go extreme, i recommend using a higher value on the first sampler, and -4 / 4 on the refiner. That way you can push it colse to -8 / 8 with strong prompts.\nRecommended range: -5.0 to 5.0\nMax range (will impact the face): -8.0 to 8.0\nZIT:\n\nNot perfect. I made this a while ago, so the qualiry is probably not what you expect from my LoRAs.\nSame range as the Krea2 range.\n\nAll my work is 100% free. The only thing that really matters to me is people leaving a review, good or bad. I will NEVER remove or block anyone for leaving a bad review, so don't be afraid to give me criticism.\n\nI'm stating this because when a creator blocks someone for leaving a bad review, that person can no longer see any of the creator's models, essentially muting their critics. This is something I'm highly critical of, and I believe it's a fundamental quality problem on this site."
136
+ },
137
+ {
138
+ "id": 2554559,
139
+ "title": "Protruding Nipples Slider - (Krea2 + ZIT)",
140
+ "url": "https://civitai.red/models/2554559/protruding-nipples-slider-krea2-zit?modelVersionId=3191856",
141
+ "download_url": "https://civitai.red/api/download/models/3191856?fileId=3072600",
142
+ "hf_filename": "nipples_protruding_krea2_loraholic.safetensors",
143
+ "category": "slider",
144
+ "tags": [
145
+ "nipples",
146
+ "protruding",
147
+ "breasts"
148
+ ],
149
+ "trigger_words": [],
150
+ "strength": null,
151
+ "description": "Krea2:\n\nAt high values like 4.0 and up they dont always look as good as i would like. But with good prompts and scenes this can produce some incedible breasts.\nCombines well with my Breast Size LoRA, but my not always good result combined with my areola size slider.\nRecommended range: -5.0 to 5.0\nMax range: It depends, but probably around -10.0 to 10.0\nZ-image:\n\nRecommended range is what i use in the sample image (tiny text at the bottom of the images)\n\nAll my work is 100% free. The only thing that really matters to me is people leaving a review, good or bad. I will NEVER remove or block anyone for leaving a bad review, so don't be afraid to give me criticism.\n\nI'm stating this because when a creator blocks someone for leaving a bad review, that person can no longer see any of the creator's models, essentially muting their critics. This is something I'm highly critical of, and I believe it's a fundamental quality problem on this site."
152
+ },
153
+ {
154
+ "id": 2775639,
155
+ "title": "PornMaster Krea2 Breasts Slider",
156
+ "url": "https://civitai.red/models/2775639/pornmaster-krea2-breasts-slider",
157
+ "download_url": "https://civitai.red/api/download/models/3125465?fileId=3005912",
158
+ "hf_filename": "PornMaster_Breasts_Slider_Krea2_V1.safetensors",
159
+ "category": "slider",
160
+ "tags": [
161
+ "breasts",
162
+ "size"
163
+ ],
164
+ "trigger_words": [
165
+ "Large breasts",
166
+ "Small breasts"
167
+ ],
168
+ "strength": null,
169
+ "description": "模型介紹為中英雙語,中文使用者可以關閉翻譯。\nPornMaster 色情大師-Krea2\n\n此lora無法直接生成乳房,必須使用包含nsfw的lora或檢查站。\n\n正面權重:乳房變大。\n\n負面權重:乳房變小。\n\nLora權重:+15 to -10,權重超過10以上可能會改變”角色lora”的面部特徵,最高可到達+20。\n\n添加乳房相關描述會有幫助。\n\n \n\nPositive weight: Breasts become larger.\n\nNegative weight: Breasts become smaller.\n\n \n\nThis Lora cannot generate breasts directly; a Lora with NSFW or a checkpoint must be used.\n\n \n\nLora weight: +15 to -10. Weights exceeding 10 may alter the facial features of the \"character Lora,\" reaching a maximum of +20.\n\n \n\nAdding breast-related descriptions will be helpful.\n\n我的其他檢查站和Lora。\nMy other checkpoints and Lora.\n\n--\n我已將模型上傳至runninghub。\nI have uploaded the model to runninghub.\n\nPornMaster_Breasts_Slider_Krea2_V1\n\nhttps://www.runninghub.ai/model/public/2076599526287671297/?inviteCode=rh-v1304\n\n不要問我如何安裝的問題與comfyui如何使用。\n\n客製化lora:我的Telegram ID:@iamddtla0620\n\n我的微信ID:iamddtla\n\n我的line ID:iamddtla\n\n時間寶貴,請直接說明來意,例如:訂製lora.\n\nDo not ask me questions about how to install it or how to use ComfyUI.\n\nCustomized lora: My Telegram ID: @iamddtla0620\n\nMy WeChat ID: iamddtla\n\nMy Line ID: iamddtla\n\nTime is precious, please state your intention directly, for example: customized LORA."
170
+ },
171
+ {
172
+ "id": 2769967,
173
+ "title": "PornMaster Krea2 Flat chest & Innie pussy",
174
+ "url": "https://civitai.red/models/2769967/pornmaster-krea2-flat-chest-and-innie-pussy?modelVersionId=3118444",
175
+ "download_url": "https://civitai.red/api/download/models/3118444?fileId=2998737",
176
+ "hf_filename": "PornMaster_Flat_chest_&_Innie_pussy_krea2_V1.safetensors",
177
+ "category": "anatomy",
178
+ "tags": [
179
+ "flat-chest",
180
+ "innie-pussy",
181
+ "small-breasts",
182
+ "female-genitals"
183
+ ],
184
+ "trigger_words": [
185
+ "her genitals were just a slit",
186
+ "she has small areolas",
187
+ "nipples visible.",
188
+ "she has no areolas. nipples visible.",
189
+ "and the extremely thin white panties clung tightly to her genitals",
190
+ "making their shape visible through them."
191
+ ],
192
+ "strength": null,
193
+ "description": "模型介紹為中英雙語,中文使用者可以關閉翻譯。\n\n當\"Flat chest \"加上\"Innie pussy\"生成圖片時,我的許多範例圖片無法被展示出來,已經被\"civitai\"自動的阻擋.\n\nWhen \"Flat chest\" is combined with \"Innie pussy\" to generate an image, many of my example images cannot be displayed because they are automatically blocked by \"civitai\".\n\n某些內褲或服裝,此lora也可以當\"駱駝趾\"使用.\n\nFor certain underwear or clothing, this lora can also be used as \"camel toe\".\n\nPornMaster 色情大師-Krea2\n\nLora權重:+1.4~+1.5。\n\nLora weight: +1.4~1.5.\n\n建議搭配我的Uncensored lora一起使用,即可降低此lora的權重。\n\n此lora如果與經由”合併的檢查站”一起使用時可能失去效果,因為他們所合併的lora可能會覆蓋掉”Flat chest”和”Innie pussy”的功能。\n\nFlat chest只有訓練裸照,沒有訓練穿衣服的照片。\n\n也有訓練其它乳房尺寸的照片。\n\n訓練中的大部分訓練的照片都沒有臉部。\n\nIt is recommended to use this together with my Uncensored LoRA, which allows you to reduce the weight of this LoRA.\n\nThis LoRA may lose its effectiveness when used together with a merged checkpoint, because the LoRAs merged into that checkpoint may override the \"Flat chest\" and \"Innie pussy\" features.\n\nThe Flat chest training only includes nude images and does not include images of clothed subjects.\n\nThere are also photos of training for other breast sizes.\n\nMost of the training images do not contain faces.\n\n我的其他檢查站和Lora。\nMy other checkpoints and Lora.\n\n--\n我已將模型上傳至runninghub。\nI have uploaded the model to runninghub.\n\nPornMaster_Flat_chest_&_Innie_pussy_krea2_V1\n\nhttps://www.runninghub.ai/model/public/2075826964388245506/?inviteCode=rh-v1304\n\n不要問我如何安裝的問題與comfyui如何使用。\n\n客製化lora:我的Telegram ID:@iamddtla0620\n\n我的微信ID:iamddtla\n\n我的line ID:iamddtla\n\n時間寶貴,請直接說明來意,例如:訂製lora.\n\nDo not ask me questions about how to install it or how to use ComfyUI.\n\nCustomized lora: My Telegram ID: @iamddtla0620\n\nMy WeChat ID: iamddtla\n\nMy Line ID: iamddtla\n\nTime is precious, please state your intention directly, for example: customized LORA."
194
+ },
195
+ {
196
+ "id": 2257360,
197
+ "title": "spread_pussy v2",
198
+ "url": "https://civitai.red/models/2257360/spreadpussy-v2?modelVersionId=3158874",
199
+ "download_url": "https://civitai.red/api/download/models/3158874?fileId=3039496",
200
+ "hf_filename": "Krea2 spread pussy.safetensors",
201
+ "category": "pose",
202
+ "tags": [
203
+ "pussy",
204
+ "spread",
205
+ "female-genitals"
206
+ ],
207
+ "trigger_words": [
208
+ "zitpussy",
209
+ "spread pussy",
210
+ "pussy",
211
+ "1girl",
212
+ "close-up",
213
+ "pubic hair",
214
+ "uncensored",
215
+ "solo",
216
+ "anus",
217
+ "realistic",
218
+ "female pubic hair",
219
+ "clitoris",
220
+ "photorealistic",
221
+ "clitoral hood",
222
+ "spread legs",
223
+ "urethra",
224
+ "nude",
225
+ "fingernails",
226
+ "ass",
227
+ "pink nails"
228
+ ],
229
+ "strength": "0.9",
230
+ "description": "Krea2 spread_pussy v2\n\nLora type:Krea2\n\ntrigger:zitpussy, spread pussy, 1girl, solo, pussy, anus, ass, uncensored, long hair, from behind, pubic hair, nail polish, brown hair, nude, bent over, female pubic hair, red nails, presenting, spread ass, ring, clitoris, urethra, ass focus, mole on ass\n\ngenarated checkpoint: moodyKrea2Mix_v40.safetensors\n\ntraining checkpoint: Krea 2 Raw\n\nrecommend strength: 0.9\n\nsampler name: ddim\n\nscheduler: sgm_uniform\n\n--\n\n适合Asian 的掰穴LORA,不是很稳定,需要多抽卡\n\nZIT spread_pussy v2(5-7-2026)\n\nLora type: ZIT\n\nprompt:zitpussy, realistic, pussy, 1girl, photorealistic, nipples, solo, spread pussy, uncensored, nude, clitoris, anus, breasts, pussy juice, pubic hair, spread legs, lips, on back, nail polish, looking at viewer, female pubic hair, brown eyes, lying, clitoral hood, brown hair, red nails\n\ngenarated checkpoint: z_image_turbo_bf16.safetensors\n\ntraining checkpoint: z_image_turbo_bf16.safetensors\n\nrecommend strength: 1\n\nsampler name: ddim\n\nscheduler: sgm_uniform\n\n-\n\nZIT spread_pussy\n\nLora type: ZIT\n\ntrigger:zitpussy, spread pussy, 1girl, nude, breasts, nipples, hetero, pussy, jewelry, blonde hair, realistic, ring, spread legs, solo focus, uncensored, blue eyes, anus, 1boy, medium breasts, smile, grin, lying, photorealistic, on back, watch\n\ngenarated checkpoint: z_image_turbo_bf16.safetensors\n\ntraining checkpoint: z_image_turbo_bf16.safetensors\n\nrecommend strength:1\n\ndenoise:1"
231
+ },
232
+ {
233
+ "id": 2617090,
234
+ "title": "Pubic Hair Slider & Body Hair Slider - (Krea2 + ZIT)",
235
+ "url": "https://civitai.red/models/2617090/pubic-hair-slider-and-body-hair-slider-krea2-zit?modelVersionId=3136749",
236
+ "download_url": "https://civitai.red/api/download/models/3136749?fileId=3016918",
237
+ "hf_filename": "pubes_krea2_loraholic.safetensors",
238
+ "category": "slider",
239
+ "tags": [
240
+ "pubic-hair",
241
+ "body-hair"
242
+ ],
243
+ "trigger_words": [],
244
+ "strength": null,
245
+ "description": "Krea2:\n\nI have made a completely new way of making slider LoRAs, witch allows me to create extremely potent and accurate Slider LoRAs. This is the very first test with my new methos. And i must say it exceeded my expectation by a lot. I have tried to make several pubic hair sliders for Krea2, but they allways seems to make the rest of the body get hairy as well. This also have this problem at high levels. But since its so potent at low levels its never a problem.\nYou should prompt pubic hair if you want it to kick in at around 1-2, but you can also leave everything up to the Slider and set it to 3-4 with a potential hairy body as well.\nAnd it is a Slider, even if its not used in the name on the samples. I forgot to write Slider when i made them.\nStr used on the samples are in the imges comments. I had some deactivated nodes, and i didnt notice until everything was uploaded.\nRecommended range PROMPTED: -2.0 to 2.0\nRecommended range NOT PROMPTED: -2.0 to 5.0\nZIT:\n\nNot the best work i have done. The hair gets a bit out or control to fast for what i would like.\nI have another version that i may release when i have tested it a bit more.\n\n\nThe Body Hair also affect the pubic hairs, but it spread to the whole body extremely fast.\n\nBody Hair also messes up the private parts pretty fast, so best used to to add body hair, or when Pubic Hair is to weak.\n\nRecommended range Pubic Hair -1.5 to 2.5\nRecommended range Body Hair -1.5 to 1.5\n\nAll my work is 100% free. The only thing that really matters to me is people leaving a review, good or bad. I will NEVER remove or block anyone for leaving a bad review, so don't be afraid to give me criticism.\n\nI'm stating this because when a creator blocks someone for leaving a bad review, that person can no longer see any of the creator's models, essentially muting their critics. This is something I'm highly critical of, and I believe it's a fundamental quality problem on this site."
246
+ },
247
+ {
248
+ "id": 2809783,
249
+ "title": "Krea2 - Uncut / Uncircumcised Penis",
250
+ "url": "https://civitai.red/models/2809783/krea2-uncut-uncircumcised-penis?modelVersionId=3168543",
251
+ "download_url": "https://civitai.red/api/download/models/3168543?fileId=3048970",
252
+ "hf_filename": "uncut_penis_v0.5_Krea2.safetensors",
253
+ "category": "anatomy",
254
+ "tags": [
255
+ "penis",
256
+ "uncut",
257
+ "foreskin",
258
+ "male-genitals"
259
+ ],
260
+ "trigger_words": [
261
+ "unc0ck"
262
+ ],
263
+ "strength": "1",
264
+ "description": "Trained on 30 images of uncut shlongs (erect, half erect) from different angles and with varying degrees of tip coverage. However, most of the results I get still show the head mostly uncovered. I’m releasing this as a version 0.5 for now because I only did very limited editing of the captions.\n\nWorks with men, trans women, futa, and pairs very well with the Loraholic penis sliders.\n\nYou can try it with or without the trigger word “un0ck”. It helps to describe if the penis is being seen form above, the side or below.\n\nValidation loss graph:"
265
+ },
266
+ {
267
+ "id": 2744200,
268
+ "title": "Hairy Pussy",
269
+ "url": "https://civitai.red/models/2744200/hairy-pussy?modelVersionId=3086526",
270
+ "download_url": "https://civitai.red/api/download/models/3086526?fileId=2965976",
271
+ "hf_filename": "Krea 2 - Hairy Pussy.safetensors",
272
+ "category": "anatomy",
273
+ "tags": [
274
+ "pussy",
275
+ "hairy",
276
+ "pubic-hair",
277
+ "female-genitals"
278
+ ],
279
+ "trigger_words": [
280
+ "she has a hairy pussy"
281
+ ],
282
+ "strength": null,
283
+ "description": "Trigger: She has a hairy pussy."
284
+ },
285
+ {
286
+ "id": 2822722,
287
+ "title": "Natural Body Hair: Krea2 Hairy",
288
+ "url": "https://civitai.red/models/2822722/natural-body-hair-krea2-hairy?modelVersionId=3199811",
289
+ "download_url": "https://civitai.red/api/download/models/3199811?fileId=3081042",
290
+ "hf_filename": "Krea2_Hairy_V2.safetensors",
291
+ "category": "anatomy",
292
+ "tags": [
293
+ "body-hair",
294
+ "hairy",
295
+ "natural",
296
+ "female"
297
+ ],
298
+ "trigger_words": [],
299
+ "strength": "1",
300
+ "description": "This lora adds realistic, natural body hair to female subjects across the entire body. This lora ensures a full-body \"hairy\" look by automatically adding hair to the arms, legs, armpits, thighs, belly, and vagina without needing extra keywords. It was trained not using faces and tried with character loras without issues.\n\nKey Features:\n\n Full Coverage: No need to prompt for specific areas; it covers the limbs, torso, and pelvic region out of the box.\n\n The \"Natural\" Boost: Use the keyword \"she's naturally hairy\" to emphasize the effect, particularly for a fuller, more lush belly area.\n\n Versatility: Works perfectly as a standalone LoRA or stacked with other ones including character loras. .\n\nRecommended Settings:\n\n Strength : 1.0 (Standard). Adjust lower (e.g., 0.5) for subtle fuzz; adjust higher (e.g., 1.2+) for thick, wild hair.\n\n Stacking Tip: Pairs beautifully with a Realism LoRA at a strength of 0.75–0.85 to ground the hair in realistic textures.\n\n Sampler: euler_ancestral\n\n Scheduler: beta\n\nFeedback is welcome! If this lora gets good reception, I'll work on refining the hair density and variety.\n\nPixaroma workflows and nodes are used to generate the images, his new nodes and workflows are amazing and can be found in a link from this video:"
301
+ },
302
+ {
303
+ "id": 2796748,
304
+ "title": "Damp Armpit Hair / Hairy Sweaty Male Armpits / Long Curly Thick Wet Bushy Pits - Krea 2",
305
+ "url": "https://civitai.red/models/2796748/damp-armpit-hair-hairy-sweaty-male-armpits-long-curly-thick-wet-bushy-pits-krea-2?modelVersionId=3161349",
306
+ "download_url": "https://civitai.red/api/download/models/3161349?fileId=3041728",
307
+ "hf_filename": "Damp_Armpit_v1_Full_Krea2.safetensors",
308
+ "category": "anatomy",
309
+ "tags": [
310
+ "armpit-hair",
311
+ "damp",
312
+ "sweaty",
313
+ "male",
314
+ "body-hair"
315
+ ],
316
+ "trigger_words": [
317
+ "damp armpit"
318
+ ],
319
+ "strength": "1.4",
320
+ "description": "Krea 2 version.\nIf you need quite a little more hair on your generated armpits, or you would like more realism on hair wetness, this is the LoRa for it!\nRecommended strength is 1.4! + krea2filterbypass3 at 1.60\n\nWithout the filter bypass3 it won't give you good results.\n\nThe lora effect can be good from 0.4-1.6 as well depending on what level of the effect you want.\n\nThis is a quick and dirty trained LoRA with no captions except for \"damp armpit\". I classified my collection of a very specific type of male armpit hair that I like, hairy and damp/wet/sweaty. This was over 700 images.\n\nI classified them into 1,2,3,5 repeats depending on the quality (very subjectively chosen by me).\n\nTrained with my GUI of Musubi: https://github.com/diodiogod/musubi-tuner_simple_GUI\n\nKrea 2 trains really well and this turned out even better than my Flux Lora.\n\nMy first attempt at 256 resolution for two epochs worked really well. All further training was not better, even at 1024. Then I trained a whole new version at only 2048 for two epochs and I think that one was better...\n\nIt learned the concept, but using it with some other loras SOMETIMES gives quality/anatomy problems.\n\nSo I did a post training block analysis and saved it using my fork of https://github.com/diodiogod/comfyUI-Realtime-Lora. It fixed the problem and a bonus is that the lora will NOT kill your pose and composition. But it does produce less pronounced Damp Armpit effect. Check some of the comparisson XY plots.\n\nThe remerge used this blocks: 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.05, 1.00, 1.00, 1.00, 1.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.20\n\nSome observations:\n\n Because of the lack of captions, the amount of bush on the armpit defaults to quite hairy and bushy.\n\n The thick long hair wetness can bleed to other parts of the body, which can actually be a bonus. You can get damp leg hair, chest hair and ass hair.\n\nI recommend the full blocks one if using this lora alone or maybe with +1 other lora. Use the edited blocks one if you want to keep your original seed pose and use a bunch of loras."
321
+ },
322
+ {
323
+ "id": 2595562,
324
+ "title": "Flaccid Uncut Hairy Penis aka P00TSARA",
325
+ "url": "https://civitai.red/models/2595562/flaccid-uncut-hairy-penis-aka-p00tsara?modelVersionId=3119203",
326
+ "download_url": "https://civitai.red/api/download/models/3119203?fileId=2999475",
327
+ "hf_filename": "P00TSARA_KREA2_V1_000008000.safetensors",
328
+ "category": "anatomy",
329
+ "tags": [
330
+ "penis",
331
+ "flaccid",
332
+ "uncut",
333
+ "foreskin",
334
+ "hairy",
335
+ "male-genitals"
336
+ ],
337
+ "trigger_words": [
338
+ "uncut flaccid penis",
339
+ "POOTSARA"
340
+ ],
341
+ "strength": null,
342
+ "description": "I decided to port my WAN 2.2 14B LORA to FLUX KLEIN 9B.\n\nI think it performs OK although the usual KLEIN issues do persist.\n\nSeems to work well in edit mode.\n\nAs per original V1 this is mostly lighter complexions"
343
+ },
344
+ {
345
+ "id": 2605595,
346
+ "title": "[Krea2 / ZIT] Japanese Woman Face 01",
347
+ "url": "https://civitai.red/models/2605595/krea2-zit-japanese-woman-face-01?modelVersionId=3104311",
348
+ "download_url": "https://civitai.red/api/download/models/3104311?fileId=2984083",
349
+ "hf_filename": "krea2_JPwoman01_v01.safetensors",
350
+ "category": "style",
351
+ "tags": [
352
+ "japanese",
353
+ "face",
354
+ "woman",
355
+ "character"
356
+ ],
357
+ "trigger_words": [
358
+ "jpwmn01"
359
+ ],
360
+ "strength": "0.8",
361
+ "description": "Krea2 turbo\n\nUploaded as Version 0.1 for testing Krea2 LoRA generation.\nZ-Image turbo\n\nUploaded as Version 0.1 for testing ZIT LoRA generation. All sample images were generated using Z-Image Power Nodes, with FlashVSR used as the detail enhancer.\nUsage\n\n Trigger word: jpwmn01\n\n Recommended model strength: 1.0 (ZIT), 0.8 (Krea2)\n\n CLIP/Text Encoder connection is not required.\n\nDisclaimer\n\n This model is intended for creating the faces of fictional adult Japanese women.\n\n This model does not depict any real person.\n\n The creator assumes no responsibility for generated content or misuse of this model.\n\n Users are solely responsible for the content they generate with this model.\n\nTraining Information\n\n Trained with AI-Toolkit using 17 images for 600 steps on an RTX 3060.\n\n This LoRA was trained as UNet-only. CLIP / Text Encoder training was disabled.\n\n私の初めてのLoRA作成は、こちらのYouTube動画を参考にしました。(日本人向け)\n\nダルトワ★TVさんありがとうございます。"
362
+ }
363
+ ]
364
+ }
lustifyWorkflowsKrea2_krea2.json ADDED
The diff for this file is too large to render. See raw diff
 
lustifyWorkflowsKrea2_krea2Edit.json ADDED
@@ -0,0 +1,3012 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": "4121e481-914e-4051-92d5-ab65617caf19",
3
+ "revision": 0,
4
+ "last_node_id": 317,
5
+ "last_link_id": 726,
6
+ "nodes": [
7
+ {
8
+ "id": 54,
9
+ "type": "VAEDecode",
10
+ "pos": [
11
+ 40,
12
+ -1660
13
+ ],
14
+ "size": [
15
+ 170,
16
+ 50
17
+ ],
18
+ "flags": {
19
+ "collapsed": false
20
+ },
21
+ "order": 10,
22
+ "mode": 0,
23
+ "inputs": [
24
+ {
25
+ "name": "samples",
26
+ "type": "LATENT",
27
+ "link": 564
28
+ },
29
+ {
30
+ "name": "vae",
31
+ "type": "VAE",
32
+ "link": 228
33
+ }
34
+ ],
35
+ "outputs": [
36
+ {
37
+ "name": "IMAGE",
38
+ "type": "IMAGE",
39
+ "slot_index": 0,
40
+ "links": [
41
+ 707
42
+ ]
43
+ }
44
+ ],
45
+ "properties": {
46
+ "cnr_id": "comfy-core",
47
+ "ver": "0.25.0",
48
+ "Node name for S&R": "VAEDecode"
49
+ },
50
+ "widgets_values": []
51
+ },
52
+ {
53
+ "id": 308,
54
+ "type": "ImageScaleToTotalPixels",
55
+ "pos": [
56
+ -730,
57
+ -1030
58
+ ],
59
+ "size": [
60
+ 290,
61
+ 110
62
+ ],
63
+ "flags": {
64
+ "collapsed": true
65
+ },
66
+ "order": 19,
67
+ "mode": 4,
68
+ "inputs": [
69
+ {
70
+ "name": "image",
71
+ "type": "IMAGE",
72
+ "link": 691
73
+ },
74
+ {
75
+ "name": "megapixels",
76
+ "type": "FLOAT",
77
+ "widget": {
78
+ "name": "megapixels"
79
+ },
80
+ "link": 704
81
+ }
82
+ ],
83
+ "outputs": [
84
+ {
85
+ "name": "IMAGE",
86
+ "type": "IMAGE",
87
+ "links": [
88
+ 690,
89
+ 701
90
+ ]
91
+ }
92
+ ],
93
+ "properties": {
94
+ "cnr_id": "comfy-core",
95
+ "ver": "0.27.0",
96
+ "Node name for S&R": "ImageScaleToTotalPixels"
97
+ },
98
+ "widgets_values": [
99
+ "lanczos",
100
+ 1.4,
101
+ 64
102
+ ]
103
+ },
104
+ {
105
+ "id": 306,
106
+ "type": "VAEEncode",
107
+ "pos": [
108
+ -650,
109
+ -990
110
+ ],
111
+ "size": [
112
+ 230,
113
+ 100
114
+ ],
115
+ "flags": {
116
+ "collapsed": true
117
+ },
118
+ "order": 18,
119
+ "mode": 4,
120
+ "inputs": [
121
+ {
122
+ "name": "pixels",
123
+ "type": "IMAGE",
124
+ "link": 690
125
+ },
126
+ {
127
+ "name": "vae",
128
+ "type": "VAE",
129
+ "link": 693
130
+ }
131
+ ],
132
+ "outputs": [
133
+ {
134
+ "name": "LATENT",
135
+ "type": "LATENT",
136
+ "links": [
137
+ 700
138
+ ]
139
+ }
140
+ ],
141
+ "properties": {
142
+ "cnr_id": "comfy-core",
143
+ "ver": "0.3.50",
144
+ "Node name for S&R": "VAEEncode",
145
+ "enableTabs": false,
146
+ "tabWidth": 65,
147
+ "tabXOffset": 10,
148
+ "hasSecondTab": false,
149
+ "secondTabText": "Send Back",
150
+ "secondTabOffset": 80,
151
+ "secondTabWidth": 65,
152
+ "ue_properties": {
153
+ "widget_ue_connectable": {}
154
+ }
155
+ },
156
+ "widgets_values": []
157
+ },
158
+ {
159
+ "id": 300,
160
+ "type": "LoadImage",
161
+ "pos": [
162
+ -910,
163
+ -1170
164
+ ],
165
+ "size": [
166
+ 380,
167
+ 410
168
+ ],
169
+ "flags": {},
170
+ "order": 0,
171
+ "mode": 4,
172
+ "inputs": [],
173
+ "outputs": [
174
+ {
175
+ "name": "IMAGE",
176
+ "type": "IMAGE",
177
+ "links": [
178
+ 677,
179
+ 691
180
+ ]
181
+ },
182
+ {
183
+ "name": "MASK",
184
+ "type": "MASK",
185
+ "links": []
186
+ }
187
+ ],
188
+ "properties": {
189
+ "cnr_id": "comfy-core",
190
+ "ver": "0.26.0",
191
+ "Node name for S&R": "LoadImage",
192
+ "image": "clipspace/clipspace-painted-masked-1784460460455.png [input]"
193
+ },
194
+ "widgets_values": [
195
+ "279425998_1141582773352671_2339930963903914959_n.jpg",
196
+ "image"
197
+ ],
198
+ "color": "#222",
199
+ "bgcolor": "#000"
200
+ },
201
+ {
202
+ "id": 115,
203
+ "type": "CLIPLoader",
204
+ "pos": [
205
+ -500,
206
+ -1200
207
+ ],
208
+ "size": [
209
+ 380,
210
+ 110
211
+ ],
212
+ "flags": {},
213
+ "order": 1,
214
+ "mode": 0,
215
+ "inputs": [],
216
+ "outputs": [
217
+ {
218
+ "name": "CLIP",
219
+ "type": "CLIP",
220
+ "links": [
221
+ 462
222
+ ]
223
+ }
224
+ ],
225
+ "properties": {
226
+ "cnr_id": "comfy-core",
227
+ "ver": "0.25.0",
228
+ "Node name for S&R": "CLIPLoader",
229
+ "models": [
230
+ {
231
+ "name": "qwen3vl_4b_fp8_scaled.safetensors",
232
+ "url": "https://huggingface.co/Comfy-Org/Krea-2/resolve/main/text_encoders/qwen3vl_4b_fp8_scaled.safetensors",
233
+ "directory": "text_encoders"
234
+ }
235
+ ]
236
+ },
237
+ "widgets_values": [
238
+ "qwen3vl_4b_fp8_scaled.safetensors",
239
+ "krea2",
240
+ "default"
241
+ ],
242
+ "color": "#222",
243
+ "bgcolor": "#000"
244
+ },
245
+ {
246
+ "id": 116,
247
+ "type": "VAELoader",
248
+ "pos": [
249
+ -500,
250
+ -1050
251
+ ],
252
+ "size": [
253
+ 380,
254
+ 60
255
+ ],
256
+ "flags": {},
257
+ "order": 2,
258
+ "mode": 0,
259
+ "inputs": [],
260
+ "outputs": [
261
+ {
262
+ "name": "VAE",
263
+ "type": "VAE",
264
+ "links": [
265
+ 228,
266
+ 693,
267
+ 697
268
+ ]
269
+ }
270
+ ],
271
+ "properties": {
272
+ "cnr_id": "comfy-core",
273
+ "ver": "0.25.0",
274
+ "Node name for S&R": "VAELoader",
275
+ "models": [
276
+ {
277
+ "name": "qwen_image_vae.safetensors",
278
+ "url": "https://huggingface.co/Comfy-Org/Krea-2/resolve/main/vae/qwen_image_vae.safetensors",
279
+ "directory": "vae"
280
+ }
281
+ ]
282
+ },
283
+ "widgets_values": [
284
+ "wan_2.1_vae.safetensors"
285
+ ],
286
+ "color": "#222",
287
+ "bgcolor": "#000"
288
+ },
289
+ {
290
+ "id": 266,
291
+ "type": "f0c08e17-ae37-4f4b-be97-5035d833db71",
292
+ "pos": [
293
+ -110,
294
+ -1660
295
+ ],
296
+ "size": [
297
+ 310,
298
+ 590
299
+ ],
300
+ "flags": {},
301
+ "order": 16,
302
+ "mode": 0,
303
+ "inputs": [
304
+ {
305
+ "name": "seed",
306
+ "type": "INT",
307
+ "widget": {
308
+ "name": "seed"
309
+ },
310
+ "link": 556
311
+ },
312
+ {
313
+ "name": "model",
314
+ "type": "MODEL",
315
+ "link": 557
316
+ },
317
+ {
318
+ "name": "positive",
319
+ "type": "CONDITIONING",
320
+ "link": 711
321
+ },
322
+ {
323
+ "name": "negative",
324
+ "type": "CONDITIONING",
325
+ "link": 712
326
+ },
327
+ {
328
+ "name": "latent_image",
329
+ "type": "LATENT",
330
+ "link": 705
331
+ },
332
+ {
333
+ "name": "image",
334
+ "type": "IMAGE",
335
+ "link": 708
336
+ }
337
+ ],
338
+ "outputs": [
339
+ {
340
+ "name": "steps",
341
+ "type": "INT",
342
+ "links": [
343
+ 562
344
+ ]
345
+ },
346
+ {
347
+ "name": "cfg",
348
+ "type": "FLOAT",
349
+ "links": [
350
+ 563
351
+ ]
352
+ },
353
+ {
354
+ "name": "LATENT",
355
+ "type": "LATENT",
356
+ "links": [
357
+ 564
358
+ ]
359
+ },
360
+ {
361
+ "label": "sampler",
362
+ "name": "string_1",
363
+ "type": "STRING",
364
+ "links": [
365
+ 566
366
+ ]
367
+ },
368
+ {
369
+ "name": "width",
370
+ "type": "INT",
371
+ "links": [
372
+ 567
373
+ ]
374
+ },
375
+ {
376
+ "name": "height",
377
+ "type": "INT",
378
+ "links": [
379
+ 568
380
+ ]
381
+ }
382
+ ],
383
+ "properties": {
384
+ "proxyWidgets": [
385
+ [
386
+ "261",
387
+ "seed"
388
+ ],
389
+ [
390
+ "261",
391
+ "steps"
392
+ ],
393
+ [
394
+ "261",
395
+ "cfg"
396
+ ],
397
+ [
398
+ "261",
399
+ "sampler"
400
+ ],
401
+ [
402
+ "265",
403
+ "scheduler"
404
+ ],
405
+ [
406
+ "265",
407
+ "$$canvas-image-preview"
408
+ ]
409
+ ],
410
+ "cnr_id": "comfy-core",
411
+ "ver": "0.27.0"
412
+ },
413
+ "widgets_values": [],
414
+ "color": "#222",
415
+ "bgcolor": "#000"
416
+ },
417
+ {
418
+ "id": 272,
419
+ "type": "Image Saver Simple",
420
+ "pos": [
421
+ 780,
422
+ -1580
423
+ ],
424
+ "size": [
425
+ 390,
426
+ 530
427
+ ],
428
+ "flags": {},
429
+ "order": 17,
430
+ "mode": 0,
431
+ "inputs": [
432
+ {
433
+ "name": "images",
434
+ "type": "IMAGE",
435
+ "link": 726
436
+ },
437
+ {
438
+ "name": "metadata",
439
+ "shape": 7,
440
+ "type": "METADATA",
441
+ "link": 575
442
+ }
443
+ ],
444
+ "outputs": [
445
+ {
446
+ "name": "hashes",
447
+ "type": "STRING",
448
+ "links": null
449
+ },
450
+ {
451
+ "name": "a1111_params",
452
+ "type": "STRING",
453
+ "links": null
454
+ }
455
+ ],
456
+ "properties": {
457
+ "cnr_id": "comfyui-image-saver",
458
+ "ver": "1.23.0",
459
+ "Node name for S&R": "Image Saver Simple"
460
+ },
461
+ "widgets_values": [
462
+ "%time_%basemodelname_%seed",
463
+ "",
464
+ "png",
465
+ true,
466
+ 100,
467
+ false,
468
+ true,
469
+ false,
470
+ 0,
471
+ "%Y-%m-%d-%H%M%S",
472
+ true
473
+ ]
474
+ },
475
+ {
476
+ "id": 246,
477
+ "type": "Image Saver Metadata",
478
+ "pos": [
479
+ 780,
480
+ -1620
481
+ ],
482
+ "size": [
483
+ 400,
484
+ 640
485
+ ],
486
+ "flags": {
487
+ "collapsed": true
488
+ },
489
+ "order": 14,
490
+ "mode": 0,
491
+ "inputs": [
492
+ {
493
+ "name": "positive",
494
+ "shape": 7,
495
+ "type": "STRING",
496
+ "widget": {
497
+ "name": "positive"
498
+ },
499
+ "link": 468
500
+ },
501
+ {
502
+ "name": "width",
503
+ "shape": 7,
504
+ "type": "INT",
505
+ "widget": {
506
+ "name": "width"
507
+ },
508
+ "link": 567
509
+ },
510
+ {
511
+ "name": "height",
512
+ "shape": 7,
513
+ "type": "INT",
514
+ "widget": {
515
+ "name": "height"
516
+ },
517
+ "link": 568
518
+ },
519
+ {
520
+ "name": "seed_value",
521
+ "shape": 7,
522
+ "type": "INT",
523
+ "widget": {
524
+ "name": "seed_value"
525
+ },
526
+ "link": 472
527
+ },
528
+ {
529
+ "name": "steps",
530
+ "shape": 7,
531
+ "type": "INT",
532
+ "widget": {
533
+ "name": "steps"
534
+ },
535
+ "link": 562
536
+ },
537
+ {
538
+ "name": "cfg",
539
+ "shape": 7,
540
+ "type": "FLOAT",
541
+ "widget": {
542
+ "name": "cfg"
543
+ },
544
+ "link": 563
545
+ },
546
+ {
547
+ "name": "sampler_name",
548
+ "shape": 7,
549
+ "type": "STRING",
550
+ "widget": {
551
+ "name": "sampler_name"
552
+ },
553
+ "link": 566
554
+ }
555
+ ],
556
+ "outputs": [
557
+ {
558
+ "name": "metadata",
559
+ "type": "METADATA",
560
+ "links": [
561
+ 575
562
+ ]
563
+ },
564
+ {
565
+ "name": "hashes",
566
+ "type": "STRING",
567
+ "links": null
568
+ },
569
+ {
570
+ "name": "a1111_params",
571
+ "type": "STRING",
572
+ "links": null
573
+ }
574
+ ],
575
+ "properties": {
576
+ "cnr_id": "comfyui-image-saver",
577
+ "ver": "1.23.0",
578
+ "Node name for S&R": "Image Saver Metadata"
579
+ },
580
+ "widgets_values": [
581
+ "",
582
+ "",
583
+ "",
584
+ 512,
585
+ 512,
586
+ 0,
587
+ 8,
588
+ 1,
589
+ "",
590
+ "normal",
591
+ 1,
592
+ 0,
593
+ "",
594
+ true,
595
+ true,
596
+ ""
597
+ ]
598
+ },
599
+ {
600
+ "id": 101,
601
+ "type": "ConditioningZeroOut",
602
+ "pos": [
603
+ 550,
604
+ -1030
605
+ ],
606
+ "size": [
607
+ 210,
608
+ 40
609
+ ],
610
+ "flags": {
611
+ "collapsed": false
612
+ },
613
+ "order": 13,
614
+ "mode": 0,
615
+ "inputs": [
616
+ {
617
+ "name": "conditioning",
618
+ "type": "CONDITIONING",
619
+ "link": 464
620
+ }
621
+ ],
622
+ "outputs": [
623
+ {
624
+ "name": "CONDITIONING",
625
+ "type": "CONDITIONING",
626
+ "links": [
627
+ 712
628
+ ]
629
+ }
630
+ ],
631
+ "properties": {
632
+ "cnr_id": "comfy-core",
633
+ "ver": "0.27.0",
634
+ "Node name for S&R": "ConditioningZeroOut"
635
+ },
636
+ "widgets_values": [],
637
+ "color": "#322",
638
+ "bgcolor": "#533"
639
+ },
640
+ {
641
+ "id": 97,
642
+ "type": "ModelSamplingAuraFlow",
643
+ "pos": [
644
+ 110,
645
+ -1030
646
+ ],
647
+ "size": [
648
+ 220,
649
+ 60
650
+ ],
651
+ "flags": {},
652
+ "order": 12,
653
+ "mode": 0,
654
+ "inputs": [
655
+ {
656
+ "name": "model",
657
+ "type": "MODEL",
658
+ "link": 703
659
+ }
660
+ ],
661
+ "outputs": [
662
+ {
663
+ "name": "MODEL",
664
+ "type": "MODEL",
665
+ "links": [
666
+ 557
667
+ ]
668
+ }
669
+ ],
670
+ "properties": {
671
+ "cnr_id": "comfy-core",
672
+ "ver": "0.27.0",
673
+ "Node name for S&R": "ModelSamplingAuraFlow"
674
+ },
675
+ "widgets_values": [
676
+ 4
677
+ ],
678
+ "color": "#222",
679
+ "bgcolor": "#000"
680
+ },
681
+ {
682
+ "id": 105,
683
+ "type": "Power Lora Loader (rgthree)",
684
+ "pos": [
685
+ -500,
686
+ -950
687
+ ],
688
+ "size": [
689
+ 380,
690
+ 210
691
+ ],
692
+ "flags": {},
693
+ "order": 9,
694
+ "mode": 0,
695
+ "inputs": [
696
+ {
697
+ "dir": 3,
698
+ "name": "model",
699
+ "type": "MODEL",
700
+ "link": 231
701
+ },
702
+ {
703
+ "dir": 3,
704
+ "name": "clip",
705
+ "type": "CLIP",
706
+ "link": null
707
+ }
708
+ ],
709
+ "outputs": [
710
+ {
711
+ "dir": 4,
712
+ "name": "MODEL",
713
+ "shape": 3,
714
+ "type": "MODEL",
715
+ "links": [
716
+ 699
717
+ ]
718
+ },
719
+ {
720
+ "dir": 4,
721
+ "name": "CLIP",
722
+ "shape": 3,
723
+ "type": "CLIP",
724
+ "links": null
725
+ }
726
+ ],
727
+ "properties": {
728
+ "cnr_id": "rgthree-comfy",
729
+ "ver": "1.0.2606200020",
730
+ "Show Strengths": "Single Strength",
731
+ "Match": ""
732
+ },
733
+ "widgets_values": [
734
+ {},
735
+ {
736
+ "type": "PowerLoraLoaderHeaderWidget"
737
+ },
738
+ {
739
+ "on": true,
740
+ "lora": "krea\\krea2_identity_edit_v1_2.safetensors",
741
+ "strength": 1,
742
+ "strengthTwo": null
743
+ },
744
+ {
745
+ "on": false,
746
+ "lora": "krea\\krea2_raw_to_turbo_r256_comfy.safetensors",
747
+ "strength": 1,
748
+ "strengthTwo": null
749
+ },
750
+ {},
751
+ ""
752
+ ],
753
+ "color": "#222",
754
+ "bgcolor": "#000"
755
+ },
756
+ {
757
+ "id": 245,
758
+ "type": "MarkdownNote",
759
+ "pos": [
760
+ 760,
761
+ -910
762
+ ],
763
+ "size": [
764
+ 410,
765
+ 170
766
+ ],
767
+ "flags": {},
768
+ "order": 3,
769
+ "mode": 0,
770
+ "inputs": [],
771
+ "outputs": [],
772
+ "title": "Note",
773
+ "properties": {},
774
+ "widgets_values": [
775
+ "<----- grounding resolution (trained range 512–1536). This is a quality dial: lower = stronger edit adherence, higher = stronger identity/likeness. Try 1024+ for people, 512 for stubborn scene changes.\n\nGet the node from [there](https://github.com/lbouaraba/comfyui-krea2edit) (I think it's not available via Comfy manager right now).\n\nGet the identity edit LoRA from [there](https://huggingface.co/conradlocke/krea2-identity-edit/tree/main) (any of the newer ones)."
776
+ ],
777
+ "color": "#432",
778
+ "bgcolor": "#653"
779
+ },
780
+ {
781
+ "id": 311,
782
+ "type": "Note",
783
+ "pos": [
784
+ 110,
785
+ -930
786
+ ],
787
+ "size": [
788
+ 220,
789
+ 190
790
+ ],
791
+ "flags": {},
792
+ "order": 4,
793
+ "mode": 0,
794
+ "inputs": [],
795
+ "outputs": [],
796
+ "properties": {},
797
+ "widgets_values": [
798
+ "value - the amount of megapixels.\n\nref_boost (default 1.0) — reference-fidelity dial; >1 pulls harder toward the reference's appearance, <1 loosens. \nref_boost_a is the same dial for the scene ref in two-ref edits.\n\nref_boost >1 affects the speed."
799
+ ],
800
+ "color": "#432",
801
+ "bgcolor": "#653"
802
+ },
803
+ {
804
+ "id": 310,
805
+ "type": "Fast Groups Bypasser (rgthree)",
806
+ "pos": [
807
+ -500,
808
+ -1480
809
+ ],
810
+ "size": [
811
+ 380,
812
+ 106
813
+ ],
814
+ "flags": {},
815
+ "order": 5,
816
+ "mode": 0,
817
+ "inputs": [],
818
+ "outputs": [
819
+ {
820
+ "name": "OPT_CONNECTION",
821
+ "type": "*",
822
+ "links": null
823
+ }
824
+ ],
825
+ "properties": {
826
+ "matchColors": "",
827
+ "matchTitle": "",
828
+ "showNav": true,
829
+ "showAllGraphs": true,
830
+ "sort": "position",
831
+ "customSortAlphabet": "",
832
+ "toggleRestriction": "default"
833
+ },
834
+ "color": "#233",
835
+ "bgcolor": "#355"
836
+ },
837
+ {
838
+ "id": 117,
839
+ "type": "UNETLoader",
840
+ "pos": [
841
+ -500,
842
+ -1330
843
+ ],
844
+ "size": [
845
+ 380,
846
+ 90
847
+ ],
848
+ "flags": {},
849
+ "order": 6,
850
+ "mode": 0,
851
+ "inputs": [],
852
+ "outputs": [
853
+ {
854
+ "name": "MODEL",
855
+ "type": "MODEL",
856
+ "links": [
857
+ 231
858
+ ]
859
+ }
860
+ ],
861
+ "properties": {
862
+ "cnr_id": "comfy-core",
863
+ "ver": "0.25.0",
864
+ "Node name for S&R": "UNETLoader",
865
+ "models": [
866
+ {
867
+ "name": "pornmasterKrea2_v2TurboInt8.safetensors",
868
+ "url": "https://huggingface.co/mpasila/Krea-2-Models/resolve/main/pornmasterKrea2_v2TurboInt8.safetensors",
869
+ "directory": "diffusion_models"
870
+ }
871
+ ]
872
+ },
873
+ "widgets_values": [
874
+ "lustify-v10-krea-turbo-int8_convrot.safetensors",
875
+ "default"
876
+ ],
877
+ "color": "#222",
878
+ "bgcolor": "#000"
879
+ },
880
+ {
881
+ "id": 309,
882
+ "type": "b898f649-8abc-44f2-a47c-2219759f01c2",
883
+ "pos": [
884
+ -110,
885
+ -1030
886
+ ],
887
+ "size": [
888
+ 210,
889
+ 290
890
+ ],
891
+ "flags": {},
892
+ "order": 20,
893
+ "mode": 0,
894
+ "inputs": [
895
+ {
896
+ "name": "vae",
897
+ "type": "VAE",
898
+ "link": 697
899
+ },
900
+ {
901
+ "name": "image",
902
+ "type": "IMAGE",
903
+ "link": 698
904
+ },
905
+ {
906
+ "name": "model",
907
+ "type": "MODEL",
908
+ "link": 699
909
+ },
910
+ {
911
+ "name": "source_latent_b",
912
+ "shape": 7,
913
+ "type": "LATENT",
914
+ "link": 700
915
+ },
916
+ {
917
+ "name": "source_image_b",
918
+ "shape": 7,
919
+ "type": "IMAGE",
920
+ "link": 701
921
+ }
922
+ ],
923
+ "outputs": [
924
+ {
925
+ "name": "IMAGE",
926
+ "type": "IMAGE",
927
+ "links": [
928
+ 702
929
+ ]
930
+ },
931
+ {
932
+ "name": "MODEL",
933
+ "type": "MODEL",
934
+ "links": [
935
+ 703
936
+ ]
937
+ },
938
+ {
939
+ "name": "FLOAT",
940
+ "type": "FLOAT",
941
+ "links": [
942
+ 704
943
+ ]
944
+ },
945
+ {
946
+ "name": "LATENT",
947
+ "type": "LATENT",
948
+ "links": [
949
+ 705
950
+ ]
951
+ }
952
+ ],
953
+ "properties": {
954
+ "proxyWidgets": [
955
+ [
956
+ "305",
957
+ "value"
958
+ ],
959
+ [
960
+ "307",
961
+ "ref_boost"
962
+ ],
963
+ [
964
+ "307",
965
+ "ref_boost_a"
966
+ ]
967
+ ],
968
+ "cnr_id": "comfy-core",
969
+ "ver": "0.27.0"
970
+ },
971
+ "widgets_values": [],
972
+ "color": "#222",
973
+ "bgcolor": "#000"
974
+ },
975
+ {
976
+ "id": 241,
977
+ "type": "Seed (rgthree)",
978
+ "pos": [
979
+ -500,
980
+ -1660
981
+ ],
982
+ "size": [
983
+ 380,
984
+ 140
985
+ ],
986
+ "flags": {},
987
+ "order": 7,
988
+ "mode": 0,
989
+ "inputs": [],
990
+ "outputs": [
991
+ {
992
+ "dir": 4,
993
+ "name": "SEED",
994
+ "shape": 3,
995
+ "type": "INT",
996
+ "links": [
997
+ 472,
998
+ 556
999
+ ]
1000
+ }
1001
+ ],
1002
+ "properties": {
1003
+ "cnr_id": "rgthree-comfy",
1004
+ "ver": "1.0.2606200020",
1005
+ "randomMax": 1125899906842624,
1006
+ "randomMin": 0
1007
+ },
1008
+ "widgets_values": [
1009
+ 367334738896668,
1010
+ "",
1011
+ "",
1012
+ "okay"
1013
+ ],
1014
+ "color": "#233",
1015
+ "bgcolor": "#355"
1016
+ },
1017
+ {
1018
+ "id": 72,
1019
+ "type": "LoadImage",
1020
+ "pos": [
1021
+ -908.3726150392818,
1022
+ -1660
1023
+ ],
1024
+ "size": [
1025
+ 380,
1026
+ 410
1027
+ ],
1028
+ "flags": {},
1029
+ "order": 8,
1030
+ "mode": 0,
1031
+ "inputs": [],
1032
+ "outputs": [
1033
+ {
1034
+ "name": "IMAGE",
1035
+ "type": "IMAGE",
1036
+ "links": [
1037
+ 698,
1038
+ 708
1039
+ ]
1040
+ },
1041
+ {
1042
+ "name": "MASK",
1043
+ "type": "MASK",
1044
+ "links": []
1045
+ }
1046
+ ],
1047
+ "properties": {
1048
+ "cnr_id": "comfy-core",
1049
+ "ver": "0.26.0",
1050
+ "Node name for S&R": "LoadImage",
1051
+ "image": "clipspace/clipspace-painted-masked-1784460460455.png [input]"
1052
+ },
1053
+ "widgets_values": [
1054
+ "pasted/image (793).png",
1055
+ "image"
1056
+ ],
1057
+ "color": "#222",
1058
+ "bgcolor": "#000"
1059
+ },
1060
+ {
1061
+ "id": 247,
1062
+ "type": "ccb2ef07-5f9a-4343-8df4-b8b3a5994046",
1063
+ "pos": [
1064
+ 340,
1065
+ -1030
1066
+ ],
1067
+ "size": [
1068
+ 410,
1069
+ 290
1070
+ ],
1071
+ "flags": {},
1072
+ "order": 15,
1073
+ "mode": 0,
1074
+ "inputs": [
1075
+ {
1076
+ "name": "clip",
1077
+ "type": "CLIP",
1078
+ "link": 462
1079
+ },
1080
+ {
1081
+ "name": "image",
1082
+ "shape": 7,
1083
+ "type": "IMAGE",
1084
+ "link": 702
1085
+ },
1086
+ {
1087
+ "name": "image_b",
1088
+ "shape": 7,
1089
+ "type": "IMAGE",
1090
+ "link": 677
1091
+ }
1092
+ ],
1093
+ "outputs": [
1094
+ {
1095
+ "name": "CONDITIONING",
1096
+ "type": "CONDITIONING",
1097
+ "links": [
1098
+ 464,
1099
+ 711
1100
+ ]
1101
+ },
1102
+ {
1103
+ "name": "STRING",
1104
+ "type": "STRING",
1105
+ "links": [
1106
+ 468
1107
+ ]
1108
+ }
1109
+ ],
1110
+ "properties": {
1111
+ "proxyWidgets": [
1112
+ [
1113
+ "248",
1114
+ "value"
1115
+ ],
1116
+ [
1117
+ "86",
1118
+ "grounding_px"
1119
+ ]
1120
+ ],
1121
+ "cnr_id": "comfy-core",
1122
+ "ver": "0.27.0"
1123
+ },
1124
+ "widgets_values": [],
1125
+ "color": "#222",
1126
+ "bgcolor": "#000"
1127
+ },
1128
+ {
1129
+ "id": 90,
1130
+ "type": "PreviewImage",
1131
+ "pos": [
1132
+ 210,
1133
+ -1660
1134
+ ],
1135
+ "size": [
1136
+ 540,
1137
+ 590
1138
+ ],
1139
+ "flags": {},
1140
+ "order": 11,
1141
+ "mode": 0,
1142
+ "inputs": [
1143
+ {
1144
+ "name": "images",
1145
+ "type": "IMAGE",
1146
+ "link": 707
1147
+ }
1148
+ ],
1149
+ "outputs": [
1150
+ {
1151
+ "name": "images",
1152
+ "type": "IMAGE",
1153
+ "links": [
1154
+ 726
1155
+ ]
1156
+ }
1157
+ ],
1158
+ "properties": {
1159
+ "cnr_id": "comfy-core",
1160
+ "ver": "0.27.0",
1161
+ "Node name for S&R": "PreviewImage"
1162
+ },
1163
+ "widgets_values": [],
1164
+ "color": "#222",
1165
+ "bgcolor": "#000"
1166
+ }
1167
+ ],
1168
+ "links": [
1169
+ [
1170
+ 228,
1171
+ 116,
1172
+ 0,
1173
+ 54,
1174
+ 1,
1175
+ "VAE"
1176
+ ],
1177
+ [
1178
+ 231,
1179
+ 117,
1180
+ 0,
1181
+ 105,
1182
+ 0,
1183
+ "MODEL"
1184
+ ],
1185
+ [
1186
+ 462,
1187
+ 115,
1188
+ 0,
1189
+ 247,
1190
+ 0,
1191
+ "CLIP"
1192
+ ],
1193
+ [
1194
+ 464,
1195
+ 247,
1196
+ 0,
1197
+ 101,
1198
+ 0,
1199
+ "CONDITIONING"
1200
+ ],
1201
+ [
1202
+ 468,
1203
+ 247,
1204
+ 1,
1205
+ 246,
1206
+ 0,
1207
+ "STRING"
1208
+ ],
1209
+ [
1210
+ 472,
1211
+ 241,
1212
+ 0,
1213
+ 246,
1214
+ 3,
1215
+ "INT"
1216
+ ],
1217
+ [
1218
+ 556,
1219
+ 241,
1220
+ 0,
1221
+ 266,
1222
+ 0,
1223
+ "INT"
1224
+ ],
1225
+ [
1226
+ 557,
1227
+ 97,
1228
+ 0,
1229
+ 266,
1230
+ 1,
1231
+ "MODEL"
1232
+ ],
1233
+ [
1234
+ 562,
1235
+ 266,
1236
+ 0,
1237
+ 246,
1238
+ 4,
1239
+ "INT"
1240
+ ],
1241
+ [
1242
+ 563,
1243
+ 266,
1244
+ 1,
1245
+ 246,
1246
+ 5,
1247
+ "FLOAT"
1248
+ ],
1249
+ [
1250
+ 564,
1251
+ 266,
1252
+ 2,
1253
+ 54,
1254
+ 0,
1255
+ "LATENT"
1256
+ ],
1257
+ [
1258
+ 566,
1259
+ 266,
1260
+ 3,
1261
+ 246,
1262
+ 6,
1263
+ "STRING"
1264
+ ],
1265
+ [
1266
+ 567,
1267
+ 266,
1268
+ 4,
1269
+ 246,
1270
+ 1,
1271
+ "INT"
1272
+ ],
1273
+ [
1274
+ 568,
1275
+ 266,
1276
+ 5,
1277
+ 246,
1278
+ 2,
1279
+ "INT"
1280
+ ],
1281
+ [
1282
+ 575,
1283
+ 246,
1284
+ 0,
1285
+ 272,
1286
+ 1,
1287
+ "METADATA"
1288
+ ],
1289
+ [
1290
+ 677,
1291
+ 300,
1292
+ 0,
1293
+ 247,
1294
+ 2,
1295
+ "IMAGE"
1296
+ ],
1297
+ [
1298
+ 690,
1299
+ 308,
1300
+ 0,
1301
+ 306,
1302
+ 0,
1303
+ "IMAGE"
1304
+ ],
1305
+ [
1306
+ 691,
1307
+ 300,
1308
+ 0,
1309
+ 308,
1310
+ 0,
1311
+ "IMAGE"
1312
+ ],
1313
+ [
1314
+ 693,
1315
+ 116,
1316
+ 0,
1317
+ 306,
1318
+ 1,
1319
+ "VAE"
1320
+ ],
1321
+ [
1322
+ 697,
1323
+ 116,
1324
+ 0,
1325
+ 309,
1326
+ 0,
1327
+ "VAE"
1328
+ ],
1329
+ [
1330
+ 698,
1331
+ 72,
1332
+ 0,
1333
+ 309,
1334
+ 1,
1335
+ "IMAGE"
1336
+ ],
1337
+ [
1338
+ 699,
1339
+ 105,
1340
+ 0,
1341
+ 309,
1342
+ 2,
1343
+ "MODEL"
1344
+ ],
1345
+ [
1346
+ 700,
1347
+ 306,
1348
+ 0,
1349
+ 309,
1350
+ 3,
1351
+ "LATENT"
1352
+ ],
1353
+ [
1354
+ 701,
1355
+ 308,
1356
+ 0,
1357
+ 309,
1358
+ 4,
1359
+ "IMAGE"
1360
+ ],
1361
+ [
1362
+ 702,
1363
+ 309,
1364
+ 0,
1365
+ 247,
1366
+ 1,
1367
+ "IMAGE"
1368
+ ],
1369
+ [
1370
+ 703,
1371
+ 309,
1372
+ 1,
1373
+ 97,
1374
+ 0,
1375
+ "MODEL"
1376
+ ],
1377
+ [
1378
+ 704,
1379
+ 309,
1380
+ 2,
1381
+ 308,
1382
+ 1,
1383
+ "FLOAT"
1384
+ ],
1385
+ [
1386
+ 705,
1387
+ 309,
1388
+ 3,
1389
+ 266,
1390
+ 4,
1391
+ "LATENT"
1392
+ ],
1393
+ [
1394
+ 707,
1395
+ 54,
1396
+ 0,
1397
+ 90,
1398
+ 0,
1399
+ "IMAGE"
1400
+ ],
1401
+ [
1402
+ 708,
1403
+ 72,
1404
+ 0,
1405
+ 266,
1406
+ 5,
1407
+ "IMAGE"
1408
+ ],
1409
+ [
1410
+ 711,
1411
+ 247,
1412
+ 0,
1413
+ 266,
1414
+ 2,
1415
+ "CONDITIONING"
1416
+ ],
1417
+ [
1418
+ 712,
1419
+ 101,
1420
+ 0,
1421
+ 266,
1422
+ 3,
1423
+ "CONDITIONING"
1424
+ ],
1425
+ [
1426
+ 726,
1427
+ 90,
1428
+ 0,
1429
+ 272,
1430
+ 0,
1431
+ "IMAGE"
1432
+ ]
1433
+ ],
1434
+ "groups": [
1435
+ {
1436
+ "id": 5,
1437
+ "title": "Second Reference",
1438
+ "bounding": [
1439
+ -920,
1440
+ -1240,
1441
+ 400,
1442
+ 490
1443
+ ],
1444
+ "color": "#3f789e",
1445
+ "flags": {}
1446
+ },
1447
+ {
1448
+ "id": 6,
1449
+ "title": "Save Image",
1450
+ "bounding": [
1451
+ 770,
1452
+ -1690,
1453
+ 410,
1454
+ 660
1455
+ ],
1456
+ "color": "#3f789e",
1457
+ "flags": {}
1458
+ }
1459
+ ],
1460
+ "definitions": {
1461
+ "subgraphs": [
1462
+ {
1463
+ "id": "ccb2ef07-5f9a-4343-8df4-b8b3a5994046",
1464
+ "version": 1,
1465
+ "state": {
1466
+ "lastGroupId": 6,
1467
+ "lastNodeId": 317,
1468
+ "lastLinkId": 726,
1469
+ "lastRerouteId": 1
1470
+ },
1471
+ "revision": 0,
1472
+ "config": {},
1473
+ "name": "Edit Prompt",
1474
+ "inputNode": {
1475
+ "id": -10,
1476
+ "bounding": [
1477
+ 62,
1478
+ 461,
1479
+ 128,
1480
+ 108
1481
+ ]
1482
+ },
1483
+ "outputNode": {
1484
+ "id": -20,
1485
+ "bounding": [
1486
+ 760,
1487
+ 471,
1488
+ 137.267578125,
1489
+ 88
1490
+ ]
1491
+ },
1492
+ "inputs": [
1493
+ {
1494
+ "id": "d5e0b5d2-a705-43a3-b143-c499b31843ed",
1495
+ "name": "clip",
1496
+ "type": "CLIP",
1497
+ "linkIds": [
1498
+ 227
1499
+ ],
1500
+ "localized_name": "clip",
1501
+ "pos": [
1502
+ 166,
1503
+ 485
1504
+ ]
1505
+ },
1506
+ {
1507
+ "id": "76e0f294-768b-4477-b8d0-0448e2a223cd",
1508
+ "name": "image",
1509
+ "type": "IMAGE",
1510
+ "linkIds": [
1511
+ 200
1512
+ ],
1513
+ "localized_name": "image",
1514
+ "shape": 7,
1515
+ "pos": [
1516
+ 166,
1517
+ 505
1518
+ ]
1519
+ },
1520
+ {
1521
+ "id": "8aec684b-a930-4500-9e0f-69b2ada9cacf",
1522
+ "name": "image_b",
1523
+ "type": "IMAGE",
1524
+ "linkIds": [
1525
+ 665
1526
+ ],
1527
+ "pos": [
1528
+ 166,
1529
+ 525
1530
+ ]
1531
+ }
1532
+ ],
1533
+ "outputs": [
1534
+ {
1535
+ "id": "ed30d7a0-7e03-4f1b-8952-6f6e718563fc",
1536
+ "name": "CONDITIONING",
1537
+ "type": "CONDITIONING",
1538
+ "linkIds": [
1539
+ 186,
1540
+ 186
1541
+ ],
1542
+ "localized_name": "CONDITIONING",
1543
+ "pos": [
1544
+ 784,
1545
+ 495
1546
+ ]
1547
+ },
1548
+ {
1549
+ "id": "20f172db-2493-4bc0-89fb-c641f793b4a3",
1550
+ "name": "STRING",
1551
+ "type": "STRING",
1552
+ "linkIds": [
1553
+ 466
1554
+ ],
1555
+ "pos": [
1556
+ 784,
1557
+ 515
1558
+ ]
1559
+ }
1560
+ ],
1561
+ "widgets": [],
1562
+ "nodes": [
1563
+ {
1564
+ "id": 248,
1565
+ "type": "PrimitiveStringMultiline",
1566
+ "pos": [
1567
+ 250,
1568
+ 670
1569
+ ],
1570
+ "size": [
1571
+ 450,
1572
+ 190
1573
+ ],
1574
+ "flags": {},
1575
+ "order": 0,
1576
+ "mode": 0,
1577
+ "inputs": [],
1578
+ "outputs": [
1579
+ {
1580
+ "localized_name": "STRING",
1581
+ "name": "STRING",
1582
+ "type": "STRING",
1583
+ "links": [
1584
+ 466,
1585
+ 467
1586
+ ]
1587
+ }
1588
+ ],
1589
+ "properties": {
1590
+ "cnr_id": "comfy-core",
1591
+ "ver": "0.27.0",
1592
+ "Node name for S&R": "PrimitiveStringMultiline"
1593
+ },
1594
+ "widgets_values": [
1595
+ "restore the image quality to 4k HDR."
1596
+ ]
1597
+ },
1598
+ {
1599
+ "id": 86,
1600
+ "type": "Krea2EditGroundedEncode",
1601
+ "pos": [
1602
+ 250,
1603
+ 410
1604
+ ],
1605
+ "size": [
1606
+ 450,
1607
+ 220
1608
+ ],
1609
+ "flags": {
1610
+ "collapsed": false
1611
+ },
1612
+ "order": 1,
1613
+ "mode": 0,
1614
+ "inputs": [
1615
+ {
1616
+ "localized_name": "clip",
1617
+ "name": "clip",
1618
+ "type": "CLIP",
1619
+ "link": 227
1620
+ },
1621
+ {
1622
+ "localized_name": "image",
1623
+ "name": "image",
1624
+ "shape": 7,
1625
+ "type": "IMAGE",
1626
+ "link": 200
1627
+ },
1628
+ {
1629
+ "localized_name": "image_b",
1630
+ "name": "image_b",
1631
+ "shape": 7,
1632
+ "type": "IMAGE",
1633
+ "link": 665
1634
+ },
1635
+ {
1636
+ "localized_name": "prompt",
1637
+ "name": "prompt",
1638
+ "type": "STRING",
1639
+ "widget": {
1640
+ "name": "prompt"
1641
+ },
1642
+ "link": 467
1643
+ }
1644
+ ],
1645
+ "outputs": [
1646
+ {
1647
+ "localized_name": "CONDITIONING",
1648
+ "name": "CONDITIONING",
1649
+ "type": "CONDITIONING",
1650
+ "links": [
1651
+ 186
1652
+ ]
1653
+ }
1654
+ ],
1655
+ "title": "Edit Prompt",
1656
+ "properties": {
1657
+ "cnr_id": "comfyui-krea2edit",
1658
+ "ver": "17af88332728c97ab5c7d26296b2cae59c935976",
1659
+ "Node name for S&R": "Krea2EditGroundedEncode",
1660
+ "aux_id": "lbouaraba/comfyui-krea2edit"
1661
+ },
1662
+ "widgets_values": [
1663
+ "",
1664
+ 768,
1665
+ ""
1666
+ ],
1667
+ "color": "#232",
1668
+ "bgcolor": "#353"
1669
+ }
1670
+ ],
1671
+ "groups": [],
1672
+ "links": [
1673
+ {
1674
+ "id": 227,
1675
+ "origin_id": -10,
1676
+ "origin_slot": 0,
1677
+ "target_id": 86,
1678
+ "target_slot": 0,
1679
+ "type": "CLIP"
1680
+ },
1681
+ {
1682
+ "id": 200,
1683
+ "origin_id": -10,
1684
+ "origin_slot": 1,
1685
+ "target_id": 86,
1686
+ "target_slot": 1,
1687
+ "type": "IMAGE"
1688
+ },
1689
+ {
1690
+ "id": 186,
1691
+ "origin_id": 86,
1692
+ "origin_slot": 0,
1693
+ "target_id": -20,
1694
+ "target_slot": 0,
1695
+ "type": "CONDITIONING"
1696
+ },
1697
+ {
1698
+ "id": 466,
1699
+ "origin_id": 248,
1700
+ "origin_slot": 0,
1701
+ "target_id": -20,
1702
+ "target_slot": 1,
1703
+ "type": "STRING"
1704
+ },
1705
+ {
1706
+ "id": 467,
1707
+ "origin_id": 248,
1708
+ "origin_slot": 0,
1709
+ "target_id": 86,
1710
+ "target_slot": 3,
1711
+ "type": "STRING"
1712
+ },
1713
+ {
1714
+ "id": 665,
1715
+ "origin_id": -10,
1716
+ "origin_slot": 2,
1717
+ "target_id": 86,
1718
+ "target_slot": 2,
1719
+ "type": "IMAGE"
1720
+ }
1721
+ ],
1722
+ "extra": {}
1723
+ },
1724
+ {
1725
+ "id": "f0c08e17-ae37-4f4b-be97-5035d833db71",
1726
+ "version": 1,
1727
+ "state": {
1728
+ "lastGroupId": 6,
1729
+ "lastNodeId": 317,
1730
+ "lastLinkId": 726,
1731
+ "lastRerouteId": 1
1732
+ },
1733
+ "revision": 0,
1734
+ "config": {},
1735
+ "name": "Sampler",
1736
+ "inputNode": {
1737
+ "id": -10,
1738
+ "bounding": [
1739
+ -747.7378042814593,
1740
+ -1219.6911731082582,
1741
+ 128,
1742
+ 168
1743
+ ]
1744
+ },
1745
+ "outputNode": {
1746
+ "id": -20,
1747
+ "bounding": [
1748
+ 776.63448967841,
1749
+ -1229.6911731082582,
1750
+ 128,
1751
+ 168
1752
+ ]
1753
+ },
1754
+ "inputs": [
1755
+ {
1756
+ "id": "d514dc20-97bb-430a-b2cd-466ebd4a451a",
1757
+ "name": "seed",
1758
+ "type": "INT",
1759
+ "linkIds": [
1760
+ 543,
1761
+ 542
1762
+ ],
1763
+ "localized_name": "seed",
1764
+ "pos": [
1765
+ -643.7378042814593,
1766
+ -1195.6911731082582
1767
+ ]
1768
+ },
1769
+ {
1770
+ "id": "51f94c53-d3ed-4f2f-a9f1-e0a289fef590",
1771
+ "name": "model",
1772
+ "type": "MODEL",
1773
+ "linkIds": [
1774
+ 538
1775
+ ],
1776
+ "localized_name": "model",
1777
+ "pos": [
1778
+ -643.7378042814593,
1779
+ -1175.6911731082582
1780
+ ]
1781
+ },
1782
+ {
1783
+ "id": "b5d4a7a3-3b2d-44fa-b267-6347ab685e02",
1784
+ "name": "positive",
1785
+ "type": "CONDITIONING",
1786
+ "linkIds": [
1787
+ 539
1788
+ ],
1789
+ "localized_name": "positive",
1790
+ "pos": [
1791
+ -643.7378042814593,
1792
+ -1155.6911731082582
1793
+ ]
1794
+ },
1795
+ {
1796
+ "id": "80379873-b993-43dc-a731-dbe57bb72cff",
1797
+ "name": "negative",
1798
+ "type": "CONDITIONING",
1799
+ "linkIds": [
1800
+ 540
1801
+ ],
1802
+ "localized_name": "negative",
1803
+ "pos": [
1804
+ -643.7378042814593,
1805
+ -1135.6911731082582
1806
+ ]
1807
+ },
1808
+ {
1809
+ "id": "1375adfb-3bc1-41f7-b185-a2a955cba2ce",
1810
+ "name": "latent_image",
1811
+ "type": "LATENT",
1812
+ "linkIds": [
1813
+ 541
1814
+ ],
1815
+ "localized_name": "latent_image",
1816
+ "pos": [
1817
+ -643.7378042814593,
1818
+ -1115.6911731082582
1819
+ ]
1820
+ },
1821
+ {
1822
+ "id": "ee4891bb-f5fc-47e9-8a5f-603b69527e57",
1823
+ "name": "image",
1824
+ "type": "IMAGE",
1825
+ "linkIds": [
1826
+ 544
1827
+ ],
1828
+ "localized_name": "image",
1829
+ "pos": [
1830
+ -643.7378042814593,
1831
+ -1095.6911731082582
1832
+ ]
1833
+ }
1834
+ ],
1835
+ "outputs": [
1836
+ {
1837
+ "id": "11667b3c-6281-44ba-88b9-7445e33f03e1",
1838
+ "name": "steps",
1839
+ "type": "INT",
1840
+ "linkIds": [
1841
+ 545
1842
+ ],
1843
+ "localized_name": "steps",
1844
+ "pos": [
1845
+ 800.63448967841,
1846
+ -1205.6911731082582
1847
+ ]
1848
+ },
1849
+ {
1850
+ "id": "4ff5b37e-b767-4b68-a4da-0abd18c0013e",
1851
+ "name": "cfg",
1852
+ "type": "FLOAT",
1853
+ "linkIds": [
1854
+ 546
1855
+ ],
1856
+ "localized_name": "cfg",
1857
+ "pos": [
1858
+ 800.63448967841,
1859
+ -1185.6911731082582
1860
+ ]
1861
+ },
1862
+ {
1863
+ "id": "2c84b0a0-04a0-4a74-8a51-3ce2d47b9fe9",
1864
+ "name": "LATENT",
1865
+ "type": "LATENT",
1866
+ "linkIds": [
1867
+ 551
1868
+ ],
1869
+ "localized_name": "LATENT",
1870
+ "pos": [
1871
+ 800.63448967841,
1872
+ -1165.6911731082582
1873
+ ]
1874
+ },
1875
+ {
1876
+ "id": "e9555dd6-9214-41d5-8aea-5d5481080604",
1877
+ "name": "string_1",
1878
+ "type": "STRING",
1879
+ "linkIds": [
1880
+ 547
1881
+ ],
1882
+ "localized_name": "string_1",
1883
+ "label": "sampler",
1884
+ "pos": [
1885
+ 800.63448967841,
1886
+ -1145.6911731082582
1887
+ ]
1888
+ },
1889
+ {
1890
+ "id": "de11f682-8aee-41e2-ace2-c8eed5333382",
1891
+ "name": "width",
1892
+ "type": "INT",
1893
+ "linkIds": [
1894
+ 549
1895
+ ],
1896
+ "localized_name": "width",
1897
+ "pos": [
1898
+ 800.63448967841,
1899
+ -1125.6911731082582
1900
+ ]
1901
+ },
1902
+ {
1903
+ "id": "1f9c390d-a181-4e12-8338-5f6107534d6b",
1904
+ "name": "height",
1905
+ "type": "INT",
1906
+ "linkIds": [
1907
+ 550
1908
+ ],
1909
+ "localized_name": "height",
1910
+ "pos": [
1911
+ 800.63448967841,
1912
+ -1105.6911731082582
1913
+ ]
1914
+ }
1915
+ ],
1916
+ "widgets": [],
1917
+ "nodes": [
1918
+ {
1919
+ "id": 264,
1920
+ "type": "GetImageSize",
1921
+ "pos": [
1922
+ 20.510282180001006,
1923
+ -1333.7180513215392
1924
+ ],
1925
+ "size": [
1926
+ 140,
1927
+ 66
1928
+ ],
1929
+ "flags": {},
1930
+ "order": 2,
1931
+ "mode": 0,
1932
+ "inputs": [
1933
+ {
1934
+ "localized_name": "image",
1935
+ "name": "image",
1936
+ "type": "IMAGE",
1937
+ "link": 544
1938
+ }
1939
+ ],
1940
+ "outputs": [
1941
+ {
1942
+ "localized_name": "width",
1943
+ "name": "width",
1944
+ "type": "INT",
1945
+ "links": [
1946
+ 549
1947
+ ]
1948
+ },
1949
+ {
1950
+ "localized_name": "height",
1951
+ "name": "height",
1952
+ "type": "INT",
1953
+ "links": [
1954
+ 550
1955
+ ]
1956
+ },
1957
+ {
1958
+ "localized_name": "batch_size",
1959
+ "name": "batch_size",
1960
+ "type": "INT",
1961
+ "links": []
1962
+ }
1963
+ ],
1964
+ "properties": {
1965
+ "cnr_id": "comfy-core",
1966
+ "ver": "0.27.0",
1967
+ "Node name for S&R": "GetImageSize"
1968
+ },
1969
+ "widgets_values": []
1970
+ },
1971
+ {
1972
+ "id": 262,
1973
+ "type": "Any to String (Image Saver)",
1974
+ "pos": [
1975
+ -240,
1976
+ -1340
1977
+ ],
1978
+ "size": [
1979
+ 221.8111328125,
1980
+ 26
1981
+ ],
1982
+ "flags": {},
1983
+ "order": 1,
1984
+ "mode": 0,
1985
+ "inputs": [
1986
+ {
1987
+ "localized_name": "value",
1988
+ "name": "value",
1989
+ "type": "*",
1990
+ "link": 536
1991
+ }
1992
+ ],
1993
+ "outputs": [
1994
+ {
1995
+ "localized_name": "string",
1996
+ "name": "string",
1997
+ "type": "STRING",
1998
+ "links": [
1999
+ 547
2000
+ ]
2001
+ }
2002
+ ],
2003
+ "properties": {
2004
+ "cnr_id": "comfyui-image-saver",
2005
+ "ver": "1.23.0",
2006
+ "Node name for S&R": "Any to String (Image Saver)"
2007
+ },
2008
+ "widgets_values": []
2009
+ },
2010
+ {
2011
+ "id": 265,
2012
+ "type": "KSampler",
2013
+ "pos": [
2014
+ 396.63448967841015,
2015
+ -1415.6911731082582
2016
+ ],
2017
+ "size": [
2018
+ 320,
2019
+ 590
2020
+ ],
2021
+ "flags": {},
2022
+ "order": 3,
2023
+ "mode": 0,
2024
+ "inputs": [
2025
+ {
2026
+ "localized_name": "model",
2027
+ "name": "model",
2028
+ "type": "MODEL",
2029
+ "link": 538
2030
+ },
2031
+ {
2032
+ "localized_name": "positive",
2033
+ "name": "positive",
2034
+ "type": "CONDITIONING",
2035
+ "link": 539
2036
+ },
2037
+ {
2038
+ "localized_name": "negative",
2039
+ "name": "negative",
2040
+ "type": "CONDITIONING",
2041
+ "link": 540
2042
+ },
2043
+ {
2044
+ "localized_name": "latent_image",
2045
+ "name": "latent_image",
2046
+ "type": "LATENT",
2047
+ "link": 541
2048
+ },
2049
+ {
2050
+ "localized_name": "seed",
2051
+ "name": "seed",
2052
+ "type": "INT",
2053
+ "widget": {
2054
+ "name": "seed"
2055
+ },
2056
+ "link": 542
2057
+ },
2058
+ {
2059
+ "localized_name": "steps",
2060
+ "name": "steps",
2061
+ "type": "INT",
2062
+ "widget": {
2063
+ "name": "steps"
2064
+ },
2065
+ "link": 531
2066
+ },
2067
+ {
2068
+ "localized_name": "cfg",
2069
+ "name": "cfg",
2070
+ "type": "FLOAT",
2071
+ "widget": {
2072
+ "name": "cfg"
2073
+ },
2074
+ "link": 532
2075
+ },
2076
+ {
2077
+ "localized_name": "sampler_name",
2078
+ "name": "sampler_name",
2079
+ "type": "COMBO",
2080
+ "widget": {
2081
+ "name": "sampler_name"
2082
+ },
2083
+ "link": 553
2084
+ },
2085
+ {
2086
+ "localized_name": "denoise",
2087
+ "name": "denoise",
2088
+ "type": "FLOAT",
2089
+ "widget": {
2090
+ "name": "denoise"
2091
+ },
2092
+ "link": 535
2093
+ }
2094
+ ],
2095
+ "outputs": [
2096
+ {
2097
+ "localized_name": "LATENT",
2098
+ "name": "LATENT",
2099
+ "type": "LATENT",
2100
+ "links": [
2101
+ 551
2102
+ ]
2103
+ }
2104
+ ],
2105
+ "properties": {
2106
+ "cnr_id": "comfy-core",
2107
+ "ver": "0.27.0",
2108
+ "Node name for S&R": "KSampler"
2109
+ },
2110
+ "widgets_values": [
2111
+ 0,
2112
+ "fixed",
2113
+ 10,
2114
+ 1,
2115
+ "euler",
2116
+ "beta",
2117
+ 1
2118
+ ],
2119
+ "color": "#233",
2120
+ "bgcolor": "#355"
2121
+ },
2122
+ {
2123
+ "id": 261,
2124
+ "type": "Input Parameters (Image Saver)",
2125
+ "pos": [
2126
+ -560,
2127
+ -1340
2128
+ ],
2129
+ "size": [
2130
+ 309.312109375,
2131
+ 302
2132
+ ],
2133
+ "flags": {},
2134
+ "order": 0,
2135
+ "mode": 0,
2136
+ "inputs": [
2137
+ {
2138
+ "localized_name": "seed",
2139
+ "name": "seed",
2140
+ "type": "INT",
2141
+ "widget": {
2142
+ "name": "seed"
2143
+ },
2144
+ "link": 543
2145
+ }
2146
+ ],
2147
+ "outputs": [
2148
+ {
2149
+ "localized_name": "seed",
2150
+ "name": "seed",
2151
+ "type": "INT",
2152
+ "links": []
2153
+ },
2154
+ {
2155
+ "localized_name": "steps",
2156
+ "name": "steps",
2157
+ "type": "INT",
2158
+ "links": [
2159
+ 531,
2160
+ 545
2161
+ ]
2162
+ },
2163
+ {
2164
+ "localized_name": "cfg",
2165
+ "name": "cfg",
2166
+ "type": "FLOAT",
2167
+ "links": [
2168
+ 532,
2169
+ 546
2170
+ ]
2171
+ },
2172
+ {
2173
+ "localized_name": "sampler",
2174
+ "name": "sampler",
2175
+ "type": "COMBO",
2176
+ "links": [
2177
+ 536,
2178
+ 553
2179
+ ]
2180
+ },
2181
+ {
2182
+ "localized_name": "scheduler",
2183
+ "name": "scheduler",
2184
+ "type": "COMBO",
2185
+ "links": []
2186
+ },
2187
+ {
2188
+ "localized_name": "denoise",
2189
+ "name": "denoise",
2190
+ "type": "FLOAT",
2191
+ "links": [
2192
+ 535
2193
+ ]
2194
+ }
2195
+ ],
2196
+ "properties": {
2197
+ "cnr_id": "comfyui-image-saver",
2198
+ "ver": "1.23.0",
2199
+ "Node name for S&R": "Input Parameters (Image Saver)"
2200
+ },
2201
+ "widgets_values": [
2202
+ 0,
2203
+ "fixed",
2204
+ 8,
2205
+ 1,
2206
+ "euler",
2207
+ "beta",
2208
+ 1
2209
+ ]
2210
+ }
2211
+ ],
2212
+ "groups": [],
2213
+ "links": [
2214
+ {
2215
+ "id": 531,
2216
+ "origin_id": 261,
2217
+ "origin_slot": 1,
2218
+ "target_id": 265,
2219
+ "target_slot": 5,
2220
+ "type": "INT"
2221
+ },
2222
+ {
2223
+ "id": 532,
2224
+ "origin_id": 261,
2225
+ "origin_slot": 2,
2226
+ "target_id": 265,
2227
+ "target_slot": 6,
2228
+ "type": "FLOAT"
2229
+ },
2230
+ {
2231
+ "id": 553,
2232
+ "origin_id": 261,
2233
+ "origin_slot": 3,
2234
+ "target_id": 265,
2235
+ "target_slot": 7,
2236
+ "type": "COMBO"
2237
+ },
2238
+ {
2239
+ "id": 535,
2240
+ "origin_id": 261,
2241
+ "origin_slot": 5,
2242
+ "target_id": 265,
2243
+ "target_slot": 8,
2244
+ "type": "FLOAT"
2245
+ },
2246
+ {
2247
+ "id": 536,
2248
+ "origin_id": 261,
2249
+ "origin_slot": 3,
2250
+ "target_id": 262,
2251
+ "target_slot": 0,
2252
+ "type": "COMBO"
2253
+ },
2254
+ {
2255
+ "id": 543,
2256
+ "origin_id": -10,
2257
+ "origin_slot": 0,
2258
+ "target_id": 261,
2259
+ "target_slot": 0,
2260
+ "type": "INT"
2261
+ },
2262
+ {
2263
+ "id": 542,
2264
+ "origin_id": -10,
2265
+ "origin_slot": 0,
2266
+ "target_id": 265,
2267
+ "target_slot": 4,
2268
+ "type": "INT"
2269
+ },
2270
+ {
2271
+ "id": 538,
2272
+ "origin_id": -10,
2273
+ "origin_slot": 1,
2274
+ "target_id": 265,
2275
+ "target_slot": 0,
2276
+ "type": "MODEL"
2277
+ },
2278
+ {
2279
+ "id": 539,
2280
+ "origin_id": -10,
2281
+ "origin_slot": 2,
2282
+ "target_id": 265,
2283
+ "target_slot": 1,
2284
+ "type": "CONDITIONING"
2285
+ },
2286
+ {
2287
+ "id": 540,
2288
+ "origin_id": -10,
2289
+ "origin_slot": 3,
2290
+ "target_id": 265,
2291
+ "target_slot": 2,
2292
+ "type": "CONDITIONING"
2293
+ },
2294
+ {
2295
+ "id": 541,
2296
+ "origin_id": -10,
2297
+ "origin_slot": 4,
2298
+ "target_id": 265,
2299
+ "target_slot": 3,
2300
+ "type": "LATENT"
2301
+ },
2302
+ {
2303
+ "id": 544,
2304
+ "origin_id": -10,
2305
+ "origin_slot": 5,
2306
+ "target_id": 264,
2307
+ "target_slot": 0,
2308
+ "type": "IMAGE"
2309
+ },
2310
+ {
2311
+ "id": 545,
2312
+ "origin_id": 261,
2313
+ "origin_slot": 1,
2314
+ "target_id": -20,
2315
+ "target_slot": 0,
2316
+ "type": "INT"
2317
+ },
2318
+ {
2319
+ "id": 546,
2320
+ "origin_id": 261,
2321
+ "origin_slot": 2,
2322
+ "target_id": -20,
2323
+ "target_slot": 1,
2324
+ "type": "FLOAT"
2325
+ },
2326
+ {
2327
+ "id": 551,
2328
+ "origin_id": 265,
2329
+ "origin_slot": 0,
2330
+ "target_id": -20,
2331
+ "target_slot": 2,
2332
+ "type": "LATENT"
2333
+ },
2334
+ {
2335
+ "id": 547,
2336
+ "origin_id": 262,
2337
+ "origin_slot": 0,
2338
+ "target_id": -20,
2339
+ "target_slot": 3,
2340
+ "type": "STRING"
2341
+ },
2342
+ {
2343
+ "id": 549,
2344
+ "origin_id": 264,
2345
+ "origin_slot": 0,
2346
+ "target_id": -20,
2347
+ "target_slot": 4,
2348
+ "type": "INT"
2349
+ },
2350
+ {
2351
+ "id": 550,
2352
+ "origin_id": 264,
2353
+ "origin_slot": 1,
2354
+ "target_id": -20,
2355
+ "target_slot": 5,
2356
+ "type": "INT"
2357
+ }
2358
+ ],
2359
+ "extra": {}
2360
+ },
2361
+ {
2362
+ "id": "b898f649-8abc-44f2-a47c-2219759f01c2",
2363
+ "version": 1,
2364
+ "state": {
2365
+ "lastGroupId": 6,
2366
+ "lastNodeId": 317,
2367
+ "lastLinkId": 726,
2368
+ "lastRerouteId": 1
2369
+ },
2370
+ "revision": 0,
2371
+ "config": {},
2372
+ "name": "Preprocessing",
2373
+ "inputNode": {
2374
+ "id": -10,
2375
+ "bounding": [
2376
+ 479.591796875,
2377
+ 336,
2378
+ 140.408203125,
2379
+ 148
2380
+ ]
2381
+ },
2382
+ "outputNode": {
2383
+ "id": -20,
2384
+ "bounding": [
2385
+ 1310,
2386
+ 346,
2387
+ 128,
2388
+ 128
2389
+ ]
2390
+ },
2391
+ "inputs": [
2392
+ {
2393
+ "id": "bb60aaf1-2769-4b04-b02c-56ff5ee7a3b9",
2394
+ "name": "vae",
2395
+ "type": "VAE",
2396
+ "linkIds": [
2397
+ 681
2398
+ ],
2399
+ "localized_name": "vae",
2400
+ "pos": [
2401
+ 596,
2402
+ 360
2403
+ ]
2404
+ },
2405
+ {
2406
+ "id": "df74b1fd-393c-4cf8-a686-7ac7b5eccd79",
2407
+ "name": "image",
2408
+ "type": "IMAGE",
2409
+ "linkIds": [
2410
+ 680
2411
+ ],
2412
+ "localized_name": "image",
2413
+ "pos": [
2414
+ 596,
2415
+ 380
2416
+ ]
2417
+ },
2418
+ {
2419
+ "id": "db130b1e-ee5f-44a7-8be8-51276fc2ffe3",
2420
+ "name": "model",
2421
+ "type": "MODEL",
2422
+ "linkIds": [
2423
+ 682
2424
+ ],
2425
+ "localized_name": "model",
2426
+ "pos": [
2427
+ 596,
2428
+ 400
2429
+ ]
2430
+ },
2431
+ {
2432
+ "id": "70c607e3-4c69-4e6e-b3e4-099f69e670a5",
2433
+ "name": "source_latent_b",
2434
+ "type": "LATENT",
2435
+ "linkIds": [
2436
+ 692
2437
+ ],
2438
+ "localized_name": "source_latent_b",
2439
+ "shape": 7,
2440
+ "pos": [
2441
+ 596,
2442
+ 420
2443
+ ]
2444
+ },
2445
+ {
2446
+ "id": "338e0f51-4da7-4bfc-bd5b-814e383ecbba",
2447
+ "name": "source_image_b",
2448
+ "type": "IMAGE",
2449
+ "linkIds": [
2450
+ 694
2451
+ ],
2452
+ "localized_name": "source_image_b",
2453
+ "shape": 7,
2454
+ "pos": [
2455
+ 596,
2456
+ 440
2457
+ ]
2458
+ }
2459
+ ],
2460
+ "outputs": [
2461
+ {
2462
+ "id": "18739a55-913a-4cd9-9c5c-04958fd33b2c",
2463
+ "name": "IMAGE",
2464
+ "type": "IMAGE",
2465
+ "linkIds": [
2466
+ 685
2467
+ ],
2468
+ "localized_name": "IMAGE",
2469
+ "pos": [
2470
+ 1334,
2471
+ 370
2472
+ ]
2473
+ },
2474
+ {
2475
+ "id": "0ee3d3fd-fb19-4dac-bef9-3537004fdc32",
2476
+ "name": "MODEL",
2477
+ "type": "MODEL",
2478
+ "linkIds": [
2479
+ 684
2480
+ ],
2481
+ "localized_name": "MODEL",
2482
+ "pos": [
2483
+ 1334,
2484
+ 390
2485
+ ]
2486
+ },
2487
+ {
2488
+ "id": "464bcb90-39c4-4b09-9df7-7b36cbf3256a",
2489
+ "name": "FLOAT",
2490
+ "type": "FLOAT",
2491
+ "linkIds": [
2492
+ 696
2493
+ ],
2494
+ "pos": [
2495
+ 1334,
2496
+ 410
2497
+ ]
2498
+ },
2499
+ {
2500
+ "id": "69f7db48-b351-4e9e-92c6-60226ec8cbb9",
2501
+ "name": "LATENT",
2502
+ "type": "LATENT",
2503
+ "linkIds": [
2504
+ 683
2505
+ ],
2506
+ "localized_name": "LATENT",
2507
+ "pos": [
2508
+ 1334,
2509
+ 430
2510
+ ]
2511
+ }
2512
+ ],
2513
+ "widgets": [],
2514
+ "nodes": [
2515
+ {
2516
+ "id": 301,
2517
+ "type": "VAEEncode",
2518
+ "pos": [
2519
+ 840,
2520
+ 400
2521
+ ],
2522
+ "size": [
2523
+ 230,
2524
+ 100
2525
+ ],
2526
+ "flags": {
2527
+ "collapsed": true
2528
+ },
2529
+ "order": 1,
2530
+ "mode": 0,
2531
+ "inputs": [
2532
+ {
2533
+ "localized_name": "pixels",
2534
+ "name": "pixels",
2535
+ "type": "IMAGE",
2536
+ "link": 686
2537
+ },
2538
+ {
2539
+ "localized_name": "vae",
2540
+ "name": "vae",
2541
+ "type": "VAE",
2542
+ "link": 681
2543
+ }
2544
+ ],
2545
+ "outputs": [
2546
+ {
2547
+ "localized_name": "LATENT",
2548
+ "name": "LATENT",
2549
+ "type": "LATENT",
2550
+ "links": [
2551
+ 679
2552
+ ]
2553
+ }
2554
+ ],
2555
+ "properties": {
2556
+ "cnr_id": "comfy-core",
2557
+ "ver": "0.3.50",
2558
+ "Node name for S&R": "VAEEncode",
2559
+ "enableTabs": false,
2560
+ "tabWidth": 65,
2561
+ "tabXOffset": 10,
2562
+ "hasSecondTab": false,
2563
+ "secondTabText": "Send Back",
2564
+ "secondTabOffset": 80,
2565
+ "secondTabWidth": 65,
2566
+ "ue_properties": {
2567
+ "widget_ue_connectable": {}
2568
+ }
2569
+ },
2570
+ "widgets_values": []
2571
+ },
2572
+ {
2573
+ "id": 302,
2574
+ "type": "GetImageSize",
2575
+ "pos": [
2576
+ 680,
2577
+ 400
2578
+ ],
2579
+ "size": [
2580
+ 210,
2581
+ 165.78455492205944
2582
+ ],
2583
+ "flags": {
2584
+ "collapsed": true
2585
+ },
2586
+ "order": 2,
2587
+ "mode": 0,
2588
+ "inputs": [
2589
+ {
2590
+ "localized_name": "image",
2591
+ "name": "image",
2592
+ "type": "IMAGE",
2593
+ "link": 678
2594
+ }
2595
+ ],
2596
+ "outputs": [
2597
+ {
2598
+ "localized_name": "width",
2599
+ "name": "width",
2600
+ "type": "INT",
2601
+ "links": [
2602
+ 687
2603
+ ]
2604
+ },
2605
+ {
2606
+ "localized_name": "height",
2607
+ "name": "height",
2608
+ "type": "INT",
2609
+ "links": [
2610
+ 688
2611
+ ]
2612
+ },
2613
+ {
2614
+ "localized_name": "batch_size",
2615
+ "name": "batch_size",
2616
+ "type": "INT",
2617
+ "links": []
2618
+ }
2619
+ ],
2620
+ "properties": {
2621
+ "cnr_id": "comfy-core",
2622
+ "ver": "0.27.0",
2623
+ "Node name for S&R": "GetImageSize"
2624
+ },
2625
+ "widgets_values": []
2626
+ },
2627
+ {
2628
+ "id": 304,
2629
+ "type": "ImageScaleToTotalPixels",
2630
+ "pos": [
2631
+ 680,
2632
+ 250
2633
+ ],
2634
+ "size": [
2635
+ 290,
2636
+ 110
2637
+ ],
2638
+ "flags": {},
2639
+ "order": 4,
2640
+ "mode": 0,
2641
+ "inputs": [
2642
+ {
2643
+ "localized_name": "image",
2644
+ "name": "image",
2645
+ "type": "IMAGE",
2646
+ "link": 680
2647
+ },
2648
+ {
2649
+ "localized_name": "megapixels",
2650
+ "name": "megapixels",
2651
+ "type": "FLOAT",
2652
+ "widget": {
2653
+ "name": "megapixels"
2654
+ },
2655
+ "link": 695
2656
+ }
2657
+ ],
2658
+ "outputs": [
2659
+ {
2660
+ "localized_name": "IMAGE",
2661
+ "name": "IMAGE",
2662
+ "type": "IMAGE",
2663
+ "links": [
2664
+ 678,
2665
+ 685,
2666
+ 686,
2667
+ 689
2668
+ ]
2669
+ }
2670
+ ],
2671
+ "properties": {
2672
+ "cnr_id": "comfy-core",
2673
+ "ver": "0.27.0",
2674
+ "Node name for S&R": "ImageScaleToTotalPixels"
2675
+ },
2676
+ "widgets_values": [
2677
+ "lanczos",
2678
+ 1.4,
2679
+ 64
2680
+ ]
2681
+ },
2682
+ {
2683
+ "id": 307,
2684
+ "type": "Krea2EditModelPatch",
2685
+ "pos": [
2686
+ 980,
2687
+ 250
2688
+ ],
2689
+ "size": [
2690
+ 270,
2691
+ 226
2692
+ ],
2693
+ "flags": {},
2694
+ "order": 5,
2695
+ "mode": 0,
2696
+ "inputs": [
2697
+ {
2698
+ "localized_name": "model",
2699
+ "name": "model",
2700
+ "type": "MODEL",
2701
+ "link": 682
2702
+ },
2703
+ {
2704
+ "localized_name": "source_latent",
2705
+ "name": "source_latent",
2706
+ "type": "LATENT",
2707
+ "link": 679
2708
+ },
2709
+ {
2710
+ "localized_name": "source_latent_b",
2711
+ "name": "source_latent_b",
2712
+ "shape": 7,
2713
+ "type": "LATENT",
2714
+ "link": 692
2715
+ },
2716
+ {
2717
+ "localized_name": "ref_boost_mask",
2718
+ "name": "ref_boost_mask",
2719
+ "shape": 7,
2720
+ "type": "MASK",
2721
+ "link": null
2722
+ },
2723
+ {
2724
+ "localized_name": "vae",
2725
+ "name": "vae",
2726
+ "shape": 7,
2727
+ "type": "VAE",
2728
+ "link": null
2729
+ },
2730
+ {
2731
+ "localized_name": "source_image",
2732
+ "name": "source_image",
2733
+ "shape": 7,
2734
+ "type": "IMAGE",
2735
+ "link": 689
2736
+ },
2737
+ {
2738
+ "localized_name": "source_image_b",
2739
+ "name": "source_image_b",
2740
+ "shape": 7,
2741
+ "type": "IMAGE",
2742
+ "link": 694
2743
+ }
2744
+ ],
2745
+ "outputs": [
2746
+ {
2747
+ "localized_name": "MODEL",
2748
+ "name": "MODEL",
2749
+ "type": "MODEL",
2750
+ "links": [
2751
+ 684
2752
+ ]
2753
+ }
2754
+ ],
2755
+ "properties": {
2756
+ "cnr_id": "comfyui-krea2edit",
2757
+ "ver": "17af88332728c97ab5c7d26296b2cae59c935976",
2758
+ "Node name for S&R": "Krea2EditModelPatch",
2759
+ "aux_id": "lbouaraba/comfyui-krea2edit"
2760
+ },
2761
+ "widgets_values": [
2762
+ 1,
2763
+ 1,
2764
+ "fit"
2765
+ ]
2766
+ },
2767
+ {
2768
+ "id": 305,
2769
+ "type": "PrimitiveNode",
2770
+ "pos": [
2771
+ 980,
2772
+ 510
2773
+ ],
2774
+ "size": [
2775
+ 210,
2776
+ 90
2777
+ ],
2778
+ "flags": {},
2779
+ "order": 0,
2780
+ "mode": 0,
2781
+ "inputs": [],
2782
+ "outputs": [
2783
+ {
2784
+ "name": "FLOAT",
2785
+ "type": "FLOAT",
2786
+ "widget": {
2787
+ "name": "megapixels"
2788
+ },
2789
+ "links": [
2790
+ 695,
2791
+ 696
2792
+ ]
2793
+ }
2794
+ ],
2795
+ "properties": {
2796
+ "Run widget replace on values": false
2797
+ },
2798
+ "widgets_values": [
2799
+ 1.4,
2800
+ "fixed"
2801
+ ]
2802
+ },
2803
+ {
2804
+ "id": 303,
2805
+ "type": "EmptySD3LatentImage",
2806
+ "pos": [
2807
+ 680,
2808
+ 440
2809
+ ],
2810
+ "size": [
2811
+ 290,
2812
+ 160
2813
+ ],
2814
+ "flags": {
2815
+ "collapsed": false
2816
+ },
2817
+ "order": 3,
2818
+ "mode": 0,
2819
+ "inputs": [
2820
+ {
2821
+ "localized_name": "width",
2822
+ "name": "width",
2823
+ "type": "INT",
2824
+ "widget": {
2825
+ "name": "width"
2826
+ },
2827
+ "link": 687
2828
+ },
2829
+ {
2830
+ "localized_name": "height",
2831
+ "name": "height",
2832
+ "type": "INT",
2833
+ "widget": {
2834
+ "name": "height"
2835
+ },
2836
+ "link": 688
2837
+ }
2838
+ ],
2839
+ "outputs": [
2840
+ {
2841
+ "localized_name": "LATENT",
2842
+ "name": "LATENT",
2843
+ "type": "LATENT",
2844
+ "links": [
2845
+ 683
2846
+ ]
2847
+ }
2848
+ ],
2849
+ "properties": {
2850
+ "cnr_id": "comfy-core",
2851
+ "ver": "0.26.0",
2852
+ "Node name for S&R": "EmptySD3LatentImage"
2853
+ },
2854
+ "widgets_values": [
2855
+ 1024,
2856
+ 1024,
2857
+ 1
2858
+ ]
2859
+ }
2860
+ ],
2861
+ "groups": [],
2862
+ "links": [
2863
+ {
2864
+ "id": 686,
2865
+ "origin_id": 304,
2866
+ "origin_slot": 0,
2867
+ "target_id": 301,
2868
+ "target_slot": 0,
2869
+ "type": "IMAGE"
2870
+ },
2871
+ {
2872
+ "id": 678,
2873
+ "origin_id": 304,
2874
+ "origin_slot": 0,
2875
+ "target_id": 302,
2876
+ "target_slot": 0,
2877
+ "type": "IMAGE"
2878
+ },
2879
+ {
2880
+ "id": 695,
2881
+ "origin_id": 305,
2882
+ "origin_slot": 0,
2883
+ "target_id": 304,
2884
+ "target_slot": 1,
2885
+ "type": "FLOAT"
2886
+ },
2887
+ {
2888
+ "id": 679,
2889
+ "origin_id": 301,
2890
+ "origin_slot": 0,
2891
+ "target_id": 307,
2892
+ "target_slot": 1,
2893
+ "type": "LATENT"
2894
+ },
2895
+ {
2896
+ "id": 689,
2897
+ "origin_id": 304,
2898
+ "origin_slot": 0,
2899
+ "target_id": 307,
2900
+ "target_slot": 5,
2901
+ "type": "IMAGE"
2902
+ },
2903
+ {
2904
+ "id": 687,
2905
+ "origin_id": 302,
2906
+ "origin_slot": 0,
2907
+ "target_id": 303,
2908
+ "target_slot": 0,
2909
+ "type": "INT"
2910
+ },
2911
+ {
2912
+ "id": 688,
2913
+ "origin_id": 302,
2914
+ "origin_slot": 1,
2915
+ "target_id": 303,
2916
+ "target_slot": 1,
2917
+ "type": "INT"
2918
+ },
2919
+ {
2920
+ "id": 681,
2921
+ "origin_id": -10,
2922
+ "origin_slot": 0,
2923
+ "target_id": 301,
2924
+ "target_slot": 1,
2925
+ "type": "VAE"
2926
+ },
2927
+ {
2928
+ "id": 680,
2929
+ "origin_id": -10,
2930
+ "origin_slot": 1,
2931
+ "target_id": 304,
2932
+ "target_slot": 0,
2933
+ "type": "IMAGE"
2934
+ },
2935
+ {
2936
+ "id": 682,
2937
+ "origin_id": -10,
2938
+ "origin_slot": 2,
2939
+ "target_id": 307,
2940
+ "target_slot": 0,
2941
+ "type": "MODEL"
2942
+ },
2943
+ {
2944
+ "id": 692,
2945
+ "origin_id": -10,
2946
+ "origin_slot": 3,
2947
+ "target_id": 307,
2948
+ "target_slot": 2,
2949
+ "type": "LATENT"
2950
+ },
2951
+ {
2952
+ "id": 694,
2953
+ "origin_id": -10,
2954
+ "origin_slot": 4,
2955
+ "target_id": 307,
2956
+ "target_slot": 6,
2957
+ "type": "IMAGE"
2958
+ },
2959
+ {
2960
+ "id": 685,
2961
+ "origin_id": 304,
2962
+ "origin_slot": 0,
2963
+ "target_id": -20,
2964
+ "target_slot": 0,
2965
+ "type": "IMAGE"
2966
+ },
2967
+ {
2968
+ "id": 684,
2969
+ "origin_id": 307,
2970
+ "origin_slot": 0,
2971
+ "target_id": -20,
2972
+ "target_slot": 1,
2973
+ "type": "MODEL"
2974
+ },
2975
+ {
2976
+ "id": 696,
2977
+ "origin_id": 305,
2978
+ "origin_slot": 0,
2979
+ "target_id": -20,
2980
+ "target_slot": 2,
2981
+ "type": "FLOAT"
2982
+ },
2983
+ {
2984
+ "id": 683,
2985
+ "origin_id": 303,
2986
+ "origin_slot": 0,
2987
+ "target_id": -20,
2988
+ "target_slot": 3,
2989
+ "type": "LATENT"
2990
+ }
2991
+ ],
2992
+ "extra": {}
2993
+ }
2994
+ ]
2995
+ },
2996
+ "config": {},
2997
+ "extra": {
2998
+ "frontendVersion": "1.45.20",
2999
+ "VHS_latentpreview": false,
3000
+ "VHS_latentpreviewrate": 0,
3001
+ "VHS_MetadataImage": true,
3002
+ "VHS_KeepIntermediate": true,
3003
+ "ds": {
3004
+ "scale": 0.8178765517241496,
3005
+ "offset": [
3006
+ 751.7823341852759,
3007
+ 1947.8199360008716
3008
+ ]
3009
+ }
3010
+ },
3011
+ "version": 0.4
3012
+ }
requirements.txt ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ --extra-index-url https://download.pytorch.org/whl/cu128
2
+ torch==2.8.0
3
+ torchvision==0.23.0
4
+ torchaudio==2.8.0
5
+ torchsde
6
+ spaces
7
+ gradio>=5,<6
8
+ huggingface_hub
9
+ transformers>=4.48.0
10
+ accelerate>=0.26.0
11
+ safetensors
12
+ einops
13
+ scipy
14
+ numpy
15
+ pillow
16
+ psutil
17
+ websocket-client
18
+ sentencepiece
19
+ protobuf
settings_utils.py ADDED
@@ -0,0 +1,333 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Portable settings and PNG metadata helpers for the Krea 2 Space."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import json
6
+ import hashlib
7
+ import math
8
+ import pathlib
9
+ import re
10
+ from pathlib import Path
11
+ from typing import Any
12
+
13
+ from PIL import Image, PngImagePlugin
14
+
15
+
16
+ APP_ID = "krea-2-turbo-i2i"
17
+ PROFILE_SCHEMA_VERSION = 3
18
+ CUSTOM_LORA_EXTENSIONS = {".safetensors", ".pt", ".ckpt", ".bin"}
19
+ CUSTOM_BASE_MODEL_EXTENSIONS = {".safetensors", ".pt", ".ckpt", ".bin"}
20
+ _HF_REPO_RE = re.compile(
21
+ r"^[A-Za-z0-9][A-Za-z0-9._-]{0,95}/[A-Za-z0-9][A-Za-z0-9._-]{0,95}$"
22
+ )
23
+
24
+
25
+ def _finite_number(value: Any, field: str) -> float:
26
+ try:
27
+ number = float(value)
28
+ except (TypeError, ValueError) as exc:
29
+ raise ValueError(f"{field} must be a number") from exc
30
+ if not math.isfinite(number):
31
+ raise ValueError(f"{field} must be finite")
32
+ return number
33
+
34
+
35
+ def _text(value: Any, field: str, limit: int = 8192) -> str:
36
+ result = "" if value is None else str(value)
37
+ if "\x00" in result or len(result) > limit:
38
+ raise ValueError(f"{field} is invalid or too long")
39
+ return result.strip()
40
+
41
+
42
+ def _finite_number(value: Any, field: str) -> float:
43
+ try:
44
+ number = float(value)
45
+ except (TypeError, ValueError) as exc:
46
+ raise ValueError(f"{field} must be a number") from exc
47
+ if not math.isfinite(number):
48
+ raise ValueError(f"{field} must be finite")
49
+ return number
50
+
51
+
52
+ def validate_custom_lora(row: Any) -> dict[str, Any]:
53
+ """Validate and normalize one custom Hugging Face LoRA row."""
54
+ if isinstance(row, dict):
55
+ repo_id = row.get("repo_id", "")
56
+ filename = row.get("filename", row.get("file", ""))
57
+ revision = row.get("revision", "")
58
+ weight = row.get("weight", 0.0)
59
+ elif isinstance(row, (list, tuple)):
60
+ values = list(row) + [""] * 4
61
+ repo_id, filename, revision, weight = values[:4]
62
+ else:
63
+ raise ValueError("custom LoRA rows must be objects or four-column arrays")
64
+
65
+ repo_id = _text(repo_id, "custom LoRA repository", 193)
66
+ if not _HF_REPO_RE.fullmatch(repo_id):
67
+ raise ValueError(
68
+ f"invalid Hugging Face repository ID {repo_id!r}; expected namespace/name"
69
+ )
70
+
71
+ filename = _text(filename, "custom LoRA file", 512).replace("\\", "/")
72
+ path = pathlib.PurePosixPath(filename)
73
+ if (
74
+ not filename
75
+ or path.is_absolute()
76
+ or any(part in {"", ".", ".."} for part in path.parts)
77
+ or path.suffix.lower() not in CUSTOM_LORA_EXTENSIONS
78
+ ):
79
+ allowed = ", ".join(sorted(CUSTOM_LORA_EXTENSIONS))
80
+ raise ValueError(f"custom LoRA file must be relative and end in {allowed}")
81
+
82
+ revision = _text(revision, "custom LoRA revision", 256)
83
+ if any(ord(char) < 32 for char in revision):
84
+ raise ValueError("custom LoRA revision contains control characters")
85
+
86
+ weight_number = _finite_number(weight or 0.0, "custom LoRA weight")
87
+ if weight_number < -3.0 or weight_number > 3.0:
88
+ raise ValueError("custom LoRA weight must be between -3 and 3")
89
+
90
+ return {
91
+ "repo_id": repo_id,
92
+ "filename": filename,
93
+ "revision": revision,
94
+ "weight": round(weight_number, 6),
95
+ }
96
+
97
+
98
+ def normalize_custom_loras(rows: Any) -> tuple[list[dict[str, Any]], list[str]]:
99
+ """Normalize non-empty custom rows and collect row errors as warnings."""
100
+ if rows is None:
101
+ return [], []
102
+ if isinstance(rows, dict):
103
+ rows = [rows]
104
+ normalized: list[dict[str, Any]] = []
105
+ warnings: list[str] = []
106
+ for index, row in enumerate(rows):
107
+ if row is None or row == [] or row == {}:
108
+ continue
109
+ if isinstance(row, (list, tuple)):
110
+ values = list(row) + [""] * 4
111
+ if not any(str(value).strip() for value in values[:3]) and not values[3]:
112
+ continue
113
+ try:
114
+ normalized.append(validate_custom_lora(row))
115
+ except ValueError as exc:
116
+ warnings.append(f"custom LoRA row {index + 1}: {exc}")
117
+ return normalized, warnings
118
+
119
+
120
+ def validate_custom_base_model(value: Any) -> dict[str, str]:
121
+ """Validate one custom Hugging Face diffusion-model reference."""
122
+ if isinstance(value, dict):
123
+ repo_id = value.get("repo_id", "")
124
+ filename = value.get("filename", value.get("file", ""))
125
+ revision = value.get("revision", "")
126
+ elif isinstance(value, (list, tuple)):
127
+ values = list(value) + [""] * 3
128
+ repo_id, filename, revision = values[:3]
129
+ else:
130
+ raise ValueError("custom base model must be an object or three-column array")
131
+
132
+ repo_id = _text(repo_id, "custom base-model repository", 193)
133
+ if not _HF_REPO_RE.fullmatch(repo_id):
134
+ raise ValueError(
135
+ f"invalid Hugging Face repository ID {repo_id!r}; expected namespace/name"
136
+ )
137
+
138
+ filename = _text(filename, "custom base-model file", 512).replace("\\", "/")
139
+ path = pathlib.PurePosixPath(filename)
140
+ if (
141
+ not filename
142
+ or path.is_absolute()
143
+ or any(part in {"", ".", ".."} for part in path.parts)
144
+ or path.suffix.lower() not in CUSTOM_BASE_MODEL_EXTENSIONS
145
+ ):
146
+ allowed = ", ".join(sorted(CUSTOM_BASE_MODEL_EXTENSIONS))
147
+ raise ValueError(f"custom base-model file must be relative and end in {allowed}")
148
+
149
+ revision = _text(revision, "custom base-model revision", 256)
150
+ if any(ord(char) < 32 for char in revision):
151
+ raise ValueError("custom base-model revision contains control characters")
152
+ return {"repo_id": repo_id, "filename": filename, "revision": revision}
153
+
154
+
155
+ def stable_custom_lora_namespace(repo_id: str, filename: str, revision: str = "") -> str:
156
+ """Return a filesystem-safe stable namespace for one remote LoRA."""
157
+ identity = "\x00".join((repo_id, revision, filename)).encode("utf-8")
158
+ return hashlib.sha256(identity).hexdigest()[:20]
159
+
160
+
161
+ def stable_custom_base_model_namespace(repo_id: str, filename: str, revision: str = "") -> str:
162
+ """Return a filesystem-safe stable namespace for one remote base model."""
163
+ identity = "\x00".join((repo_id, revision, filename)).encode("utf-8")
164
+ return hashlib.sha256(identity).hexdigest()[:20]
165
+
166
+
167
+ def build_settings(
168
+ *,
169
+ mode: str,
170
+ prompt: str,
171
+ edit_prompt: str,
172
+ width: int,
173
+ height: int,
174
+ target_megapixels: float,
175
+ grounding_px: int,
176
+ ref_boost: float,
177
+ ref_boost_a: float,
178
+ steps: int,
179
+ cfg: float,
180
+ sampler_name: str,
181
+ scheduler: str,
182
+ seed: int,
183
+ randomize_seed: bool,
184
+ gen_budget: float,
185
+ effective_seed: int | None = None,
186
+ base_model: str = "",
187
+ custom_base_model: dict[str, Any] | None = None,
188
+ catalog_loras: list[dict[str, Any]] | None = None,
189
+ custom_loras: list[dict[str, Any]] | None = None,
190
+ ) -> dict[str, Any]:
191
+ """Build the canonical profile embedded in generated PNG files."""
192
+ return {
193
+ "app": APP_ID,
194
+ "schema_version": PROFILE_SCHEMA_VERSION,
195
+ "base_model": _text(base_model, "base model", 256),
196
+ "custom_base_model": (
197
+ validate_custom_base_model(custom_base_model)
198
+ if custom_base_model
199
+ else None
200
+ ),
201
+ "mode": _text(mode, "mode", 32),
202
+ "prompt": _text(prompt, "prompt"),
203
+ "edit_prompt": _text(edit_prompt, "edit prompt"),
204
+ "width": int(width),
205
+ "height": int(height),
206
+ "target_megapixels": float(target_megapixels),
207
+ "grounding_px": int(grounding_px),
208
+ "ref_boost": float(ref_boost),
209
+ "ref_boost_a": float(ref_boost_a),
210
+ "steps": int(steps),
211
+ "cfg": float(cfg),
212
+ "sampler_name": _text(sampler_name, "sampler", 64),
213
+ "scheduler": _text(scheduler, "scheduler", 64),
214
+ "seed": int(seed),
215
+ "effective_seed": None if effective_seed is None else int(effective_seed),
216
+ "randomize_seed": bool(randomize_seed),
217
+ "gen_budget": float(gen_budget),
218
+ "catalog_loras": [
219
+ {
220
+ "hf_filename": _text(item.get("hf_filename", ""), "catalog LoRA filename", 512),
221
+ "weight": float(item.get("weight", 0.0)),
222
+ }
223
+ for item in (catalog_loras or [])
224
+ if item.get("hf_filename") and abs(float(item.get("weight", 0.0))) > 1e-6
225
+ ],
226
+ "custom_loras": [validate_custom_lora(item) for item in (custom_loras or [])],
227
+ }
228
+
229
+
230
+ def parse_settings_text(text: Any) -> tuple[dict[str, Any], list[str]]:
231
+ """Parse a Krea JSON profile or a compact A1111-style parameter string."""
232
+ value = "" if text is None else str(text).strip()
233
+ if not value:
234
+ return {}, ["settings text is empty"]
235
+ try:
236
+ decoded = json.loads(value)
237
+ except json.JSONDecodeError:
238
+ lines = value.splitlines()
239
+ result: dict[str, Any] = {}
240
+ steps = re.search(r"Steps:\s*(\d+)", value, re.I)
241
+ cfg = re.search(r"CFG scale:\s*([\d.]+)", value, re.I)
242
+ sampler = re.search(r"Sampler:\s*([^,\n]+)", value, re.I)
243
+ seed = re.search(r"Seed:\s*(\d+)", value, re.I)
244
+ size = re.search(r"Size:\s*(\d+)\s*[xX×]\s*(\d+)", value, re.I)
245
+ negative_line = next(
246
+ (index for index, line in enumerate(lines) if line.lower().startswith("negative prompt:")),
247
+ None,
248
+ )
249
+ if negative_line is not None:
250
+ result["prompt"] = "\n".join(lines[:negative_line]).strip()
251
+ else:
252
+ result["prompt"] = lines[0].strip() if lines else ""
253
+ if steps:
254
+ result["steps"] = int(steps.group(1))
255
+ if cfg:
256
+ result["cfg"] = float(cfg.group(1))
257
+ if sampler:
258
+ result["sampler_name"] = sampler.group(1).strip()
259
+ if seed:
260
+ result["effective_seed"] = int(seed.group(1))
261
+ if size:
262
+ result["width"] = int(size.group(1))
263
+ result["height"] = int(size.group(2))
264
+ return result, []
265
+ if not isinstance(decoded, dict):
266
+ return {}, ["settings JSON must be an object"]
267
+ if isinstance(decoded.get("krea_settings"), str):
268
+ try:
269
+ decoded = json.loads(decoded["krea_settings"])
270
+ except json.JSONDecodeError:
271
+ return {}, ["krea_settings metadata is not valid JSON"]
272
+ return decoded, []
273
+
274
+
275
+ def extract_image_settings(path: str | Path) -> tuple[dict[str, Any], list[str]]:
276
+ """Extract Krea settings or common parameter text from an image."""
277
+ try:
278
+ with Image.open(path) as image:
279
+ metadata = dict(image.info)
280
+ except Exception as exc:
281
+ return {}, [f"could not read image metadata: {exc}"]
282
+ for key in ("krea_settings", "parameters", "prompt"):
283
+ raw = metadata.get(key)
284
+ if isinstance(raw, bytes):
285
+ raw = raw.decode("utf-8", errors="ignore")
286
+ if isinstance(raw, str) and raw.strip():
287
+ data, warnings = parse_settings_text(raw)
288
+ if data:
289
+ return data, warnings
290
+ return {}, ["image contains no recognized Krea settings"]
291
+
292
+
293
+ def build_parameters_text(settings: dict[str, Any]) -> str:
294
+ """Build a readable generation summary for image viewers."""
295
+ prompt = settings.get("edit_prompt") or settings.get("prompt", "")
296
+ parts = [
297
+ f"Base model: {settings.get('base_model', '')}",
298
+ f"Steps: {settings.get('steps')}",
299
+ f"CFG scale: {settings.get('cfg')}",
300
+ f"Sampler: {settings.get('sampler_name')}",
301
+ f"Schedule type: {settings.get('scheduler')}",
302
+ f"Seed: {settings.get('effective_seed', settings.get('seed'))}",
303
+ f"Size: {settings.get('width')}x{settings.get('height')}",
304
+ ]
305
+ if settings.get("mode") == "edit":
306
+ parts.extend([
307
+ f"Grounding: {settings.get('grounding_px')}px",
308
+ f"Reference strength: {settings.get('ref_boost')}",
309
+ f"Second reference strength: {settings.get('ref_boost_a')}",
310
+ ])
311
+ lora_tags = []
312
+ for item in settings.get("catalog_loras", []):
313
+ name = pathlib.PurePosixPath(str(item.get("hf_filename", ""))).stem
314
+ lora_tags.append(f"{name}:{float(item.get('weight', 0.0)):g}")
315
+ for item in settings.get("custom_loras", []):
316
+ name = pathlib.PurePosixPath(str(item.get("filename", ""))).stem
317
+ lora_tags.append(f"{name}:{float(item.get('weight', 0.0)):g}")
318
+ if lora_tags:
319
+ parts.append("LoRAs: " + ", ".join(lora_tags))
320
+ return f"{prompt}\n" + ", ".join(parts)
321
+
322
+
323
+ def write_png_metadata(source: str | Path, destination: str | Path, settings: dict[str, Any]) -> None:
324
+ """Copy an image while adding canonical and readable Krea metadata."""
325
+ with Image.open(source) as image:
326
+ output = image.copy()
327
+ info = PngImagePlugin.PngInfo()
328
+ for key, value in image.info.items():
329
+ if key not in {"krea_settings", "parameters"} and isinstance(value, str):
330
+ info.add_text(key, value)
331
+ info.add_text("krea_settings", json.dumps(settings, sort_keys=True))
332
+ info.add_text("parameters", build_parameters_text(settings))
333
+ output.save(destination, format="PNG", pnginfo=info)
test_app.py ADDED
@@ -0,0 +1,185 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Pure runtime tests; no ComfyUI clone or model download is required."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import os
6
+ import sys
7
+ import tempfile
8
+ import unittest
9
+ from pathlib import Path
10
+ from unittest.mock import patch
11
+
12
+ os.environ["KREA_SKIP_STARTUP"] = "1"
13
+ sys.path.insert(0, os.path.dirname(__file__))
14
+
15
+ import app # noqa: E402
16
+
17
+
18
+ class WorkflowTests(unittest.TestCase):
19
+ def test_text_to_image_loader_and_prompt_injection(self):
20
+ workflow = app._t2i_workflow()
21
+ app._inject_t2i(
22
+ workflow,
23
+ prompt="a blue glass sculpture",
24
+ width=1024,
25
+ height=768,
26
+ steps=8,
27
+ cfg=1.0,
28
+ sampler="euler",
29
+ scheduler="beta",
30
+ seed=42,
31
+ )
32
+ self.assertEqual(workflow["1"]["inputs"]["unet_name"], app.CUSTOM_KREA_FILE)
33
+ self.assertEqual(app.BASE_MODELS[app.CUSTOM_KREA_FILE]["repo"], "mpasila/Krea-2-Models")
34
+ self.assertIn(app.MUSE_KREA_FILE, app.BASE_MODELS)
35
+ self.assertEqual(workflow["2"]["inputs"]["clip_name"], "qwen3vl_4b_fp8_scaled.safetensors")
36
+ self.assertEqual(workflow["5"]["inputs"]["text"], "a blue glass sculpture")
37
+ self.assertEqual(workflow["7"]["inputs"]["height"], 768)
38
+ self.assertEqual(workflow["8"]["inputs"]["seed"], 42)
39
+
40
+ def test_edit_workflow_has_mandatory_adapter_and_optional_second_reference(self):
41
+ workflow = app._edit_workflow(True)
42
+ self.assertEqual(workflow["6"]["class_type"], "LoraLoaderModelOnly")
43
+ self.assertTrue(workflow["6"]["inputs"]["lora_name"].endswith(app.IDENTITY_FILE))
44
+ self.assertIn("source_latent_b", workflow["9"]["inputs"])
45
+ self.assertIn("image_b", workflow["10"]["inputs"])
46
+
47
+ def test_edit_workflow_without_second_reference_omits_b_inputs(self):
48
+ workflow = app._edit_workflow(False)
49
+ self.assertNotIn("2", workflow)
50
+ self.assertNotIn("source_latent_b", workflow["9"]["inputs"])
51
+ self.assertNotIn("source_image_b", workflow["9"]["inputs"])
52
+ self.assertNotIn("image_b", workflow["10"]["inputs"])
53
+
54
+ def test_text_to_image_supports_selected_model_and_ordered_loras(self):
55
+ workflow = app._t2i_workflow(app.MUSE_KREA_FILE)
56
+ app._inject_t2i(
57
+ workflow,
58
+ prompt="a portrait",
59
+ width=1024,
60
+ height=1024,
61
+ steps=8,
62
+ cfg=1.0,
63
+ sampler="euler",
64
+ scheduler="beta",
65
+ seed=7,
66
+ enabled_loras=[("krea2/first.safetensors", 0.5), ("huggingface/second.safetensors", -0.25)],
67
+ )
68
+ self.assertEqual(workflow["1"]["inputs"]["unet_name"], app.MUSE_KREA_FILE)
69
+ self.assertEqual(workflow["user_lora_0"]["inputs"]["model"], ["1", 0])
70
+ self.assertEqual(workflow["user_lora_1"]["inputs"]["model"], ["user_lora_0", 0])
71
+ self.assertEqual(workflow["4"]["inputs"]["model"], ["user_lora_1", 0])
72
+ self.assertEqual(workflow["5"]["inputs"]["clip"], ["user_lora_1", 1])
73
+
74
+ def test_custom_base_model_download_uses_managed_namespace(self):
75
+ original_models = app.MODELS
76
+ with tempfile.TemporaryDirectory() as directory:
77
+ app.MODELS = Path(directory) / "models"
78
+
79
+ def fake_download(**kwargs):
80
+ destination = Path(kwargs["local_dir"]) / kwargs["filename"]
81
+ destination.parent.mkdir(parents=True, exist_ok=True)
82
+ destination.write_bytes(b"test")
83
+ return str(destination)
84
+
85
+ try:
86
+ with patch.object(app, "hf_hub_download", side_effect=fake_download):
87
+ relative = app._ensure_custom_base_model({
88
+ "repo_id": "org/repo",
89
+ "filename": "sub/base.safetensors",
90
+ "revision": "main",
91
+ })
92
+ finally:
93
+ app.MODELS = original_models
94
+
95
+ self.assertTrue(relative.startswith("huggingface/"))
96
+ self.assertTrue(relative.endswith("/sub/base.safetensors"))
97
+ workflow = app._t2i_workflow(relative)
98
+ self.assertEqual(workflow["1"]["inputs"]["unet_name"], relative)
99
+
100
+ def test_edit_user_loras_follow_identity_adapter(self):
101
+ workflow = app._edit_workflow(False, app.MUSE_KREA_FILE)
102
+ app._inject_edit(
103
+ workflow,
104
+ primary_name="source.png",
105
+ second_name=None,
106
+ width=1024,
107
+ height=1024,
108
+ edit_prompt="change the shirt",
109
+ grounding_px=768,
110
+ ref_boost=1.0,
111
+ ref_boost_a=1.0,
112
+ steps=8,
113
+ cfg=1.0,
114
+ sampler="euler",
115
+ scheduler="beta",
116
+ seed=7,
117
+ enabled_loras=[("krea2/style.safetensors", 1.0)],
118
+ )
119
+ self.assertEqual(workflow["5"]["inputs"]["unet_name"], app.MUSE_KREA_FILE)
120
+ self.assertEqual(workflow["user_lora_0"]["inputs"]["model"], ["6", 0])
121
+ self.assertEqual(workflow["9"]["inputs"]["model"], ["user_lora_0", 0])
122
+ self.assertEqual(workflow["10"]["inputs"]["clip"], ["user_lora_0", 1])
123
+ self.assertEqual(workflow["6"]["class_type"], "LoraLoaderModelOnly")
124
+
125
+ def test_custom_lora_download_uses_managed_namespace(self):
126
+ original_root = app.LORA_ROOT
127
+ original_custom_root = app.CUSTOM_LORA_DEST_DIR
128
+ with tempfile.TemporaryDirectory() as directory:
129
+ app.LORA_ROOT = Path(directory) / "loras"
130
+ app.CUSTOM_LORA_DEST_DIR = app.LORA_ROOT / "huggingface"
131
+
132
+ def fake_download(**kwargs):
133
+ destination = Path(kwargs["local_dir"]) / kwargs["filename"]
134
+ destination.parent.mkdir(parents=True, exist_ok=True)
135
+ destination.write_bytes(b"test")
136
+ return str(destination)
137
+
138
+ try:
139
+ with patch.object(app, "hf_hub_download", side_effect=fake_download):
140
+ relative = app._ensure_custom_lora({
141
+ "repo_id": "org/repo",
142
+ "filename": "sub/style.safetensors",
143
+ "revision": "main",
144
+ "weight": 0.8,
145
+ })
146
+ finally:
147
+ app.LORA_ROOT = original_root
148
+ app.CUSTOM_LORA_DEST_DIR = original_custom_root
149
+
150
+ self.assertTrue(relative.startswith("huggingface/"))
151
+ self.assertTrue(relative.endswith("/sub/style.safetensors"))
152
+
153
+ def test_mode_validation(self):
154
+ with self.assertRaises(ValueError):
155
+ app._validate_request("text2image", "", "", None)
156
+ with self.assertRaises(ValueError):
157
+ app._validate_request("edit", "", "change the color", None)
158
+ with self.assertRaises(ValueError):
159
+ app._validate_request("edit", "", "", "source.png")
160
+ app._validate_request("edit", "", "change the color", "source.png")
161
+ app._validate_request("edit", "change the color", "", "source.png")
162
+
163
+ def test_gpu_duration_accepts_spaces_positional_callback(self):
164
+ values = [
165
+ "text2image", "prompt", "", None, None,
166
+ 1024, 1024, 1.4, 768, 1.0, 1.0,
167
+ 8, 1.0, "euler", "beta", 2, False, 0, None,
168
+ ]
169
+ duration = app.get_gpu_duration(*values)
170
+ self.assertGreaterEqual(duration, app.MIN_GPU_SECONDS)
171
+
172
+ def test_gpu_duration_accepts_keyword_callback(self):
173
+ duration = app.get_gpu_duration(steps=8, width=1024, height=1024, gen_budget=120)
174
+ self.assertEqual(duration, 120)
175
+
176
+ def test_runtime_uses_ram_pressure_executor_configuration(self):
177
+ with open(app.__file__, encoding="utf-8") as source_file:
178
+ source = source_file.read()
179
+ self.assertIn("cache_type=execution.CacheType.RAM_PRESSURE", source)
180
+ self.assertIn('"ram": 2.0', source)
181
+ self.assertIn('"ram_inactive": 8.0', source)
182
+
183
+
184
+ if __name__ == "__main__":
185
+ unittest.main()
test_settings_utils.py ADDED
@@ -0,0 +1,140 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Unit tests for Krea profile and image metadata helpers."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import tempfile
6
+ import unittest
7
+ from pathlib import Path
8
+
9
+ from PIL import Image
10
+
11
+ from settings_utils import (
12
+ APP_ID,
13
+ build_settings,
14
+ extract_image_settings,
15
+ normalize_custom_loras,
16
+ parse_settings_text,
17
+ validate_custom_base_model,
18
+ validate_custom_lora,
19
+ write_png_metadata,
20
+ )
21
+
22
+
23
+ class SettingsTests(unittest.TestCase):
24
+ def settings(self):
25
+ return build_settings(
26
+ mode="edit",
27
+ prompt="",
28
+ edit_prompt="change the coat to blue",
29
+ width=1024,
30
+ height=768,
31
+ target_megapixels=1.4,
32
+ grounding_px=768,
33
+ ref_boost=1.0,
34
+ ref_boost_a=1.0,
35
+ steps=8,
36
+ cfg=1.0,
37
+ sampler_name="euler",
38
+ scheduler="beta",
39
+ seed=2,
40
+ randomize_seed=False,
41
+ gen_budget=0,
42
+ effective_seed=2,
43
+ base_model="pornmasterKrea2_v2TurboInt8.safetensors",
44
+ catalog_loras=[{"hf_filename": "slider.safetensors", "weight": 0.8}],
45
+ custom_loras=[{
46
+ "repo_id": "org/repo",
47
+ "filename": "custom.safetensors",
48
+ "revision": "main",
49
+ "weight": 0.5,
50
+ }],
51
+ )
52
+
53
+ def test_custom_base_model_is_preserved_in_settings(self):
54
+ settings = build_settings(
55
+ mode="text2image",
56
+ prompt="a landscape",
57
+ edit_prompt="",
58
+ width=1024,
59
+ height=1024,
60
+ target_megapixels=1.4,
61
+ grounding_px=768,
62
+ ref_boost=1.0,
63
+ ref_boost_a=1.0,
64
+ steps=8,
65
+ cfg=1.0,
66
+ sampler_name="euler",
67
+ scheduler="beta",
68
+ seed=2,
69
+ randomize_seed=False,
70
+ gen_budget=0,
71
+ base_model="__custom_huggingface_base_model__",
72
+ custom_base_model={
73
+ "repo_id": "org/repo",
74
+ "filename": "models/base.safetensors",
75
+ "revision": "main",
76
+ },
77
+ )
78
+ self.assertEqual(settings["custom_base_model"]["repo_id"], "org/repo")
79
+ self.assertEqual(settings["custom_base_model"]["filename"], "models/base.safetensors")
80
+
81
+ def test_custom_base_model_validation_blocks_unsafe_paths(self):
82
+ valid = validate_custom_base_model(["org/repo", "base.safetensors", "main"])
83
+ self.assertEqual(valid["filename"], "base.safetensors")
84
+ with self.assertRaises(ValueError):
85
+ validate_custom_base_model({
86
+ "repo_id": "org/repo",
87
+ "filename": "../escape.safetensors",
88
+ })
89
+
90
+ def test_png_metadata_round_trip(self):
91
+ settings = self.settings()
92
+ with tempfile.TemporaryDirectory() as directory:
93
+ source = Path(directory) / "source.png"
94
+ destination = Path(directory) / "output.png"
95
+ Image.new("RGB", (8, 8), (1, 2, 3)).save(source)
96
+ write_png_metadata(source, destination, settings)
97
+ loaded, warnings = extract_image_settings(destination)
98
+ self.assertEqual(loaded["app"], APP_ID)
99
+ self.assertEqual(loaded["edit_prompt"], "change the coat to blue")
100
+ self.assertEqual(loaded["ref_boost"], 1.0)
101
+ self.assertEqual(loaded["base_model"], "pornmasterKrea2_v2TurboInt8.safetensors")
102
+ self.assertEqual(loaded["catalog_loras"][0]["weight"], 0.8)
103
+ self.assertEqual(loaded["custom_loras"][0]["repo_id"], "org/repo")
104
+ self.assertEqual(warnings, [])
105
+
106
+ def test_json_profile_round_trip(self):
107
+ parsed, warnings = parse_settings_text(__import__("json").dumps(self.settings()))
108
+ self.assertEqual(warnings, [])
109
+ self.assertEqual(parsed["mode"], "edit")
110
+ self.assertEqual(parsed["grounding_px"], 768)
111
+ self.assertEqual(parsed["custom_loras"][0]["filename"], "custom.safetensors")
112
+
113
+ def test_a1111_parameter_text(self):
114
+ parsed, warnings = parse_settings_text(
115
+ "a portrait\nSteps: 8, CFG scale: 1, Sampler: euler, Seed: 7, Size: 512x768"
116
+ )
117
+ self.assertEqual(warnings, [])
118
+ self.assertEqual(parsed["prompt"], "a portrait")
119
+ self.assertEqual(parsed["width"], 512)
120
+ self.assertEqual(parsed["effective_seed"], 7)
121
+
122
+ def test_custom_lora_validation_blocks_unsafe_rows(self):
123
+ valid = validate_custom_lora(["org/repo", "sub/style.safetensors", "main", 0.8])
124
+ self.assertEqual(valid["filename"], "sub/style.safetensors")
125
+ normalized, warnings = normalize_custom_loras([
126
+ ["", "", "", 0],
127
+ ["org/repo", "../escape.safetensors", "", 1],
128
+ ])
129
+ self.assertEqual(normalized, [])
130
+ self.assertEqual(len(warnings), 1)
131
+ with self.assertRaises(ValueError):
132
+ validate_custom_lora({
133
+ "repo_id": "not-a-repo",
134
+ "filename": "style.safetensors",
135
+ "weight": 0.5,
136
+ })
137
+
138
+
139
+ if __name__ == "__main__":
140
+ unittest.main()