Spaces:
Running on Zero
Running on Zero
refactor(injectors): consolidate boogu and qwen-2.1 into reference_image with flexible max_images
Browse filesFiles changed (17)
- chain_injectors/boogu_image_edit_injector.pyDeleted-73
- chain_injectors/qwen_image_2_1_edit_injector.pyDeleted-73
- chain_injectors/reference_image_injector.py+48-22
- core/pipelines/pipeline_input_processor.py-24
- core/pipelines/sd_image_pipeline.py-4
- core/pipelines/workflow_recipes/_partials/conditioning/boogu-image.yaml+5-5
- core/pipelines/workflow_recipes/_partials/conditioning/qwen-image-2.1.yaml+5-4
- mcp_tools/common.py+1-7
- ui/events/chain_handlers.py+1-67
- ui/events/change_handlers.py+2-6
- ui/events/main.py+3-15
- ui/events/run_handlers.py+1-5
- ui/imagegen_ui.py+1-3
- ui/shared/ui_components.py+3-61
- yaml/chain_features.yaml+2-30
- yaml/model_architecture_features.yaml+2-2
- yaml/task_features.yaml-10
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273def create_node(assembler, class_type, title):
try:
node = assembler._get_node_template(class_type)
except Exception:
node = {
"inputs": {},
"class_type": class_type,
"_meta": {"title": title}
}
node['_meta']['title'] = title
return node
def inject(assembler, chain_definition, chain_items):
if not chain_items:
return
valid_images = []
for item in chain_items:
if not item:
continue
img_path = item
if isinstance(item, dict):
img_path = item.get('image') or item.get('filename') or item.get('path')
if img_path:
valid_images.append(img_path)
if not valid_images:
return
valid_images = valid_images[:10]
boogu_prompt_name = chain_definition.get('boogu_prompt_node', 'boogu_prompt')
vae_loader_name = chain_definition.get('vae_loader_node', 'vae_loader')
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 not boogu_prompt_id:
print(f"Warning: Target node '{boogu_prompt_name}' (TextEncodeBooguEdit) for Boogu Edit chain not found. Skipping.")
return
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_id = node_id
break
if vae_id:
assembler.workflow[boogu_prompt_id]['inputs']['vae'] = [vae_id, 0]
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}")
load_node['inputs']['image'] = img_filename
assembler.workflow[load_id] = load_node
scale_id = assembler._get_unique_id()
scale_node = create_node(assembler, "ImageScaleToTotalPixels", f"Scale Reference {i+1}")
scale_node['inputs']['upscale_method'] = "nearest-exact"
scale_node['inputs']['megapixels'] = 1
scale_node['inputs']['resolution_steps'] = 1
scale_node['inputs']['image'] = [load_id, 0]
assembler.workflow[scale_id] = scale_node
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). Connected VAE dynamically.")12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273def create_node(assembler, class_type, title): try: node = assembler._get_node_template(class_type) except Exception: node = { "inputs": {}, "class_type": class_type, "_meta": {"title": title} } node['_meta']['title'] = title return node
def inject(assembler, chain_definition, chain_items): if not chain_items: return
valid_images = [] for item in chain_items: if not item: continue img_path = item if isinstance(item, dict): img_path = item.get('image') or item.get('filename') or item.get('path') if img_path: valid_images.append(img_path)
if not valid_images: return
valid_images = valid_images[:10]
prompt_name = chain_definition.get('prompt_node', 'prompt') vae_loader_name = chain_definition.get('vae_loader_node', 'vae_loader')
prompt_id = assembler.node_map.get(prompt_name) if not prompt_id or prompt_id not in assembler.workflow: for node_id, node in assembler.workflow.items(): if isinstance(node, dict) and node.get('class_type') == 'TextEncodeQwenImage21': prompt_id = node_id break
if not prompt_id: print(f"Warning: Target node '{prompt_name}' (TextEncodeQwenImage21) for Qwen-Image-2.1 Edit chain not found. Skipping.") return
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_id = node_id break
if vae_id: assembler.workflow[prompt_id]['inputs']['vae'] = [vae_id, 0]
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}") load_node['inputs']['image'] = img_filename assembler.workflow[load_id] = load_node
scale_id = assembler._get_unique_id() scale_node = create_node(assembler, "ImageScaleToTotalPixels", f"Scale Reference {i+1}") scale_node['inputs']['upscale_method'] = "nearest-exact" scale_node['inputs']['megapixels'] = 1 scale_node['inputs']['resolution_steps'] = 1 scale_node['inputs']['image'] = [load_id, 0] assembler.workflow[scale_id] = scale_node
image_key = f"images.image_{i+1}" assembler.workflow[prompt_id]['inputs'][image_key] = [scale_id, 0]
print(f"Qwen-Image-2.1 Edit injector applied with {len(valid_images)} reference image(s). Connected VAE dynamically.")11234567891011121314151612 unmodified lines2930312021222324323334353637383940414243444546472627484950513031525354555634575836596061626364654366676869707172734774754976777853545556798081828358848586628788648990import os
def create_node(assembler, class_type, title):
try:
node = assembler._get_node_template(class_type)
except Exception:
node = {
"inputs": {},
"class_type": class_type,
"_meta": {"title": title}
}
if "_meta" not in node:
node["_meta"] = {}
node['_meta']['title'] = title
return node
def inject(assembler, chain_definition, chain_items):
if not chain_items:12 unmodified lines if not valid_images:
return
text_encode_name = chain_definition.get('text_encode_node')
text_encode_id = None
if text_encode_name and text_encode_name in assembler.node_map:
text_encode_id = assembler.node_map[text_encode_name]
else:
max_images = chain_definition.get('max_images', 10)
if isinstance(max_images, int) and max_images > 0:
valid_images = valid_images[:max_images]
# Target prompt/text_encode node resolution
target_node_name = (
chain_definition.get('text_encode_node')
or chain_definition.get('prompt_node')
or chain_definition.get('boogu_prompt_node')
or 'prompt'
)
target_node_id = assembler.node_map.get(target_node_name)
if not target_node_id or target_node_id not in assembler.workflow:
supported_types = ('TextEncodeMageFlowEdit', 'TextEncodeQwenImage21', 'TextEncodeBooguEdit')
for node_id, node in assembler.workflow.items():
if isinstance(node, dict) and node.get('class_type') == 'TextEncodeMageFlowEdit':
text_encode_id = node_id
if isinstance(node, dict) and node.get('class_type') in supported_types:
target_node_id = node_id
break
if not text_encode_id or text_encode_id not in assembler.workflow:
print("Warning: TextEncodeMageFlowEdit node not found for Reference Image chain. Skipping.")
if not target_node_id or target_node_id not in assembler.workflow:
print(f"Warning: Target text encode node '{target_node_name}' for Reference Image chain not found. Skipping.")
return
# VAE loader node resolution
vae_node_name = chain_definition.get('vae_node', 'vae_loader')
vae_node_name = chain_definition.get('vae_node') or chain_definition.get('vae_loader_node', 'vae_loader')
vae_node_id = assembler.node_map.get(vae_node_name)
if not vae_node_id:
if not vae_node_id or vae_node_id not in assembler.workflow:
for node_id, node in assembler.workflow.items():
if isinstance(node, dict) and node.get('class_type') == 'VAELoader':
vae_node_id = node_id
break
if vae_node_id:
assembler.workflow[text_encode_id]['inputs']['vae'] = [vae_node_id, 0]
assembler.workflow[target_node_id]['inputs']['vae'] = [vae_node_id, 0]
upscale_method = chain_definition.get('upscale_method', 'nearest-exact')
megapixels = chain_definition.get('megapixels', 1.0)
resolution_steps = chain_definition.get('resolution_steps', 1)
for i, img_filename in enumerate(valid_images):
load_id = assembler._get_unique_id()
load_node = assembler._get_node_template("LoadImage")
load_node = create_node(assembler, "LoadImage", f"Load Reference Image {i+1}")
load_node['inputs']['image'] = img_filename
load_node['_meta']['title'] = f"Load Reference Image {i+1}"
assembler.workflow[load_id] = load_node
scale_id = assembler._get_unique_id()
scale_node = assembler._get_node_template("ImageScaleToTotalPixels")
scale_node['inputs']['megapixels'] = 1.0
scale_node['inputs']['upscale_method'] = "nearest-exact"
scale_node['inputs']['resolution_steps'] = 1
scale_node = create_node(assembler, "ImageScaleToTotalPixels", f"Scale Reference {i+1}")
scale_node['inputs']['upscale_method'] = upscale_method
scale_node['inputs']['megapixels'] = megapixels
scale_node['inputs']['resolution_steps'] = resolution_steps
scale_node['inputs']['image'] = [load_id, 0]
scale_node['_meta']['title'] = f"Scale Reference {i+1}"
assembler.workflow[scale_id] = scale_node
input_key = f"images.image_{i+1}"
assembler.workflow[text_encode_id]['inputs'][input_key] = [scale_id, 0]
assembler.workflow[target_node_id]['inputs'][input_key] = [scale_id, 0]
print(f"Reference Image injector applied. Injected {len(valid_images)} reference images to TextEncodeMageFlowEdit node '{text_encode_id}'.") node_class = assembler.workflow[target_node_id].get('class_type', 'Unknown')
print(f"Reference Image injector applied: {len(valid_images)} image(s) injected into '{target_node_id}' ({node_class}), max_images={max_images}.")411 unmodified lines41241341441541641741841942042142242342442542642742842943043143243343443543641541641757 unmodified lines475476477500501478479480411 unmodified lines temp_files_to_clean.append(temp_path)
active_qwen_image_edit.append(os.path.basename(temp_path))
boogu_edit_data = ui_inputs.get('boogu_edit_data', [])
active_boogu_edit = []
if 'boogu_image_edit' in enabled_chains and boogu_edit_data:
for img in boogu_edit_data:
if img:
if not os.path.exists(INPUT_DIR): os.makedirs(INPUT_DIR)
temp_path = os.path.join(INPUT_DIR, f"temp_boogu_edit_ref_{random.randint(1000, 9999)}.png")
img.save(temp_path, "PNG")
temp_files_to_clean.append(temp_path)
active_boogu_edit.append(os.path.basename(temp_path))
qwen_image_2_1_edit_data = ui_inputs.get('qwen_image_2_1_edit_data', [])
active_qwen_image_2_1_edit = []
if 'qwen_image_2_1_edit' in enabled_chains and qwen_image_2_1_edit_data:
for img in qwen_image_2_1_edit_data:
if img:
if not os.path.exists(INPUT_DIR): os.makedirs(INPUT_DIR)
temp_path = os.path.join(INPUT_DIR, f"temp_qwen21_edit_ref_{random.randint(1000, 9999)}.png")
img.save(temp_path, "PNG")
temp_files_to_clean.append(temp_path)
active_qwen_image_2_1_edit.append(os.path.basename(temp_path))
reference_image_data = ui_inputs.get('reference_image_data', [])
active_reference_images = []
if 'reference_image' in enabled_chains and reference_image_data:57 unmodified lines "active_krea2_identity_edit": active_krea2_identity_edit,
"active_krea2_reference_edit": active_krea2_reference_edit,
"active_qwen_image_edit": active_qwen_image_edit,
"active_qwen_image_2_1_edit": active_qwen_image_2_1_edit,
"active_boogu_edit": active_boogu_edit,
"active_reference_images": active_reference_images,
"active_conditioning": active_conditioning,
"temp_files_to_clean": temp_files_to_clean119 unmodified lines12012112212312412312412555 unmodified lines181182183186187184185186119 unmodified lines active_krea2_identity_edit = processed.get("active_krea2_identity_edit", [])
active_krea2_reference_edit = processed.get("active_krea2_reference_edit", [])
active_qwen_image_edit = processed.get("active_qwen_image_edit", [])
active_qwen_image_2_1_edit = processed.get("active_qwen_image_2_1_edit", [])
active_boogu_edit = processed.get("active_boogu_edit", [])
active_reference_images = processed.get("active_reference_images", [])
active_conditioning = processed["active_conditioning"]
55 unmodified lines "krea2_identity_edit_chain": active_krea2_identity_edit,
"krea2_style_reference_chain": active_krea2_reference_edit,
"qwen_image_edit_chain": active_qwen_image_edit,
"qwen_image_2_1_edit_chain": active_qwen_image_2_1_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') and 'vae' in enabled_chains) else [],
"hidream_o1_smoothing_chain": hidream_o1_smoothing_data,48 unmodified lines4950515253545556525354555657585948 unmodified lines 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_reference_image_chains:
reference_image_chain:
text_encode_node: "boogu_prompt"
vae_node: "vae_loader"
max_images: 10
dynamic_pid_chains:
pid_chain:63 unmodified lines64656667686970676869707172737463 unmodified lines pid_chain: ksampler_node: "ksampler"
dynamic_qwen_image_2_1_edit_chains: qwen_image_2_1_edit_chain: prompt_node: "prompt" vae_loader_node: "vae_loader"dynamic_reference_image_chains: reference_image_chain: text_encode_node: "prompt" vae_node: "vae_loader" max_images: 10
ui_map: positive_prompt: "prompt:prompt"446 unmodified lines447448449450450451452229 unmodified lines6826836846866856866876881 unmodified line69069169269469569669769369469556 unmodified lines752753754760755756757446 unmodified lines reference_latent_data = []
reference_image_data = []
joyai_reference_data = []
boogu_edit_data = []
qwen_image_edit_data = []
hidream_o1_reference_data = []
sensenova_reference_data = []229 unmodified lines img = _parse_image_param(item.get("image"))
if img:
reference_latent_data.append(img)
elif itype in ("reference_image", "mage_flow_reference_edit"):
elif itype in ("reference_image", "mage_flow_reference_edit", "boogu_image_edit", "boogu_edit", "qwen_image_2_1_edit"):
img = _parse_image_param(item.get("image"))
if img:
reference_image_data.append(img)1 unmodified line img = _parse_image_param(item.get("image"))
if img:
joyai_reference_data.append(img)
elif itype in ("boogu_image_edit", "boogu_edit"):
img = _parse_image_param(item.get("image"))
if img:
boogu_edit_data.append(img)
elif itype == "qwen_image_edit":
img = _parse_image_param(item.get("image"))
if img:56 unmodified lines if reference_latent_data: ui_inputs["reference_latent_data"] = reference_latent_data
if reference_image_data: ui_inputs["reference_image_data"] = reference_image_data
if joyai_reference_data: ui_inputs["joyai_reference_data"] = joyai_reference_data
if boogu_edit_data: ui_inputs["boogu_edit_data"] = boogu_edit_data
if qwen_image_edit_data: ui_inputs["qwen_image_edit_data"] = qwen_image_edit_data
if hidream_o1_reference_data: ui_inputs["hidream_o1_reference_data"] = hidream_o1_reference_data
if sensenova_reference_data: ui_inputs["sensenova_reference_data"] = sensenova_reference_data987 unmodified lines9889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057991987 unmodified lines add_outputs = [count_state, add_button, del_button] + ref_rows
del_outputs = [count_state, add_button, del_button] + ref_rows + images
add_button.click(fn=add_ref_row, inputs=[count_state], outputs=add_outputs, show_progress=False)
del_button.click(fn=del_ref_row, inputs=[count_state], outputs=del_outputs, show_progress=False)
def create_boogu_edit_event_handlers(prefix, ui_components, max_units=10):
ref_rows = ui_components.get(f'boogu_edit_rows_{prefix}')
if not ref_rows: return
count_state = ui_components[f'boogu_edit_count_state_{prefix}']
add_button = ui_components[f'add_boogu_edit_button_{prefix}']
del_button = ui_components[f'delete_boogu_edit_button_{prefix}']
images = ui_components[f'boogu_edit_images_{prefix}']
def add_ref_row(c):
c += 1
return {
count_state: c,
ref_rows[c - 1]: gr.update(visible=True),
add_button: gr.update(visible=c < max_units),
del_button: gr.update(visible=True),
}
def del_ref_row(c):
c -= 1
return {
count_state: c,
ref_rows[c]: gr.update(visible=False),
images[c]: None,
add_button: gr.update(visible=True),
del_button: gr.update(visible=c > 1),
}
add_outputs = [count_state, add_button, del_button] + ref_rows
del_outputs = [count_state, add_button, del_button] + ref_rows + images
add_button.click(fn=add_ref_row, inputs=[count_state], outputs=add_outputs, show_progress=False)
del_button.click(fn=del_ref_row, inputs=[count_state], outputs=del_outputs, show_progress=False)
def create_qwen_image_2_1_edit_event_handlers(prefix, ui_components, max_units=10):
ref_rows = ui_components.get(f'qwen_image_2_1_edit_rows_{prefix}')
if not ref_rows: return
count_state = ui_components[f'qwen_image_2_1_edit_count_state_{prefix}']
add_button = ui_components[f'add_qwen_image_2_1_edit_button_{prefix}']
del_button = ui_components[f'delete_qwen_image_2_1_edit_button_{prefix}']
images = ui_components[f'qwen_image_2_1_edit_images_{prefix}']
def add_ref_row(c):
c += 1
return {
count_state: c,
ref_rows[c - 1]: gr.update(visible=True),
add_button: gr.update(visible=c < max_units),
del_button: gr.update(visible=True),
}
def del_ref_row(c):
c -= 1
return {
count_state: c,
ref_rows[c]: gr.update(visible=False),
images[c]: None,
add_button: gr.update(visible=True),
del_button: gr.update(visible=c > 1),
}
add_outputs = [count_state, add_button, del_button] + ref_rows
del_outputs = [count_state, add_button, del_button] + ref_rows + images
add_button.click(fn=add_ref_row, inputs=[count_state], outputs=add_outputs, show_progress=False)
del_button.click(fn=del_ref_row, inputs=[count_state], outputs=del_outputs, show_progress=False) del_button.click(fn=del_ref_row, inputs=[count_state], outputs=del_outputs, show_progress=False)
17 unmodified lines181920212122232462 unmodified lines878889909190919264 unmodified lines15715815916216016116216370 unmodified lines23423523623924023723823917 unmodified lines load_ipadapter_config
)
def make_update_fn(m_comp, cat_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, prompt_comp, neg_prompt_comp, steps_comp, cfg_comp, sampler_comp, scheduler_comp, pid_acc=None, vae_acc=None, joyai_ref_acc=None, krea2_identity_edit_acc=None, krea2_reference_edit_acc=None, qwen_image_edit_acc=None, qwen_image_2_1_edit_acc=None, boogu_edit_acc=None, ref_img_acc=None, sensenova_ref_acc=None, task_type=None, type_comp=None):
def make_update_fn(m_comp, cat_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, prompt_comp, neg_prompt_comp, steps_comp, cfg_comp, sampler_comp, scheduler_comp, pid_acc=None, vae_acc=None, joyai_ref_acc=None, krea2_identity_edit_acc=None, krea2_reference_edit_acc=None, qwen_image_edit_acc=None, ref_img_acc=None, sensenova_ref_acc=None, task_type=None, type_comp=None):
def update_fn(*args):
arch = args[0]
category = args[1]62 unmodified lines 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_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 qwen_image_2_1_edit_acc: updates[qwen_image_2_1_edit_acc] = gr.update(visible=('qwen_image_2_1_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))64 unmodified lines return update_fn
def make_model_change_fn(cat_comp_ref, 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, prompt_comp, neg_prompt_comp, steps_comp, cfg_comp, sampler_comp, scheduler_comp, pid_acc=None, vae_acc=None, joyai_ref_acc=None, krea2_identity_edit_acc=None, krea2_reference_edit_acc=None, qwen_image_edit_acc=None, qwen_image_2_1_edit_acc=None, boogu_edit_acc=None, ref_img_acc=None, sensenova_ref_acc=None, task_type=None, type_comp=None):
def make_model_change_fn(cat_comp_ref, 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, prompt_comp, neg_prompt_comp, steps_comp, cfg_comp, sampler_comp, scheduler_comp, pid_acc=None, vae_acc=None, joyai_ref_acc=None, krea2_identity_edit_acc=None, krea2_reference_edit_acc=None, qwen_image_edit_acc=None, ref_img_acc=None, sensenova_ref_acc=None, task_type=None, type_comp=None):
def change_fn(*args):
model_name = args[0]
idx = 170 unmodified lines 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_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 qwen_image_2_1_edit_acc: updates[qwen_image_2_1_edit_acc] = gr.update(visible=('qwen_image_2_1_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))17 unmodified lines181920212221222353 unmodified lines777879828380818235 unmodified lines1181191201251261211221239 unmodified lines13313413514213613713813931 unmodified lines17117217318018117417517614 unmodified lines19119219320219419519619718 unmodified lines21621721822722821922022163 unmodified lines28528628729829928828929031 unmodified lines32232332433732532632732817 unmodified lines create_krea2_identity_edit_event_handlers,
create_krea2_reference_edit_event_handlers,
create_qwen_image_edit_event_handlers,
create_qwen_image_2_1_edit_event_handlers,
create_boogu_edit_event_handlers,
create_reference_image_event_handlers
)
from .change_handlers import (53 unmodified lines krea2_identity_edit_accordion = ui_components.get(f'krea2_identity_edit_accordion_{prefix}')
krea2_reference_edit_accordion = ui_components.get(f'krea2_reference_edit_accordion_{prefix}')
qwen_image_edit_accordion = ui_components.get(f'qwen_image_edit_accordion_{prefix}')
qwen_image_2_1_edit_accordion = ui_components.get(f'qwen_image_2_1_edit_accordion_{prefix}')
boogu_edit_accordion = ui_components.get(f'boogu_edit_accordion_{prefix}')
ref_img_accordion = ui_components.get(f'reference_image_accordion_{prefix}')
pid_accordion = ui_components.get(f'pid_accordion_{prefix}')
vae_accordion = ui_components.get(f'vae_accordion_{prefix}')35 unmodified lines if krea2_identity_edit_accordion: outputs.append(krea2_identity_edit_accordion)
if krea2_reference_edit_accordion: outputs.append(krea2_reference_edit_accordion)
if qwen_image_edit_accordion: outputs.append(qwen_image_edit_accordion)
if qwen_image_2_1_edit_accordion: outputs.append(qwen_image_2_1_edit_accordion)
if boogu_edit_accordion: outputs.append(boogu_edit_accordion)
if ref_img_accordion: outputs.append(ref_img_accordion)
if pid_accordion: outputs.append(pid_accordion)
if vae_accordion: outputs.append(vae_accordion)9 unmodified lines krea2_cn_types_list, krea2_cn_series_list, krea2_cn_filepaths_list,
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,
ref_latent_accordion, hidream_o1_ref_accordion, prompt_comp, neg_prompt_comp, steps_comp, cfg_comp, sampler_comp, scheduler_comp,
pid_acc=pid_accordion, vae_acc=vae_accordion, joyai_ref_acc=joyai_ref_accordion, krea2_identity_edit_acc=krea2_identity_edit_accordion, krea2_reference_edit_acc=krea2_reference_edit_accordion, qwen_image_edit_acc=qwen_image_edit_accordion, qwen_image_2_1_edit_acc=qwen_image_2_1_edit_accordion, boogu_edit_acc=boogu_edit_accordion, ref_img_acc=ref_img_accordion, sensenova_ref_acc=sensenova_ref_accordion,
pid_acc=pid_accordion, vae_acc=vae_accordion, joyai_ref_acc=joyai_ref_accordion, krea2_identity_edit_acc=krea2_identity_edit_accordion, krea2_reference_edit_acc=krea2_reference_edit_accordion, qwen_image_edit_acc=qwen_image_edit_accordion, ref_img_acc=ref_img_accordion, sensenova_ref_acc=sensenova_ref_accordion,
task_type=task_type, type_comp=type_comp
)
inputs = [arch_comp, cat_comp]31 unmodified lines if krea2_identity_edit_accordion: outputs2.append(krea2_identity_edit_accordion)
if krea2_reference_edit_accordion: outputs2.append(krea2_reference_edit_accordion)
if qwen_image_edit_accordion: outputs2.append(qwen_image_edit_accordion)
if qwen_image_2_1_edit_accordion: outputs2.append(qwen_image_2_1_edit_accordion)
if boogu_edit_accordion: outputs2.append(boogu_edit_accordion)
if ref_img_accordion: outputs2.append(ref_img_accordion)
if pid_accordion: outputs2.append(pid_accordion)
if vae_accordion: outputs2.append(vae_accordion)14 unmodified lines krea2_cn_types_list, krea2_cn_series_list, krea2_cn_filepaths_list,
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,
ref_latent_accordion, hidream_o1_ref_accordion, prompt_comp, neg_prompt_comp, steps_comp, cfg_comp, sampler_comp, scheduler_comp,
pid_acc=pid_accordion, vae_acc=vae_accordion, joyai_ref_acc=joyai_ref_accordion, krea2_identity_edit_acc=krea2_identity_edit_accordion, krea2_reference_edit_acc=krea2_reference_edit_accordion, qwen_image_edit_acc=qwen_image_edit_accordion, qwen_image_2_1_edit_acc=qwen_image_2_1_edit_accordion, boogu_edit_acc=boogu_edit_accordion, ref_img_acc=ref_img_accordion, sensenova_ref_acc=sensenova_ref_accordion,
pid_acc=pid_accordion, vae_acc=vae_accordion, joyai_ref_acc=joyai_ref_accordion, krea2_identity_edit_acc=krea2_identity_edit_accordion, krea2_reference_edit_acc=krea2_reference_edit_accordion, qwen_image_edit_acc=qwen_image_edit_accordion, ref_img_acc=ref_img_accordion, sensenova_ref_acc=sensenova_ref_accordion,
task_type=task_type, type_comp=type_comp
)
if type_comp:18 unmodified lines create_krea2_identity_edit_event_handlers(prefix, ui_components)
create_krea2_reference_edit_event_handlers(prefix, ui_components)
create_qwen_image_edit_event_handlers(prefix, ui_components)
create_qwen_image_2_1_edit_event_handlers(prefix, ui_components)
create_boogu_edit_event_handlers(prefix, ui_components)
create_reference_image_event_handlers(prefix, ui_components)
create_run_event(prefix, task_type, ui_components)
63 unmodified lines f'krea2_identity_edit_accordion_{prefix}': 'krea2_identity_edit',
f'krea2_reference_edit_accordion_{prefix}': 'krea2_style_reference',
f'qwen_image_edit_accordion_{prefix}': 'qwen_image_edit',
f'qwen_image_2_1_edit_accordion_{prefix}': 'qwen_image_2_1_edit',
f'boogu_edit_accordion_{prefix}': 'boogu_image_edit',
f'reference_image_accordion_{prefix}': 'reference_image',
f'pid_accordion_{prefix}': 'pid',
f'vae_accordion_{prefix}': 'vae',31 unmodified lines 'conditioning_accordion_imagegen', 'reference_latent_accordion_imagegen',
'hidream_o1_reference_accordion_imagegen', 'sensenova_reference_accordion_imagegen', 'joyai_reference_accordion_imagegen',
'krea2_identity_edit_accordion_imagegen', 'krea2_reference_edit_accordion_imagegen',
'qwen_image_edit_accordion_imagegen', 'qwen_image_2_1_edit_accordion_imagegen', 'boogu_edit_accordion_imagegen',
'qwen_image_edit_accordion_imagegen',
'reference_image_accordion_imagegen', 'pid_accordion_imagegen', 'vae_accordion_imagegen',
]
for key in accordion_keys:86 unmodified lines87888990919091925 unmodified lines989910010310110210310428 unmodified lines13313413513813913613713886 unmodified lines krea2_identity_edit_data_components = ui_components.get(f'all_krea2_identity_edit_components_flat_{prefix}', [])
krea2_reference_edit_data_components = ui_components.get(f'all_krea2_reference_edit_components_flat_{prefix}', [])
qwen_image_edit_data_components = ui_components.get(f'all_qwen_image_edit_components_flat_{prefix}', [])
qwen_image_2_1_edit_data_components = ui_components.get(f'all_qwen_image_2_1_edit_components_flat_{prefix}', [])
boogu_edit_data_components = ui_components.get(f'all_boogu_edit_components_flat_{prefix}', [])
reference_image_data_components = ui_components.get(f'all_reference_image_components_flat_{prefix}', [])
run_inputs_map['vae_source'] = ui_components.get(f'vae_source_{prefix}')5 unmodified lines all_chains = [
lora_data_components, controlnet_data_components, anima_controlnet_lllite_data_components, diffsynth_controlnet_data_components, krea2_controlnet_data_components, ipadapter_data_components,
sd3_ipadapter_data_components, flux1_ipadapter_data_components, style_data_components,
embedding_data_components, conditioning_data_components, reference_latent_data_components, hidream_o1_reference_data_components, sensenova_reference_data_components, joyai_reference_data_components, krea2_identity_edit_data_components, krea2_reference_edit_data_components, qwen_image_edit_data_components, qwen_image_2_1_edit_data_components, boogu_edit_data_components, reference_image_data_components
embedding_data_components, conditioning_data_components, reference_latent_data_components, hidream_o1_reference_data_components, sensenova_reference_data_components, joyai_reference_data_components, krea2_identity_edit_data_components, krea2_reference_edit_data_components, qwen_image_edit_data_components, reference_image_data_components
]
for chain in all_chains:
if chain:28 unmodified lines assign_chain_data('krea2_identity_edit_data', krea2_identity_edit_data_components)
assign_chain_data('krea2_reference_edit_data', krea2_reference_edit_data_components)
assign_chain_data('qwen_image_edit_data', qwen_image_edit_data_components)
assign_chain_data('qwen_image_2_1_edit_data', qwen_image_2_1_edit_data_components)
assign_chain_data('boogu_edit_data', boogu_edit_data_components)
assign_chain_data('reference_image_data', reference_image_data_components)
if 'ui_type' in ui_dict:7 unmodified lines89101111121314174 unmodified lines1891901911921931921931947 unmodified lines create_conditioning_ui, create_vae_override_ui, create_model_architecture_filter_ui, create_category_filter_ui, create_sd3_ipadapter_ui, create_flux1_ipadapter_ui, create_style_ui, create_reference_latent_ui, create_hidream_o1_reference_ui, create_sensenova_reference_ui, create_joyai_reference_ui, create_reference_image_ui, create_krea2_identity_edit_ui, create_krea2_reference_edit_ui, create_qwen_image_edit_ui, create_qwen_image_2_1_edit_ui, create_boogu_edit_ui, create_reference_latent_ui, create_hidream_o1_reference_ui, create_sensenova_reference_ui, create_joyai_reference_ui, create_reference_image_ui, create_krea2_identity_edit_ui, create_krea2_reference_edit_ui, create_qwen_image_edit_ui, create_pid_ui)
174 unmodified lines components.update(create_krea2_identity_edit_ui(prefix)) components.update(create_krea2_reference_edit_ui(prefix)) components.update(create_qwen_image_edit_ui(prefix)) components.update(create_qwen_image_2_1_edit_ui(prefix)) components.update(create_boogu_edit_ui(prefix)) components.update(create_reference_image_ui(prefix)) components.update(create_vae_override_ui(prefix)) components.update(create_pid_ui(prefix))754 unmodified lines755756757758758759760760761762763118 unmodified lines882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943885754 unmodified lines components = {}
key = lambda name: f"{name}_{prefix}"
with gr.Accordion("Mage-Flow Reference Edit Settings", open=False, visible=('reference_image' in default_enabled_chains)) as ref_accordion:
with gr.Accordion("Reference Image Edit Settings", open=False, visible=('reference_image' in default_enabled_chains)) as ref_accordion:
components[key('reference_image_accordion')] = ref_accordion
gr.Markdown("💡 **Tip:** (Mage-Flow-Edit-Turbo/Mage-Flow-Edit recommended) For multimodal models, this feature enables powerful editing and combining capabilities. In txt2img mode, adding a single reference image performs an **Image Edit**, while adding multiple images performs an **Image Combine**.")
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**, while adding multiple images performs an **Image Combine**.")
ref_image_groups = []
ref_image_inputs = []118 unmodified lines
components[key('all_krea2_reference_edit_components_flat')] = ref_image_inputs
return components
def create_boogu_edit_ui(prefix: str, max_units=10):
components = {}
key = lambda name: f"{name}_{prefix}"
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**.")
ref_image_groups = []
ref_image_inputs = []
with gr.Row():
for i in range(max_units):
with gr.Column(visible=(i < 1), min_width=160) as img_col:
img_comp = gr.Image(type="pil", label=f"Ref. {i+1}", sources=["upload"], height=150)
ref_image_groups.append(img_col)
ref_image_inputs.append(img_comp)
components[key('boogu_edit_rows')] = ref_image_groups
components[key('boogu_edit_images')] = ref_image_inputs
with gr.Row():
components[key('add_boogu_edit_button')] = gr.Button("✚ Add Reference Image")
components[key('delete_boogu_edit_button')] = gr.Button("➖ Delete Reference Image", visible=False)
components[key('boogu_edit_count_state')] = gr.State(1)
components[key('all_boogu_edit_components_flat')] = ref_image_inputs
return components
def create_qwen_image_2_1_edit_ui(prefix: str, max_units=10):
components = {}
key = lambda name: f"{name}_{prefix}"
with gr.Accordion("Qwen-Image-2.1 Edit Settings", open=False, visible=('qwen_image_2_1_edit' in default_enabled_chains)) as ref_accordion:
components[key('qwen_image_2_1_edit_accordion')] = ref_accordion
gr.Markdown("💡 **Tip:** For Qwen-Image-2.1 models, this feature enables reference image editing and combining capabilities. In txt2img mode, adding a single reference image performs an **Image Edit**, while adding multiple images performs an **Image Combine**.")
ref_image_groups = []
ref_image_inputs = []
with gr.Row():
for i in range(max_units):
with gr.Column(visible=(i < 1), min_width=160) as img_col:
img_comp = gr.Image(type="pil", label=f"Ref. {i+1}", sources=["upload"], height=150)
ref_image_groups.append(img_col)
ref_image_inputs.append(img_comp)
components[key('qwen_image_2_1_edit_rows')] = ref_image_groups
components[key('qwen_image_2_1_edit_images')] = ref_image_inputs
with gr.Row():
components[key('add_qwen_image_2_1_edit_button')] = gr.Button("✚ Add Reference Image")
components[key('delete_qwen_image_2_1_edit_button')] = gr.Button("➖ Delete Reference Image", visible=False)
components[key('qwen_image_2_1_edit_count_state')] = gr.State(1)
components[key('all_qwen_image_2_1_edit_components_flat')] = ref_image_inputs
return components return components
222 unmodified lines22322422522622722622722822923062 unmodified lines29329429529629729829930030130230330430530630730830929629729825 unmodified lines324325326341342343344345346347348349350351352353354327328329222 unmodified lines
mage_flow_reference_edit:
chains: reference_image
display_name: "Mage-Flow Reference Edit"
description: " (Mage-Flow-Edit-Turbo/Mage-Flow-Edit recommended) For multimodal models, this feature enables powerful editing and combining capabilities. In txt2img mode, adding a single reference image performs an Image Edit, while adding multiple images performs an Image Combine."
display_name: "Reference Image Edit"
description: "For multimodal models, this feature enables reference image editing and combining capabilities. In txt2img mode, adding a single reference image performs an Image Edit, while adding multiple images performs an Image Combine."
max_count: 10
usage_guideline: "Supply reference image as Base64 Data URI or HTTP/HTTPS URL."
parameters_schema:62 unmodified lines - series
- image
boogu_image_edit:
chains: boogu_image_edit
display_name: "Boogu-Image Edit"
description: " (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."
max_count: 2
usage_guideline: "Supply reference image as Base64 Data URI or HTTP/HTTPS URL."
parameters_schema:
type: object
properties:
image:
type: string
description: "Reference image encoded as Base64 Data URI or HTTP/HTTPS URL."
required:
- image
joyai_reference_edit:
chains: joyai_image25 unmodified lines required:
- image
qwen_image_2_1_edit:
chains: qwen_image_2_1_edit
display_name: "Qwen-Image-2.1 Edit"
description: "For Qwen-Image-2.1 models, this feature enables reference image editing and combining capabilities. In txt2img mode, adding a single reference image performs an Image Edit, while adding multiple images performs an Image Combine."
max_count: 10
usage_guideline: "Supply reference image(s) (up to 10) encoded as Base64 Data URI or HTTP/HTTPS URL. Passing reference image(s) scales them to 1MP via nearest-exact method and feeds them dynamically into TextEncodeQwenImage21."
parameters_schema:
type: object
properties:
image:
type: string
description: "Reference image encoded as Base64 Data URI or HTTP/HTTPS URL."
required:
- image
hidream_o1_smoothing:
chains: hidream_o1_smoothing23 unmodified lines242526272728293042 unmodified lines737475767677787923 unmodified linesboogu-image: enabled_chains: - lora - boogu_image_edit - reference_image - pid
pixeldit:42 unmodified linesqwen-image-2.1: enabled_chains: - lora - qwen_image_2_1_edit - reference_image
qwen-image: enabled_chains:23 unmodified lines242526272827282919 unmodified lines495051545552535418 unmodified lines737475808176777818 unmodified lines97989910610710010110218 unmodified lines12112212313213312412523 unmodified lines - krea2_identity_edit - krea2_style_reference - qwen_image_edit - qwen_image_2_1_edit - boogu_image_edit - reference_image - pid - vae19 unmodified lines - krea2_identity_edit - krea2_style_reference - qwen_image_edit - qwen_image_2_1_edit - boogu_image_edit - reference_image - vae
18 unmodified lines - krea2_identity_edit - krea2_style_reference - qwen_image_edit - qwen_image_2_1_edit - boogu_image_edit - reference_image - vae
18 unmodified lines - krea2_identity_edit - krea2_style_reference - qwen_image_edit - qwen_image_2_1_edit - boogu_image_edit - reference_image - vae
18 unmodified lines - krea2_identity_edit - krea2_style_reference - qwen_image_edit - qwen_image_2_1_edit - boogu_image_edit - reference_image - vaechain_injectors/boogu_image_edit_injector.pyDeleted-73
chain_injectors/qwen_image_2_1_edit_injector.pyDeleted-73
chain_injectors/reference_image_injector.py+48-22
core/pipelines/pipeline_input_processor.py-24
core/pipelines/sd_image_pipeline.py-4
core/pipelines/workflow_recipes/_partials/conditioning/boogu-image.yaml+5-5
core/pipelines/workflow_recipes/_partials/conditioning/qwen-image-2.1.yaml+5-4
mcp_tools/common.py+1-7
ui/events/chain_handlers.py+1-67
ui/events/change_handlers.py+2-6
ui/events/main.py+3-15
ui/events/run_handlers.py+1-5
ui/imagegen_ui.py+1-3
ui/shared/ui_components.py+3-61
yaml/chain_features.yaml+2-30
yaml/model_architecture_features.yaml+2-2
yaml/task_features.yaml-10