Upload 105 files
Browse files- chain_injectors/krea2_controlnet_injector.py +78 -0
- comfy_integration/setup.py +14 -0
- core/pipelines/pipeline_input_processor.py +22 -1
- core/pipelines/sd_image_pipeline.py +2 -0
- core/pipelines/workflow_recipes/_partials/conditioning/krea-2.yaml +5 -0
- requirements.txt +3 -3
- ui/events/__init__.py +2 -0
- ui/events/chain_handlers.py +95 -1
- ui/events/change_handlers.py +30 -2
- ui/events/config_loaders.py +38 -1
- ui/events/main.py +19 -2
- ui/events/run_handlers.py +3 -1
- ui/shared/hires_fix_ui.py +3 -1
- ui/shared/img2img_ui.py +2 -1
- ui/shared/inpaint_ui.py +2 -1
- ui/shared/outpaint_ui.py +2 -1
- ui/shared/txt2img_ui.py +2 -1
- ui/shared/ui_components.py +43 -0
- yaml/file_list.yaml +5 -0
- yaml/image_gen_features.yaml +1 -0
- yaml/injectors.yaml +3 -0
- yaml/krea2_controlnet_models.yaml +4 -0
chain_injectors/krea2_controlnet_injector.py
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
def inject(assembler, chain_definition, chain_items):
|
| 2 |
+
if not chain_items:
|
| 3 |
+
return
|
| 4 |
+
|
| 5 |
+
ksampler_name = chain_definition.get('ksampler_node', 'ksampler')
|
| 6 |
+
if ksampler_name not in assembler.node_map:
|
| 7 |
+
print(f"Warning: Target node '{ksampler_name}' for Krea2 ControlNet chain not found. Skipping.")
|
| 8 |
+
return
|
| 9 |
+
|
| 10 |
+
ksampler_id = assembler.node_map[ksampler_name]
|
| 11 |
+
|
| 12 |
+
if 'model' not in assembler.workflow[ksampler_id]['inputs']:
|
| 13 |
+
print(f"Warning: KSampler node '{ksampler_name}' is missing 'model' input. Skipping.")
|
| 14 |
+
return
|
| 15 |
+
|
| 16 |
+
vae_source_str = chain_definition.get('vae_source')
|
| 17 |
+
vae_connection = None
|
| 18 |
+
if vae_source_str:
|
| 19 |
+
vae_node_name, vae_idx_str = vae_source_str.split(':')
|
| 20 |
+
if vae_node_name in assembler.node_map:
|
| 21 |
+
vae_connection = [assembler.node_map[vae_node_name], int(vae_idx_str)]
|
| 22 |
+
|
| 23 |
+
latent_connection = assembler.workflow[ksampler_id]['inputs'].get('latent_image')
|
| 24 |
+
if not latent_connection:
|
| 25 |
+
print(f"Warning: KSampler node '{ksampler_name}' is missing 'latent_image' input. Krea2 ControlNet requires it. Skipping.")
|
| 26 |
+
return
|
| 27 |
+
|
| 28 |
+
current_model_connection = assembler.workflow[ksampler_id]['inputs']['model']
|
| 29 |
+
|
| 30 |
+
for item_data in chain_items:
|
| 31 |
+
image_loader_id = assembler._get_unique_id()
|
| 32 |
+
image_loader_node = assembler._get_node_template("LoadImage")
|
| 33 |
+
image_loader_node['inputs']['image'] = item_data['image']
|
| 34 |
+
assembler.workflow[image_loader_id] = image_loader_node
|
| 35 |
+
|
| 36 |
+
image_scaler_id = assembler._get_unique_id()
|
| 37 |
+
image_scaler_node = assembler._get_node_template("ImageScaleToTotalPixels")
|
| 38 |
+
image_scaler_node['inputs']['image'] = [image_loader_id, 0]
|
| 39 |
+
image_scaler_node['inputs']['upscale_method'] = 'nearest-exact'
|
| 40 |
+
image_scaler_node['inputs']['megapixels'] = 1.0
|
| 41 |
+
image_scaler_node['inputs']['resolution_steps'] = 1
|
| 42 |
+
assembler.workflow[image_scaler_id] = image_scaler_node
|
| 43 |
+
|
| 44 |
+
lora_loader_id = assembler._get_unique_id()
|
| 45 |
+
lora_loader_node = assembler._get_node_template("Krea2ControlLoRALoader")
|
| 46 |
+
lora_loader_node['inputs']['lora_name'] = item_data['control_net_name']
|
| 47 |
+
lora_loader_node['inputs']['strength'] = item_data.get('strength', 1.0)
|
| 48 |
+
lora_loader_node['inputs']['model'] = current_model_connection
|
| 49 |
+
assembler.workflow[lora_loader_id] = lora_loader_node
|
| 50 |
+
|
| 51 |
+
img_encode_id = assembler._get_unique_id()
|
| 52 |
+
img_encode_node = assembler._get_node_template("Krea2ControlImageEncode")
|
| 53 |
+
img_encode_node['inputs']['resize'] = "match_latent_size"
|
| 54 |
+
img_encode_node['inputs']['upscale_method'] = "lanczos"
|
| 55 |
+
img_encode_node['inputs']['crop'] = "center"
|
| 56 |
+
img_encode_node['inputs']['channel_mode'] = "rgb"
|
| 57 |
+
img_encode_node['inputs']['normalize'] = "none"
|
| 58 |
+
img_encode_node['inputs']['invert'] = False
|
| 59 |
+
img_encode_node['inputs']['batch_mode'] = "independent_images"
|
| 60 |
+
img_encode_node['inputs']['control_image'] = [image_scaler_id, 0]
|
| 61 |
+
if vae_connection:
|
| 62 |
+
img_encode_node['inputs']['vae'] = vae_connection
|
| 63 |
+
if latent_connection:
|
| 64 |
+
img_encode_node['inputs']['latent'] = latent_connection
|
| 65 |
+
assembler.workflow[img_encode_id] = img_encode_node
|
| 66 |
+
|
| 67 |
+
apply_cn_id = assembler._get_unique_id()
|
| 68 |
+
apply_cn_node = assembler._get_node_template("Krea2ControlApply")
|
| 69 |
+
apply_cn_node['inputs']['model'] = [lora_loader_id, 0]
|
| 70 |
+
apply_cn_node['inputs']['control_latent'] = [img_encode_id, 0]
|
| 71 |
+
|
| 72 |
+
assembler.workflow[apply_cn_id] = apply_cn_node
|
| 73 |
+
|
| 74 |
+
current_model_connection = [apply_cn_id, 0]
|
| 75 |
+
|
| 76 |
+
assembler.workflow[ksampler_id]['inputs']['model'] = current_model_connection
|
| 77 |
+
|
| 78 |
+
print(f"Krea2 ControlNet injector applied. KSampler model input redirected through {len(chain_items)} Krea2 ControlNet nodes.")
|
comfy_integration/setup.py
CHANGED
|
@@ -65,6 +65,12 @@ def initialize_comfyui():
|
|
| 65 |
print("✅ ComfyUI-IPAdapter-Flux extension cloned.")
|
| 66 |
else:
|
| 67 |
print("✅ ComfyUI-IPAdapter-Flux extension already exists.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
|
| 69 |
# 4. ComfyUI-Newbie-Nodes
|
| 70 |
newbie_nodes_path = os.path.join(APP_DIR, "custom_nodes", "ComfyUI-Newbie-Nodes")
|
|
@@ -82,6 +88,14 @@ def initialize_comfyui():
|
|
| 82 |
else:
|
| 83 |
print("✅ ComfyUI-Anima-LLLite extension already exists.")
|
| 84 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 85 |
print(f"✅ Current working directory is: {os.getcwd()}")
|
| 86 |
|
| 87 |
import comfy.model_management
|
|
|
|
| 65 |
print("✅ ComfyUI-IPAdapter-Flux extension cloned.")
|
| 66 |
else:
|
| 67 |
print("✅ ComfyUI-IPAdapter-Flux extension already exists.")
|
| 68 |
+
try:
|
| 69 |
+
print("--- [Setup] Applying PR #108 compatibility patch for ComfyUI-IPAdapter-Flux ---")
|
| 70 |
+
os.system(f"git -C {ipadapter_flux_path} fetch origin pull/108/head && git -C {ipadapter_flux_path} checkout -f FETCH_HEAD")
|
| 71 |
+
print("✅ Successfully applied PR #108 compatibility patch.")
|
| 72 |
+
except Exception as e:
|
| 73 |
+
print(f"⚠️ Warning: Could not apply PR #108 compatibility patch for ComfyUI-IPAdapter-Flux: {e}")
|
| 74 |
|
| 75 |
# 4. ComfyUI-Newbie-Nodes
|
| 76 |
newbie_nodes_path = os.path.join(APP_DIR, "custom_nodes", "ComfyUI-Newbie-Nodes")
|
|
|
|
| 88 |
else:
|
| 89 |
print("✅ ComfyUI-Anima-LLLite extension already exists.")
|
| 90 |
|
| 91 |
+
# 6. comfyui-krea2-controlnet
|
| 92 |
+
krea2_controlnet_nodes_path = os.path.join(APP_DIR, "custom_nodes", "comfyui-krea2-controlnet")
|
| 93 |
+
if not os.path.exists(krea2_controlnet_nodes_path):
|
| 94 |
+
os.system(f"git clone https://github.com/facok/comfyui-krea2-controlnet.git {krea2_controlnet_nodes_path}")
|
| 95 |
+
print("✅ comfyui-krea2-controlnet extension cloned.")
|
| 96 |
+
else:
|
| 97 |
+
print("✅ comfyui-krea2-controlnet extension already exists.")
|
| 98 |
+
|
| 99 |
print(f"✅ Current working directory is: {os.getcwd()}")
|
| 100 |
|
| 101 |
import comfy.model_management
|
core/pipelines/pipeline_input_processor.py
CHANGED
|
@@ -199,6 +199,22 @@ def process_pipeline_inputs(ui_inputs: Dict[str, Any], progress: gr.Progress, wo
|
|
| 199 |
"image": os.path.basename(cn_temp_path), "strength": cn_strengths[i],
|
| 200 |
"control_net_name": cn_filepaths[i]
|
| 201 |
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 202 |
|
| 203 |
ipadapter_data = ui_inputs.get('ipadapter_data', [])
|
| 204 |
active_ipadapters = []
|
|
@@ -288,9 +304,13 @@ def process_pipeline_inputs(ui_inputs: Dict[str, Any], progress: gr.Progress, wo
|
|
| 288 |
num_units = len(style_data) // 2
|
| 289 |
st_images = style_data[0*num_units : 1*num_units]
|
| 290 |
st_strengths = style_data[1*num_units : 2*num_units]
|
|
|
|
| 291 |
for i in range(len(st_images)):
|
| 292 |
if st_images[i] and st_strengths[i] > 0:
|
| 293 |
-
|
|
|
|
|
|
|
|
|
|
| 294 |
temp_path = os.path.join(INPUT_DIR, f"temp_style_{i}_{random.randint(1000, 9999)}.png")
|
| 295 |
st_images[i].save(temp_path, "PNG")
|
| 296 |
temp_files_to_clean.append(temp_path)
|
|
@@ -351,6 +371,7 @@ def process_pipeline_inputs(ui_inputs: Dict[str, Any], progress: gr.Progress, wo
|
|
| 351 |
"active_controlnets": active_controlnets,
|
| 352 |
"active_anima_controlnets": active_anima_controlnets,
|
| 353 |
"active_diffsynth_controlnets": active_diffsynth_controlnets,
|
|
|
|
| 354 |
"active_ipadapters": active_ipadapters,
|
| 355 |
"active_flux1_ipadapters": active_flux1_ipadapters,
|
| 356 |
"active_sd3_ipadapters": active_sd3_ipadapters,
|
|
|
|
| 199 |
"image": os.path.basename(cn_temp_path), "strength": cn_strengths[i],
|
| 200 |
"control_net_name": cn_filepaths[i]
|
| 201 |
})
|
| 202 |
+
|
| 203 |
+
krea2_controlnet_data = ui_inputs.get('krea2_controlnet_data', [])
|
| 204 |
+
active_krea2_controlnets = []
|
| 205 |
+
if krea2_controlnet_data:
|
| 206 |
+
(cn_images, _, _, cn_strengths, cn_filepaths) = [krea2_controlnet_data[i::5] for i in range(5)]
|
| 207 |
+
for i in range(len(cn_images)):
|
| 208 |
+
if cn_images[i] and cn_strengths[i] > 0 and cn_filepaths[i] and cn_filepaths[i] != "None":
|
| 209 |
+
ensure_controlnet_model_downloaded(cn_filepaths[i], progress)
|
| 210 |
+
if not os.path.exists(INPUT_DIR): os.makedirs(INPUT_DIR)
|
| 211 |
+
cn_temp_path = os.path.join(INPUT_DIR, f"temp_krea2_cn_{i}_{random.randint(1000, 9999)}.png")
|
| 212 |
+
cn_images[i].save(cn_temp_path, "PNG")
|
| 213 |
+
temp_files_to_clean.append(cn_temp_path)
|
| 214 |
+
active_krea2_controlnets.append({
|
| 215 |
+
"image": os.path.basename(cn_temp_path), "strength": cn_strengths[i],
|
| 216 |
+
"control_net_name": cn_filepaths[i]
|
| 217 |
+
})
|
| 218 |
|
| 219 |
ipadapter_data = ui_inputs.get('ipadapter_data', [])
|
| 220 |
active_ipadapters = []
|
|
|
|
| 304 |
num_units = len(style_data) // 2
|
| 305 |
st_images = style_data[0*num_units : 1*num_units]
|
| 306 |
st_strengths = style_data[1*num_units : 2*num_units]
|
| 307 |
+
style_models_downloaded = False
|
| 308 |
for i in range(len(st_images)):
|
| 309 |
if st_images[i] and st_strengths[i] > 0:
|
| 310 |
+
if not style_models_downloaded:
|
| 311 |
+
_ensure_model_downloaded("sigclip_vision_patch14_384.safetensors", progress)
|
| 312 |
+
_ensure_model_downloaded("flux1-redux-dev.safetensors", progress)
|
| 313 |
+
style_models_downloaded = True
|
| 314 |
temp_path = os.path.join(INPUT_DIR, f"temp_style_{i}_{random.randint(1000, 9999)}.png")
|
| 315 |
st_images[i].save(temp_path, "PNG")
|
| 316 |
temp_files_to_clean.append(temp_path)
|
|
|
|
| 371 |
"active_controlnets": active_controlnets,
|
| 372 |
"active_anima_controlnets": active_anima_controlnets,
|
| 373 |
"active_diffsynth_controlnets": active_diffsynth_controlnets,
|
| 374 |
+
"active_krea2_controlnets": active_krea2_controlnets,
|
| 375 |
"active_ipadapters": active_ipadapters,
|
| 376 |
"active_flux1_ipadapters": active_flux1_ipadapters,
|
| 377 |
"active_sd3_ipadapters": active_sd3_ipadapters,
|
core/pipelines/sd_image_pipeline.py
CHANGED
|
@@ -109,6 +109,7 @@ class SdImagePipeline(BasePipeline):
|
|
| 109 |
active_controlnets = processed["active_controlnets"]
|
| 110 |
active_anima_controlnets = processed["active_anima_controlnets"]
|
| 111 |
active_diffsynth_controlnets = processed["active_diffsynth_controlnets"]
|
|
|
|
| 112 |
active_ipadapters = processed["active_ipadapters"]
|
| 113 |
active_flux1_ipadapters = processed["active_flux1_ipadapters"]
|
| 114 |
active_sd3_ipadapters = processed["active_sd3_ipadapters"]
|
|
@@ -163,6 +164,7 @@ class SdImagePipeline(BasePipeline):
|
|
| 163 |
"controlnet_chain": active_controlnets if not active_anima_controlnets else [],
|
| 164 |
"anima_controlnet_lllite_chain": active_anima_controlnets,
|
| 165 |
"diffsynth_controlnet_chain": active_diffsynth_controlnets,
|
|
|
|
| 166 |
"ipadapter_chain": active_ipadapters,
|
| 167 |
"flux1_ipadapter_chain": active_flux1_ipadapters,
|
| 168 |
"sd3_ipadapter_chain": active_sd3_ipadapters,
|
|
|
|
| 109 |
active_controlnets = processed["active_controlnets"]
|
| 110 |
active_anima_controlnets = processed["active_anima_controlnets"]
|
| 111 |
active_diffsynth_controlnets = processed["active_diffsynth_controlnets"]
|
| 112 |
+
active_krea2_controlnets = processed.get("active_krea2_controlnets", [])
|
| 113 |
active_ipadapters = processed["active_ipadapters"]
|
| 114 |
active_flux1_ipadapters = processed["active_flux1_ipadapters"]
|
| 115 |
active_sd3_ipadapters = processed["active_sd3_ipadapters"]
|
|
|
|
| 164 |
"controlnet_chain": active_controlnets if not active_anima_controlnets else [],
|
| 165 |
"anima_controlnet_lllite_chain": active_anima_controlnets,
|
| 166 |
"diffsynth_controlnet_chain": active_diffsynth_controlnets,
|
| 167 |
+
"krea2_controlnet_chain": active_krea2_controlnets,
|
| 168 |
"ipadapter_chain": active_ipadapters,
|
| 169 |
"flux1_ipadapter_chain": active_flux1_ipadapters,
|
| 170 |
"sd3_ipadapter_chain": active_sd3_ipadapters,
|
core/pipelines/workflow_recipes/_partials/conditioning/krea-2.yaml
CHANGED
|
@@ -43,6 +43,11 @@ dynamic_lora_chains:
|
|
| 43 |
"model": ["ksampler:model"]
|
| 44 |
"clip": ["pos_prompt:clip", "neg_prompt:clip"]
|
| 45 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
dynamic_conditioning_chains:
|
| 47 |
conditioning_chain:
|
| 48 |
ksampler_node: "ksampler"
|
|
|
|
| 43 |
"model": ["ksampler:model"]
|
| 44 |
"clip": ["pos_prompt:clip", "neg_prompt:clip"]
|
| 45 |
|
| 46 |
+
dynamic_krea2_controlnet_chains:
|
| 47 |
+
krea2_controlnet_chain:
|
| 48 |
+
ksampler_node: "ksampler"
|
| 49 |
+
vae_source: "vae_loader:0"
|
| 50 |
+
|
| 51 |
dynamic_conditioning_chains:
|
| 52 |
conditioning_chain:
|
| 53 |
ksampler_node: "ksampler"
|
requirements.txt
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
comfyui-frontend-package==1.45.20
|
| 2 |
-
comfyui-workflow-templates==0.11.
|
| 3 |
-
comfyui-embedded-docs==0.5.
|
| 4 |
torch
|
| 5 |
torchsde
|
| 6 |
torchvision
|
|
@@ -22,7 +22,7 @@ alembic
|
|
| 22 |
SQLAlchemy>=2.0.0
|
| 23 |
filelock
|
| 24 |
av>=16.0.0
|
| 25 |
-
comfy-kitchen==0.2.
|
| 26 |
comfy-aimdo==0.4.10
|
| 27 |
requests
|
| 28 |
simpleeval>=1.0.0
|
|
|
|
| 1 |
comfyui-frontend-package==1.45.20
|
| 2 |
+
comfyui-workflow-templates==0.11.9
|
| 3 |
+
comfyui-embedded-docs==0.5.8
|
| 4 |
torch
|
| 5 |
torchsde
|
| 6 |
torchvision
|
|
|
|
| 22 |
SQLAlchemy>=2.0.0
|
| 23 |
filelock
|
| 24 |
av>=16.0.0
|
| 25 |
+
comfy-kitchen==0.2.19
|
| 26 |
comfy-aimdo==0.4.10
|
| 27 |
requests
|
| 28 |
simpleeval>=1.0.0
|
ui/events/__init__.py
CHANGED
|
@@ -6,5 +6,7 @@ from .config_loaders import (
|
|
| 6 |
get_anima_cn_defaults,
|
| 7 |
load_diffsynth_controlnet_config,
|
| 8 |
get_diffsynth_cn_defaults,
|
|
|
|
|
|
|
| 9 |
load_ipadapter_config
|
| 10 |
)
|
|
|
|
| 6 |
get_anima_cn_defaults,
|
| 7 |
load_diffsynth_controlnet_config,
|
| 8 |
get_diffsynth_cn_defaults,
|
| 9 |
+
load_krea2_controlnet_config,
|
| 10 |
+
get_krea2_cn_defaults,
|
| 11 |
load_ipadapter_config
|
| 12 |
)
|
ui/events/chain_handlers.py
CHANGED
|
@@ -12,6 +12,7 @@ from .config_loaders import (
|
|
| 12 |
load_controlnet_config,
|
| 13 |
load_anima_controlnet_lllite_config,
|
| 14 |
load_diffsynth_controlnet_config,
|
|
|
|
| 15 |
load_ipadapter_config
|
| 16 |
)
|
| 17 |
|
|
@@ -191,6 +192,99 @@ def create_controlnet_event_handlers(prefix, ui_components):
|
|
| 191 |
)
|
| 192 |
|
| 193 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 194 |
def create_anima_controlnet_lllite_event_handlers(prefix, ui_components):
|
| 195 |
cn_rows = ui_components.get(f'anima_controlnet_lllite_rows_{prefix}')
|
| 196 |
if not cn_rows: return
|
|
@@ -677,4 +771,4 @@ def create_conditioning_event_handlers(prefix, ui_components):
|
|
| 677 |
add_outputs = [count_state, add_button, del_button] + rows
|
| 678 |
del_outputs = [count_state, add_button, del_button] + rows + prompts
|
| 679 |
add_button.click(fn=add_row, inputs=[count_state], outputs=add_outputs, show_progress=False)
|
| 680 |
-
del_button.click(fn=del_row, inputs=[count_state], outputs=del_outputs, show_progress=False)
|
|
|
|
| 12 |
load_controlnet_config,
|
| 13 |
load_anima_controlnet_lllite_config,
|
| 14 |
load_diffsynth_controlnet_config,
|
| 15 |
+
load_krea2_controlnet_config,
|
| 16 |
load_ipadapter_config
|
| 17 |
)
|
| 18 |
|
|
|
|
| 192 |
)
|
| 193 |
|
| 194 |
|
| 195 |
+
def create_krea2_controlnet_event_handlers(prefix, ui_components):
|
| 196 |
+
cn_rows = ui_components.get(f'krea2_controlnet_rows_{prefix}')
|
| 197 |
+
if not cn_rows: return
|
| 198 |
+
cn_types = ui_components[f'krea2_controlnet_types_{prefix}']
|
| 199 |
+
cn_series = ui_components[f'krea2_controlnet_series_{prefix}']
|
| 200 |
+
cn_filepaths = ui_components[f'krea2_controlnet_filepaths_{prefix}']
|
| 201 |
+
cn_images = ui_components[f'krea2_controlnet_images_{prefix}']
|
| 202 |
+
cn_strengths = ui_components[f'krea2_controlnet_strengths_{prefix}']
|
| 203 |
+
|
| 204 |
+
count_state = ui_components[f'krea2_controlnet_count_state_{prefix}']
|
| 205 |
+
add_button = ui_components[f'add_krea2_controlnet_button_{prefix}']
|
| 206 |
+
del_button = ui_components[f'delete_krea2_controlnet_button_{prefix}']
|
| 207 |
+
accordion = ui_components[f'krea2_controlnet_accordion_{prefix}']
|
| 208 |
+
|
| 209 |
+
def add_cn_row(c):
|
| 210 |
+
c += 1
|
| 211 |
+
updates = {
|
| 212 |
+
count_state: c,
|
| 213 |
+
cn_rows[c-1]: gr.update(visible=True),
|
| 214 |
+
add_button: gr.update(visible=c < MAX_CONTROLNETS),
|
| 215 |
+
del_button: gr.update(visible=True)
|
| 216 |
+
}
|
| 217 |
+
return updates
|
| 218 |
+
|
| 219 |
+
def del_cn_row(c):
|
| 220 |
+
c -= 1
|
| 221 |
+
updates = {
|
| 222 |
+
count_state: c,
|
| 223 |
+
cn_rows[c]: gr.update(visible=False),
|
| 224 |
+
cn_images[c]: None,
|
| 225 |
+
cn_strengths[c]: 1.0,
|
| 226 |
+
add_button: gr.update(visible=True),
|
| 227 |
+
del_button: gr.update(visible=c > 0)
|
| 228 |
+
}
|
| 229 |
+
return updates
|
| 230 |
+
|
| 231 |
+
add_outputs = [count_state, add_button, del_button] + cn_rows
|
| 232 |
+
del_outputs = [count_state, add_button, del_button] + cn_rows + cn_images + cn_strengths
|
| 233 |
+
add_button.click(fn=add_cn_row, inputs=[count_state], outputs=add_outputs, show_progress=False)
|
| 234 |
+
del_button.click(fn=del_cn_row, inputs=[count_state], outputs=del_outputs, show_progress=False)
|
| 235 |
+
|
| 236 |
+
def on_cn_type_change(selected_type):
|
| 237 |
+
cn_config = load_krea2_controlnet_config()
|
| 238 |
+
series_choices = []
|
| 239 |
+
if selected_type:
|
| 240 |
+
series_choices = sorted(list(set(
|
| 241 |
+
model.get("Series", "Default") for model in cn_config
|
| 242 |
+
if selected_type in model.get("Type", [])
|
| 243 |
+
)))
|
| 244 |
+
default_series = series_choices[0] if series_choices else None
|
| 245 |
+
filepath = "None"
|
| 246 |
+
if default_series:
|
| 247 |
+
for model in cn_config:
|
| 248 |
+
if model.get("Series") == default_series and selected_type in model.get("Type", []):
|
| 249 |
+
filepath = model.get("Filepath")
|
| 250 |
+
break
|
| 251 |
+
return gr.update(choices=series_choices, value=default_series), filepath
|
| 252 |
+
|
| 253 |
+
def on_cn_series_change(selected_series, selected_type):
|
| 254 |
+
cn_config = load_krea2_controlnet_config()
|
| 255 |
+
filepath = "None"
|
| 256 |
+
if selected_series and selected_type:
|
| 257 |
+
for model in cn_config:
|
| 258 |
+
if model.get("Series") == selected_series and selected_type in model.get("Type", []):
|
| 259 |
+
filepath = model.get("Filepath")
|
| 260 |
+
break
|
| 261 |
+
return filepath
|
| 262 |
+
|
| 263 |
+
for i in range(MAX_CONTROLNETS):
|
| 264 |
+
cn_types[i].change(
|
| 265 |
+
fn=on_cn_type_change,
|
| 266 |
+
inputs=[cn_types[i]],
|
| 267 |
+
outputs=[cn_series[i], cn_filepaths[i]],
|
| 268 |
+
show_progress=False
|
| 269 |
+
)
|
| 270 |
+
cn_series[i].change(
|
| 271 |
+
fn=on_cn_series_change,
|
| 272 |
+
inputs=[cn_series[i], cn_types[i]],
|
| 273 |
+
outputs=[cn_filepaths[i]],
|
| 274 |
+
show_progress=False
|
| 275 |
+
)
|
| 276 |
+
|
| 277 |
+
def on_accordion_expand(*images):
|
| 278 |
+
return [gr.update() for _ in images]
|
| 279 |
+
|
| 280 |
+
accordion.expand(
|
| 281 |
+
fn=on_accordion_expand,
|
| 282 |
+
inputs=cn_images,
|
| 283 |
+
outputs=cn_images,
|
| 284 |
+
show_progress=False
|
| 285 |
+
)
|
| 286 |
+
|
| 287 |
+
|
| 288 |
def create_anima_controlnet_lllite_event_handlers(prefix, ui_components):
|
| 289 |
cn_rows = ui_components.get(f'anima_controlnet_lllite_rows_{prefix}')
|
| 290 |
if not cn_rows: return
|
|
|
|
| 771 |
add_outputs = [count_state, add_button, del_button] + rows
|
| 772 |
del_outputs = [count_state, add_button, del_button] + rows + prompts
|
| 773 |
add_button.click(fn=add_row, inputs=[count_state], outputs=add_outputs, show_progress=False)
|
| 774 |
+
del_button.click(fn=del_row, inputs=[count_state], outputs=del_outputs, show_progress=False)
|
ui/events/change_handlers.py
CHANGED
|
@@ -13,10 +13,11 @@ from .config_loaders import (
|
|
| 13 |
get_cn_defaults,
|
| 14 |
get_anima_cn_defaults,
|
| 15 |
get_diffsynth_cn_defaults,
|
|
|
|
| 16 |
load_ipadapter_config
|
| 17 |
)
|
| 18 |
|
| 19 |
-
def make_update_fn(m_comp, cat_comp, cs_comp, ar_comp, width_comp, height_comp, cn_types, cn_series, cn_filepaths, anima_cn_types, anima_cn_series, anima_cn_filepaths, diffsynth_cn_types, diffsynth_cn_series, diffsynth_cn_filepaths, ipa_preset, lora_acc, cn_acc, anima_cn_acc, diffsynth_cn_acc, ipa_acc, sd3_ipa_acc, flux1_ipa_acc, style_acc, embed_acc, cond_acc, ref_latent_acc, hidream_o1_ref_acc, guidance_comp, prompt_comp, neg_prompt_comp, steps_comp, cfg_comp, sampler_comp, scheduler_comp, pid_acc=None, vae_acc=None):
|
| 20 |
def update_fn(*args):
|
| 21 |
arch = args[0]
|
| 22 |
category = args[1]
|
|
@@ -58,6 +59,7 @@ def make_update_fn(m_comp, cat_comp, cs_comp, ar_comp, width_comp, height_comp,
|
|
| 58 |
if cn_acc: updates[cn_acc] = gr.update(visible=('controlnet' in enabled_chains))
|
| 59 |
if anima_cn_acc: updates[anima_cn_acc] = gr.update(visible=('anima_controlnet_lllite' in enabled_chains))
|
| 60 |
if diffsynth_cn_acc: updates[diffsynth_cn_acc] = gr.update(visible=('controlnet_model_patch' in enabled_chains))
|
|
|
|
| 61 |
if ipa_acc: updates[ipa_acc] = gr.update(visible=('ipadapter' in enabled_chains))
|
| 62 |
if flux1_ipa_acc: updates[flux1_ipa_acc] = gr.update(visible=('flux1_ipadapter' in enabled_chains))
|
| 63 |
if sd3_ipa_acc: updates[sd3_ipa_acc] = gr.update(visible=('sd3_ipadapter' in enabled_chains))
|
|
@@ -110,6 +112,14 @@ def make_update_fn(m_comp, cat_comp, cs_comp, ar_comp, width_comp, height_comp,
|
|
| 110 |
updates[s_comp] = gr.update(choices=diffsynth_series_choices, value=diffsynth_default_series)
|
| 111 |
for f_comp in diffsynth_cn_filepaths:
|
| 112 |
updates[f_comp] = diffsynth_filepath
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 113 |
|
| 114 |
if ipa_preset and (arch_model_type in ["sdxl", "sd15", "sd35"]):
|
| 115 |
config = load_ipadapter_config()
|
|
@@ -132,7 +142,7 @@ def make_update_fn(m_comp, cat_comp, cs_comp, ar_comp, width_comp, height_comp,
|
|
| 132 |
return update_fn
|
| 133 |
|
| 134 |
|
| 135 |
-
def make_model_change_fn(cat_comp_ref, cs_comp, ar_comp, width_comp, height_comp, cn_types, cn_series, cn_filepaths, anima_cn_types, anima_cn_series, anima_cn_filepaths, diffsynth_cn_types, diffsynth_cn_series, diffsynth_cn_filepaths, arch_comp_ref, ipa_preset, lora_acc, cn_acc, anima_cn_acc, diffsynth_cn_acc, ipa_acc, sd3_ipa_acc, flux1_ipa_acc, style_acc, embed_acc, cond_acc, ref_latent_acc, hidream_o1_ref_acc, guidance_comp, prompt_comp, neg_prompt_comp, steps_comp, cfg_comp, sampler_comp, scheduler_comp, pid_acc=None, vae_acc=None):
|
| 136 |
def change_fn(*args):
|
| 137 |
model_name = args[0]
|
| 138 |
idx = 1
|
|
@@ -179,6 +189,7 @@ def make_model_change_fn(cat_comp_ref, cs_comp, ar_comp, width_comp, height_comp
|
|
| 179 |
if cn_acc: updates[cn_acc] = gr.update(visible=('controlnet' in enabled_chains))
|
| 180 |
if anima_cn_acc: updates[anima_cn_acc] = gr.update(visible=('anima_controlnet_lllite' in enabled_chains))
|
| 181 |
if diffsynth_cn_acc: updates[diffsynth_cn_acc] = gr.update(visible=('controlnet_model_patch' in enabled_chains))
|
|
|
|
| 182 |
if ipa_acc: updates[ipa_acc] = gr.update(visible=('ipadapter' in enabled_chains))
|
| 183 |
if flux1_ipa_acc: updates[flux1_ipa_acc] = gr.update(visible=('flux1_ipadapter' in enabled_chains))
|
| 184 |
if sd3_ipa_acc: updates[sd3_ipa_acc] = gr.update(visible=('sd3_ipadapter' in enabled_chains))
|
|
@@ -231,6 +242,14 @@ def make_model_change_fn(cat_comp_ref, cs_comp, ar_comp, width_comp, height_comp
|
|
| 231 |
updates[s_comp] = gr.update(choices=diffsynth_series_choices, value=diffsynth_default_series)
|
| 232 |
for f_comp in diffsynth_cn_filepaths:
|
| 233 |
updates[f_comp] = diffsynth_filepath
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 234 |
|
| 235 |
if ipa_preset and (arch_model_type in ["sdxl", "sd15", "sd35"]):
|
| 236 |
config = load_ipadapter_config()
|
|
@@ -262,6 +281,7 @@ def initialize_all_cn_dropdowns(ui_components):
|
|
| 262 |
all_types, default_type, series_choices, default_series, filepath = get_cn_defaults(controlnet_key)
|
| 263 |
anima_all_types, anima_default_type, anima_series_choices, anima_default_series, anima_filepath = get_anima_cn_defaults()
|
| 264 |
diffsynth_all_types, diffsynth_default_type, diffsynth_series_choices, diffsynth_default_series, diffsynth_filepath = get_diffsynth_cn_defaults(controlnet_key)
|
|
|
|
| 265 |
|
| 266 |
updates = {}
|
| 267 |
for prefix in ["txt2img", "img2img", "inpaint", "outpaint", "hires_fix"]:
|
|
@@ -288,6 +308,14 @@ def initialize_all_cn_dropdowns(ui_components):
|
|
| 288 |
updates[series_dd] = gr.update(choices=diffsynth_series_choices, value=default_series)
|
| 289 |
for filepath_state in ui_components[f'diffsynth_controlnet_filepaths_{prefix}']:
|
| 290 |
updates[filepath_state] = diffsynth_filepath
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 291 |
|
| 292 |
return updates
|
| 293 |
|
|
|
|
| 13 |
get_cn_defaults,
|
| 14 |
get_anima_cn_defaults,
|
| 15 |
get_diffsynth_cn_defaults,
|
| 16 |
+
get_krea2_cn_defaults,
|
| 17 |
load_ipadapter_config
|
| 18 |
)
|
| 19 |
|
| 20 |
+
def make_update_fn(m_comp, cat_comp, cs_comp, ar_comp, width_comp, height_comp, cn_types, cn_series, cn_filepaths, anima_cn_types, anima_cn_series, anima_cn_filepaths, diffsynth_cn_types, diffsynth_cn_series, diffsynth_cn_filepaths, krea2_cn_types, krea2_cn_series, krea2_cn_filepaths, ipa_preset, lora_acc, cn_acc, anima_cn_acc, diffsynth_cn_acc, krea2_cn_acc, ipa_acc, sd3_ipa_acc, flux1_ipa_acc, style_acc, embed_acc, cond_acc, ref_latent_acc, hidream_o1_ref_acc, guidance_comp, prompt_comp, neg_prompt_comp, steps_comp, cfg_comp, sampler_comp, scheduler_comp, pid_acc=None, vae_acc=None):
|
| 21 |
def update_fn(*args):
|
| 22 |
arch = args[0]
|
| 23 |
category = args[1]
|
|
|
|
| 59 |
if cn_acc: updates[cn_acc] = gr.update(visible=('controlnet' in enabled_chains))
|
| 60 |
if anima_cn_acc: updates[anima_cn_acc] = gr.update(visible=('anima_controlnet_lllite' in enabled_chains))
|
| 61 |
if diffsynth_cn_acc: updates[diffsynth_cn_acc] = gr.update(visible=('controlnet_model_patch' in enabled_chains))
|
| 62 |
+
if krea2_cn_acc: updates[krea2_cn_acc] = gr.update(visible=('krea2_controlnet' in enabled_chains))
|
| 63 |
if ipa_acc: updates[ipa_acc] = gr.update(visible=('ipadapter' in enabled_chains))
|
| 64 |
if flux1_ipa_acc: updates[flux1_ipa_acc] = gr.update(visible=('flux1_ipadapter' in enabled_chains))
|
| 65 |
if sd3_ipa_acc: updates[sd3_ipa_acc] = gr.update(visible=('sd3_ipadapter' in enabled_chains))
|
|
|
|
| 112 |
updates[s_comp] = gr.update(choices=diffsynth_series_choices, value=diffsynth_default_series)
|
| 113 |
for f_comp in diffsynth_cn_filepaths:
|
| 114 |
updates[f_comp] = diffsynth_filepath
|
| 115 |
+
|
| 116 |
+
krea2_all_types, krea2_default_type, krea2_series_choices, krea2_default_series, krea2_filepath = get_krea2_cn_defaults()
|
| 117 |
+
for t_comp in krea2_cn_types:
|
| 118 |
+
updates[t_comp] = gr.update(choices=krea2_all_types, value=krea2_default_type)
|
| 119 |
+
for s_comp in krea2_cn_series:
|
| 120 |
+
updates[s_comp] = gr.update(choices=krea2_series_choices, value=krea2_default_series)
|
| 121 |
+
for f_comp in krea2_cn_filepaths:
|
| 122 |
+
updates[f_comp] = krea2_filepath
|
| 123 |
|
| 124 |
if ipa_preset and (arch_model_type in ["sdxl", "sd15", "sd35"]):
|
| 125 |
config = load_ipadapter_config()
|
|
|
|
| 142 |
return update_fn
|
| 143 |
|
| 144 |
|
| 145 |
+
def make_model_change_fn(cat_comp_ref, cs_comp, ar_comp, width_comp, height_comp, cn_types, cn_series, cn_filepaths, anima_cn_types, anima_cn_series, anima_cn_filepaths, diffsynth_cn_types, diffsynth_cn_series, diffsynth_cn_filepaths, krea2_cn_types, krea2_cn_series, krea2_cn_filepaths, arch_comp_ref, ipa_preset, lora_acc, cn_acc, anima_cn_acc, diffsynth_cn_acc, krea2_cn_acc, ipa_acc, sd3_ipa_acc, flux1_ipa_acc, style_acc, embed_acc, cond_acc, ref_latent_acc, hidream_o1_ref_acc, guidance_comp, prompt_comp, neg_prompt_comp, steps_comp, cfg_comp, sampler_comp, scheduler_comp, pid_acc=None, vae_acc=None):
|
| 146 |
def change_fn(*args):
|
| 147 |
model_name = args[0]
|
| 148 |
idx = 1
|
|
|
|
| 189 |
if cn_acc: updates[cn_acc] = gr.update(visible=('controlnet' in enabled_chains))
|
| 190 |
if anima_cn_acc: updates[anima_cn_acc] = gr.update(visible=('anima_controlnet_lllite' in enabled_chains))
|
| 191 |
if diffsynth_cn_acc: updates[diffsynth_cn_acc] = gr.update(visible=('controlnet_model_patch' in enabled_chains))
|
| 192 |
+
if krea2_cn_acc: updates[krea2_cn_acc] = gr.update(visible=('krea2_controlnet' in enabled_chains))
|
| 193 |
if ipa_acc: updates[ipa_acc] = gr.update(visible=('ipadapter' in enabled_chains))
|
| 194 |
if flux1_ipa_acc: updates[flux1_ipa_acc] = gr.update(visible=('flux1_ipadapter' in enabled_chains))
|
| 195 |
if sd3_ipa_acc: updates[sd3_ipa_acc] = gr.update(visible=('sd3_ipadapter' in enabled_chains))
|
|
|
|
| 242 |
updates[s_comp] = gr.update(choices=diffsynth_series_choices, value=diffsynth_default_series)
|
| 243 |
for f_comp in diffsynth_cn_filepaths:
|
| 244 |
updates[f_comp] = diffsynth_filepath
|
| 245 |
+
|
| 246 |
+
krea2_all_types, krea2_default_type, krea2_series_choices, krea2_default_series, krea2_filepath = get_krea2_cn_defaults()
|
| 247 |
+
for t_comp in krea2_cn_types:
|
| 248 |
+
updates[t_comp] = gr.update(choices=krea2_all_types, value=krea2_default_type)
|
| 249 |
+
for s_comp in krea2_cn_series:
|
| 250 |
+
updates[s_comp] = gr.update(choices=krea2_series_choices, value=krea2_default_series)
|
| 251 |
+
for f_comp in krea2_cn_filepaths:
|
| 252 |
+
updates[f_comp] = krea2_filepath
|
| 253 |
|
| 254 |
if ipa_preset and (arch_model_type in ["sdxl", "sd15", "sd35"]):
|
| 255 |
config = load_ipadapter_config()
|
|
|
|
| 281 |
all_types, default_type, series_choices, default_series, filepath = get_cn_defaults(controlnet_key)
|
| 282 |
anima_all_types, anima_default_type, anima_series_choices, anima_default_series, anima_filepath = get_anima_cn_defaults()
|
| 283 |
diffsynth_all_types, diffsynth_default_type, diffsynth_series_choices, diffsynth_default_series, diffsynth_filepath = get_diffsynth_cn_defaults(controlnet_key)
|
| 284 |
+
krea2_all_types, krea2_default_type, krea2_series_choices, krea2_default_series, krea2_filepath = get_krea2_cn_defaults()
|
| 285 |
|
| 286 |
updates = {}
|
| 287 |
for prefix in ["txt2img", "img2img", "inpaint", "outpaint", "hires_fix"]:
|
|
|
|
| 308 |
updates[series_dd] = gr.update(choices=diffsynth_series_choices, value=default_series)
|
| 309 |
for filepath_state in ui_components[f'diffsynth_controlnet_filepaths_{prefix}']:
|
| 310 |
updates[filepath_state] = diffsynth_filepath
|
| 311 |
+
|
| 312 |
+
if f'krea2_controlnet_types_{prefix}' in ui_components:
|
| 313 |
+
for type_dd in ui_components[f'krea2_controlnet_types_{prefix}']:
|
| 314 |
+
updates[type_dd] = gr.update(choices=krea2_all_types, value=krea2_default_type)
|
| 315 |
+
for series_dd in ui_components[f'krea2_controlnet_series_{prefix}']:
|
| 316 |
+
updates[series_dd] = gr.update(choices=krea2_series_choices, value=krea2_default_series)
|
| 317 |
+
for filepath_state in ui_components[f'krea2_controlnet_filepaths_{prefix}']:
|
| 318 |
+
updates[filepath_state] = krea2_filepath
|
| 319 |
|
| 320 |
return updates
|
| 321 |
|
ui/events/config_loaders.py
CHANGED
|
@@ -116,6 +116,43 @@ def get_diffsynth_cn_defaults(arch_val):
|
|
| 116 |
return all_types, default_type, series_choices, default_series, filepath
|
| 117 |
|
| 118 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 119 |
@lru_cache(maxsize=1)
|
| 120 |
def load_ipadapter_config():
|
| 121 |
_PROJECT_ROOT = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
|
@@ -128,4 +165,4 @@ def load_ipadapter_config():
|
|
| 128 |
return config
|
| 129 |
except Exception as e:
|
| 130 |
print(f"Error loading ipadapter.yaml: {e}")
|
| 131 |
-
return {}
|
|
|
|
| 116 |
return all_types, default_type, series_choices, default_series, filepath
|
| 117 |
|
| 118 |
|
| 119 |
+
@lru_cache(maxsize=1)
|
| 120 |
+
def load_krea2_controlnet_config():
|
| 121 |
+
_PROJECT_ROOT = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
| 122 |
+
_CN_MODEL_LIST_PATH = os.path.join(_PROJECT_ROOT, 'yaml', 'krea2_controlnet_models.yaml')
|
| 123 |
+
try:
|
| 124 |
+
print("--- Loading krea2_controlnet_models.yaml ---")
|
| 125 |
+
with open(_CN_MODEL_LIST_PATH, 'r', encoding='utf-8') as f:
|
| 126 |
+
config = yaml.safe_load(f)
|
| 127 |
+
print("--- ✅ krea2_controlnet_models.yaml loaded successfully ---")
|
| 128 |
+
return config.get("Krea2_ControlNet", [])
|
| 129 |
+
except Exception as e:
|
| 130 |
+
print(f"Error loading krea2_controlnet_models.yaml: {e}")
|
| 131 |
+
return []
|
| 132 |
+
|
| 133 |
+
def get_krea2_cn_defaults():
|
| 134 |
+
cn_config = load_krea2_controlnet_config()
|
| 135 |
+
if not cn_config:
|
| 136 |
+
return [], None, [], None, "None"
|
| 137 |
+
|
| 138 |
+
all_types = sorted(list(set(t for model in cn_config for t in model.get("Type", []))))
|
| 139 |
+
default_type = all_types[0] if all_types else None
|
| 140 |
+
|
| 141 |
+
series_choices = []
|
| 142 |
+
if default_type:
|
| 143 |
+
series_choices = sorted(list(set(model.get("Series", "Default") for model in cn_config if default_type in model.get("Type", []))))
|
| 144 |
+
default_series = series_choices[0] if series_choices else None
|
| 145 |
+
|
| 146 |
+
filepath = "None"
|
| 147 |
+
if default_series and default_type:
|
| 148 |
+
for model in cn_config:
|
| 149 |
+
if model.get("Series") == default_series and default_type in model.get("Type", []):
|
| 150 |
+
filepath = model.get("Filepath")
|
| 151 |
+
break
|
| 152 |
+
|
| 153 |
+
return all_types, default_type, series_choices, default_series, filepath
|
| 154 |
+
|
| 155 |
+
|
| 156 |
@lru_cache(maxsize=1)
|
| 157 |
def load_ipadapter_config():
|
| 158 |
_PROJECT_ROOT = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
|
|
|
| 165 |
return config
|
| 166 |
except Exception as e:
|
| 167 |
print(f"Error loading ipadapter.yaml: {e}")
|
| 168 |
+
return {}
|
ui/events/main.py
CHANGED
|
@@ -4,6 +4,7 @@ from .chain_handlers import (
|
|
| 4 |
create_controlnet_event_handlers,
|
| 5 |
create_anima_controlnet_lllite_event_handlers,
|
| 6 |
create_diffsynth_controlnet_event_handlers,
|
|
|
|
| 7 |
create_ipadapter_event_handlers,
|
| 8 |
create_embedding_event_handlers,
|
| 9 |
create_conditioning_event_handlers,
|
|
@@ -47,11 +48,16 @@ def attach_event_handlers(ui_components, demo):
|
|
| 47 |
diffsynth_cn_types_list = ui_components.get(f'diffsynth_controlnet_types_{prefix}', [])
|
| 48 |
diffsynth_cn_series_list = ui_components.get(f'diffsynth_controlnet_series_{prefix}', [])
|
| 49 |
diffsynth_cn_filepaths_list = ui_components.get(f'diffsynth_controlnet_filepaths_{prefix}', [])
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
|
| 51 |
lora_accordion = ui_components.get(f'lora_accordion_{prefix}')
|
| 52 |
cn_accordion = ui_components.get(f'controlnet_accordion_{prefix}')
|
| 53 |
anima_cn_accordion = ui_components.get(f'anima_controlnet_lllite_accordion_{prefix}')
|
| 54 |
diffsynth_cn_accordion = ui_components.get(f'diffsynth_controlnet_accordion_{prefix}')
|
|
|
|
| 55 |
ipa_accordion = ui_components.get(f'ipadapter_accordion_{prefix}')
|
| 56 |
sd3_ipa_accordion = ui_components.get(f'sd3_ipadapter_accordion_{prefix}')
|
| 57 |
flux1_ipa_accordion = ui_components.get(f'flux1_ipadapter_accordion_{prefix}')
|
|
@@ -83,10 +89,12 @@ def attach_event_handlers(ui_components, demo):
|
|
| 83 |
outputs.extend(cn_types_list + cn_series_list + cn_filepaths_list)
|
| 84 |
outputs.extend(anima_cn_types_list + anima_cn_series_list + anima_cn_filepaths_list)
|
| 85 |
outputs.extend(diffsynth_cn_types_list + diffsynth_cn_series_list + diffsynth_cn_filepaths_list)
|
|
|
|
| 86 |
if lora_accordion: outputs.append(lora_accordion)
|
| 87 |
if cn_accordion: outputs.append(cn_accordion)
|
| 88 |
if anima_cn_accordion: outputs.append(anima_cn_accordion)
|
| 89 |
if diffsynth_cn_accordion: outputs.append(diffsynth_cn_accordion)
|
|
|
|
| 90 |
if ipa_accordion: outputs.append(ipa_accordion)
|
| 91 |
if sd3_ipa_accordion: outputs.append(sd3_ipa_accordion)
|
| 92 |
if flux1_ipa_accordion: outputs.append(flux1_ipa_accordion)
|
|
@@ -106,7 +114,8 @@ def attach_event_handlers(ui_components, demo):
|
|
| 106 |
cn_types_list, cn_series_list, cn_filepaths_list,
|
| 107 |
anima_cn_types_list, anima_cn_series_list, anima_cn_filepaths_list,
|
| 108 |
diffsynth_cn_types_list, diffsynth_cn_series_list, diffsynth_cn_filepaths_list,
|
| 109 |
-
|
|
|
|
| 110 |
ref_latent_accordion, hidream_o1_ref_accordion, guidance_comp, prompt_comp, neg_prompt_comp, steps_comp, cfg_comp, sampler_comp, scheduler_comp,
|
| 111 |
pid_acc=pid_accordion, vae_acc=vae_accordion
|
| 112 |
)
|
|
@@ -126,10 +135,12 @@ def attach_event_handlers(ui_components, demo):
|
|
| 126 |
outputs2.extend(cn_types_list + cn_series_list + cn_filepaths_list)
|
| 127 |
outputs2.extend(anima_cn_types_list + anima_cn_series_list + anima_cn_filepaths_list)
|
| 128 |
outputs2.extend(diffsynth_cn_types_list + diffsynth_cn_series_list + diffsynth_cn_filepaths_list)
|
|
|
|
| 129 |
if lora_accordion: outputs2.append(lora_accordion)
|
| 130 |
if cn_accordion: outputs2.append(cn_accordion)
|
| 131 |
if anima_cn_accordion: outputs2.append(anima_cn_accordion)
|
| 132 |
if diffsynth_cn_accordion: outputs2.append(diffsynth_cn_accordion)
|
|
|
|
| 133 |
if ipa_accordion: outputs2.append(ipa_accordion)
|
| 134 |
if sd3_ipa_accordion: outputs2.append(sd3_ipa_accordion)
|
| 135 |
if flux1_ipa_accordion: outputs2.append(flux1_ipa_accordion)
|
|
@@ -154,7 +165,8 @@ def attach_event_handlers(ui_components, demo):
|
|
| 154 |
cn_types_list, cn_series_list, cn_filepaths_list,
|
| 155 |
anima_cn_types_list, anima_cn_series_list, anima_cn_filepaths_list,
|
| 156 |
diffsynth_cn_types_list, diffsynth_cn_series_list, diffsynth_cn_filepaths_list,
|
| 157 |
-
|
|
|
|
| 158 |
ref_latent_accordion, hidream_o1_ref_accordion, guidance_comp, prompt_comp, neg_prompt_comp, steps_comp, cfg_comp, sampler_comp, scheduler_comp,
|
| 159 |
pid_acc=pid_accordion, vae_acc=vae_accordion
|
| 160 |
)
|
|
@@ -164,6 +176,7 @@ def attach_event_handlers(ui_components, demo):
|
|
| 164 |
create_controlnet_event_handlers(prefix, ui_components)
|
| 165 |
create_anima_controlnet_lllite_event_handlers(prefix, ui_components)
|
| 166 |
create_diffsynth_controlnet_event_handlers(prefix, ui_components)
|
|
|
|
| 167 |
create_ipadapter_event_handlers(prefix, ui_components)
|
| 168 |
create_embedding_event_handlers(prefix, ui_components)
|
| 169 |
create_conditioning_event_handlers(prefix, ui_components)
|
|
@@ -228,6 +241,10 @@ def attach_event_handlers(ui_components, demo):
|
|
| 228 |
all_load_outputs.extend(ui_components[f'diffsynth_controlnet_types_{prefix}'])
|
| 229 |
all_load_outputs.extend(ui_components[f'diffsynth_controlnet_series_{prefix}'])
|
| 230 |
all_load_outputs.extend(ui_components[f'diffsynth_controlnet_filepaths_{prefix}'])
|
|
|
|
|
|
|
|
|
|
|
|
|
| 231 |
if f'ipadapter_final_preset_{prefix}' in ui_components:
|
| 232 |
all_load_outputs.extend(ui_components[f'ipadapter_lora_strengths_{prefix}'])
|
| 233 |
all_load_outputs.append(ui_components[f'ipadapter_final_preset_{prefix}'])
|
|
|
|
| 4 |
create_controlnet_event_handlers,
|
| 5 |
create_anima_controlnet_lllite_event_handlers,
|
| 6 |
create_diffsynth_controlnet_event_handlers,
|
| 7 |
+
create_krea2_controlnet_event_handlers,
|
| 8 |
create_ipadapter_event_handlers,
|
| 9 |
create_embedding_event_handlers,
|
| 10 |
create_conditioning_event_handlers,
|
|
|
|
| 48 |
diffsynth_cn_types_list = ui_components.get(f'diffsynth_controlnet_types_{prefix}', [])
|
| 49 |
diffsynth_cn_series_list = ui_components.get(f'diffsynth_controlnet_series_{prefix}', [])
|
| 50 |
diffsynth_cn_filepaths_list = ui_components.get(f'diffsynth_controlnet_filepaths_{prefix}', [])
|
| 51 |
+
|
| 52 |
+
krea2_cn_types_list = ui_components.get(f'krea2_controlnet_types_{prefix}', [])
|
| 53 |
+
krea2_cn_series_list = ui_components.get(f'krea2_controlnet_series_{prefix}', [])
|
| 54 |
+
krea2_cn_filepaths_list = ui_components.get(f'krea2_controlnet_filepaths_{prefix}', [])
|
| 55 |
|
| 56 |
lora_accordion = ui_components.get(f'lora_accordion_{prefix}')
|
| 57 |
cn_accordion = ui_components.get(f'controlnet_accordion_{prefix}')
|
| 58 |
anima_cn_accordion = ui_components.get(f'anima_controlnet_lllite_accordion_{prefix}')
|
| 59 |
diffsynth_cn_accordion = ui_components.get(f'diffsynth_controlnet_accordion_{prefix}')
|
| 60 |
+
krea2_cn_accordion = ui_components.get(f'krea2_controlnet_accordion_{prefix}')
|
| 61 |
ipa_accordion = ui_components.get(f'ipadapter_accordion_{prefix}')
|
| 62 |
sd3_ipa_accordion = ui_components.get(f'sd3_ipadapter_accordion_{prefix}')
|
| 63 |
flux1_ipa_accordion = ui_components.get(f'flux1_ipadapter_accordion_{prefix}')
|
|
|
|
| 89 |
outputs.extend(cn_types_list + cn_series_list + cn_filepaths_list)
|
| 90 |
outputs.extend(anima_cn_types_list + anima_cn_series_list + anima_cn_filepaths_list)
|
| 91 |
outputs.extend(diffsynth_cn_types_list + diffsynth_cn_series_list + diffsynth_cn_filepaths_list)
|
| 92 |
+
outputs.extend(krea2_cn_types_list + krea2_cn_series_list + krea2_cn_filepaths_list)
|
| 93 |
if lora_accordion: outputs.append(lora_accordion)
|
| 94 |
if cn_accordion: outputs.append(cn_accordion)
|
| 95 |
if anima_cn_accordion: outputs.append(anima_cn_accordion)
|
| 96 |
if diffsynth_cn_accordion: outputs.append(diffsynth_cn_accordion)
|
| 97 |
+
if krea2_cn_accordion: outputs.append(krea2_cn_accordion)
|
| 98 |
if ipa_accordion: outputs.append(ipa_accordion)
|
| 99 |
if sd3_ipa_accordion: outputs.append(sd3_ipa_accordion)
|
| 100 |
if flux1_ipa_accordion: outputs.append(flux1_ipa_accordion)
|
|
|
|
| 114 |
cn_types_list, cn_series_list, cn_filepaths_list,
|
| 115 |
anima_cn_types_list, anima_cn_series_list, anima_cn_filepaths_list,
|
| 116 |
diffsynth_cn_types_list, diffsynth_cn_series_list, diffsynth_cn_filepaths_list,
|
| 117 |
+
krea2_cn_types_list, krea2_cn_series_list, krea2_cn_filepaths_list,
|
| 118 |
+
ipa_preset_list, lora_accordion, cn_accordion, anima_cn_accordion, diffsynth_cn_accordion, krea2_cn_accordion, ipa_accordion, sd3_ipa_accordion, flux1_ipa_accordion, style_accordion, embedding_accordion, conditioning_accordion,
|
| 119 |
ref_latent_accordion, hidream_o1_ref_accordion, guidance_comp, prompt_comp, neg_prompt_comp, steps_comp, cfg_comp, sampler_comp, scheduler_comp,
|
| 120 |
pid_acc=pid_accordion, vae_acc=vae_accordion
|
| 121 |
)
|
|
|
|
| 135 |
outputs2.extend(cn_types_list + cn_series_list + cn_filepaths_list)
|
| 136 |
outputs2.extend(anima_cn_types_list + anima_cn_series_list + anima_cn_filepaths_list)
|
| 137 |
outputs2.extend(diffsynth_cn_types_list + diffsynth_cn_series_list + diffsynth_cn_filepaths_list)
|
| 138 |
+
outputs2.extend(krea2_cn_types_list + krea2_cn_series_list + krea2_cn_filepaths_list)
|
| 139 |
if lora_accordion: outputs2.append(lora_accordion)
|
| 140 |
if cn_accordion: outputs2.append(cn_accordion)
|
| 141 |
if anima_cn_accordion: outputs2.append(anima_cn_accordion)
|
| 142 |
if diffsynth_cn_accordion: outputs2.append(diffsynth_cn_accordion)
|
| 143 |
+
if krea2_cn_accordion: outputs2.append(krea2_cn_accordion)
|
| 144 |
if ipa_accordion: outputs2.append(ipa_accordion)
|
| 145 |
if sd3_ipa_accordion: outputs2.append(sd3_ipa_accordion)
|
| 146 |
if flux1_ipa_accordion: outputs2.append(flux1_ipa_accordion)
|
|
|
|
| 165 |
cn_types_list, cn_series_list, cn_filepaths_list,
|
| 166 |
anima_cn_types_list, anima_cn_series_list, anima_cn_filepaths_list,
|
| 167 |
diffsynth_cn_types_list, diffsynth_cn_series_list, diffsynth_cn_filepaths_list,
|
| 168 |
+
krea2_cn_types_list, krea2_cn_series_list, krea2_cn_filepaths_list,
|
| 169 |
+
arch_comp, ipa_preset_list, lora_accordion, cn_accordion, anima_cn_accordion, diffsynth_cn_accordion, krea2_cn_accordion, ipa_accordion, sd3_ipa_accordion, flux1_ipa_accordion, style_accordion, embedding_accordion, conditioning_accordion,
|
| 170 |
ref_latent_accordion, hidream_o1_ref_accordion, guidance_comp, prompt_comp, neg_prompt_comp, steps_comp, cfg_comp, sampler_comp, scheduler_comp,
|
| 171 |
pid_acc=pid_accordion, vae_acc=vae_accordion
|
| 172 |
)
|
|
|
|
| 176 |
create_controlnet_event_handlers(prefix, ui_components)
|
| 177 |
create_anima_controlnet_lllite_event_handlers(prefix, ui_components)
|
| 178 |
create_diffsynth_controlnet_event_handlers(prefix, ui_components)
|
| 179 |
+
create_krea2_controlnet_event_handlers(prefix, ui_components)
|
| 180 |
create_ipadapter_event_handlers(prefix, ui_components)
|
| 181 |
create_embedding_event_handlers(prefix, ui_components)
|
| 182 |
create_conditioning_event_handlers(prefix, ui_components)
|
|
|
|
| 241 |
all_load_outputs.extend(ui_components[f'diffsynth_controlnet_types_{prefix}'])
|
| 242 |
all_load_outputs.extend(ui_components[f'diffsynth_controlnet_series_{prefix}'])
|
| 243 |
all_load_outputs.extend(ui_components[f'diffsynth_controlnet_filepaths_{prefix}'])
|
| 244 |
+
if f'krea2_controlnet_types_{prefix}' in ui_components:
|
| 245 |
+
all_load_outputs.extend(ui_components[f'krea2_controlnet_types_{prefix}'])
|
| 246 |
+
all_load_outputs.extend(ui_components[f'krea2_controlnet_series_{prefix}'])
|
| 247 |
+
all_load_outputs.extend(ui_components[f'krea2_controlnet_filepaths_{prefix}'])
|
| 248 |
if f'ipadapter_final_preset_{prefix}' in ui_components:
|
| 249 |
all_load_outputs.extend(ui_components[f'ipadapter_lora_strengths_{prefix}'])
|
| 250 |
all_load_outputs.append(ui_components[f'ipadapter_final_preset_{prefix}'])
|
ui/events/run_handlers.py
CHANGED
|
@@ -43,6 +43,7 @@ def create_run_event(prefix: str, task_type: str, ui_components: dict):
|
|
| 43 |
controlnet_data_components = ui_components.get(f'all_controlnet_components_flat_{prefix}', [])
|
| 44 |
anima_controlnet_lllite_data_components = ui_components.get(f'all_anima_controlnet_lllite_components_flat_{prefix}', [])
|
| 45 |
diffsynth_controlnet_data_components = ui_components.get(f'all_diffsynth_controlnet_components_flat_{prefix}', [])
|
|
|
|
| 46 |
ipadapter_data_components = ui_components.get(f'all_ipadapter_components_flat_{prefix}', [])
|
| 47 |
sd3_ipadapter_data_components = ui_components.get(f'all_sd3_ipadapter_components_flat_{prefix}', [])
|
| 48 |
flux1_ipadapter_data_components = ui_components.get(f'all_flux1_ipadapter_components_flat_{prefix}', [])
|
|
@@ -59,7 +60,7 @@ def create_run_event(prefix: str, task_type: str, ui_components: dict):
|
|
| 59 |
input_keys = list(run_inputs_map.keys())
|
| 60 |
input_list_flat = [v for v in run_inputs_map.values() if v is not None]
|
| 61 |
all_chains = [
|
| 62 |
-
lora_data_components, controlnet_data_components, anima_controlnet_lllite_data_components, diffsynth_controlnet_data_components, ipadapter_data_components,
|
| 63 |
sd3_ipadapter_data_components, flux1_ipadapter_data_components, style_data_components,
|
| 64 |
embedding_data_components, conditioning_data_components, reference_latent_data_components, hidream_o1_reference_data_components
|
| 65 |
]
|
|
@@ -82,6 +83,7 @@ def create_run_event(prefix: str, task_type: str, ui_components: dict):
|
|
| 82 |
assign_chain_data('controlnet_data', controlnet_data_components)
|
| 83 |
assign_chain_data('anima_controlnet_lllite_data', anima_controlnet_lllite_data_components)
|
| 84 |
assign_chain_data('diffsynth_controlnet_data', diffsynth_controlnet_data_components)
|
|
|
|
| 85 |
assign_chain_data('ipadapter_data', ipadapter_data_components)
|
| 86 |
assign_chain_data('sd3_ipadapter_chain', sd3_ipadapter_data_components)
|
| 87 |
assign_chain_data('flux1_ipadapter_data', flux1_ipadapter_data_components)
|
|
|
|
| 43 |
controlnet_data_components = ui_components.get(f'all_controlnet_components_flat_{prefix}', [])
|
| 44 |
anima_controlnet_lllite_data_components = ui_components.get(f'all_anima_controlnet_lllite_components_flat_{prefix}', [])
|
| 45 |
diffsynth_controlnet_data_components = ui_components.get(f'all_diffsynth_controlnet_components_flat_{prefix}', [])
|
| 46 |
+
krea2_controlnet_data_components = ui_components.get(f'all_krea2_controlnet_components_flat_{prefix}', [])
|
| 47 |
ipadapter_data_components = ui_components.get(f'all_ipadapter_components_flat_{prefix}', [])
|
| 48 |
sd3_ipadapter_data_components = ui_components.get(f'all_sd3_ipadapter_components_flat_{prefix}', [])
|
| 49 |
flux1_ipadapter_data_components = ui_components.get(f'all_flux1_ipadapter_components_flat_{prefix}', [])
|
|
|
|
| 60 |
input_keys = list(run_inputs_map.keys())
|
| 61 |
input_list_flat = [v for v in run_inputs_map.values() if v is not None]
|
| 62 |
all_chains = [
|
| 63 |
+
lora_data_components, controlnet_data_components, anima_controlnet_lllite_data_components, diffsynth_controlnet_data_components, krea2_controlnet_data_components, ipadapter_data_components,
|
| 64 |
sd3_ipadapter_data_components, flux1_ipadapter_data_components, style_data_components,
|
| 65 |
embedding_data_components, conditioning_data_components, reference_latent_data_components, hidream_o1_reference_data_components
|
| 66 |
]
|
|
|
|
| 83 |
assign_chain_data('controlnet_data', controlnet_data_components)
|
| 84 |
assign_chain_data('anima_controlnet_lllite_data', anima_controlnet_lllite_data_components)
|
| 85 |
assign_chain_data('diffsynth_controlnet_data', diffsynth_controlnet_data_components)
|
| 86 |
+
assign_chain_data('krea2_controlnet_data', krea2_controlnet_data_components)
|
| 87 |
assign_chain_data('ipadapter_data', ipadapter_data_components)
|
| 88 |
assign_chain_data('sd3_ipadapter_chain', sd3_ipadapter_data_components)
|
| 89 |
assign_chain_data('flux1_ipadapter_data', flux1_ipadapter_data_components)
|
ui/shared/hires_fix_ui.py
CHANGED
|
@@ -3,7 +3,7 @@ from core.settings import MODEL_MAP_CHECKPOINT, MODEL_DEFAULTS_CONFIG
|
|
| 3 |
from comfy_integration.nodes import SAMPLER_CHOICES, SCHEDULER_CHOICES
|
| 4 |
from .ui_components import (
|
| 5 |
create_lora_settings_ui,
|
| 6 |
-
create_controlnet_ui, create_anima_controlnet_lllite_ui, create_ipadapter_ui, create_embedding_ui,
|
| 7 |
create_conditioning_ui, create_vae_override_ui,
|
| 8 |
create_model_architecture_filter_ui, create_category_filter_ui,
|
| 9 |
create_sd3_ipadapter_ui, create_flux1_ipadapter_ui, create_style_ui,
|
|
@@ -91,6 +91,8 @@ def create_ui():
|
|
| 91 |
components.update(create_lora_settings_ui(prefix))
|
| 92 |
components.update(create_controlnet_ui(prefix))
|
| 93 |
components.update(create_anima_controlnet_lllite_ui(prefix))
|
|
|
|
|
|
|
| 94 |
components.update(create_ipadapter_ui(prefix))
|
| 95 |
components.update(create_flux1_ipadapter_ui(prefix))
|
| 96 |
components.update(create_sd3_ipadapter_ui(prefix))
|
|
|
|
| 3 |
from comfy_integration.nodes import SAMPLER_CHOICES, SCHEDULER_CHOICES
|
| 4 |
from .ui_components import (
|
| 5 |
create_lora_settings_ui,
|
| 6 |
+
create_controlnet_ui, create_anima_controlnet_lllite_ui, create_diffsynth_controlnet_ui, create_krea2_controlnet_ui, create_ipadapter_ui, create_embedding_ui,
|
| 7 |
create_conditioning_ui, create_vae_override_ui,
|
| 8 |
create_model_architecture_filter_ui, create_category_filter_ui,
|
| 9 |
create_sd3_ipadapter_ui, create_flux1_ipadapter_ui, create_style_ui,
|
|
|
|
| 91 |
components.update(create_lora_settings_ui(prefix))
|
| 92 |
components.update(create_controlnet_ui(prefix))
|
| 93 |
components.update(create_anima_controlnet_lllite_ui(prefix))
|
| 94 |
+
components.update(create_diffsynth_controlnet_ui(prefix))
|
| 95 |
+
components.update(create_krea2_controlnet_ui(prefix))
|
| 96 |
components.update(create_ipadapter_ui(prefix))
|
| 97 |
components.update(create_flux1_ipadapter_ui(prefix))
|
| 98 |
components.update(create_sd3_ipadapter_ui(prefix))
|
ui/shared/img2img_ui.py
CHANGED
|
@@ -3,7 +3,7 @@ from core.settings import MODEL_MAP_CHECKPOINT, MODEL_DEFAULTS_CONFIG
|
|
| 3 |
from comfy_integration.nodes import SAMPLER_CHOICES, SCHEDULER_CHOICES
|
| 4 |
from .ui_components import (
|
| 5 |
create_lora_settings_ui,
|
| 6 |
-
create_controlnet_ui, create_anima_controlnet_lllite_ui, create_diffsynth_controlnet_ui, create_ipadapter_ui, create_embedding_ui,
|
| 7 |
create_conditioning_ui, create_vae_override_ui,
|
| 8 |
create_model_architecture_filter_ui, create_category_filter_ui,
|
| 9 |
create_sd3_ipadapter_ui, create_flux1_ipadapter_ui, create_style_ui,
|
|
@@ -73,6 +73,7 @@ def create_ui():
|
|
| 73 |
components.update(create_controlnet_ui(prefix))
|
| 74 |
components.update(create_anima_controlnet_lllite_ui(prefix))
|
| 75 |
components.update(create_diffsynth_controlnet_ui(prefix))
|
|
|
|
| 76 |
components.update(create_ipadapter_ui(prefix))
|
| 77 |
components.update(create_flux1_ipadapter_ui(prefix))
|
| 78 |
components.update(create_sd3_ipadapter_ui(prefix))
|
|
|
|
| 3 |
from comfy_integration.nodes import SAMPLER_CHOICES, SCHEDULER_CHOICES
|
| 4 |
from .ui_components import (
|
| 5 |
create_lora_settings_ui,
|
| 6 |
+
create_controlnet_ui, create_anima_controlnet_lllite_ui, create_diffsynth_controlnet_ui, create_krea2_controlnet_ui, create_ipadapter_ui, create_embedding_ui,
|
| 7 |
create_conditioning_ui, create_vae_override_ui,
|
| 8 |
create_model_architecture_filter_ui, create_category_filter_ui,
|
| 9 |
create_sd3_ipadapter_ui, create_flux1_ipadapter_ui, create_style_ui,
|
|
|
|
| 73 |
components.update(create_controlnet_ui(prefix))
|
| 74 |
components.update(create_anima_controlnet_lllite_ui(prefix))
|
| 75 |
components.update(create_diffsynth_controlnet_ui(prefix))
|
| 76 |
+
components.update(create_krea2_controlnet_ui(prefix))
|
| 77 |
components.update(create_ipadapter_ui(prefix))
|
| 78 |
components.update(create_flux1_ipadapter_ui(prefix))
|
| 79 |
components.update(create_sd3_ipadapter_ui(prefix))
|
ui/shared/inpaint_ui.py
CHANGED
|
@@ -2,7 +2,7 @@ import gradio as gr
|
|
| 2 |
from core.settings import MODEL_MAP_CHECKPOINT, MODEL_DEFAULTS_CONFIG
|
| 3 |
from .ui_components import (
|
| 4 |
create_base_parameter_ui, create_lora_settings_ui,
|
| 5 |
-
create_controlnet_ui, create_anima_controlnet_lllite_ui, create_diffsynth_controlnet_ui, create_ipadapter_ui, create_embedding_ui,
|
| 6 |
create_conditioning_ui, create_vae_override_ui,
|
| 7 |
create_model_architecture_filter_ui, create_category_filter_ui,
|
| 8 |
create_sd3_ipadapter_ui, create_flux1_ipadapter_ui, create_style_ui,
|
|
@@ -105,6 +105,7 @@ def create_ui():
|
|
| 105 |
components.update(create_controlnet_ui(prefix))
|
| 106 |
components.update(create_anima_controlnet_lllite_ui(prefix))
|
| 107 |
components.update(create_diffsynth_controlnet_ui(prefix))
|
|
|
|
| 108 |
components.update(create_ipadapter_ui(prefix))
|
| 109 |
components.update(create_flux1_ipadapter_ui(prefix))
|
| 110 |
components.update(create_sd3_ipadapter_ui(prefix))
|
|
|
|
| 2 |
from core.settings import MODEL_MAP_CHECKPOINT, MODEL_DEFAULTS_CONFIG
|
| 3 |
from .ui_components import (
|
| 4 |
create_base_parameter_ui, create_lora_settings_ui,
|
| 5 |
+
create_controlnet_ui, create_anima_controlnet_lllite_ui, create_diffsynth_controlnet_ui, create_krea2_controlnet_ui, create_ipadapter_ui, create_embedding_ui,
|
| 6 |
create_conditioning_ui, create_vae_override_ui,
|
| 7 |
create_model_architecture_filter_ui, create_category_filter_ui,
|
| 8 |
create_sd3_ipadapter_ui, create_flux1_ipadapter_ui, create_style_ui,
|
|
|
|
| 105 |
components.update(create_controlnet_ui(prefix))
|
| 106 |
components.update(create_anima_controlnet_lllite_ui(prefix))
|
| 107 |
components.update(create_diffsynth_controlnet_ui(prefix))
|
| 108 |
+
components.update(create_krea2_controlnet_ui(prefix))
|
| 109 |
components.update(create_ipadapter_ui(prefix))
|
| 110 |
components.update(create_flux1_ipadapter_ui(prefix))
|
| 111 |
components.update(create_sd3_ipadapter_ui(prefix))
|
ui/shared/outpaint_ui.py
CHANGED
|
@@ -3,7 +3,7 @@ from core.settings import MODEL_MAP_CHECKPOINT, MODEL_DEFAULTS_CONFIG
|
|
| 3 |
from comfy_integration.nodes import SAMPLER_CHOICES, SCHEDULER_CHOICES
|
| 4 |
from .ui_components import (
|
| 5 |
create_lora_settings_ui,
|
| 6 |
-
create_controlnet_ui, create_anima_controlnet_lllite_ui, create_diffsynth_controlnet_ui, create_ipadapter_ui, create_embedding_ui,
|
| 7 |
create_conditioning_ui, create_vae_override_ui,
|
| 8 |
create_model_architecture_filter_ui, create_category_filter_ui,
|
| 9 |
create_sd3_ipadapter_ui, create_flux1_ipadapter_ui, create_style_ui,
|
|
@@ -88,6 +88,7 @@ def create_ui():
|
|
| 88 |
components.update(create_controlnet_ui(prefix))
|
| 89 |
components.update(create_anima_controlnet_lllite_ui(prefix))
|
| 90 |
components.update(create_diffsynth_controlnet_ui(prefix))
|
|
|
|
| 91 |
components.update(create_ipadapter_ui(prefix))
|
| 92 |
components.update(create_flux1_ipadapter_ui(prefix))
|
| 93 |
components.update(create_sd3_ipadapter_ui(prefix))
|
|
|
|
| 3 |
from comfy_integration.nodes import SAMPLER_CHOICES, SCHEDULER_CHOICES
|
| 4 |
from .ui_components import (
|
| 5 |
create_lora_settings_ui,
|
| 6 |
+
create_controlnet_ui, create_anima_controlnet_lllite_ui, create_diffsynth_controlnet_ui, create_krea2_controlnet_ui, create_ipadapter_ui, create_embedding_ui,
|
| 7 |
create_conditioning_ui, create_vae_override_ui,
|
| 8 |
create_model_architecture_filter_ui, create_category_filter_ui,
|
| 9 |
create_sd3_ipadapter_ui, create_flux1_ipadapter_ui, create_style_ui,
|
|
|
|
| 88 |
components.update(create_controlnet_ui(prefix))
|
| 89 |
components.update(create_anima_controlnet_lllite_ui(prefix))
|
| 90 |
components.update(create_diffsynth_controlnet_ui(prefix))
|
| 91 |
+
components.update(create_krea2_controlnet_ui(prefix))
|
| 92 |
components.update(create_ipadapter_ui(prefix))
|
| 93 |
components.update(create_flux1_ipadapter_ui(prefix))
|
| 94 |
components.update(create_sd3_ipadapter_ui(prefix))
|
ui/shared/txt2img_ui.py
CHANGED
|
@@ -2,7 +2,7 @@ import gradio as gr
|
|
| 2 |
from core.settings import MODEL_MAP_CHECKPOINT
|
| 3 |
from .ui_components import (
|
| 4 |
create_base_parameter_ui, create_lora_settings_ui,
|
| 5 |
-
create_controlnet_ui, create_anima_controlnet_lllite_ui, create_diffsynth_controlnet_ui, create_ipadapter_ui, create_embedding_ui,
|
| 6 |
create_conditioning_ui, create_vae_override_ui,
|
| 7 |
create_model_architecture_filter_ui, create_category_filter_ui,
|
| 8 |
create_sd3_ipadapter_ui, create_flux1_ipadapter_ui, create_style_ui,
|
|
@@ -45,6 +45,7 @@ def create_ui():
|
|
| 45 |
components.update(create_controlnet_ui(prefix))
|
| 46 |
components.update(create_anima_controlnet_lllite_ui(prefix))
|
| 47 |
components.update(create_diffsynth_controlnet_ui(prefix))
|
|
|
|
| 48 |
components.update(create_ipadapter_ui(prefix))
|
| 49 |
components.update(create_flux1_ipadapter_ui(prefix))
|
| 50 |
components.update(create_sd3_ipadapter_ui(prefix))
|
|
|
|
| 2 |
from core.settings import MODEL_MAP_CHECKPOINT
|
| 3 |
from .ui_components import (
|
| 4 |
create_base_parameter_ui, create_lora_settings_ui,
|
| 5 |
+
create_controlnet_ui, create_anima_controlnet_lllite_ui, create_diffsynth_controlnet_ui, create_krea2_controlnet_ui, create_ipadapter_ui, create_embedding_ui,
|
| 6 |
create_conditioning_ui, create_vae_override_ui,
|
| 7 |
create_model_architecture_filter_ui, create_category_filter_ui,
|
| 8 |
create_sd3_ipadapter_ui, create_flux1_ipadapter_ui, create_style_ui,
|
|
|
|
| 45 |
components.update(create_controlnet_ui(prefix))
|
| 46 |
components.update(create_anima_controlnet_lllite_ui(prefix))
|
| 47 |
components.update(create_diffsynth_controlnet_ui(prefix))
|
| 48 |
+
components.update(create_krea2_controlnet_ui(prefix))
|
| 49 |
components.update(create_ipadapter_ui(prefix))
|
| 50 |
components.update(create_flux1_ipadapter_ui(prefix))
|
| 51 |
components.update(create_sd3_ipadapter_ui(prefix))
|
ui/shared/ui_components.py
CHANGED
|
@@ -203,6 +203,49 @@ def create_controlnet_ui(prefix: str, max_units=MAX_CONTROLNETS):
|
|
| 203 |
|
| 204 |
return components
|
| 205 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 206 |
def create_anima_controlnet_lllite_ui(prefix: str, max_units=MAX_CONTROLNETS):
|
| 207 |
components = {}
|
| 208 |
key = lambda name: f"{name}_{prefix}"
|
|
|
|
| 203 |
|
| 204 |
return components
|
| 205 |
|
| 206 |
+
def create_krea2_controlnet_ui(prefix: str, max_units=MAX_CONTROLNETS):
|
| 207 |
+
components = {}
|
| 208 |
+
key = lambda name: f"{name}_{prefix}"
|
| 209 |
+
|
| 210 |
+
with gr.Accordion("Krea2 ControlNet Settings", open=False, visible=('krea2_controlnet' in default_enabled_chains)) as accordion:
|
| 211 |
+
components[key('krea2_controlnet_accordion')] = accordion
|
| 212 |
+
gr.Markdown("💡 **Tip:** Processed using the [facok/comfyui-krea2-controlnet](https://github.com/facok/comfyui-krea2-controlnet) node.")
|
| 213 |
+
|
| 214 |
+
cn_rows, images, series, types, strengths, filepaths = [], [], [], [], [], []
|
| 215 |
+
components.update({
|
| 216 |
+
key('krea2_controlnet_rows'): cn_rows,
|
| 217 |
+
key('krea2_controlnet_images'): images,
|
| 218 |
+
key('krea2_controlnet_series'): series,
|
| 219 |
+
key('krea2_controlnet_types'): types,
|
| 220 |
+
key('krea2_controlnet_strengths'): strengths,
|
| 221 |
+
key('krea2_controlnet_filepaths'): filepaths
|
| 222 |
+
})
|
| 223 |
+
|
| 224 |
+
for i in range(max_units):
|
| 225 |
+
with gr.Row(visible=(i < 1)) as row:
|
| 226 |
+
with gr.Column(scale=1):
|
| 227 |
+
images.append(gr.Image(label=f"Control Image {i+1}", type="pil", sources=["upload"], height=256))
|
| 228 |
+
with gr.Column(scale=2):
|
| 229 |
+
types.append(gr.Dropdown(label="Type", choices=[], interactive=True, allow_custom_value=True))
|
| 230 |
+
series.append(gr.Dropdown(label="Series", choices=[], interactive=True, allow_custom_value=True))
|
| 231 |
+
strengths.append(gr.Slider(label="Strength", minimum=0.0, maximum=2.0, step=0.05, value=1.0, interactive=True))
|
| 232 |
+
filepaths.append(gr.State(None))
|
| 233 |
+
cn_rows.append(row)
|
| 234 |
+
|
| 235 |
+
with gr.Row():
|
| 236 |
+
components[key('add_krea2_controlnet_button')] = gr.Button("✚ Add Krea2 ControlNet")
|
| 237 |
+
components[key('delete_krea2_controlnet_button')] = gr.Button("➖ Delete Krea2 ControlNet", visible=False)
|
| 238 |
+
components[key('krea2_controlnet_count_state')] = gr.State(1)
|
| 239 |
+
|
| 240 |
+
all_cn_components_flat = []
|
| 241 |
+
for i in range(max_units):
|
| 242 |
+
all_cn_components_flat.extend([
|
| 243 |
+
images[i], types[i], series[i], strengths[i], filepaths[i]
|
| 244 |
+
])
|
| 245 |
+
components[key('all_krea2_controlnet_components_flat')] = all_cn_components_flat
|
| 246 |
+
|
| 247 |
+
return components
|
| 248 |
+
|
| 249 |
def create_anima_controlnet_lllite_ui(prefix: str, max_units=MAX_CONTROLNETS):
|
| 250 |
components = {}
|
| 251 |
key = lambda name: f"{name}_{prefix}"
|
yaml/file_list.yaml
CHANGED
|
@@ -718,6 +718,11 @@ file:
|
|
| 718 |
repo_id: "black-forest-labs/FLUX.1-Redux-dev"
|
| 719 |
repository_file_path: "flux1-redux-dev.safetensors"
|
| 720 |
loras:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 721 |
# SD1.5 FaceID
|
| 722 |
- filename: "ip-adapter-faceid_sd15_lora.safetensors"
|
| 723 |
source: "hf"
|
|
|
|
| 718 |
repo_id: "black-forest-labs/FLUX.1-Redux-dev"
|
| 719 |
repository_file_path: "flux1-redux-dev.safetensors"
|
| 720 |
loras:
|
| 721 |
+
# Krea2 ControlNet
|
| 722 |
+
- filename: "depth-control-lora.safetensors"
|
| 723 |
+
source: "hf"
|
| 724 |
+
repo_id: "Patil/Krea-2-depth-controlnet"
|
| 725 |
+
repository_file_path: "depth-control-lora.safetensors"
|
| 726 |
# SD1.5 FaceID
|
| 727 |
- filename: "ip-adapter-faceid_sd15_lora.safetensors"
|
| 728 |
source: "hf"
|
yaml/image_gen_features.yaml
CHANGED
|
@@ -11,6 +11,7 @@ default:
|
|
| 11 |
krea-2:
|
| 12 |
enabled_chains:
|
| 13 |
- lora
|
|
|
|
| 14 |
- conditioning
|
| 15 |
- pid
|
| 16 |
|
|
|
|
| 11 |
krea-2:
|
| 12 |
enabled_chains:
|
| 13 |
- lora
|
| 14 |
+
- krea2_controlnet
|
| 15 |
- conditioning
|
| 16 |
- pid
|
| 17 |
|
yaml/injectors.yaml
CHANGED
|
@@ -7,6 +7,8 @@ injector_definitions:
|
|
| 7 |
module: "chain_injectors.newbie_lora_injector"
|
| 8 |
dynamic_controlnet_chains:
|
| 9 |
module: "chain_injectors.controlnet_injector"
|
|
|
|
|
|
|
| 10 |
dynamic_anima_controlnet_lllite_chains:
|
| 11 |
module: "chain_injectors.anima_controlnet_lllite_injector"
|
| 12 |
dynamic_diffsynth_controlnet_chains:
|
|
@@ -42,6 +44,7 @@ injector_order:
|
|
| 42 |
- dynamic_conditioning_chains
|
| 43 |
- dynamic_style_chains
|
| 44 |
- dynamic_controlnet_chains
|
|
|
|
| 45 |
- dynamic_anima_controlnet_lllite_chains
|
| 46 |
- dynamic_hidream_o1_smoothing_chains
|
| 47 |
- dynamic_hidream_o1_reference_chains
|
|
|
|
| 7 |
module: "chain_injectors.newbie_lora_injector"
|
| 8 |
dynamic_controlnet_chains:
|
| 9 |
module: "chain_injectors.controlnet_injector"
|
| 10 |
+
dynamic_krea2_controlnet_chains:
|
| 11 |
+
module: "chain_injectors.krea2_controlnet_injector"
|
| 12 |
dynamic_anima_controlnet_lllite_chains:
|
| 13 |
module: "chain_injectors.anima_controlnet_lllite_injector"
|
| 14 |
dynamic_diffsynth_controlnet_chains:
|
|
|
|
| 44 |
- dynamic_conditioning_chains
|
| 45 |
- dynamic_style_chains
|
| 46 |
- dynamic_controlnet_chains
|
| 47 |
+
- dynamic_krea2_controlnet_chains
|
| 48 |
- dynamic_anima_controlnet_lllite_chains
|
| 49 |
- dynamic_hidream_o1_smoothing_chains
|
| 50 |
- dynamic_hidream_o1_reference_chains
|
yaml/krea2_controlnet_models.yaml
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Krea2_ControlNet:
|
| 2 |
+
- Filepath: "depth-control-lora.safetensors"
|
| 3 |
+
Series: "Patil"
|
| 4 |
+
Type: ["Depth"]
|