Spaces:
Running on Zero
Running on Zero
Add JoyAI-Image architecture model.
Browse filesFiles changed (23)
- README.md+2
- chain_injectors/joyai_reference_injector.pyAdded+63
- core/pipelines/pipeline_input_processor.py+12
- core/pipelines/sd_image_pipeline.py+2
- core/pipelines/workflow_recipes/_partials/conditioning/joyai-image.yamlAdded+86
- requirements.txt+1-1
- ui/events/chain_handlers.py+33
- ui/events/change_handlers.py+5-2
- ui/events/main.py+8-3
- ui/events/run_handlers.py+3-1
- ui/shared/hires_fix_ui.py+2-1
- ui/shared/img2img_ui.py+2-1
- ui/shared/inpaint_ui.py+2-1
- ui/shared/outpaint_ui.py+2-1
- ui/shared/txt2img_ui.py+2-1
- ui/shared/ui_components.py+29
- yaml/constants.yaml+9
- yaml/file_list.yaml+18
- yaml/image_gen_features.yaml+4
- yaml/injectors.yaml+3
- yaml/model_architectures.yaml+3
- yaml/model_defaults.yaml+10
- yaml/model_list.yaml+13
84 unmodified lines85868788899084 unmodified lines- InstantX/Qwen-Image-ControlNet-Inpainting- InstantX/Qwen-Image-ControlNet-Union- InstantX/SD3.5-Large-IP-Adapter- kandinskylab/Kandinsky-5.0-T2I-Lite- Kijai/flux-fp8- Laxhar/noob_openpose84 unmodified lines858687888990919284 unmodified lines- InstantX/Qwen-Image-ControlNet-Inpainting- InstantX/Qwen-Image-ControlNet-Union- InstantX/SD3.5-Large-IP-Adapter- jdopensource/JoyAI-Image-Edit-ComfyUI- jdopensource/JoyAI-Image-Edit-Plus-ComfyUI- kandinskylab/Kandinsky-5.0-T2I-Lite- Kijai/flux-fp8- Laxhar/noob_openpose
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263import os
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[:2]
pos_prompt_name = chain_definition.get('pos_prompt_node', 'pos_prompt') neg_prompt_name = chain_definition.get('neg_prompt_node', 'neg_prompt') vae_node_name = chain_definition.get('vae_node', 'vae_loader')
if pos_prompt_name not in assembler.node_map: print(f"Warning: Positive prompt node '{pos_prompt_name}' not found for JoyAI Reference chain. Skipping.") return
if vae_node_name not in assembler.node_map: print(f"Warning: VAE loader node '{vae_node_name}' not found for JoyAI Reference chain. Skipping.") return
pos_prompt_id = assembler.node_map[pos_prompt_name] neg_prompt_id = assembler.node_map.get(neg_prompt_name) vae_node_id = assembler.node_map[vae_node_name]
assembler.workflow[pos_prompt_id]['inputs']['vae'] = [vae_node_id, 0] if neg_prompt_id and neg_prompt_id in assembler.workflow: assembler.workflow[neg_prompt_id]['inputs']['vae'] = [vae_node_id, 0]
for i, img_filename in enumerate(valid_images): load_id = assembler._get_unique_id() load_node = assembler._get_node_template("LoadImage") 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['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}" assembler.workflow[pos_prompt_id]['inputs'][input_key] = [scale_id, 0] if neg_prompt_id and neg_prompt_id in assembler.workflow: assembler.workflow[neg_prompt_id]['inputs'][input_key] = [scale_id, 0]
print(f"JoyAI Reference injector applied. Injected {len(valid_images)} reference images to JoyAI text encoding nodes.")339 unmodified lines34034134234334434532 unmodified lines378379380381382383339 unmodified linestemp_files_to_clean.append(temp_path)active_hidream_o1_reference.append(os.path.basename(temp_path))vae_source = ui_inputs.get('vae_source')vae_id = ui_inputs.get('vae_id')vae_name_override = None32 unmodified lines"active_styles": active_styles,"active_reference_latents": active_reference_latents,"active_hidream_o1_reference": active_hidream_o1_reference,"active_conditioning": active_conditioning,"temp_files_to_clean": temp_files_to_clean}339 unmodified lines34034134234334434534634734834935035135235335435535632 unmodified lines389390391392393394395339 unmodified linestemp_files_to_clean.append(temp_path)active_hidream_o1_reference.append(os.path.basename(temp_path))joyai_reference_data = ui_inputs.get('joyai_reference_data', [])active_joyai_reference = []if joyai_reference_data:for img in joyai_reference_data:if img:if not os.path.exists(INPUT_DIR): os.makedirs(INPUT_DIR)temp_path = os.path.join(INPUT_DIR, f"temp_joyai_ref_{random.randint(1000, 9999)}.png")img.save(temp_path, "PNG")temp_files_to_clean.append(temp_path)active_joyai_reference.append(os.path.basename(temp_path))vae_source = ui_inputs.get('vae_source')vae_id = ui_inputs.get('vae_id')vae_name_override = None32 unmodified lines"active_styles": active_styles,"active_reference_latents": active_reference_latents,"active_hidream_o1_reference": active_hidream_o1_reference,"active_joyai_reference": active_joyai_reference,"active_conditioning": active_conditioning,"temp_files_to_clean": temp_files_to_clean}
115 unmodified lines11611711811912012150 unmodified lines172173174175176177115 unmodified linesactive_styles = processed["active_styles"]active_reference_latents = processed["active_reference_latents"]active_hidream_o1_reference = processed["active_hidream_o1_reference"]active_conditioning = processed["active_conditioning"]loras_string = f"LoRAs: [{', '.join(active_loras_for_meta)}]" if active_loras_for_meta else ""50 unmodified lines"conditioning_chain": active_conditioning,"reference_latent_chain": active_reference_latents,"hidream_o1_reference_chain": active_hidream_o1_reference,"vae_chain": [ui_inputs.get('vae_name')] if ui_inputs.get('vae_name') else [],"hidream_o1_smoothing_chain": hidream_o1_smoothing_data,"pid_chain": [ui_inputs.get('pid_settings', 'OFF')] if is_pid_enabled else [],115 unmodified lines11611711811912012112250 unmodified lines173174175176177178179115 unmodified linesactive_styles = processed["active_styles"]active_reference_latents = processed["active_reference_latents"]active_hidream_o1_reference = processed["active_hidream_o1_reference"]active_joyai_reference = processed.get("active_joyai_reference", [])active_conditioning = processed["active_conditioning"]loras_string = f"LoRAs: [{', '.join(active_loras_for_meta)}]" if active_loras_for_meta else ""50 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,"vae_chain": [ui_inputs.get('vae_name')] if ui_inputs.get('vae_name') else [],"hidream_o1_smoothing_chain": hidream_o1_smoothing_data,"pid_chain": [ui_inputs.get('pid_settings', 'OFF')] if is_pid_enabled else [],
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586nodes: unet_loader: class_type: UNETLoader title: "Load Diffusion Model" params: weight_dtype: "default" vae_loader: class_type: VAELoader title: "Load VAE" clip_loader: class_type: CLIPLoader title: "Load CLIP" params: type: "joyimage" device: "default"
pos_prompt: class_type: TextEncodeJoyImageEdit title: "TextEncodeJoyImageEdit (Positive)" neg_prompt: class_type: TextEncodeJoyImageEdit title: "TextEncodeJoyImageEdit (Negative)"
cfg_norm: class_type: CFGNorm title: "CFGNorm" params: strength: 1.0 pre_cfg: true
connections: - from: "unet_loader:0" to: "cfg_norm:model" - from: "cfg_norm: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": ["cfg_norm:model"] "clip": ["pos_prompt:clip", "neg_prompt:clip"]
dynamic_conditioning_chains: conditioning_chain: ksampler_node: "ksampler" clip_source: "clip_loader:0"
dynamic_pid_chains: pid_chain: ksampler_node: "ksampler"
dynamic_joyai_reference_chains: joyai_reference_chain: pos_prompt_node: "pos_prompt" neg_prompt_node: "neg_prompt" vae_node: "vae_loader"
ui_map: unet_name: "unet_loader:unet_name" vae_name: "vae_loader:vae_name" clip_name: "clip_loader:clip_name" positive_prompt: "pos_prompt:prompt" negative_prompt: "neg_prompt:prompt"
12345comfyui-frontend-package==1.47.10comfyui-workflow-templates==0.11.15comfyui-embedded-docs==0.5.8torchtorchsde12345comfyui-frontend-package==1.47.10comfyui-workflow-templates==0.11.17comfyui-embedded-docs==0.5.8torchtorchsde
714 unmodified lines715716717718719720714 unmodified linesdel_button.click(fn=del_ref_row, inputs=[count_state], outputs=del_outputs, show_progress=False)def create_embedding_event_handlers(prefix, ui_components):rows = ui_components.get(f'embedding_rows_{prefix}')if not rows: return714 unmodified lines715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753714 unmodified linesdel_button.click(fn=del_ref_row, inputs=[count_state], outputs=del_outputs, show_progress=False)def create_joyai_reference_event_handlers(prefix, ui_components):ref_rows = ui_components.get(f'joyai_reference_rows_{prefix}')if not ref_rows: returncount_state = ui_components[f'joyai_reference_count_state_{prefix}']add_button = ui_components[f'add_joyai_reference_button_{prefix}']del_button = ui_components[f'delete_joyai_reference_button_{prefix}']images = ui_components[f'joyai_reference_images_{prefix}']def add_ref_row(c):c += 1return {count_state: c,ref_rows[c - 1]: gr.update(visible=True),add_button: gr.update(visible=c < 2),del_button: gr.update(visible=True),}def del_ref_row(c):c -= 1return {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 > 0),}add_outputs = [count_state, add_button, del_button] + ref_rowsdel_outputs = [count_state, add_button, del_button] + ref_rows + imagesadd_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_embedding_event_handlers(prefix, ui_components):rows = ui_components.get(f'embedding_rows_{prefix}')if not rows: return
16 unmodified lines1718192021222344 unmodified lines68697071727368 unmodified lines14214314414514614714849 unmodified lines19819920020120220320420516 unmodified linesload_ipadapter_config)def make_update_fn(m_comp, cat_comp, cs_comp, ar_comp, width_comp, height_comp, cn_types, cn_series, cn_filepaths, anima_cn_types, anima_cn_series, anima_cn_filepaths, diffsynth_cn_types, diffsynth_cn_series, diffsynth_cn_filepaths, krea2_cn_types, krea2_cn_series, krea2_cn_filepaths, ipa_preset, lora_acc, cn_acc, anima_cn_acc, diffsynth_cn_acc, krea2_cn_acc, ipa_acc, sd3_ipa_acc, flux1_ipa_acc, style_acc, embed_acc, cond_acc, ref_latent_acc, hidream_o1_ref_acc, guidance_comp, prompt_comp, neg_prompt_comp, steps_comp, cfg_comp, sampler_comp, scheduler_comp, pid_acc=None, vae_acc=None):def update_fn(*args):arch = args[0]category = args[1]44 unmodified linesif 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 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))68 unmodified linesreturn update_fndef make_model_change_fn(cat_comp_ref, cs_comp, ar_comp, width_comp, height_comp, cn_types, cn_series, cn_filepaths, anima_cn_types, anima_cn_series, anima_cn_filepaths, diffsynth_cn_types, diffsynth_cn_series, diffsynth_cn_filepaths, krea2_cn_types, krea2_cn_series, krea2_cn_filepaths, arch_comp_ref, ipa_preset, lora_acc, cn_acc, anima_cn_acc, diffsynth_cn_acc, krea2_cn_acc, ipa_acc, sd3_ipa_acc, flux1_ipa_acc, style_acc, embed_acc, cond_acc, ref_latent_acc, hidream_o1_ref_acc, guidance_comp, prompt_comp, neg_prompt_comp, steps_comp, cfg_comp, sampler_comp, scheduler_comp, pid_acc=None, vae_acc=None):def change_fn(*args):model_name = args[0]idx = 149 unmodified linesif 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 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))if cs_comp:updates[cs_comp] = gr.update(visible=(arch_model_type == "sd15"))16 unmodified lines1718192021222344 unmodified lines6869707172737468 unmodified lines14314414514614714814949 unmodified lines19920020120220320420520620720816 unmodified linesload_ipadapter_config)def make_update_fn(m_comp, cat_comp, cs_comp, ar_comp, width_comp, height_comp, cn_types, cn_series, cn_filepaths, anima_cn_types, anima_cn_series, anima_cn_filepaths, diffsynth_cn_types, diffsynth_cn_series, diffsynth_cn_filepaths, krea2_cn_types, krea2_cn_series, krea2_cn_filepaths, ipa_preset, lora_acc, cn_acc, anima_cn_acc, diffsynth_cn_acc, krea2_cn_acc, ipa_acc, sd3_ipa_acc, flux1_ipa_acc, style_acc, embed_acc, cond_acc, ref_latent_acc, hidream_o1_ref_acc, guidance_comp, prompt_comp, neg_prompt_comp, steps_comp, cfg_comp, sampler_comp, scheduler_comp, pid_acc=None, vae_acc=None, joyai_ref_acc=None):def update_fn(*args):arch = args[0]category = args[1]44 unmodified linesif 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 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))68 unmodified linesreturn update_fndef make_model_change_fn(cat_comp_ref, cs_comp, ar_comp, width_comp, height_comp, cn_types, cn_series, cn_filepaths, anima_cn_types, anima_cn_series, anima_cn_filepaths, diffsynth_cn_types, diffsynth_cn_series, diffsynth_cn_filepaths, krea2_cn_types, krea2_cn_series, krea2_cn_filepaths, arch_comp_ref, ipa_preset, lora_acc, cn_acc, anima_cn_acc, diffsynth_cn_acc, krea2_cn_acc, ipa_acc, sd3_ipa_acc, flux1_ipa_acc, style_acc, embed_acc, cond_acc, ref_latent_acc, hidream_o1_ref_acc, guidance_comp, prompt_comp, neg_prompt_comp, steps_comp, cfg_comp, sampler_comp, scheduler_comp, pid_acc=None, vae_acc=None, joyai_ref_acc=None):def change_fn(*args):model_name = args[0]idx = 149 unmodified linesif 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 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))if vae_acc: updates[vae_acc] = gr.update(visible=('vae' in enabled_chains))if cs_comp:updates[cs_comp] = gr.update(visible=(arch_model_type == "sd15"))
11 unmodified lines1213141516171847 unmodified lines66676869707131 unmodified lines1031041051061071088 unmodified lines11711811912012112212325 unmodified lines14915015115215315413 unmodified lines16816917017117217317410 unmodified lines18518618718818919011 unmodified linescreate_sd3_ipadapter_event_handlers,create_style_event_handlers,create_reference_latent_event_handlers,create_hidream_o1_reference_event_handlers)from .change_handlers import (make_update_fn,47 unmodified linesconditioning_accordion = ui_components.get(f'conditioning_accordion_{prefix}')ref_latent_accordion = ui_components.get(f'reference_latent_accordion_{prefix}')hidream_o1_ref_accordion = ui_components.get(f'hidream_o1_reference_accordion_{prefix}')pid_accordion = ui_components.get(f'pid_accordion_{prefix}')vae_accordion = ui_components.get(f'vae_accordion_{prefix}')31 unmodified linesif conditioning_accordion: outputs.append(conditioning_accordion)if ref_latent_accordion: outputs.append(ref_latent_accordion)if hidream_o1_ref_accordion: outputs.append(hidream_o1_ref_accordion)if pid_accordion: outputs.append(pid_accordion)if vae_accordion: outputs.append(vae_accordion)if ipa_preset_list: outputs.append(ipa_preset_list)8 unmodified lineskrea2_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, guidance_comp, prompt_comp, neg_prompt_comp, steps_comp, cfg_comp, sampler_comp, scheduler_comp,pid_acc=pid_accordion, vae_acc=vae_accordion)inputs = [arch_comp, cat_comp]if aspect_ratio_comp:25 unmodified linesif conditioning_accordion: outputs2.append(conditioning_accordion)if ref_latent_accordion: outputs2.append(ref_latent_accordion)if hidream_o1_ref_accordion: outputs2.append(hidream_o1_ref_accordion)if pid_accordion: outputs2.append(pid_accordion)if vae_accordion: outputs2.append(vae_accordion)if ipa_preset_list: outputs2.append(ipa_preset_list)13 unmodified lineskrea2_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, guidance_comp, prompt_comp, neg_prompt_comp, steps_comp, cfg_comp, sampler_comp, scheduler_comp,pid_acc=pid_accordion, vae_acc=vae_accordion)model_comp.change(fn=change_fn, inputs=inputs2, outputs=outputs2)10 unmodified linescreate_style_event_handlers(prefix, ui_components)create_reference_latent_event_handlers(prefix, ui_components)create_hidream_o1_reference_event_handlers(prefix, ui_components)create_run_event(prefix, task_type, ui_components)if 'view_mode_inpaint' in ui_components:11 unmodified lines121314151617181947 unmodified lines6768697071727331 unmodified lines1051061071081091101118 unmodified lines12012112212312412512625 unmodified lines15215315415515615715813 unmodified lines17217317417517617717810 unmodified lines18919019119219319419511 unmodified linescreate_sd3_ipadapter_event_handlers,create_style_event_handlers,create_reference_latent_event_handlers,create_hidream_o1_reference_event_handlers,create_joyai_reference_event_handlers)from .change_handlers import (make_update_fn,47 unmodified linesconditioning_accordion = ui_components.get(f'conditioning_accordion_{prefix}')ref_latent_accordion = ui_components.get(f'reference_latent_accordion_{prefix}')hidream_o1_ref_accordion = ui_components.get(f'hidream_o1_reference_accordion_{prefix}')joyai_ref_accordion = ui_components.get(f'joyai_reference_accordion_{prefix}')pid_accordion = ui_components.get(f'pid_accordion_{prefix}')vae_accordion = ui_components.get(f'vae_accordion_{prefix}')31 unmodified linesif conditioning_accordion: outputs.append(conditioning_accordion)if ref_latent_accordion: outputs.append(ref_latent_accordion)if hidream_o1_ref_accordion: outputs.append(hidream_o1_ref_accordion)if joyai_ref_accordion: outputs.append(joyai_ref_accordion)if pid_accordion: outputs.append(pid_accordion)if vae_accordion: outputs.append(vae_accordion)if ipa_preset_list: outputs.append(ipa_preset_list)8 unmodified lineskrea2_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, guidance_comp, 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)inputs = [arch_comp, cat_comp]if aspect_ratio_comp:25 unmodified linesif conditioning_accordion: outputs2.append(conditioning_accordion)if ref_latent_accordion: outputs2.append(ref_latent_accordion)if hidream_o1_ref_accordion: outputs2.append(hidream_o1_ref_accordion)if joyai_ref_accordion: outputs2.append(joyai_ref_accordion)if pid_accordion: outputs2.append(pid_accordion)if vae_accordion: outputs2.append(vae_accordion)if ipa_preset_list: outputs2.append(ipa_preset_list)13 unmodified lineskrea2_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, guidance_comp, 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)model_comp.change(fn=change_fn, inputs=inputs2, outputs=outputs2)10 unmodified linescreate_style_event_handlers(prefix, ui_components)create_reference_latent_event_handlers(prefix, ui_components)create_hidream_o1_reference_event_handlers(prefix, ui_components)create_joyai_reference_event_handlers(prefix, ui_components)create_run_event(prefix, task_type, ui_components)if 'view_mode_inpaint' in ui_components:
51 unmodified lines5253545556574 unmodified lines6263646566676823 unmodified lines92939495969751 unmodified linesconditioning_data_components = ui_components.get(f'all_conditioning_components_flat_{prefix}', [])reference_latent_data_components = ui_components.get(f'all_reference_latent_components_flat_{prefix}', [])hidream_o1_reference_data_components = ui_components.get(f'all_hidream_o1_reference_components_flat_{prefix}', [])run_inputs_map['vae_source'] = ui_components.get(f'vae_source_{prefix}')run_inputs_map['vae_id'] = ui_components.get(f'vae_id_{prefix}')4 unmodified linesall_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]for chain in all_chains:if chain:23 unmodified linesassign_chain_data('conditioning_data', conditioning_data_components)assign_chain_data('reference_latent_data', reference_latent_data_components)assign_chain_data('hidream_o1_reference_data', hidream_o1_reference_data_components)return ui_dict51 unmodified lines525354555657584 unmodified lines6364656667686923 unmodified lines9394959697989951 unmodified linesconditioning_data_components = ui_components.get(f'all_conditioning_components_flat_{prefix}', [])reference_latent_data_components = ui_components.get(f'all_reference_latent_components_flat_{prefix}', [])hidream_o1_reference_data_components = ui_components.get(f'all_hidream_o1_reference_components_flat_{prefix}', [])joyai_reference_data_components = ui_components.get(f'all_joyai_reference_components_flat_{prefix}', [])run_inputs_map['vae_source'] = ui_components.get(f'vae_source_{prefix}')run_inputs_map['vae_id'] = ui_components.get(f'vae_id_{prefix}')4 unmodified linesall_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, joyai_reference_data_components]for chain in all_chains:if chain:23 unmodified linesassign_chain_data('conditioning_data', conditioning_data_components)assign_chain_data('reference_latent_data', reference_latent_data_components)assign_chain_data('hidream_o1_reference_data', hidream_o1_reference_data_components)assign_chain_data('joyai_reference_data', joyai_reference_data_components)return ui_dict
6 unmodified lines7891011121387 unmodified lines1011021031041051066 unmodified linescreate_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)default_vals = MODEL_DEFAULTS_CONFIG.get('Default', {})87 unmodified linescomponents.update(create_conditioning_ui(prefix))components.update(create_reference_latent_ui(prefix))components.update(create_hidream_o1_reference_ui(prefix))components.update(create_vae_override_ui(prefix))return components6 unmodified lines7891011121387 unmodified lines1011021031041051061076 unmodified linescreate_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_joyai_reference_ui)default_vals = MODEL_DEFAULTS_CONFIG.get('Default', {})87 unmodified linescomponents.update(create_conditioning_ui(prefix))components.update(create_reference_latent_ui(prefix))components.update(create_hidream_o1_reference_ui(prefix))components.update(create_joyai_reference_ui(prefix))components.update(create_vae_override_ui(prefix))return components
6 unmodified lines7891011121368 unmodified lines8283848586876 unmodified linescreate_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)default_vals = MODEL_DEFAULTS_CONFIG.get('Default', {})68 unmodified linescomponents.update(create_conditioning_ui(prefix))components.update(create_reference_latent_ui(prefix))components.update(create_hidream_o1_reference_ui(prefix))components.update(create_vae_override_ui(prefix))return components6 unmodified lines7891011121368 unmodified lines828384858687886 unmodified linescreate_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_joyai_reference_ui)default_vals = MODEL_DEFAULTS_CONFIG.get('Default', {})68 unmodified linescomponents.update(create_conditioning_ui(prefix))components.update(create_reference_latent_ui(prefix))components.update(create_hidream_o1_reference_ui(prefix))components.update(create_joyai_reference_ui(prefix))components.update(create_vae_override_ui(prefix))return components
5 unmodified lines6789101112101 unmodified lines1141151161171181195 unmodified linescreate_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)default_vals = MODEL_DEFAULTS_CONFIG.get('Default', {})101 unmodified linescomponents.update(create_conditioning_ui(prefix))components.update(create_reference_latent_ui(prefix))components.update(create_hidream_o1_reference_ui(prefix))components.update(create_vae_override_ui(prefix))components[f'accordion_wrapper_{prefix}'] = accordion_wrapper5 unmodified lines6789101112101 unmodified lines1141151161171181191205 unmodified linescreate_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_joyai_reference_ui)default_vals = MODEL_DEFAULTS_CONFIG.get('Default', {})101 unmodified linescomponents.update(create_conditioning_ui(prefix))components.update(create_reference_latent_ui(prefix))components.update(create_hidream_o1_reference_ui(prefix))components.update(create_joyai_reference_ui(prefix))components.update(create_vae_override_ui(prefix))components[f'accordion_wrapper_{prefix}'] = accordion_wrapper
6 unmodified lines7891011121383 unmodified lines9798991001011026 unmodified linescreate_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)default_vals = MODEL_DEFAULTS_CONFIG.get('Default', {})83 unmodified linescomponents.update(create_conditioning_ui(prefix))components.update(create_reference_latent_ui(prefix))components.update(create_hidream_o1_reference_ui(prefix))components.update(create_vae_override_ui(prefix))return components6 unmodified lines7891011121383 unmodified lines9798991001011021036 unmodified linescreate_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_joyai_reference_ui)default_vals = MODEL_DEFAULTS_CONFIG.get('Default', {})83 unmodified linescomponents.update(create_conditioning_ui(prefix))components.update(create_reference_latent_ui(prefix))components.update(create_hidream_o1_reference_ui(prefix))components.update(create_joyai_reference_ui(prefix))components.update(create_vae_override_ui(prefix))return components
5 unmodified lines678910111241 unmodified lines5455565758595 unmodified linescreate_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_pid_ui)41 unmodified linescomponents.update(create_conditioning_ui(prefix))components.update(create_reference_latent_ui(prefix))components.update(create_hidream_o1_reference_ui(prefix))components.update(create_vae_override_ui(prefix))components.update(create_pid_ui(prefix))5 unmodified lines678910111241 unmodified lines545556575859605 unmodified linescreate_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_joyai_reference_ui,create_pid_ui)41 unmodified linescomponents.update(create_conditioning_ui(prefix))components.update(create_reference_latent_ui(prefix))components.update(create_hidream_o1_reference_ui(prefix))components.update(create_joyai_reference_ui(prefix))components.update(create_vae_override_ui(prefix))components.update(create_pid_ui(prefix))
695 unmodified lines696697698699700701695 unmodified linesreturn componentsdef create_pid_ui(prefix: str):components = {}key = lambda name: f"{name}_{prefix}"695 unmodified lines696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730695 unmodified linesreturn componentsdef create_joyai_reference_ui(prefix: str, max_units=2):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:components[key('joyai_reference_accordion')] = ref_accordiongr.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).")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('joyai_reference_rows')] = ref_image_groupscomponents[key('joyai_reference_images')] = ref_image_inputswith gr.Row():components[key('add_joyai_reference_button')] = gr.Button("✚ Add Reference Image")components[key('delete_joyai_reference_button')] = gr.Button("➖ Delete Reference Image", visible=False)components[key('joyai_reference_count_state')] = gr.State(1)components[key('all_joyai_reference_components_flat')] = ref_image_inputsreturn componentsdef create_pid_ui(prefix: str):components = {}key = lambda name: f"{name}_{prefix}"
14 unmodified lines151617181920212 unmodified lines23323423523623723814 unmodified lines"3:4 (Classic Portrait)": [896, 1152]"3:2 (Photography)": [1216, 832]"2:3 (Photography Portrait)": [832, 1216]boogu-image:"1:1 (Square)": [1024, 1024]"16:9 (Landscape)": [1344, 768]212 unmodified lines"2:3 (Portrait)": [512, 768]MULTIPLIERS_MAP:krea-2: 1boogu-image: 1pixeldit: 114 unmodified lines1516171819202122232425262728212 unmodified lines24124224324424524624714 unmodified lines"3:4 (Classic Portrait)": [896, 1152]"3:2 (Photography)": [1216, 832]"2:3 (Photography Portrait)": [832, 1216]joyai-image:"1:1 (Square)": [1024, 1024]"16:9 (Landscape)": [1344, 768]"9:16 (Portrait)": [768, 1344]"4:3 (Classic)": [1152, 896]"3:4 (Classic Portrait)": [896, 1152]"3:2 (Photography)": [1216, 832]"2:3 (Photography Portrait)": [832, 1216]boogu-image:"1:1 (Square)": [1024, 1024]"16:9 (Landscape)": [1344, 768]212 unmodified lines"2:3 (Portrait)": [512, 768]MULTIPLIERS_MAP:joyai-image: 1krea-2: 1boogu-image: 1pixeldit: 1
404 unmodified lines405406407408409410367 unmodified lines778779780781782783404 unmodified linessource: "hf"repo_id: "Comfy-Org/Krea-2"repository_file_path: "diffusion_models/krea2_raw_fp8_scaled.safetensors"# Boogu-Image- filename: "boogu_image_base_nvfp4.safetensors"source: "hf"367 unmodified linessource: "hf"repo_id: "Comfy-Org/Krea-2"repository_file_path: "text_encoders/qwen3vl_4b_fp8_scaled.safetensors"# Cosmos-Predict2- filename: "oldt5_xxl_fp8_e4m3fn_scaled.safetensors"source: "hf"404 unmodified lines405406407408409410411412413414415416417418419367 unmodified lines787788789790791792793794795796797798799800801404 unmodified linessource: "hf"repo_id: "Comfy-Org/Krea-2"repository_file_path: "diffusion_models/krea2_raw_fp8_scaled.safetensors"# JoyAI-Image- filename: "joyai_image_edit_int8_convrot.safetensors"source: "hf"repo_id: "jdopensource/JoyAI-Image-Edit-ComfyUI"repository_file_path: "diffusion_models/joyai_image_edit_int8_convrot.safetensors"- filename: "joyai_image_edit_plus_int8_convrot.safetensors"source: "hf"repo_id: "jdopensource/JoyAI-Image-Edit-Plus-ComfyUI"repository_file_path: "diffusion_models/joyai_image_edit_plus_int8_convrot.safetensors"# Boogu-Image- filename: "boogu_image_base_nvfp4.safetensors"source: "hf"367 unmodified linessource: "hf"repo_id: "Comfy-Org/Krea-2"repository_file_path: "text_encoders/qwen3vl_4b_fp8_scaled.safetensors"# JoyAI-Image- filename: "qwen3vl_8b_joyimage_edit_int8_convrot.safetensors"source: "hf"repo_id: "jdopensource/JoyAI-Image-Edit-ComfyUI"repository_file_path: "text_encoders/qwen3vl_8b_joyimage_edit_int8_convrot.safetensors"- filename: "qwen3vl_8b_joyimage_edit_plus_int8_convrot.safetensors"source: "hf"repo_id: "jdopensource/JoyAI-Image-Edit-Plus-ComfyUI"repository_file_path: "text_encoders/qwen3vl_8b_joyimage_edit_plus_int8_convrot.safetensors"# Cosmos-Predict2- filename: "oldt5_xxl_fp8_e4m3fn_scaled.safetensors"source: "hf"
7 unmodified lines89101112137 unmodified lines- conditioning- vaekrea-2:enabled_chains:- lora7 unmodified lines8910111213141516177 unmodified lines- conditioning- vaejoyai-image:enabled_chains:- joyai_referencekrea-2:enabled_chains:- lora
28 unmodified lines29303132333413 unmodified lines4849505128 unmodified linesmodule: "chain_injectors.hidream_o1_smoothing_injector"dynamic_hidream_o1_reference_chains:module: "chain_injectors.hidream_o1_reference_injector"dynamic_pid_chains:module: "chain_injectors.pid_injector"13 unmodified lines- dynamic_anima_controlnet_lllite_chains- dynamic_hidream_o1_smoothing_chains- dynamic_hidream_o1_reference_chains- dynamic_pid_chains28 unmodified lines293031323334353613 unmodified lines505152535428 unmodified linesmodule: "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_pid_chains:module: "chain_injectors.pid_injector"13 unmodified lines- dynamic_anima_controlnet_lllite_chains- dynamic_hidream_o1_smoothing_chains- dynamic_hidream_o1_reference_chains- dynamic_joyai_reference_chains- dynamic_pid_chains
1234525 unmodified lines313233343536architecture_order:- "Krea-2"- "Boogu-Image"- "PixelDiT"- "Ideogram-4"25 unmodified linesarchitectures:Krea-2:model_type: "krea-2""Boogu-Image":model_type: "boogu-image""PixelDiT":12345625 unmodified lines3233343536373839architecture_order:- "Krea-2"- "JoyAI-Image"- "Boogu-Image"- "PixelDiT"- "Ideogram-4"25 unmodified linesarchitectures:Krea-2:model_type: "krea-2""JoyAI-Image":model_type: "joyai-image""Boogu-Image":model_type: "boogu-image""PixelDiT":
17 unmodified lines18192021222317 unmodified linessampler_name: "euler"scheduler: "simple"Boogu-Image:_defaults:steps: 2517 unmodified lines1819202122232425262728293031323317 unmodified linessampler_name: "euler"scheduler: "simple"JoyAI-Image:_defaults:steps: 40cfg: 4.0sampler_name: "euler"scheduler: "normal""JoyAI-Image-Edit-Plus":steps: 30cfg: 4.0Boogu-Image:_defaults:steps: 25
11 unmodified lines12131415161711 unmodified linesunet: "krea2_raw_fp8_scaled.safetensors"clip: "qwen3vl_4b_fp8_scaled.safetensors"vae: "qwen_image_vae.safetensors"Boogu-Image:latent_type: latentmodels:11 unmodified lines1213141516171819202122232425262728293011 unmodified linesunet: "krea2_raw_fp8_scaled.safetensors"clip: "qwen3vl_4b_fp8_scaled.safetensors"vae: "qwen_image_vae.safetensors"JoyAI-Image:latent_type: sd3_latentmodels:- display_name: "JoyAI-Image-Edit"components:unet: "joyai_image_edit_int8_convrot.safetensors"clip: "qwen3vl_8b_joyimage_edit_int8_convrot.safetensors"vae: "wan_2.1_vae.safetensors"- display_name: "JoyAI-Image-Edit-Plus"components:unet: "joyai_image_edit_plus_int8_convrot.safetensors"clip: "qwen3vl_8b_joyimage_edit_plus_int8_convrot.safetensors"vae: "wan_2.1_vae.safetensors"Boogu-Image:latent_type: latentmodels:
README.md+2
chain_injectors/joyai_reference_injector.pyAdded+63
core/pipelines/pipeline_input_processor.py+12
core/pipelines/sd_image_pipeline.py+2
core/pipelines/workflow_recipes/_partials/conditioning/joyai-image.yamlAdded+86
requirements.txt+1-1
ui/events/chain_handlers.py+33
ui/events/change_handlers.py+5-2
ui/events/main.py+8-3
ui/events/run_handlers.py+3-1
ui/shared/hires_fix_ui.py+2-1
ui/shared/img2img_ui.py+2-1
ui/shared/inpaint_ui.py+2-1
ui/shared/outpaint_ui.py+2-1
ui/shared/txt2img_ui.py+2-1
ui/shared/ui_components.py+29
yaml/constants.yaml+9
yaml/file_list.yaml+18
yaml/image_gen_features.yaml+4
yaml/injectors.yaml+3
yaml/model_architectures.yaml+3
yaml/model_defaults.yaml+10
yaml/model_list.yaml+13