Optimize workflows and configuration files, and standardize file naming.
Browse filesFiles changed (20)
- chain_injectors/__init__.py+50
- chain_injectors/boogu_edit_injector.py → chain_injectors/boogu_image_edit_injector.pyRenamed+17-72
- chain_injectors/joyai_reference_injector.py → chain_injectors/joyai_image_injector.pyRenamed
- chain_injectors/krea2_reference_edit_injector.py → chain_injectors/krea2_style_reference_injector.pyRenamed
- chain_injectors/newbie_lora_injector.pyDeleted-63
- chain_injectors/qwen_image_edit_injector.py+17-74
- comfy_integration/setup.py+2-10
- core/pipelines/sd_image_pipeline.py+4-4
- core/pipelines/workflow_recipes/_partials/_base_sampler_sd.yaml → core/pipelines/workflow_recipes/_partials/_base_sampler.yamlRenamed+27-27
- core/pipelines/workflow_recipes/_partials/conditioning/boogu-image.yaml+67-74
- core/pipelines/workflow_recipes/_partials/conditioning/joyai-image.yaml+2-2
- core/pipelines/workflow_recipes/_partials/conditioning/krea-2.yaml+2-2
- core/pipelines/workflow_recipes/_partials/conditioning/newbie-image.yaml+2-2
- core/pipelines/workflow_recipes/_partials/conditioning/qwen-image.yaml+90-91
- core/pipelines/workflow_recipes/sd_unified_recipe.yaml → core/pipelines/workflow_recipes/unified_recipe.yamlRenamed+7-7
- core/workflow_assembler.py+164-178
- ui/events/change_handlers.py+10-10
- ui/shared/ui_components.py+5-5
- yaml/image_gen_features.yaml+199-207
- yaml/injectors.yamlDeleted-69
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950import osimport importlibimport pkgutil
def discover_injectors(): injectors = {} package_dir = os.path.dirname(__file__)
for _, module_name, is_pkg in pkgutil.iter_modules([package_dir]): if is_pkg or module_name.startswith('_'): continue
full_module_name = f"chain_injectors.{module_name}" try: module = importlib.import_module(full_module_name) if hasattr(module, 'inject') and callable(module.inject): feature_name = getattr(module, 'FEATURE_NAME', None) if not feature_name: feature_name = module_name[:-9] if module_name.endswith('_injector') else module_name
chain_type = getattr(module, 'CHAIN_TYPE', None) if not chain_type: chain_type = f"dynamic_{feature_name}_chains"
injectors[chain_type] = module.inject else: print(f"Warning: Module '{full_module_name}' does not have a callable 'inject' function.") except Exception as e: print(f"Error importing injector module '{full_module_name}': {e}")
return injectors
def get_registered_features(): features = {} package_dir = os.path.dirname(__file__)
for _, module_name, is_pkg in pkgutil.iter_modules([package_dir]): if is_pkg or module_name.startswith('_'): continue
feature_name = module_name[:-9] if module_name.endswith('_injector') else module_name full_module_name = f"chain_injectors.{module_name}" chain_type = f"dynamic_{feature_name}_chains"
features[feature_name] = { 'module': full_module_name, 'chain_type': chain_type }
return features1212325 unmodified lines2930313435363732333440414243443536373839404146474243444550515253464748495650515259606162636465666768697071727353545575767778798081828384858687888990915657587 unmodified lines6667681051061071081091101111121131141151161171181191201211221236912512670717212873import os
def create_node(assembler, class_type, title): try: node = assembler._get_node_template(class_type)25 unmodified lines
valid_images = valid_images[:10]
ksampler_name = chain_definition.get('ksampler_node', 'ksampler') pos_prompt_name = chain_definition.get('pos_prompt_node', 'pos_prompt') neg_prompt_name = chain_definition.get('neg_prompt_node', 'neg_prompt') clip_loader_name = chain_definition.get('clip_loader_node', 'clip_loader') boogu_prompt_name = chain_definition.get('boogu_prompt_node', 'boogu_prompt') vae_loader_name = chain_definition.get('vae_loader_node', 'vae_loader')
if ksampler_name not in assembler.node_map: print(f"Warning: Target node '{ksampler_name}' for Boogu Edit chain not found. Skipping.") return
ksampler_id = assembler.node_map[ksampler_name] boogu_prompt_id = assembler.node_map.get(boogu_prompt_name) if not boogu_prompt_id or boogu_prompt_id not in assembler.workflow: for node_id, node in assembler.workflow.items(): if isinstance(node, dict) and node.get('class_type') == 'TextEncodeBooguEdit': boogu_prompt_id = node_id break
if 'model' not in assembler.workflow[ksampler_id]['inputs']: print(f"Warning: KSampler node '{ksampler_name}' is missing 'model' input. Skipping.") if not boogu_prompt_id: print(f"Warning: Target node '{boogu_prompt_name}' (TextEncodeBooguEdit) for Boogu Edit chain not found. Skipping.") return
vae_connection = None if vae_loader_name in assembler.node_map: vae_connection = [assembler.node_map[vae_loader_name], 0] else: vae_id = assembler.node_map.get(vae_loader_name) if not vae_id: for node_id, node in assembler.workflow.items(): if isinstance(node, dict) and node.get('class_type') == 'VAELoader': vae_connection = [node_id, 0] vae_id = node_id break
clip_connection = None if clip_loader_name in assembler.node_map: clip_connection = [assembler.node_map[clip_loader_name], 0] elif pos_prompt_name in assembler.node_map: pos_id = assembler.node_map[pos_prompt_name] clip_connection = assembler.workflow[pos_id]['inputs'].get('clip')
pos_prompt_id = assembler.node_map.get(pos_prompt_name) neg_prompt_id = assembler.node_map.get(neg_prompt_name)
pos_text = "" if pos_prompt_id and pos_prompt_id in assembler.workflow: pos_text = assembler.workflow[pos_prompt_id]['inputs'].get('text', '') elif hasattr(assembler, 'ui_values') and isinstance(assembler.ui_values, dict): pos_text = assembler.ui_values.get('positive_prompt') or assembler.ui_values.get('prompt') or '' if vae_id: assembler.workflow[boogu_prompt_id]['inputs']['vae'] = [vae_id, 0]
if not pos_text: for node_id, node in assembler.workflow.items(): if isinstance(node, dict): cls = node.get('class_type', '') if cls in ['TextEncodeBooguEdit', 'Krea2EditGroundedEncode', 'TextEncodeQwenImageEditPlus', 'CLIPTextEncode']: t = node.get('inputs', {}).get('prompt') or node.get('inputs', {}).get('text') if t: pos_text = t break
neg_text = "" if neg_prompt_id and neg_prompt_id in assembler.workflow: neg_text = assembler.workflow[neg_prompt_id]['inputs'].get('text', '') elif hasattr(assembler, 'ui_values') and isinstance(assembler.ui_values, dict): neg_text = assembler.ui_values.get('negative_prompt') or assembler.ui_values.get('neg_prompt') or ''
scaled_image_ids = [] for i, img_filename in enumerate(valid_images): load_id = assembler._get_unique_id() load_node = create_node(assembler, "LoadImage", f"Load Reference Image {i+1}")7 unmodified lines scale_node['inputs']['resolution_steps'] = 1 scale_node['inputs']['image'] = [load_id, 0] assembler.workflow[scale_id] = scale_node scaled_image_ids.append(scale_id)
boogu_encode_id = assembler._get_unique_id() boogu_encode_node = create_node(assembler, "TextEncodeBooguEdit", "TextEncodeBooguEdit") boogu_encode_node['inputs']['prompt'] = pos_text boogu_encode_node['inputs']['negative_prompt'] = neg_text if clip_connection: boogu_encode_node['inputs']['clip'] = clip_connection if vae_connection: boogu_encode_node['inputs']['vae'] = vae_connection for idx, s_id in enumerate(scaled_image_ids): boogu_encode_node['inputs'][f"images.image_{idx+1}"] = [s_id, 0] assembler.workflow[boogu_encode_id] = boogu_encode_node
assembler.workflow[ksampler_id]['inputs']['positive'] = [boogu_encode_id, 0] assembler.workflow[ksampler_id]['inputs']['negative'] = [boogu_encode_id, 1]
if pos_prompt_id and pos_prompt_id in assembler.workflow: del assembler.workflow[pos_prompt_id]
if neg_prompt_id and neg_prompt_id in assembler.workflow: del assembler.workflow[neg_prompt_id] image_key = f"images.image_{i+1}" assembler.workflow[boogu_prompt_id]['inputs'][image_key] = [scale_id, 0]
print(f"Boogu Edit injector applied with {len(valid_images)} reference image(s). Original CLIPTextEncode nodes replaced.") print(f"Boogu Edit injector applied with {len(valid_images)} reference image(s). Connected VAE dynamically.")123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263from copy import deepcopy
def inject(assembler, chain_definition, chain_items):
if not chain_items:
return
output_map = chain_definition.get('output_map', {})
current_connections = {}
for key, type_name in output_map.items():
if ':' in str(key):
node_name, idx_str = key.split(':')
if node_name not in assembler.node_map:
print(f"Warning: [NewBie LoRA Injector] Node '{node_name}' in chain's output_map not found. Skipping.")
continue
node_id = assembler.node_map[node_name]
start_output_idx = int(idx_str)
current_connections[type_name] = [node_id, start_output_idx]
else:
print(f"Warning: [NewBie LoRA Injector] output_map key '{key}' is not in 'node:index' format. Skipping this connection.")
template_name = chain_definition.get('template')
if not template_name:
print(f"Warning: [NewBie LoRA Injector] No 'template' defined for chain. Skipping.")
return
for item_data in chain_items:
template = assembler._get_node_template(template_name)
node_data = deepcopy(template)
node_data['inputs']['lora_name'] = item_data.get('lora_name')
node_data['inputs']['strength'] = item_data.get('strength_model', 1.0)
node_data['inputs']['enabled'] = True
if 'model' in current_connections:
node_data['inputs']['model'] = current_connections['model']
if 'clip' in current_connections:
node_data['inputs']['clip'] = current_connections['clip']
new_node_id = assembler._get_unique_id()
assembler.workflow[new_node_id] = node_data
current_connections['model'] = [new_node_id, 0]
current_connections['clip'] = [new_node_id, 1]
end_input_map = chain_definition.get('end_input_map', {})
for type_name, targets in end_input_map.items():
if type_name in current_connections:
if not isinstance(targets, list):
targets = [targets]
for target_str in targets:
try:
end_node_name, end_input_name = target_str.split(':')
if end_node_name in assembler.node_map:
end_node_id = assembler.node_map[end_node_name]
assembler.workflow[end_node_id]['inputs'][end_input_name] = current_connections[type_name]
else:
print(f"Warning: [NewBie LoRA Injector] End node '{end_node_name}' for dynamic chain not found. Skipping connection.")
except ValueError:
print(f"Warning: [NewBie LoRA Injector] Invalid target format '{target_str}' in end_input_map. Skipping.")
if chain_items:
print(f"NewBie LoRA injector applied. Re-routed model and clip through {len(chain_items)} LoRA(s).")1212328 unmodified lines323334373536372 unmodified lines4041424344454748464748495152535450515253575455566061626364656667685758596070717273747576777879808182838485868788899091926162637 unmodified lines71727310610710810911011111211311411511611711811912012112212312412512612712874757677787980811338283848586871398889909118 unmodified lines110111112164165166167168169170113import os
def create_node(assembler, class_type, title): try: node = assembler._get_node_template(class_type)28 unmodified lines ksampler_name = chain_definition.get('ksampler_node', 'ksampler') pos_prompt_name = chain_definition.get('pos_prompt_node', 'pos_prompt') neg_prompt_name = chain_definition.get('neg_prompt_node', 'neg_prompt') clip_loader_name = chain_definition.get('clip_loader_node', 'clip_loader') vae_loader_name = chain_definition.get('vae_loader_node', 'vae_loader') model_sampler_name = chain_definition.get('model_sampler_node', 'model_sampler')
2 unmodified lines return
ksampler_id = assembler.node_map[ksampler_name] pos_prompt_id = assembler.node_map.get(pos_prompt_name) neg_prompt_id = assembler.node_map.get(neg_prompt_name)
if 'model' not in assembler.workflow[ksampler_id]['inputs']: print(f"Warning: KSampler node '{ksampler_name}' is missing 'model' input. Skipping.") if not pos_prompt_id or not neg_prompt_id: print("Warning: Positive or negative prompt node not found for Qwen-Image Edit chain. Skipping.") return
vae_connection = None if vae_loader_name in assembler.node_map: vae_connection = [assembler.node_map[vae_loader_name], 0] else: vae_id = assembler.node_map.get(vae_loader_name) if not vae_id: for node_id, node in assembler.workflow.items(): if isinstance(node, dict) and node.get('class_type') == 'VAELoader': vae_connection = [node_id, 0] vae_id = node_id break
clip_connection = None if clip_loader_name in assembler.node_map: clip_connection = [assembler.node_map[clip_loader_name], 0] elif pos_prompt_name in assembler.node_map: pos_id = assembler.node_map[pos_prompt_name] clip_connection = assembler.workflow[pos_id]['inputs'].get('clip')
pos_prompt_id = assembler.node_map.get(pos_prompt_name) neg_prompt_id = assembler.node_map.get(neg_prompt_name) if vae_id: assembler.workflow[pos_prompt_id]['inputs']['vae'] = [vae_id, 0] assembler.workflow[neg_prompt_id]['inputs']['vae'] = [vae_id, 0]
pos_text = "" if pos_prompt_id and pos_prompt_id in assembler.workflow: pos_text = assembler.workflow[pos_prompt_id]['inputs'].get('text', '') elif hasattr(assembler, 'ui_values') and isinstance(assembler.ui_values, dict): pos_text = assembler.ui_values.get('positive_prompt') or assembler.ui_values.get('prompt') or ''
if not pos_text: for node_id, node in assembler.workflow.items(): if isinstance(node, dict): cls = node.get('class_type', '') if cls in ['Krea2EditGroundedEncode', 'TextEncodeQwenImageEditPlus', 'CLIPTextEncode']: t = node.get('inputs', {}).get('prompt') or node.get('inputs', {}).get('text') if t: pos_text = t break
neg_text = "" if neg_prompt_id and neg_prompt_id in assembler.workflow: neg_text = assembler.workflow[neg_prompt_id]['inputs'].get('text', '') elif hasattr(assembler, 'ui_values') and isinstance(assembler.ui_values, dict): neg_text = assembler.ui_values.get('negative_prompt') or assembler.ui_values.get('neg_prompt') or ''
scaled_image_ids = [] for i, img_filename in enumerate(valid_images): load_id = assembler._get_unique_id() load_node = create_node(assembler, "LoadImage", f"Load Reference Image {i+1}")7 unmodified lines scale_node['inputs']['resolution_steps'] = 1 scale_node['inputs']['image'] = [load_id, 0] assembler.workflow[scale_id] = scale_node scaled_image_ids.append(scale_id)
pos_encode_id = assembler._get_unique_id() pos_encode_node = create_node(assembler, "TextEncodeQwenImageEditPlus", "TextEncodeQwenImageEditPlus (Positive)") pos_encode_node['inputs']['prompt'] = pos_text if clip_connection: pos_encode_node['inputs']['clip'] = clip_connection if vae_connection: pos_encode_node['inputs']['vae'] = vae_connection for idx, s_id in enumerate(scaled_image_ids): pos_encode_node['inputs'][f"image{idx+1}"] = [s_id, 0] assembler.workflow[pos_encode_id] = pos_encode_node
neg_encode_id = assembler._get_unique_id() neg_encode_node = create_node(assembler, "TextEncodeQwenImageEditPlus", "TextEncodeQwenImageEditPlus") neg_encode_node['inputs']['prompt'] = neg_text if clip_connection: neg_encode_node['inputs']['clip'] = clip_connection if vae_connection: neg_encode_node['inputs']['vae'] = vae_connection for idx, s_id in enumerate(scaled_image_ids): neg_encode_node['inputs'][f"image{idx+1}"] = [s_id, 0] assembler.workflow[neg_encode_id] = neg_encode_node
image_key = f"image{i+1}" assembler.workflow[pos_prompt_id]['inputs'][image_key] = [scale_id, 0] assembler.workflow[neg_prompt_id]['inputs'][image_key] = [scale_id, 0]
pos_ref_id = assembler._get_unique_id() pos_ref_node = create_node(assembler, "FluxKontextMultiReferenceLatentMethod", "Edit Model Reference Method") pos_ref_node['inputs']['reference_latents_method'] = "index_timestep_zero" pos_ref_node['inputs']['conditioning'] = [pos_encode_id, 0] pos_ref_node['inputs']['conditioning'] = [pos_prompt_id, 0] assembler.workflow[pos_ref_id] = pos_ref_node
neg_ref_id = assembler._get_unique_id() neg_ref_node = create_node(assembler, "FluxKontextMultiReferenceLatentMethod", "Edit Model Reference Method") neg_ref_node['inputs']['reference_latents_method'] = "index_timestep_zero" neg_ref_node['inputs']['conditioning'] = [neg_encode_id, 0] neg_ref_node['inputs']['conditioning'] = [neg_prompt_id, 0] assembler.workflow[neg_ref_id] = neg_ref_node
assembler.workflow[ksampler_id]['inputs']['positive'] = [pos_ref_id, 0]18 unmodified lines assembler.workflow[cfg_norm_id] = cfg_norm_node assembler.workflow[ksampler_id]['inputs']['model'] = [cfg_norm_id, 0]
if pos_prompt_id and pos_prompt_id in assembler.workflow: del assembler.workflow[pos_prompt_id]
if neg_prompt_id and neg_prompt_id in assembler.workflow: del assembler.workflow[neg_prompt_id]
print(f"Qwen-Image Edit injector applied with {len(valid_images)} reference image(s). Original CLIPTextEncode nodes replaced.") print(f"Qwen-Image Edit injector applied with {len(valid_images)} reference image(s). Connected VAE dynamically.")71 unmodified lines727374757677787980818283757677781 unmodified line808182918384858671 unmodified lines except Exception as e:
print(f"⚠️ Warning: Could not apply PR #108 compatibility patch for ComfyUI-IPAdapter-Flux: {e}")
# 4. ComfyUI-Newbie-Nodes
newbie_nodes_path = os.path.join(APP_DIR, "custom_nodes", "ComfyUI-Newbie-Nodes")
if not os.path.exists(newbie_nodes_path):
os.system(f"git clone https://github.com/NewBieAI-Lab/ComfyUI-Newbie-Nodes.git {newbie_nodes_path}")
print("✅ ComfyUI-Newbie-Nodes extension cloned.")
else:
print("✅ ComfyUI-Newbie-Nodes extension already exists.")
# 5. comfyui-krea2-controlnet
# 4. comfyui-krea2-controlnet
krea2_controlnet_nodes_path = os.path.join(APP_DIR, "custom_nodes", "comfyui-krea2-controlnet")
if not os.path.exists(krea2_controlnet_nodes_path):
os.system(f"git clone https://github.com/facok/comfyui-krea2-controlnet.git {krea2_controlnet_nodes_path}")1 unmodified line else:
print("✅ comfyui-krea2-controlnet extension already exists.")
# 6. comfyui-krea2edit
# 5. comfyui-krea2edit
krea2edit_nodes_path = os.path.join(APP_DIR, "custom_nodes", "comfyui-krea2edit")
if not os.path.exists(krea2edit_nodes_path):
os.system(f"git clone https://github.com/lbouaraba/comfyui-krea2edit.git {krea2edit_nodes_path}")150 unmodified lines15115215315415415515615722 unmodified lines180181182183183184185185186187187188189190150 unmodified lines 'latent_generator_template': latent_generator_template
}
recipe_path = os.path.join(os.path.dirname(__file__), "workflow_recipes", "sd_unified_recipe.yaml")
recipe_path = os.path.join(os.path.dirname(__file__), "workflow_recipes", "unified_recipe.yaml")
assembler = WorkflowAssembler(recipe_path, dynamic_values=dynamic_values)
hidream_o1_smoothing_data = []22 unmodified lines "conditioning_chain": active_conditioning,
"reference_latent_chain": active_reference_latents,
"hidream_o1_reference_chain": active_hidream_o1_reference,
"joyai_reference_chain": active_joyai_reference,
"joyai_image_chain": active_joyai_reference,
"krea2_identity_edit_chain": active_krea2_identity_edit,
"krea2_reference_edit_chain": active_krea2_reference_edit,
"krea2_style_reference_chain": active_krea2_reference_edit,
"qwen_image_edit_chain": active_qwen_image_edit,
"boogu_edit_chain": active_boogu_edit,
"boogu_image_edit_chain": active_boogu_edit,
"reference_image_chain": active_reference_images,
"vae_chain": [ui_inputs.get('vae_name')] if ui_inputs.get('vae_name') else [],
"hidream_o1_smoothing_chain": hidream_o1_smoothing_data,12345678910111213141516171819202122232425262712345678910111213141516171819202122232425262728nodes:
ksampler:
class_type: KSampler
title: "KSampler"
params:
denoise: 1.0
vae_decode:
class_type: VAEDecode
title: "VAE Decode"
save_image:
class_type: SaveImage
title: "Save Image"
params: {}
connections:
- from: "ksampler:0"
to: "vae_decode:samples"
- from: "vae_decode:0"
to: "save_image:images"
ui_map:
seed: "ksampler:seed"
steps: "ksampler:steps"
cfg: "ksampler:cfg"
sampler_name: "ksampler:sampler_name"
scheduler: "ksampler:scheduler"
denoise: "ksampler:denoise"
nodes: ksampler: class_type: KSampler title: "KSampler" params: denoise: 1.0 vae_decode: class_type: VAEDecode title: "VAE Decode" save_image: class_type: SaveImage title: "Save Image" params: {}
connections: - from: "ksampler:0" to: "vae_decode:samples" - from: "vae_decode:0" to: "save_image:images"
ui_map: seed: "ksampler:seed" steps: "ksampler:steps" cfg: "ksampler:cfg" sampler_name: "ksampler:sampler_name" scheduler: "ksampler:scheduler" denoise: "ksampler:denoise" filename_prefix: "save_image:filename_prefix"123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737412345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667nodes:
pos_prompt:
class_type: CLIPTextEncode
title: "CLIP Text Encode (Positive)"
neg_prompt:
class_type: CLIPTextEncode
title: "CLIP Text Encode (Negative)"
unet_loader:
class_type: UNETLoader
title: "Load Diffusion Model"
params:
weight_dtype: "default"
clip_loader:
class_type: CLIPLoader
title: "Load CLIP"
params:
type: "boogu"
device: "default"
vae_loader:
class_type: VAELoader
title: "Load VAE"
connections:
- from: "unet_loader:0"
to: "ksampler:model"
- from: "clip_loader:0"
to: "pos_prompt:clip"
- from: "clip_loader:0"
to: "neg_prompt:clip"
- from: "pos_prompt:0"
to: "ksampler:positive"
- from: "neg_prompt:0"
to: "ksampler:negative"
- from: "vae_loader:0"
to: "vae_decode:vae"
- from: "vae_loader:0"
to: "vae_encode:vae"
dynamic_lora_chains:
lora_chain:
template: "LoraLoader"
output_map:
"unet_loader:0": "model"
"clip_loader:0": "clip"
input_map:
"model": "model"
"clip": "clip"
end_input_map:
"model": ["ksampler:model"]
"clip": ["pos_prompt:clip", "neg_prompt:clip"]
dynamic_conditioning_chains:
conditioning_chain:
ksampler_node: "ksampler"
clip_source: "clip_loader:0"
dynamic_boogu_edit_chains:
boogu_edit_chain:
ksampler_node: "ksampler"
pos_prompt_node: "pos_prompt"
neg_prompt_node: "neg_prompt"
clip_loader_node: "clip_loader"
vae_loader_node: "vae_loader"
dynamic_pid_chains:
pid_chain:
ksampler_node: "ksampler"
ui_map:
positive_prompt: "pos_prompt:text"
negative_prompt: "neg_prompt:text"
unet_name: "unet_loader:unet_name"
clip_name: "clip_loader:clip_name"
vae_name: "vae_loader:vae_name"nodes: boogu_prompt: class_type: TextEncodeBooguEdit title: "Text Encode Boogu Edit" unet_loader: class_type: UNETLoader title: "Load Diffusion Model" params: weight_dtype: "default" clip_loader: class_type: CLIPLoader title: "Load CLIP" params: type: "boogu" device: "default" vae_loader: class_type: VAELoader title: "Load VAE"
connections: - from: "unet_loader:0" to: "ksampler:model" - from: "clip_loader:0" to: "boogu_prompt:clip" - from: "boogu_prompt:0" to: "ksampler:positive" - from: "boogu_prompt:1" to: "ksampler:negative" - from: "vae_loader:0" to: "vae_decode:vae" - from: "vae_loader:0" to: "vae_encode:vae"
dynamic_lora_chains: lora_chain: template: "LoraLoader" output_map: "unet_loader:0": "model" "clip_loader:0": "clip" input_map: "model": "model" "clip": "clip" end_input_map: "model": ["ksampler:model"] "clip": ["boogu_prompt:clip"]
dynamic_conditioning_chains: conditioning_chain: ksampler_node: "ksampler" clip_source: "clip_loader:0"
dynamic_boogu_image_edit_chains: boogu_image_edit_chain: ksampler_node: "ksampler" boogu_prompt_node: "boogu_prompt" vae_loader_node: "vae_loader"
dynamic_pid_chains: pid_chain: ksampler_node: "ksampler"
ui_map: positive_prompt: "boogu_prompt:prompt" negative_prompt: "boogu_prompt:negative_prompt" unet_name: "unet_loader:unet_name" clip_name: "clip_loader:clip_name" vae_name: "vae_loader:vae_name"70 unmodified lines7172737475747576777870 unmodified lines pid_chain:
ksampler_node: "ksampler"
dynamic_joyai_reference_chains:
joyai_reference_chain:
dynamic_joyai_image_chains:
joyai_image_chain:
pos_prompt_node: "pos_prompt"
neg_prompt_node: "neg_prompt"
vae_node: "vae_loader"61 unmodified lines6263646566656667686961 unmodified lines clip_loader_node: "clip_loader"
vae_loader_node: "vae_loader"
dynamic_krea2_reference_edit_chains:
krea2_reference_edit_chain:
dynamic_krea2_style_reference_chains:
krea2_style_reference_chain:
ksampler_node: "ksampler"
pos_prompt_node: "pos_prompt"
neg_prompt_node: "neg_prompt"45 unmodified lines464748494950515152535445 unmodified lines - from: "vae_loader:0"
to: "vae_encode:vae"
dynamic_newbie_lora_chains:
dynamic_lora_chains:
lora_chain:
template: "NewBieLoraLoader"
template: "LoraLoader"
output_map:
"unet_loader:0": "model"
"clip_loader:0": "clip"1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909112345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091nodes:
pos_prompt:
class_type: CLIPTextEncode
title: "CLIP Text Encode (Positive)"
neg_prompt:
class_type: CLIPTextEncode
title: "CLIP Text Encode (Negative)"
unet_loader:
class_type: UNETLoader
title: "Load Qwen UNET"
params:
weight_dtype: "default"
vae_loader:
class_type: VAELoader
title: "Load Qwen VAE"
clip_loader:
class_type: CLIPLoader
title: "Load Qwen CLIP"
params:
type: "qwen_image"
device: "default"
model_sampler:
class_type: ModelSamplingAuraFlow
title: "ModelSamplingAuraFlow"
params:
shift: 3.1
connections:
- from: "unet_loader:0"
to: "model_sampler:model"
- from: "model_sampler:0"
to: "ksampler:model"
- from: "clip_loader:0"
to: "pos_prompt:clip"
- from: "clip_loader:0"
to: "neg_prompt:clip"
- from: "vae_loader:0"
to: "vae_decode:vae"
- from: "vae_loader:0"
to: "vae_encode:vae"
- from: "pos_prompt:0"
to: "ksampler:positive"
- from: "neg_prompt:0"
to: "ksampler:negative"
dynamic_lora_chains:
lora_chain:
template: "LoraLoader"
output_map:
"unet_loader:0": "model"
"clip_loader:0": "clip"
input_map:
"model": "model"
"clip": "clip"
end_input_map:
"model": ["model_sampler:model"]
"clip": ["pos_prompt:clip", "neg_prompt:clip"]
dynamic_controlnet_chains:
controlnet_chain:
template: "ControlNetApplyAdvanced"
ksampler_node: "ksampler"
vae_source: "vae_loader:0"
dynamic_conditioning_chains:
conditioning_chain:
ksampler_node: "ksampler"
clip_source: "clip_loader:0"
dynamic_qwen_image_edit_chains:
qwen_image_edit_chain:
ksampler_node: "ksampler"
pos_prompt_node: "pos_prompt"
neg_prompt_node: "neg_prompt"
clip_loader_node: "clip_loader"
vae_loader_node: "vae_loader"
model_sampler_node: "model_sampler"
dynamic_pid_chains:
pid_chain:
ksampler_node: "ksampler"
ui_map:
positive_prompt: "pos_prompt:text"
negative_prompt: "neg_prompt:text"
unet_name: "unet_loader:unet_name"
vae_name: "vae_loader:vae_name"
nodes: pos_prompt: class_type: TextEncodeQwenImageEditPlus title: "Text Encode Qwen Image Edit Plus (Positive)" neg_prompt: class_type: TextEncodeQwenImageEditPlus title: "Text Encode Qwen Image Edit Plus (Negative)" unet_loader: class_type: UNETLoader title: "Load Qwen UNET" params: weight_dtype: "default" vae_loader: class_type: VAELoader title: "Load Qwen VAE" clip_loader: class_type: CLIPLoader title: "Load Qwen CLIP" params: type: "qwen_image" device: "default" model_sampler: class_type: ModelSamplingAuraFlow title: "ModelSamplingAuraFlow" params: shift: 3.1
connections: - from: "unet_loader:0" to: "model_sampler:model"
- from: "model_sampler:0" to: "ksampler:model" - from: "clip_loader:0" to: "pos_prompt:clip" - from: "clip_loader:0" to: "neg_prompt:clip" - from: "vae_loader:0" to: "vae_decode:vae" - from: "vae_loader:0" to: "vae_encode:vae"
- from: "pos_prompt:0" to: "ksampler:positive" - from: "neg_prompt:0" to: "ksampler:negative"
dynamic_lora_chains: lora_chain: template: "LoraLoader" output_map: "unet_loader:0": "model" "clip_loader:0": "clip" input_map: "model": "model" "clip": "clip" end_input_map: "model": ["model_sampler:model"] "clip": ["pos_prompt:clip", "neg_prompt:clip"]
dynamic_controlnet_chains: controlnet_chain: template: "ControlNetApplyAdvanced" ksampler_node: "ksampler" vae_source: "vae_loader:0"
dynamic_conditioning_chains: conditioning_chain: ksampler_node: "ksampler" clip_source: "clip_loader:0"
dynamic_qwen_image_edit_chains: qwen_image_edit_chain: ksampler_node: "ksampler" pos_prompt_node: "pos_prompt" neg_prompt_node: "neg_prompt" vae_loader_node: "vae_loader" model_sampler_node: "model_sampler"
dynamic_pid_chains: pid_chain: ksampler_node: "ksampler"
ui_map: positive_prompt: "pos_prompt:prompt" negative_prompt: "neg_prompt:prompt" unet_name: "unet_loader:unet_name" vae_name: "vae_loader:vae_name" clip_name: "clip_loader:clip_name"123456712345678imports:
- "_partials/_base_sampler_sd.yaml"
- "_partials/input/{{ task_type }}.yaml"
- "_partials/conditioning/{{ model_type }}.yaml"
connections:
- from: "latent_source:0"
imports: - "_partials/_base_sampler.yaml" - "_partials/input/{{ task_type }}.yaml" - "_partials/conditioning/{{ model_type }}.yaml"
connections: - from: "latent_source:0" to: "ksampler:latent_image"123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165import yaml
import os
import importlib
from copy import deepcopy
from comfy_integration.nodes import NODE_CLASS_MAPPINGS
class WorkflowAssembler:
def __init__(self, recipe_path, dynamic_values=None):
self.base_path = os.path.dirname(recipe_path)
self.node_counter = 0
self.workflow = {}
self.node_map = {}
self._load_injector_config()
self.recipe = self._load_and_merge_recipe(os.path.basename(recipe_path), dynamic_values or {})
def _load_injector_config(self):
try:
project_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
injectors_path = os.path.join(project_root, 'yaml', 'injectors.yaml')
with open(injectors_path, 'r', encoding='utf-8') as f:
injector_config = yaml.safe_load(f)
definitions = injector_config.get("injector_definitions", {})
self.injector_order = injector_config.get("injector_order", [])
self.global_injectors = {}
for chain_type, config in definitions.items():
module_path = config.get("module")
if not module_path:
print(f"Warning: Injector '{chain_type}' in injectors.yaml is missing 'module' path.")
continue
try:
module = importlib.import_module(module_path)
if hasattr(module, 'inject'):
self.global_injectors[chain_type] = module.inject
else:
print(f"⚠️ Warning: Module '{module_path}' for injector '{chain_type}' does not have an 'inject' function.")
except ImportError as e:
print(f"❌ Error importing module '{module_path}' for injector '{chain_type}': {e}")
if not self.injector_order:
print("⚠️ Warning: 'injector_order' is not defined in injectors.yaml. Using definition order.")
self.injector_order = list(definitions.keys())
except FileNotFoundError:
print(f"❌ FATAL: Could not find injectors.yaml at {injectors_path}. Dynamic chains will not work.")
self.injector_order = []
self.global_injectors = {}
except Exception as e:
print(f"❌ FATAL: Could not load or parse injectors.yaml. Dynamic chains will not work. Error: {e}")
self.injector_order = []
self.global_injectors = {}
def _get_unique_id(self):
self.node_counter += 1
return str(self.node_counter)
def _get_node_template(self, class_type):
if class_type not in NODE_CLASS_MAPPINGS:
raise ValueError(f"Node class '{class_type}' not found. Ensure it's correctly imported in comfy_integration/nodes.py.")
node_class = NODE_CLASS_MAPPINGS[class_type]
input_types = node_class.INPUT_TYPES()
template = {
"inputs": {},
"class_type": class_type,
"_meta": {"title": node_class.NODE_NAME if hasattr(node_class, 'NODE_NAME') else class_type}
}
all_inputs = {**input_types.get('required', {}), **input_types.get('optional', {})}
for name, details in all_inputs.items():
config = details[1] if len(details) > 1 and isinstance(details[1], dict) else {}
template["inputs"][name] = config.get("default")
return template
def _load_and_merge_recipe(self, recipe_filename, dynamic_values, search_context_dir=None):
search_path = search_context_dir or self.base_path
recipe_path_to_use = os.path.join(search_path, recipe_filename)
if not os.path.exists(recipe_path_to_use):
raise FileNotFoundError(f"Recipe file not found: {recipe_path_to_use}")
with open(recipe_path_to_use, 'r', encoding='utf-8') as f:
content = f.read()
for key, value in dynamic_values.items():
if value is not None:
content = content.replace(f"{{{{ {key} }}}}", str(value))
main_recipe = yaml.safe_load(content)
merged_recipe = {'nodes': {}, 'connections': [], 'ui_map': {}}
for key in self.injector_order:
if key.startswith('dynamic_'):
merged_recipe[key] = {}
parent_recipe_dir = os.path.dirname(recipe_path_to_use)
for import_path_template in main_recipe.get('imports', []):
import_path = import_path_template
for key, value in dynamic_values.items():
if value is not None:
import_path = import_path.replace(f"{{{{ {key} }}}}", str(value))
try:
imported_recipe = self._load_and_merge_recipe(import_path, dynamic_values, search_context_dir=parent_recipe_dir)
merged_recipe['nodes'].update(imported_recipe.get('nodes', {}))
merged_recipe['connections'].extend(imported_recipe.get('connections', []))
merged_recipe['ui_map'].update(imported_recipe.get('ui_map', {}))
for key in self.injector_order:
if key in imported_recipe and key.startswith('dynamic_'):
merged_recipe[key].update(imported_recipe.get(key, {}))
except FileNotFoundError:
print(f"Warning: Optional recipe partial '{import_path}' not found. Skipping.")
merged_recipe['nodes'].update(main_recipe.get('nodes', {}))
merged_recipe['connections'].extend(main_recipe.get('connections', []))
merged_recipe['ui_map'].update(main_recipe.get('ui_map', {}))
for key in self.injector_order:
if key in main_recipe and key.startswith('dynamic_'):
merged_recipe[key].update(main_recipe.get(key, {}))
return merged_recipe
def assemble(self, ui_values):
self.ui_values = ui_values
for name, details in self.recipe['nodes'].items():
class_type = details['class_type']
template = self._get_node_template(class_type)
node_data = deepcopy(template)
unique_id = self._get_unique_id()
self.node_map[name] = unique_id
if 'params' in details:
for param, value in details['params'].items():
if param in node_data['inputs']:
node_data['inputs'][param] = value
self.workflow[unique_id] = node_data
for ui_key, target in self.recipe.get('ui_map', {}).items():
if ui_key in ui_values and ui_values[ui_key] is not None:
target_list = target if isinstance(target, list) else [target]
for t in target_list:
target_name, target_param = t.split(':')
if target_name in self.node_map:
self.workflow[self.node_map[target_name]]['inputs'][target_param] = ui_values[ui_key]
for conn in self.recipe.get('connections', []):
from_name, from_output_idx = conn['from'].split(':')
to_name, to_input_name = conn['to'].split(':')
from_id = self.node_map.get(from_name)
to_id = self.node_map.get(to_name)
if from_id and to_id:
self.workflow[to_id]['inputs'][to_input_name] = [from_id, int(from_output_idx)]
print("--- [Assembler] Applying dynamic injectors ---")
recipe_chain_types = {key for key in self.recipe if key.startswith('dynamic_')}
processing_order = [key for key in self.injector_order if key in recipe_chain_types]
for chain_type in processing_order:
injector_func = self.global_injectors.get(chain_type)
if injector_func:
for chain_key, chain_def in self.recipe.get(chain_type, {}).items():
if chain_key in ui_values and ui_values[chain_key]:
print(f" -> Injecting '{chain_type}' for '{chain_key}'...")
chain_items = ui_values[chain_key]
injector_func(self, chain_def, chain_items)
print("--- [Assembler] Finished applying injectors ---")
import yamlimport osimport importlibfrom copy import deepcopyfrom comfy_integration.nodes import NODE_CLASS_MAPPINGSfrom chain_injectors import discover_injectors, get_registered_featuresfrom core.settings import FEATURES_CONFIG
class WorkflowAssembler: def __init__(self, recipe_path, dynamic_values=None): self.base_path = os.path.dirname(recipe_path) self.dynamic_values = dynamic_values or {} self.node_counter = 0 self.workflow = {} self.node_map = {} model_type = self.dynamic_values.get('model_type') self._load_injector_config(model_type=model_type) self.recipe = self._load_and_merge_recipe(os.path.basename(recipe_path), self.dynamic_values)
def _load_injector_config(self, model_type=None): self.global_injectors = discover_injectors() registered_features = get_registered_features()
order = [] if model_type and model_type in FEATURES_CONFIG: enabled_features = FEATURES_CONFIG[model_type].get('enabled_chains', []) for feat in enabled_features: if feat in registered_features: chain_key = registered_features[feat]['chain_type'] else: chain_key = f"dynamic_{feat}_chains" if chain_key in self.global_injectors and chain_key not in order: order.append(chain_key)
for chain_key in self.global_injectors.keys(): if chain_key not in order: order.append(chain_key)
self.injector_order = order
def _get_unique_id(self): self.node_counter += 1 return str(self.node_counter)
def _get_node_template(self, class_type): if class_type not in NODE_CLASS_MAPPINGS: raise ValueError(f"Node class '{class_type}' not found. Ensure it's correctly imported in comfy_integration/nodes.py.") node_class = NODE_CLASS_MAPPINGS[class_type] input_types = node_class.INPUT_TYPES() template = { "inputs": {}, "class_type": class_type, "_meta": {"title": node_class.NODE_NAME if hasattr(node_class, 'NODE_NAME') else class_type} } all_inputs = {**input_types.get('required', {}), **input_types.get('optional', {})} for name, details in all_inputs.items(): config = details[1] if len(details) > 1 and isinstance(details[1], dict) else {} template["inputs"][name] = config.get("default") return template
def _load_and_merge_recipe(self, recipe_filename, dynamic_values, search_context_dir=None): search_path = search_context_dir or self.base_path recipe_path_to_use = os.path.join(search_path, recipe_filename)
if not os.path.exists(recipe_path_to_use): raise FileNotFoundError(f"Recipe file not found: {recipe_path_to_use}")
with open(recipe_path_to_use, 'r', encoding='utf-8') as f: content = f.read()
for key, value in dynamic_values.items(): if value is not None: content = content.replace(f"{{{{ {key} }}}}", str(value)) main_recipe = yaml.safe_load(content) merged_recipe = {'nodes': {}, 'connections': [], 'ui_map': {}} for key in self.injector_order: if key.startswith('dynamic_'): merged_recipe[key] = {}
parent_recipe_dir = os.path.dirname(recipe_path_to_use) for import_path_template in main_recipe.get('imports', []): import_path = import_path_template for key, value in dynamic_values.items(): if value is not None: import_path = import_path.replace(f"{{{{ {key} }}}}", str(value)) try: imported_recipe = self._load_and_merge_recipe(import_path, dynamic_values, search_context_dir=parent_recipe_dir) merged_recipe['nodes'].update(imported_recipe.get('nodes', {})) merged_recipe['connections'].extend(imported_recipe.get('connections', [])) merged_recipe['ui_map'].update(imported_recipe.get('ui_map', {})) for key in self.injector_order: if key in imported_recipe and key.startswith('dynamic_'): merged_recipe[key].update(imported_recipe.get(key, {})) except FileNotFoundError: print(f"Warning: Optional recipe partial '{import_path}' not found. Skipping.")
merged_recipe['nodes'].update(main_recipe.get('nodes', {})) merged_recipe['connections'].extend(main_recipe.get('connections', [])) merged_recipe['ui_map'].update(main_recipe.get('ui_map', {})) for key in self.injector_order: if key in main_recipe and key.startswith('dynamic_'): merged_recipe[key].update(main_recipe.get(key, {})) return merged_recipe
def assemble(self, ui_values): self.ui_values = ui_values for name, details in self.recipe['nodes'].items(): class_type = details['class_type'] template = self._get_node_template(class_type) node_data = deepcopy(template) unique_id = self._get_unique_id() self.node_map[name] = unique_id if 'params' in details: for param, value in details['params'].items(): if param in node_data['inputs']: node_data['inputs'][param] = value self.workflow[unique_id] = node_data
for ui_key, target in self.recipe.get('ui_map', {}).items(): if ui_key in ui_values and ui_values[ui_key] is not None: target_list = target if isinstance(target, list) else [target] for t in target_list: target_name, target_param = t.split(':') if target_name in self.node_map: self.workflow[self.node_map[target_name]]['inputs'][target_param] = ui_values[ui_key]
for conn in self.recipe.get('connections', []): from_name, from_output_idx = conn['from'].split(':') to_name, to_input_name = conn['to'].split(':') from_id = self.node_map.get(from_name) to_id = self.node_map.get(to_name) if from_id and to_id: self.workflow[to_id]['inputs'][to_input_name] = [from_id, int(from_output_idx)] print("--- [Assembler] Applying dynamic injectors ---") recipe_chain_types = {key for key in self.recipe if key.startswith('dynamic_')} processing_order = [key for key in self.injector_order if key in recipe_chain_types]
for chain_type in processing_order: injector_func = self.global_injectors.get(chain_type) if injector_func: for chain_key, chain_def in self.recipe.get(chain_type, {}).items(): if chain_key in ui_values and ui_values[chain_key]: print(f" -> Injecting '{chain_type}' for '{chain_key}'...") chain_items = ui_values[chain_key] injector_func(self, chain_def, chain_items) print("--- [Assembler] Finished applying injectors ---") return self.workflow51 unmodified lines5253545555565758596061616263643 unmodified lines6869707171727373747575767778109 unmodified lines1881891901911911921931941951961971971981992003 unmodified lines20420520620720720820920921021121121221321451 unmodified lines architectures_dict = ARCHITECTURES_CONFIG.get('architectures', {})
arch_model_type = architectures_dict.get(m_type, {}).get("model_type", m_type.lower().replace(" ", "").replace(".", ""))
arch_features = FEATURES_CONFIG.get(arch_model_type, FEATURES_CONFIG.get('default', {}))
arch_features = FEATURES_CONFIG.get(arch_model_type, {})
enabled_chains = arch_features.get('enabled_chains', [])
if lora_acc: updates[lora_acc] = gr.update(visible=('lora' in enabled_chains))
if cn_acc: updates[cn_acc] = gr.update(visible=('controlnet' in enabled_chains))
if anima_cn_acc: updates[anima_cn_acc] = gr.update(visible=('anima_controlnet_lllite' in enabled_chains))
if diffsynth_cn_acc: updates[diffsynth_cn_acc] = gr.update(visible=('controlnet_model_patch' in enabled_chains))
if diffsynth_cn_acc: updates[diffsynth_cn_acc] = gr.update(visible=('diffsynth_controlnet' in enabled_chains))
if krea2_cn_acc: updates[krea2_cn_acc] = gr.update(visible=('krea2_controlnet' in enabled_chains))
if ipa_acc: updates[ipa_acc] = gr.update(visible=('ipadapter' in enabled_chains))
if flux1_ipa_acc: updates[flux1_ipa_acc] = gr.update(visible=('flux1_ipadapter' in enabled_chains))3 unmodified lines if cond_acc: updates[cond_acc] = gr.update(visible=('conditioning' in enabled_chains))
if ref_latent_acc: updates[ref_latent_acc] = gr.update(visible=('reference_latent' in enabled_chains))
if hidream_o1_ref_acc: updates[hidream_o1_ref_acc] = gr.update(visible=('hidream_o1_reference' in enabled_chains))
if joyai_ref_acc: updates[joyai_ref_acc] = gr.update(visible=('joyai_reference' in enabled_chains))
if joyai_ref_acc: updates[joyai_ref_acc] = gr.update(visible=('joyai_image' in enabled_chains))
if krea2_identity_edit_acc: updates[krea2_identity_edit_acc] = gr.update(visible=('krea2_identity_edit' in enabled_chains))
if krea2_reference_edit_acc: updates[krea2_reference_edit_acc] = gr.update(visible=('krea2_reference_edit' in enabled_chains))
if krea2_reference_edit_acc: updates[krea2_reference_edit_acc] = gr.update(visible=('krea2_style_reference' in enabled_chains))
if qwen_image_edit_acc: updates[qwen_image_edit_acc] = gr.update(visible=('qwen_image_edit' in enabled_chains))
if boogu_edit_acc: updates[boogu_edit_acc] = gr.update(visible=('boogu_edit' in enabled_chains))
if boogu_edit_acc: updates[boogu_edit_acc] = gr.update(visible=('boogu_image_edit' in enabled_chains))
if ref_img_acc: updates[ref_img_acc] = gr.update(visible=('reference_image' in enabled_chains))
if pid_acc: updates[pid_acc] = gr.update(visible=('pid' in enabled_chains))
if vae_acc: updates[vae_acc] = gr.update(visible=('vae' in enabled_chains))109 unmodified lines architectures_dict = ARCHITECTURES_CONFIG.get('architectures', {})
arch_model_type = architectures_dict.get(m_type, {}).get("model_type", m_type.lower().replace(" ", "").replace(".", ""))
arch_features = FEATURES_CONFIG.get(arch_model_type, FEATURES_CONFIG.get('default', {}))
arch_features = FEATURES_CONFIG.get(arch_model_type, {})
enabled_chains = arch_features.get('enabled_chains', [])
if lora_acc: updates[lora_acc] = gr.update(visible=('lora' in enabled_chains))
if cn_acc: updates[cn_acc] = gr.update(visible=('controlnet' in enabled_chains))
if anima_cn_acc: updates[anima_cn_acc] = gr.update(visible=('anima_controlnet_lllite' in enabled_chains))
if diffsynth_cn_acc: updates[diffsynth_cn_acc] = gr.update(visible=('controlnet_model_patch' in enabled_chains))
if diffsynth_cn_acc: updates[diffsynth_cn_acc] = gr.update(visible=('diffsynth_controlnet' in enabled_chains))
if krea2_cn_acc: updates[krea2_cn_acc] = gr.update(visible=('krea2_controlnet' in enabled_chains))
if ipa_acc: updates[ipa_acc] = gr.update(visible=('ipadapter' in enabled_chains))
if flux1_ipa_acc: updates[flux1_ipa_acc] = gr.update(visible=('flux1_ipadapter' in enabled_chains))3 unmodified lines if cond_acc: updates[cond_acc] = gr.update(visible=('conditioning' in enabled_chains))
if ref_latent_acc: updates[ref_latent_acc] = gr.update(visible=('reference_latent' in enabled_chains))
if hidream_o1_ref_acc: updates[hidream_o1_ref_acc] = gr.update(visible=('hidream_o1_reference' in enabled_chains))
if joyai_ref_acc: updates[joyai_ref_acc] = gr.update(visible=('joyai_reference' in enabled_chains))
if joyai_ref_acc: updates[joyai_ref_acc] = gr.update(visible=('joyai_image' in enabled_chains))
if krea2_identity_edit_acc: updates[krea2_identity_edit_acc] = gr.update(visible=('krea2_identity_edit' in enabled_chains))
if krea2_reference_edit_acc: updates[krea2_reference_edit_acc] = gr.update(visible=('krea2_reference_edit' in enabled_chains))
if krea2_reference_edit_acc: updates[krea2_reference_edit_acc] = gr.update(visible=('krea2_style_reference' in enabled_chains))
if qwen_image_edit_acc: updates[qwen_image_edit_acc] = gr.update(visible=('qwen_image_edit' in enabled_chains))
if boogu_edit_acc: updates[boogu_edit_acc] = gr.update(visible=('boogu_edit' in enabled_chains))
if boogu_edit_acc: updates[boogu_edit_acc] = gr.update(visible=('boogu_image_edit' in enabled_chains))
if ref_img_acc: updates[ref_img_acc] = gr.update(visible=('reference_image' in enabled_chains))
if pid_acc: updates[pid_acc] = gr.update(visible=('pid' in enabled_chains))
if vae_acc: updates[vae_acc] = gr.update(visible=('vae' in enabled_chains))14 unmodified lines1516171818192021275 unmodified lines297298299300300301302303396 unmodified lines700701702703703704705706126 unmodified lines83383483583683683783883922 unmodified lines86286386486586586686786814 unmodified linesdefault_m_type = MODEL_TYPE_MAP.get(default_model_name, "SDXL") if default_model_name else "SDXL"
default_architectures_dict = ARCHITECTURES_CONFIG.get('architectures', {})
default_arch_model_type = default_architectures_dict.get(default_m_type, {}).get("model_type", default_m_type.lower().replace(" ", "").replace(".", ""))
default_arch_features = FEATURES_CONFIG.get(default_arch_model_type, FEATURES_CONFIG.get('default', {}))
default_arch_features = FEATURES_CONFIG.get(default_arch_model_type, {})
default_enabled_chains = default_arch_features.get('enabled_chains', [])
default_vals = MODEL_DEFAULTS_CONFIG.get('Default', {})275 unmodified lines components = {}
key = lambda name: f"{name}_{prefix}"
with gr.Accordion("DiffSynth ControlNet Settings", open=False, visible=('controlnet_model_patch' in default_enabled_chains)) as accordion:
with gr.Accordion("DiffSynth ControlNet Settings", open=False, visible=('diffsynth_controlnet' in default_enabled_chains)) as accordion:
components[key('diffsynth_controlnet_accordion')] = accordion
cn_rows, images, series, types, strengths, filepaths = [], [], [], [], [], []396 unmodified lines components = {}
key = lambda name: f"{name}_{prefix}"
with gr.Accordion("JoyAI Reference Edit Settings", open=False, visible=('joyai_reference' in default_enabled_chains)) as ref_accordion:
with gr.Accordion("JoyAI Reference Edit Settings", open=False, visible=('joyai_image' in default_enabled_chains)) as ref_accordion:
components[key('joyai_reference_accordion')] = ref_accordion
gr.Markdown("💡 **Tip:** For multimodal models, this feature enables powerful editing and combining capabilities. In txt2img mode, adding a single reference image performs an **Image Edit** (JoyAI-Image-Edit recommended), while adding multiple images performs an **Image Combine** (JoyAI-Image-Edit-Plus recommended with ZeroGPU Duration (s) set to 120).")
126 unmodified lines components = {}
key = lambda name: f"{name}_{prefix}"
with gr.Accordion("Krea2 Style Reference Edit Settings", open=False, visible=('krea2_reference_edit' in default_enabled_chains)) as ref_accordion:
with gr.Accordion("Krea2 Style Reference Edit Settings", open=False, visible=('krea2_style_reference' in default_enabled_chains)) as ref_accordion:
components[key('krea2_reference_edit_accordion')] = ref_accordion
gr.Markdown("💡 **Tip:** (Krea-2-Turbo recommended) Add style reference images to perform style reference editing.")
22 unmodified lines components = {}
key = lambda name: f"{name}_{prefix}"
with gr.Accordion("Boogu-Image Edit Settings", open=False, visible=('boogu_edit' in default_enabled_chains)) as ref_accordion:
with gr.Accordion("Boogu-Image Edit Settings", open=False, visible=('boogu_image_edit' in default_enabled_chains)) as ref_accordion:
components[key('boogu_edit_accordion')] = ref_accordion
gr.Markdown("💡 **Tip:** (Boogu-Image-Edit-Turbo/Boogu-Image-Edit recommended, Boogu-Image-Edit need set ZeroGPU Duration (s) to 120 ) In txt2img mode, adding a single reference image performs an **Image Edit**, while adding multiple images performs an **Image Combine**.")
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200default:
enabled_chains:
- lora
- controlnet
- ipadapter
- embedding
- style
- conditioning
- vae
mage-flow:
enabled_chains:
- reference_image
joyai-image:
enabled_chains:
- joyai_reference
krea-2:
enabled_chains:
- lora
- krea2_controlnet
- krea2_identity_edit
- krea2_reference_edit
- pid
boogu-image:
enabled_chains:
- lora
- boogu_edit
- pid
pixeldit:
enabled_chains:
- conditioning
ideogram-4:
enabled_chains:
- vae
- pid
lens:
enabled_chains:
- conditioning
- pid
flux2-kv:
enabled_chains:
- lora
- conditioning
- reference_latent
- vae
- pid
flux2:
enabled_chains:
- lora
- conditioning
- reference_latent
- vae
- pid
ernie-image:
enabled_chains:
- conditioning
- pid
z-image:
enabled_chains:
- lora
- conditioning
- controlnet_model_patch
- vae
- pid
qwen-image:
enabled_chains:
- lora
- controlnet
- conditioning
- qwen_image_edit
- vae
- pid
longcat-image:
enabled_chains:
- lora
- conditioning
- pid
cosmos-predict2:
enabled_chains:
- conditioning
- vae
anima:
enabled_chains:
- lora
- anima_controlnet_lllite
- conditioning
- vae
- pid
newbie-image:
enabled_chains:
- lora
- embedding
- conditioning
- vae
- pid
kandinsky-5:
enabled_chains:
- conditioning
- vae
- pid
ovis-image:
enabled_chains:
- conditioning
- vae
- pid
hunyuanimage:
enabled_chains:
- conditioning
- vae
chroma1-radiance:
enabled_chains:
- conditioning
chroma1:
enabled_chains:
- conditioning
- vae
- pid
omnigen2:
enabled_chains:
- conditioning
- reference_latent
- pid
lumina:
enabled_chains:
- lora
- embedding
- conditioning
- vae
- pid
hidream-o1:
enabled_chains:
- lora
- conditioning
- hidream_o1_reference
hidream-i1:
enabled_chains:
- lora
- conditioning
- pid
flux1:
enabled_chains:
- lora
- controlnet
- style
- conditioning
- flux1_ipadapter
- vae
- pid
auraflow:
enabled_chains:
- lora
- conditioning
- vae
sd35:
enabled_chains:
- lora
- controlnet
- embedding
- conditioning
- sd3_ipadapter
- vae
- pid
sdxl:
enabled_chains:
- lora
- controlnet
- ipadapter
- embedding
- conditioning
- vae
- pid
sd15:
enabled_chains:
- lora
- controlnet
- ipadapter
- embedding
- conditioning
# Feature names in enabled_chains correspond 1-to-1 with chain_injectors/<name>_injector.pykrea-2: enabled_chains: - lora - krea2_controlnet - krea2_identity_edit - krea2_style_reference - pid
mage-flow: enabled_chains: - reference_image
joyai-image: enabled_chains: - joyai_image
boogu-image: enabled_chains: - lora - boogu_image_edit - pid
pixeldit: enabled_chains: - conditioning
ideogram-4: enabled_chains: - vae - pid
lens: enabled_chains: - conditioning - pid
flux2-kv: enabled_chains: - lora - reference_latent - conditioning - vae - pid
flux2: enabled_chains: - lora - reference_latent - conditioning - vae - pid
ernie-image: enabled_chains: - conditioning - pid
z-image: enabled_chains: - lora - diffsynth_controlnet - conditioning - vae - pid
qwen-image: enabled_chains: - lora - conditioning - controlnet - qwen_image_edit - vae - pid
longcat-image: enabled_chains: - lora - conditioning - pid
cosmos-predict2: enabled_chains: - conditioning - vae
anima: enabled_chains: - lora - conditioning - anima_controlnet_lllite - vae - pid
newbie-image: enabled_chains: - lora - embedding - conditioning - vae - pid
kandinsky-5: enabled_chains: - conditioning - vae - pid
ovis-image: enabled_chains: - conditioning - vae - pid
hunyuanimage: enabled_chains: - conditioning - vae
chroma1-radiance: enabled_chains: - conditioning
chroma1: enabled_chains: - conditioning - vae - pid
omnigen2: enabled_chains: - reference_latent - conditioning - pid
lumina: enabled_chains: - lora - embedding - conditioning - vae - pid
hidream-o1: enabled_chains: - lora - conditioning - hidream_o1_smoothing - hidream_o1_reference
hidream-i1: enabled_chains: - lora - conditioning - pid
flux1: enabled_chains: - lora - flux1_ipadapter - conditioning - style - controlnet - vae - pid
auraflow: enabled_chains: - lora - conditioning - vae
sd35: enabled_chains: - lora - sd3_ipadapter - embedding - conditioning - controlnet - vae - pid
sdxl: enabled_chains: - lora - ipadapter - embedding - conditioning - controlnet - vae - pid
sd15: enabled_chains: - lora - ipadapter - embedding - conditioning - controlnet - vae123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869injector_definitions:
dynamic_vae_chains:
module: "chain_injectors.vae_injector"
dynamic_lora_chains:
module: "chain_injectors.lora_injector"
dynamic_newbie_lora_chains:
module: "chain_injectors.newbie_lora_injector"
dynamic_controlnet_chains:
module: "chain_injectors.controlnet_injector"
dynamic_krea2_controlnet_chains:
module: "chain_injectors.krea2_controlnet_injector"
dynamic_anima_controlnet_lllite_chains:
module: "chain_injectors.anima_controlnet_lllite_injector"
dynamic_diffsynth_controlnet_chains:
module: "chain_injectors.diffsynth_controlnet_injector"
dynamic_ipadapter_chains:
module: "chain_injectors.ipadapter_injector"
dynamic_flux1_ipadapter_chains:
module: "chain_injectors.flux1_ipadapter_injector"
dynamic_sd3_ipadapter_chains:
module: "chain_injectors.sd3_ipadapter_injector"
dynamic_reference_latent_chains:
module: "chain_injectors.reference_latent_injector"
dynamic_conditioning_chains:
module: "chain_injectors.conditioning_injector"
dynamic_style_chains:
module: "chain_injectors.style_injector"
dynamic_hidream_o1_smoothing_chains:
module: "chain_injectors.hidream_o1_smoothing_injector"
dynamic_hidream_o1_reference_chains:
module: "chain_injectors.hidream_o1_reference_injector"
dynamic_joyai_reference_chains:
module: "chain_injectors.joyai_reference_injector"
dynamic_krea2_identity_edit_chains:
module: "chain_injectors.krea2_identity_edit_injector"
dynamic_krea2_reference_edit_chains:
module: "chain_injectors.krea2_reference_edit_injector"
dynamic_qwen_image_edit_chains:
module: "chain_injectors.qwen_image_edit_injector"
dynamic_boogu_edit_chains:
module: "chain_injectors.boogu_edit_injector"
dynamic_reference_image_chains:
module: "chain_injectors.reference_image_injector"
dynamic_pid_chains:
module: "chain_injectors.pid_injector"
injector_order:
- dynamic_vae_chains
- dynamic_lora_chains
- dynamic_newbie_lora_chains
- dynamic_diffsynth_controlnet_chains
- dynamic_ipadapter_chains
- dynamic_flux1_ipadapter_chains
- dynamic_sd3_ipadapter_chains
- dynamic_reference_latent_chains
- dynamic_conditioning_chains
- dynamic_style_chains
- dynamic_controlnet_chains
- dynamic_krea2_controlnet_chains
- dynamic_krea2_identity_edit_chains
- dynamic_krea2_reference_edit_chains
- dynamic_qwen_image_edit_chains
- dynamic_boogu_edit_chains
- dynamic_anima_controlnet_lllite_chains
- dynamic_hidream_o1_smoothing_chains
- dynamic_hidream_o1_reference_chains
- dynamic_joyai_reference_chains
- dynamic_reference_image_chains
- dynamic_pid_chainschain_injectors/__init__.py+50
chain_injectors/boogu_edit_injector.py → chain_injectors/boogu_image_edit_injector.pyRenamed+17-72
chain_injectors/joyai_reference_injector.py → chain_injectors/joyai_image_injector.pyRenamed
chain_injectors/krea2_reference_edit_injector.py → chain_injectors/krea2_style_reference_injector.pyRenamed
chain_injectors/newbie_lora_injector.pyDeleted-63
chain_injectors/qwen_image_edit_injector.py+17-74
comfy_integration/setup.py+2-10
core/pipelines/sd_image_pipeline.py+4-4
core/pipelines/workflow_recipes/_partials/_base_sampler_sd.yaml → core/pipelines/workflow_recipes/_partials/_base_sampler.yamlRenamed+27-27
core/pipelines/workflow_recipes/_partials/conditioning/boogu-image.yaml+67-74
core/pipelines/workflow_recipes/_partials/conditioning/joyai-image.yaml+2-2
core/pipelines/workflow_recipes/_partials/conditioning/krea-2.yaml+2-2
core/pipelines/workflow_recipes/_partials/conditioning/newbie-image.yaml+2-2
core/pipelines/workflow_recipes/_partials/conditioning/qwen-image.yaml+90-91
core/pipelines/workflow_recipes/sd_unified_recipe.yaml → core/pipelines/workflow_recipes/unified_recipe.yamlRenamed+7-7
core/workflow_assembler.py+164-178
ui/events/change_handlers.py+10-10
ui/shared/ui_components.py+5-5
yaml/image_gen_features.yaml+199-207
yaml/injectors.yamlDeleted-69