Add AuraFlow architecture model.
Browse filesFiles changed (18)
- .gitattributes+35-4
- app.py+36-6
- chain_injectors/anima_controlnet_lllite_injector.py+6-1
- comfy_integration/setup.py+1-9
- core/pipelines/base_pipeline.py+14-3
- core/pipelines/workflow_recipes/_partials/conditioning/auraflow.yamlAdded+48
- requirements.txt+2-2
- ui/events/chain_handlers.py+19
- ui/events/change_handlers.py+364-364
- ui/layout.py+1-9
- ui/shared/ui_components.py+1-2
- yaml/anima_controlnet_lllite_models.yaml+5-2
- yaml/constants.yaml+9
- yaml/file_list.yaml+31-17
- yaml/image_gen_features.yaml+6
- yaml/model_architectures.yaml+4
- yaml/model_defaults.yaml+18-3
- yaml/model_list.yaml+10-1
12341234567891011121314151617181920212223242526272829303132333435/web/assets/** linguist-generated
/web/** linguist-vendored
comfy_api_nodes/apis/__init__.py linguist-generated
comfy/text_encoders/t5_pile_tokenizer/tokenizer.model filter=lfs diff=lfs merge=lfs -text*.7z filter=lfs diff=lfs merge=lfs -text*.arrow filter=lfs diff=lfs merge=lfs -text*.bin filter=lfs diff=lfs merge=lfs -text*.bz2 filter=lfs diff=lfs merge=lfs -text*.ckpt filter=lfs diff=lfs merge=lfs -text*.ftz filter=lfs diff=lfs merge=lfs -text*.gz filter=lfs diff=lfs merge=lfs -text*.h5 filter=lfs diff=lfs merge=lfs -text*.joblib filter=lfs diff=lfs merge=lfs -text*.lfs.* filter=lfs diff=lfs merge=lfs -text*.mlmodel filter=lfs diff=lfs merge=lfs -text*.model filter=lfs diff=lfs merge=lfs -text*.msgpack filter=lfs diff=lfs merge=lfs -text*.npy filter=lfs diff=lfs merge=lfs -text*.npz filter=lfs diff=lfs merge=lfs -text*.onnx filter=lfs diff=lfs merge=lfs -text*.ot filter=lfs diff=lfs merge=lfs -text*.parquet filter=lfs diff=lfs merge=lfs -text*.pb filter=lfs diff=lfs merge=lfs -text*.pickle filter=lfs diff=lfs merge=lfs -text*.pkl filter=lfs diff=lfs merge=lfs -text*.pt filter=lfs diff=lfs merge=lfs -text*.pth filter=lfs diff=lfs merge=lfs -text*.rar filter=lfs diff=lfs merge=lfs -text*.safetensors filter=lfs diff=lfs merge=lfs -textsaved_model/**/* filter=lfs diff=lfs merge=lfs -text*.tar.* filter=lfs diff=lfs merge=lfs -text*.tar filter=lfs diff=lfs merge=lfs -text*.tflite filter=lfs diff=lfs merge=lfs -text*.tgz filter=lfs diff=lfs merge=lfs -text*.wasm filter=lfs diff=lfs merge=lfs -text*.xz filter=lfs diff=lfs merge=lfs -text*.zip filter=lfs diff=lfs merge=lfs -text*.zst filter=lfs diff=lfs merge=lfs -text*tfevents* filter=lfs diff=lfs merge=lfs -text39 unmodified lines4041424344454647484950515253545556575859603 unmodified lines64656652536768556970717221 unmodified lines949596838497989910010110210310410510610710811 unmodified lines12012112212310212412512612712812913013113213313413539 unmodified lines print(msg)
return msg
def is_fatal_gpu_error(e: BaseException) -> bool:
err_type = type(e).__name__
err_str = f"{err_type}: {str(e)} | {repr(e)}".lower()
fatal_keywords = [
"ecc",
"uncorrectable",
"cudaerror",
"acceleratorerror",
"cuda error",
"cuda_error",
"device-side assertion",
"cuda_launch_blocking",
]
return any(kw in err_str for kw in fatal_keywords)
@spaces.GPU
def dummy_gpu_for_startup():
try:3 unmodified lines print("--- [GPU Startup] Startup check passed. ---")
return "Startup check passed."
except BaseException as e:
err_msg = str(e)
if "uncorrectable ECC error" in err_msg or "cudaErrorECCUncorrectable" in err_msg:
if is_fatal_gpu_error(e):
print("\n" + "="*80)
print(f"🚨 [Fatal GPU Error] Captured uncorrectable ECC error during inference: {err_msg}")
print(f"🚨 [Fatal GPU Error] Captured fatal GPU error during startup check: {e}")
print("🚨 Terminating process to trigger an automatic container restart...")
print("="*80 + "\n")
os._exit(1)21 unmodified lines print("--- Initiating GPU Startup Check & SageAttention Patch Verification ---")
try:
dummy_gpu_for_startup()
except Exception as e:
print(f"--- [GPU Startup] ⚠️ Warning: Startup check failed: {e} ---")
except BaseException as e:
err_msg = f"{type(e).__name__}: {str(e)}"
print(f"--- [GPU Startup] ⚠️ Warning: Startup check failed: {err_msg} ---")
if is_fatal_gpu_error(e):
print("\n" + "="*80)
print(f"🚨 [Fatal GPU Error] Captured fatal GPU error during startup check: {err_msg}")
print("🚨 Terminating process to trigger an automatic container restart...")
print("="*80 + "\n")
os._exit(1)
print("--- Starting Application Setup ---")
11 unmodified lines demo = build_ui(attach_event_handlers)
print("--- Launching Gradio Interface ---")
try:
demo.queue().launch(server_name="0.0.0.0", server_port=7860)
demo.queue().launch(server_name="0.0.0.0", server_port=7860)
except ValueError as e:
if "localhost is not accessible" in str(e):
print("\n" + "="*80)
print(f"🚨 [Gradio Launch Error] Localhost accessibility check failed: {e}")
print("🚨 Terminating process to trigger an automatic container restart...")
print("="*80 + "\n")
sys.exit(1)
raise e
if __name__ == "__main__":27 unmodified lines28293031323334353637383439404142434445464727 unmodified lines image_scaler_node['inputs']['megapixels'] = 1.0
assembler.workflow[image_scaler_id] = image_scaler_node
patch_loader_id = assembler._get_unique_id()
patch_loader_node = assembler._get_node_template("ModelPatchLoader")
patch_loader_node['inputs']['name'] = item_data['control_net_name']
assembler.workflow[patch_loader_id] = patch_loader_node
apply_cn_id = assembler._get_unique_id()
apply_cn_node = assembler._get_node_template("AnimaLLLiteApply")
apply_cn_node['inputs']['lllite_name'] = item_data['control_net_name']
apply_cn_node['inputs']['strength'] = item_data['strength']
apply_cn_node['inputs']['start_percent'] = item_data.get('start_percent', 0.0)
apply_cn_node['inputs']['end_percent'] = item_data.get('end_percent', 1.0)
apply_cn_node['inputs']['model'] = current_model_connection
apply_cn_node['inputs']['model_patch'] = [patch_loader_id, 0]
apply_cn_node['inputs']['image'] = [image_scaler_id, 0]
assembler.workflow[apply_cn_id] = apply_cn_node79 unmodified lines8081828384858687888990918384858679 unmodified lines else:
print("✅ ComfyUI-Newbie-Nodes extension already exists.")
# 5. ComfyUI-Anima-LLLite
anima_controlnet_lllite_nodes_path = os.path.join(APP_DIR, "custom_nodes", "ComfyUI-Anima-LLLite")
if not os.path.exists(anima_controlnet_lllite_nodes_path):
os.system(f"git clone https://github.com/kohya-ss/ComfyUI-Anima-LLLite.git {anima_controlnet_lllite_nodes_path}")
print("✅ ComfyUI-Anima-LLLite extension cloned.")
else:
print("✅ ComfyUI-Anima-LLLite extension already exists.")
# 6. comfyui-krea2-controlnet
# 5. 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}")40 unmodified lines41424344454445464748495051525354555657475859606140 unmodified lines try:
return gpu_runner(*args, **kwargs)
except BaseException as e:
err_msg = str(e)
if "uncorrectable ECC error" in err_msg or "cudaErrorECCUncorrectable" in err_msg:
err_type = type(e).__name__
err_str = f"{err_type}: {str(e)} | {repr(e)}".lower()
fatal_keywords = [
"ecc",
"uncorrectable",
"cudaerror",
"acceleratorerror",
"cuda error",
"cuda_error",
"device-side assertion",
"cuda_launch_blocking",
]
if any(kw in err_str for kw in fatal_keywords):
print("\n" + "="*80)
print(f"🚨 [Fatal GPU Error] Captured uncorrectable ECC error during inference: {err_msg}")
print(f"🚨 [Fatal GPU Error] Captured fatal GPU error during inference: {e}")
print("🚨 Terminating process to trigger an automatic container restart...")
print("="*80 + "\n")
os._exit(1)123456789101112131415161718192021222324252627282930313233343536373839404142434445464748nodes: ckpt_loader: class_type: CheckpointLoaderSimple title: "Load Checkpoint"
connections: - from: "ckpt_loader:0" to: "ksampler:model" - from: "ckpt_loader:1" to: "pos_prompt:clip" - from: "ckpt_loader:1" to: "neg_prompt:clip" - from: "pos_prompt:0" to: "ksampler:positive" - from: "neg_prompt:0" to: "ksampler:negative" - from: "ckpt_loader:2" to: "vae_decode:vae" - from: "ckpt_loader:2" to: "vae_encode:vae"
dynamic_vae_chains: vae_chain: targets: - "vae_decode:vae" - "vae_encode:vae"
dynamic_lora_chains: lora_chain: template: "LoraLoader" start: "ckpt_loader" output_map: "0": "model" "1": "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: "ckpt_loader:1"
ui_map: model_name: "ckpt_loader:ckpt_name"12234516 unmodified lines2223242525262728comfyui-frontend-package==1.45.21
comfyui-workflow-templates==0.11.9
comfyui-workflow-templates==0.11.12
comfyui-embedded-docs==0.5.8
torch
torchsde16 unmodified linesSQLAlchemy>=2.0.0
filelock
av>=16.0.0
comfy-kitchen==0.2.20
comfy-kitchen==0.2.22
comfy-aimdo==0.4.10
requests
simpleeval>=1.0.045 unmodified lines46474849505152535455565758596061626364655 unmodified lines72072172272372472572672772872973073173273373473573673773873945 unmodified lines lora_ids = ui_components[f'lora_ids_{prefix}'] lora_scales = ui_components[f'lora_scales_{prefix}'] lora_uploads = ui_components[f'lora_uploads_{prefix}'] lora_sources = ui_components[f'lora_sources_{prefix}'] count_state = ui_components[f'lora_count_state_{prefix}'] add_button = ui_components[f'add_lora_button_{prefix}'] del_button = ui_components[f'delete_lora_button_{prefix}']
for i in range(MAX_LORAS): lora_uploads[i].upload( fn=on_lora_upload, inputs=[lora_uploads[i]], outputs=[lora_ids[i], lora_sources[i]], show_progress=True )
def add_lora_row(c): updates = {} if c < MAX_LORAS:655 unmodified lines if not rows: return ids = ui_components[f'embeddings_ids_{prefix}'] files = ui_components[f'embeddings_files_{prefix}'] sources = ui_components[f'embeddings_sources_{prefix}'] upload_buttons = ui_components[f'embeddings_uploads_{prefix}'] count_state = ui_components[f'embedding_count_state_{prefix}'] add_button = ui_components[f'add_embedding_button_{prefix}'] del_button = ui_components[f'delete_embedding_button_{prefix}']
for i in range(MAX_EMBEDDINGS): upload_buttons[i].upload( fn=on_embedding_upload, inputs=[upload_buttons[i]], outputs=[ids[i], sources[i], files[i]], show_progress=True )
def add_row(c): c += 1 return {123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365import gradio as grfrom core.settings import ( MODEL_TYPE_MAP, MODEL_MAP_CHECKPOINT, FEATURES_CONFIG, ARCHITECTURES_CONFIG, MODEL_DEFAULTS_CONFIG, ARCH_CATEGORIES_MAP)from utils.app_utils import get_model_generation_defaultsfrom ui.shared.ui_components import RESOLUTION_MAPfrom .config_loaders import ( get_cn_defaults, get_anima_cn_defaults, get_diffsynth_cn_defaults, get_krea2_cn_defaults, load_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] current_ar = args[2] if len(args) > 2 else None if arch == "ALL": valid_cats = list(set(cat for cats in ARCH_CATEGORIES_MAP.values() for cat in cats)) else: valid_cats = ARCH_CATEGORIES_MAP.get(arch, []) cat_choices = ["ALL"] + sorted(valid_cats) new_category = category if category in cat_choices else "ALL"
choices = [] for name, info in MODEL_MAP_CHECKPOINT.items(): m_arch = info[2] m_cat = info[4] if len(info) > 4 else None arch_match = (arch == "ALL" or m_arch == arch) cat_match = (new_category == "ALL" or m_cat == new_category) if arch_match and cat_match: choices.append(name) val = choices[0] if choices else None updates = { m_comp: gr.update(choices=choices, value=val), cat_comp: gr.update(choices=cat_choices, value=new_category) }
m_type = MODEL_TYPE_MAP.get(val, "SDXL") if val else "SDXL" 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', {})) 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 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)) if sd3_ipa_acc: updates[sd3_ipa_acc] = gr.update(visible=('sd3_ipadapter' in enabled_chains)) if style_acc: updates[style_acc] = gr.update(visible=('style' in enabled_chains)) if embed_acc: updates[embed_acc] = gr.update(visible=('embedding' in enabled_chains)) 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 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")) if guidance_comp: updates[guidance_comp] = gr.update(visible=(arch_model_type == "flux1")) if ar_comp: res_key = arch_model_type if res_key not in RESOLUTION_MAP: res_key = 'sdxl' res_map = RESOLUTION_MAP.get(res_key, {}) target_ar = current_ar if current_ar in res_map else (list(res_map.keys())[0] if res_map else "1:1 (Square)") updates[ar_comp] = gr.update(choices=list(res_map.keys()), value=target_ar) if width_comp and height_comp and target_ar in res_map: updates[width_comp] = gr.update(value=res_map[target_ar][0]) updates[height_comp] = gr.update(value=res_map[target_ar][1]) controlnet_key = architectures_dict.get(m_type, {}).get("controlnet_key", m_type) all_types, default_type, series_choices, default_series, filepath = get_cn_defaults(controlnet_key) for t_comp in cn_types: updates[t_comp] = gr.update(choices=all_types, value=default_type) for s_comp in cn_series: updates[s_comp] = gr.update(choices=series_choices, value=default_series) for f_comp in cn_filepaths: updates[f_comp] = filepath
anima_all_types, anima_default_type, anima_series_choices, anima_default_series, anima_filepath = get_anima_cn_defaults() for t_comp in anima_cn_types: updates[t_comp] = gr.update(choices=anima_all_types, value=anima_default_type) for s_comp in anima_cn_series: updates[s_comp] = gr.update(choices=anima_series_choices, value=anima_default_series) for f_comp in anima_cn_filepaths: updates[f_comp] = anima_filepath diffsynth_all_types, diffsynth_default_type, diffsynth_series_choices, diffsynth_default_series, diffsynth_filepath = get_diffsynth_cn_defaults(controlnet_key) for t_comp in diffsynth_cn_types: updates[t_comp] = gr.update(choices=diffsynth_all_types, value=diffsynth_default_type) for s_comp in diffsynth_cn_series: updates[s_comp] = gr.update(choices=diffsynth_series_choices, value=diffsynth_default_series) for f_comp in diffsynth_cn_filepaths: updates[f_comp] = diffsynth_filepath
krea2_all_types, krea2_default_type, krea2_series_choices, krea2_default_series, krea2_filepath = get_krea2_cn_defaults() for t_comp in krea2_cn_types: updates[t_comp] = gr.update(choices=krea2_all_types, value=krea2_default_type) for s_comp in krea2_cn_series: updates[s_comp] = gr.update(choices=krea2_series_choices, value=krea2_default_series) for f_comp in krea2_cn_filepaths: updates[f_comp] = krea2_filepath if ipa_preset and (arch_model_type in ["sdxl", "sd15", "sd35"]): config = load_ipadapter_config() ipa_arch_key = "SDXL" if arch_model_type in ["sdxl", "sd35"] else "SD1.5" std_presets = config.get("IPAdapter_presets", {}).get(ipa_arch_key, []) face_presets = config.get("IPAdapter_FaceID_presets", {}).get(ipa_arch_key, []) all_ipa_presets = std_presets + face_presets default_ipa = all_ipa_presets[0] if all_ipa_presets else None updates[ipa_preset] = gr.update(choices=all_ipa_presets, value=default_ipa) defaults = get_model_generation_defaults(val, arch_model_type, MODEL_DEFAULTS_CONFIG) if steps_comp: updates[steps_comp] = gr.update(value=defaults.get('steps')) if cfg_comp: updates[cfg_comp] = gr.update(value=defaults.get('cfg')) if sampler_comp: updates[sampler_comp] = gr.update(value=defaults.get('sampler_name')) if scheduler_comp: updates[scheduler_comp] = gr.update(value=defaults.get('scheduler')) if prompt_comp: updates[prompt_comp] = gr.update(value=defaults.get('positive_prompt')) if neg_prompt_comp: updates[neg_prompt_comp] = gr.update(value=defaults.get('negative_prompt')) return updates return update_fn
def make_model_change_fn(cat_comp_ref, cs_comp, ar_comp, width_comp, height_comp, cn_types, cn_series, cn_filepaths, anima_cn_types, anima_cn_series, anima_cn_filepaths, diffsynth_cn_types, diffsynth_cn_series, diffsynth_cn_filepaths, krea2_cn_types, krea2_cn_series, krea2_cn_filepaths, arch_comp_ref, ipa_preset, lora_acc, cn_acc, anima_cn_acc, diffsynth_cn_acc, krea2_cn_acc, ipa_acc, sd3_ipa_acc, flux1_ipa_acc, style_acc, embed_acc, cond_acc, ref_latent_acc, hidream_o1_ref_acc, guidance_comp, prompt_comp, neg_prompt_comp, steps_comp, cfg_comp, sampler_comp, scheduler_comp, pid_acc=None, vae_acc=None): def change_fn(*args): model_name = args[0] idx = 1 current_arch = args[idx] if arch_comp_ref and idx < len(args) else None if arch_comp_ref: idx += 1 current_cat = args[idx] if cat_comp_ref and idx < len(args) else None if cat_comp_ref: idx += 1 current_ar = args[idx] if idx < len(args) else None m_type = MODEL_TYPE_MAP.get(model_name, "SDXL") m_info = MODEL_MAP_CHECKPOINT.get(model_name) m_cat = m_info[4] if m_info and len(m_info) > 4 else None if not m_cat: m_cat = "ALL" updates = {} target_arch = m_type if arch_comp_ref: if current_arch == "ALL": updates[arch_comp_ref] = gr.update() target_arch = "ALL" else: updates[arch_comp_ref] = m_type if cat_comp_ref: if target_arch == "ALL": valid_cats = list(set(cat for cats in ARCH_CATEGORIES_MAP.values() for cat in cats)) else: valid_cats = ARCH_CATEGORIES_MAP.get(target_arch, []) cat_choices = ["ALL"] + sorted(valid_cats) if current_cat == "ALL": updates[cat_comp_ref] = gr.update(choices=cat_choices) else: updates[cat_comp_ref] = gr.update(choices=cat_choices, value=m_cat) 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', {})) 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 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)) if sd3_ipa_acc: updates[sd3_ipa_acc] = gr.update(visible=('sd3_ipadapter' in enabled_chains)) if style_acc: updates[style_acc] = gr.update(visible=('style' in enabled_chains)) if embed_acc: updates[embed_acc] = gr.update(visible=('embedding' in enabled_chains)) 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 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")) if guidance_comp: updates[guidance_comp] = gr.update(visible=(arch_model_type == "flux1")) if ar_comp: res_key = arch_model_type if res_key not in RESOLUTION_MAP: res_key = 'sdxl' res_map = RESOLUTION_MAP.get(res_key, {}) target_ar = current_ar if current_ar in res_map else (list(res_map.keys())[0] if res_map else "1:1 (Square)") updates[ar_comp] = gr.update(choices=list(res_map.keys()), value=target_ar) if width_comp and height_comp and target_ar in res_map: updates[width_comp] = gr.update(value=res_map[target_ar][0]) updates[height_comp] = gr.update(value=res_map[target_ar][1]) controlnet_key = architectures_dict.get(m_type, {}).get("controlnet_key", m_type) all_types, default_type, series_choices, default_series, filepath = get_cn_defaults(controlnet_key) for t_comp in cn_types: updates[t_comp] = gr.update(choices=all_types, value=default_type) for s_comp in cn_series: updates[s_comp] = gr.update(choices=series_choices, value=default_series) for f_comp in cn_filepaths: updates[f_comp] = filepath
anima_all_types, anima_default_type, anima_series_choices, anima_default_series, anima_filepath = get_anima_cn_defaults() for t_comp in anima_cn_types: updates[t_comp] = gr.update(choices=anima_all_types, value=anima_default_type) for s_comp in anima_cn_series: updates[s_comp] = gr.update(choices=anima_series_choices, value=anima_default_series) for f_comp in anima_cn_filepaths: updates[f_comp] = anima_filepath diffsynth_all_types, diffsynth_default_type, diffsynth_series_choices, diffsynth_default_series, diffsynth_filepath = get_diffsynth_cn_defaults(controlnet_key) for t_comp in diffsynth_cn_types: updates[t_comp] = gr.update(choices=diffsynth_all_types, value=diffsynth_default_type) for s_comp in diffsynth_cn_series: updates[s_comp] = gr.update(choices=diffsynth_series_choices, value=diffsynth_default_series) for f_comp in diffsynth_cn_filepaths: updates[f_comp] = diffsynth_filepath
krea2_all_types, krea2_default_type, krea2_series_choices, krea2_default_series, krea2_filepath = get_krea2_cn_defaults() for t_comp in krea2_cn_types: updates[t_comp] = gr.update(choices=krea2_all_types, value=krea2_default_type) for s_comp in krea2_cn_series: updates[s_comp] = gr.update(choices=krea2_series_choices, value=krea2_default_series) for f_comp in krea2_cn_filepaths: updates[f_comp] = krea2_filepath if ipa_preset and (arch_model_type in ["sdxl", "sd15", "sd35"]): config = load_ipadapter_config() ipa_arch_key = "SDXL" if arch_model_type in ["sdxl", "sd35"] else "SD1.5" std_presets = config.get("IPAdapter_presets", {}).get(ipa_arch_key, []) face_presets = config.get("IPAdapter_FaceID_presets", {}).get(ipa_arch_key, []) all_ipa_presets = std_presets + face_presets default_ipa = all_ipa_presets[0] if all_ipa_presets else None updates[ipa_preset] = gr.update(choices=all_ipa_presets, value=default_ipa) defaults = get_model_generation_defaults(model_name, arch_model_type, MODEL_DEFAULTS_CONFIG) if steps_comp: updates[steps_comp] = gr.update(value=defaults.get('steps')) if cfg_comp: updates[cfg_comp] = gr.update(value=defaults.get('cfg')) if sampler_comp: updates[sampler_comp] = gr.update(value=defaults.get('sampler_name')) if scheduler_comp: updates[scheduler_comp] = gr.update(value=defaults.get('scheduler')) if prompt_comp: updates[prompt_comp] = gr.update(value=defaults.get('positive_prompt')) if neg_prompt_comp: updates[neg_prompt_comp] = gr.update(value=defaults.get('negative_prompt')) return updates return change_fn
def initialize_all_cn_dropdowns(ui_components): default_model_name = list(MODEL_MAP_CHECKPOINT.keys())[0] if MODEL_MAP_CHECKPOINT else None default_m_type = MODEL_TYPE_MAP.get(default_model_name, "SDXL") if default_model_name else "SDXL" architectures_dict = ARCHITECTURES_CONFIG.get('architectures', {}) controlnet_key = architectures_dict.get(default_m_type, {}).get("controlnet_key", default_m_type) all_types, default_type, series_choices, default_series, filepath = get_cn_defaults(controlnet_key) anima_all_types, anima_default_type, anima_series_choices, anima_default_series, anima_filepath = get_anima_cn_defaults() diffsynth_all_types, diffsynth_default_type, diffsynth_series_choices, diffsynth_default_series, diffsynth_filepath = get_diffsynth_cn_defaults(controlnet_key) krea2_all_types, krea2_default_type, krea2_series_choices, krea2_default_series, krea2_filepath = get_krea2_cn_defaults() updates = {} for prefix in ["txt2img", "img2img", "inpaint", "outpaint", "hires_fix"]: if f'controlnet_types_{prefix}' in ui_components: for type_dd in ui_components[f'controlnet_types_{prefix}']: updates[type_dd] = gr.update(choices=all_types, value=default_type) for series_dd in ui_components[f'controlnet_series_{prefix}']: updates[series_dd] = gr.update(choices=series_choices, value=default_series) for filepath_state in ui_components[f'controlnet_filepaths_{prefix}']: updates[filepath_state] = filepath
if f'anima_controlnet_lllite_types_{prefix}' in ui_components: for type_dd in ui_components[f'anima_controlnet_lllite_types_{prefix}']: updates[type_dd] = gr.update(choices=anima_all_types, value=anima_default_type) for series_dd in ui_components[f'anima_controlnet_lllite_series_{prefix}']: updates[series_dd] = gr.update(choices=anima_series_choices, value=anima_default_series) for filepath_state in ui_components[f'anima_controlnet_lllite_filepaths_{prefix}']: updates[filepath_state] = anima_filepath if f'diffsynth_controlnet_types_{prefix}' in ui_components: for type_dd in ui_components[f'diffsynth_controlnet_types_{prefix}']: updates[type_dd] = gr.update(choices=diffsynth_all_types, value=diffsynth_default_type) for series_dd in ui_components[f'diffsynth_controlnet_series_{prefix}']: updates[series_dd] = gr.update(choices=diffsynth_series_choices, value=default_series) for filepath_state in ui_components[f'diffsynth_controlnet_filepaths_{prefix}']: updates[filepath_state] = diffsynth_filepath
if f'krea2_controlnet_types_{prefix}' in ui_components: for type_dd in ui_components[f'krea2_controlnet_types_{prefix}']: updates[type_dd] = gr.update(choices=krea2_all_types, value=krea2_default_type) for series_dd in ui_components[f'krea2_controlnet_series_{prefix}']: updates[series_dd] = gr.update(choices=krea2_series_choices, value=krea2_default_series) for filepath_state in ui_components[f'krea2_controlnet_filepaths_{prefix}']: updates[filepath_state] = krea2_filepath return updates
def initialize_all_ipa_dropdowns(ui_components): config = load_ipadapter_config() if not config: return {} default_model_name = list(MODEL_MAP_CHECKPOINT.keys())[0] if MODEL_MAP_CHECKPOINT else None default_m_type = MODEL_TYPE_MAP.get(default_model_name, "SDXL") if default_model_name else "SDXL" architectures_dict = ARCHITECTURES_CONFIG.get('architectures', {}) arch_model_type = architectures_dict.get(default_m_type, {}).get("model_type", default_m_type.lower().replace(" ", "").replace(".", "")) ipa_arch_key = "SDXL" if arch_model_type in ["sdxl", "sd35"] else "SD1.5"
unified_presets = config.get("IPAdapter_presets", {}).get(ipa_arch_key, []) faceid_presets = config.get("IPAdapter_FaceID_presets", {}).get(ipa_arch_key, []) all_presets = unified_presets + faceid_presets default_preset = all_presets[0] if all_presets else None is_faceid_default = default_preset in faceid_presets
lora_strength_update = gr.update(visible=is_faceid_default) updates = {} for prefix in ["txt2img", "img2img", "inpaint", "outpaint", "hires_fix"]: if f'ipadapter_final_preset_{prefix}' in ui_components: for lora_strength_slider in ui_components[f'ipadapter_lora_strengths_{prefix}']: updates[lora_strength_slider] = lora_strength_update updates[ui_components[f'ipadapter_final_preset_{prefix}']] = gr.update(choices=all_presets, value=default_preset) updates[ui_components[f'ipadapter_final_lora_strength_{prefix}']] = lora_strength_update return updates
def run_on_load(ui_components): cn_updates = initialize_all_cn_dropdowns(ui_components) ipa_updates = initialize_all_ipa_dropdowns(ui_components) return {**cn_updates, **ipa_updates}
def on_aspect_ratio_change(ratio_key, model_display_name): m_type = MODEL_TYPE_MAP.get(model_display_name, 'SDXL') architectures_dict = ARCHITECTURES_CONFIG.get('architectures', {}) arch_model_type = architectures_dict.get(m_type, {}).get("model_type", m_type.lower().replace(" ", "").replace(".", "")) res_map = RESOLUTION_MAP.get(arch_model_type, RESOLUTION_MAP.get("sdxl", {})) w, h = res_map.get(ratio_key, (1024, 1024))import gradio as gr
from core.settings import (
MODEL_TYPE_MAP,
MODEL_MAP_CHECKPOINT,
FEATURES_CONFIG,
ARCHITECTURES_CONFIG,
MODEL_DEFAULTS_CONFIG,
ARCH_CATEGORIES_MAP
)
from utils.app_utils import get_model_generation_defaults
from ui.shared.ui_components import RESOLUTION_MAP
from .config_loaders import (
get_cn_defaults,
get_anima_cn_defaults,
get_diffsynth_cn_defaults,
get_krea2_cn_defaults,
load_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]
current_ar = args[2] if len(args) > 2 else None
if arch == "ALL":
valid_cats = list(set(cat for cats in ARCH_CATEGORIES_MAP.values() for cat in cats))
else:
valid_cats = ARCH_CATEGORIES_MAP.get(arch, [])
cat_choices = ["ALL"] + sorted(valid_cats)
new_category = category if category in cat_choices else "ALL"
choices = []
for name, info in MODEL_MAP_CHECKPOINT.items():
m_arch = info[2]
m_cat = info[4] if len(info) > 4 else None
arch_match = (arch == "ALL" or m_arch == arch)
cat_match = (new_category == "ALL" or m_cat == new_category)
if arch_match and cat_match:
choices.append(name)
val = choices[0] if choices else None
updates = {
m_comp: gr.update(choices=choices, value=val),
cat_comp: gr.update(choices=cat_choices, value=new_category)
}
m_type = MODEL_TYPE_MAP.get(val, "SDXL") if val else "SDXL"
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', {}))
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 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))
if sd3_ipa_acc: updates[sd3_ipa_acc] = gr.update(visible=('sd3_ipadapter' in enabled_chains))
if style_acc: updates[style_acc] = gr.update(visible=('style' in enabled_chains))
if embed_acc: updates[embed_acc] = gr.update(visible=('embedding' in enabled_chains))
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 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"))
if guidance_comp:
updates[guidance_comp] = gr.update(visible=(arch_model_type == "flux1"))
if ar_comp:
res_key = arch_model_type
if res_key not in RESOLUTION_MAP:
res_key = 'sdxl'
res_map = RESOLUTION_MAP.get(res_key, {})
target_ar = current_ar if current_ar in res_map else (list(res_map.keys())[0] if res_map else "1:1 (Square)")
updates[ar_comp] = gr.update(choices=list(res_map.keys()), value=target_ar)
if width_comp and height_comp and target_ar in res_map:
updates[width_comp] = gr.update(value=res_map[target_ar][0])
updates[height_comp] = gr.update(value=res_map[target_ar][1])
controlnet_key = architectures_dict.get(m_type, {}).get("controlnet_key", m_type)
all_types, default_type, series_choices, default_series, filepath = get_cn_defaults(controlnet_key)
for t_comp in cn_types:
updates[t_comp] = gr.update(choices=all_types, value=default_type)
for s_comp in cn_series:
updates[s_comp] = gr.update(choices=series_choices, value=default_series)
for f_comp in cn_filepaths:
updates[f_comp] = filepath
anima_all_types, anima_default_type, anima_series_choices, anima_default_series, anima_filepath = get_anima_cn_defaults()
for t_comp in anima_cn_types:
updates[t_comp] = gr.update(choices=anima_all_types, value=anima_default_type)
for s_comp in anima_cn_series:
updates[s_comp] = gr.update(choices=anima_series_choices, value=anima_default_series)
for f_comp in anima_cn_filepaths:
updates[f_comp] = anima_filepath
diffsynth_all_types, diffsynth_default_type, diffsynth_series_choices, diffsynth_default_series, diffsynth_filepath = get_diffsynth_cn_defaults(controlnet_key)
for t_comp in diffsynth_cn_types:
updates[t_comp] = gr.update(choices=diffsynth_all_types, value=diffsynth_default_type)
for s_comp in diffsynth_cn_series:
updates[s_comp] = gr.update(choices=diffsynth_series_choices, value=diffsynth_default_series)
for f_comp in diffsynth_cn_filepaths:
updates[f_comp] = diffsynth_filepath
krea2_all_types, krea2_default_type, krea2_series_choices, krea2_default_series, krea2_filepath = get_krea2_cn_defaults()
for t_comp in krea2_cn_types:
updates[t_comp] = gr.update(choices=krea2_all_types, value=krea2_default_type)
for s_comp in krea2_cn_series:
updates[s_comp] = gr.update(choices=krea2_series_choices, value=krea2_default_series)
for f_comp in krea2_cn_filepaths:
updates[f_comp] = krea2_filepath
if ipa_preset and (arch_model_type in ["sdxl", "sd15", "sd35"]):
config = load_ipadapter_config()
ipa_arch_key = "SDXL" if arch_model_type in ["sdxl", "sd35"] else "SD1.5"
std_presets = config.get("IPAdapter_presets", {}).get(ipa_arch_key, [])
face_presets = config.get("IPAdapter_FaceID_presets", {}).get(ipa_arch_key, [])
all_ipa_presets = std_presets + face_presets
default_ipa = all_ipa_presets[0] if all_ipa_presets else None
updates[ipa_preset] = gr.update(choices=all_ipa_presets, value=default_ipa)
defaults = get_model_generation_defaults(val, arch_model_type, MODEL_DEFAULTS_CONFIG)
if steps_comp: updates[steps_comp] = gr.update(value=defaults.get('steps'))
if cfg_comp: updates[cfg_comp] = gr.update(value=defaults.get('cfg'))
if sampler_comp: updates[sampler_comp] = gr.update(value=defaults.get('sampler_name'))
if scheduler_comp: updates[scheduler_comp] = gr.update(value=defaults.get('scheduler'))
if prompt_comp: updates[prompt_comp] = gr.update(value=defaults.get('positive_prompt'))
if neg_prompt_comp: updates[neg_prompt_comp] = gr.update(value=defaults.get('negative_prompt'))
return updates
return update_fn
def make_model_change_fn(cat_comp_ref, cs_comp, ar_comp, width_comp, height_comp, cn_types, cn_series, cn_filepaths, anima_cn_types, anima_cn_series, anima_cn_filepaths, diffsynth_cn_types, diffsynth_cn_series, diffsynth_cn_filepaths, krea2_cn_types, krea2_cn_series, krea2_cn_filepaths, arch_comp_ref, ipa_preset, lora_acc, cn_acc, anima_cn_acc, diffsynth_cn_acc, krea2_cn_acc, ipa_acc, sd3_ipa_acc, flux1_ipa_acc, style_acc, embed_acc, cond_acc, ref_latent_acc, hidream_o1_ref_acc, guidance_comp, prompt_comp, neg_prompt_comp, steps_comp, cfg_comp, sampler_comp, scheduler_comp, pid_acc=None, vae_acc=None):
def change_fn(*args):
model_name = args[0]
idx = 1
current_arch = args[idx] if arch_comp_ref and idx < len(args) else None
if arch_comp_ref: idx += 1
current_cat = args[idx] if cat_comp_ref and idx < len(args) else None
if cat_comp_ref: idx += 1
current_ar = args[idx] if idx < len(args) else None
m_type = MODEL_TYPE_MAP.get(model_name, "SDXL")
m_info = MODEL_MAP_CHECKPOINT.get(model_name)
m_cat = m_info[4] if m_info and len(m_info) > 4 else None
if not m_cat: m_cat = "ALL"
updates = {}
target_arch = m_type
if arch_comp_ref:
if current_arch == "ALL":
updates[arch_comp_ref] = gr.update()
target_arch = "ALL"
else:
updates[arch_comp_ref] = m_type
if cat_comp_ref:
if target_arch == "ALL":
valid_cats = list(set(cat for cats in ARCH_CATEGORIES_MAP.values() for cat in cats))
else:
valid_cats = ARCH_CATEGORIES_MAP.get(target_arch, [])
cat_choices = ["ALL"] + sorted(valid_cats)
if current_cat == "ALL":
updates[cat_comp_ref] = gr.update(choices=cat_choices)
else:
updates[cat_comp_ref] = gr.update(choices=cat_choices, value=m_cat)
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', {}))
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 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))
if sd3_ipa_acc: updates[sd3_ipa_acc] = gr.update(visible=('sd3_ipadapter' in enabled_chains))
if style_acc: updates[style_acc] = gr.update(visible=('style' in enabled_chains))
if embed_acc: updates[embed_acc] = gr.update(visible=('embedding' in enabled_chains))
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 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"))
if guidance_comp:
updates[guidance_comp] = gr.update(visible=(arch_model_type == "flux1"))
if ar_comp:
res_key = arch_model_type
if res_key not in RESOLUTION_MAP:
res_key = 'sdxl'
res_map = RESOLUTION_MAP.get(res_key, {})
target_ar = current_ar if current_ar in res_map else (list(res_map.keys())[0] if res_map else "1:1 (Square)")
updates[ar_comp] = gr.update(choices=list(res_map.keys()), value=target_ar)
if width_comp and height_comp and target_ar in res_map:
updates[width_comp] = gr.update(value=res_map[target_ar][0])
updates[height_comp] = gr.update(value=res_map[target_ar][1])
controlnet_key = architectures_dict.get(m_type, {}).get("controlnet_key", m_type)
all_types, default_type, series_choices, default_series, filepath = get_cn_defaults(controlnet_key)
for t_comp in cn_types:
updates[t_comp] = gr.update(choices=all_types, value=default_type)
for s_comp in cn_series:
updates[s_comp] = gr.update(choices=series_choices, value=default_series)
for f_comp in cn_filepaths:
updates[f_comp] = filepath
anima_all_types, anima_default_type, anima_series_choices, anima_default_series, anima_filepath = get_anima_cn_defaults()
for t_comp in anima_cn_types:
updates[t_comp] = gr.update(choices=anima_all_types, value=anima_default_type)
for s_comp in anima_cn_series:
updates[s_comp] = gr.update(choices=anima_series_choices, value=anima_default_series)
for f_comp in anima_cn_filepaths:
updates[f_comp] = anima_filepath
diffsynth_all_types, diffsynth_default_type, diffsynth_series_choices, diffsynth_default_series, diffsynth_filepath = get_diffsynth_cn_defaults(controlnet_key)
for t_comp in diffsynth_cn_types:
updates[t_comp] = gr.update(choices=diffsynth_all_types, value=diffsynth_default_type)
for s_comp in diffsynth_cn_series:
updates[s_comp] = gr.update(choices=diffsynth_series_choices, value=diffsynth_default_series)
for f_comp in diffsynth_cn_filepaths:
updates[f_comp] = diffsynth_filepath
krea2_all_types, krea2_default_type, krea2_series_choices, krea2_default_series, krea2_filepath = get_krea2_cn_defaults()
for t_comp in krea2_cn_types:
updates[t_comp] = gr.update(choices=krea2_all_types, value=krea2_default_type)
for s_comp in krea2_cn_series:
updates[s_comp] = gr.update(choices=krea2_series_choices, value=krea2_default_series)
for f_comp in krea2_cn_filepaths:
updates[f_comp] = krea2_filepath
if ipa_preset and (arch_model_type in ["sdxl", "sd15", "sd35"]):
config = load_ipadapter_config()
ipa_arch_key = "SDXL" if arch_model_type in ["sdxl", "sd35"] else "SD1.5"
std_presets = config.get("IPAdapter_presets", {}).get(ipa_arch_key, [])
face_presets = config.get("IPAdapter_FaceID_presets", {}).get(ipa_arch_key, [])
all_ipa_presets = std_presets + face_presets
default_ipa = all_ipa_presets[0] if all_ipa_presets else None
updates[ipa_preset] = gr.update(choices=all_ipa_presets, value=default_ipa)
defaults = get_model_generation_defaults(model_name, arch_model_type, MODEL_DEFAULTS_CONFIG)
if steps_comp: updates[steps_comp] = gr.update(value=defaults.get('steps'))
if cfg_comp: updates[cfg_comp] = gr.update(value=defaults.get('cfg'))
if sampler_comp: updates[sampler_comp] = gr.update(value=defaults.get('sampler_name'))
if scheduler_comp: updates[scheduler_comp] = gr.update(value=defaults.get('scheduler'))
if prompt_comp: updates[prompt_comp] = gr.update(value=defaults.get('positive_prompt'))
if neg_prompt_comp: updates[neg_prompt_comp] = gr.update(value=defaults.get('negative_prompt'))
return updates
return change_fn
def initialize_all_cn_dropdowns(ui_components):
default_model_name = list(MODEL_MAP_CHECKPOINT.keys())[0] if MODEL_MAP_CHECKPOINT else None
default_m_type = MODEL_TYPE_MAP.get(default_model_name, "SDXL") if default_model_name else "SDXL"
architectures_dict = ARCHITECTURES_CONFIG.get('architectures', {})
controlnet_key = architectures_dict.get(default_m_type, {}).get("controlnet_key", default_m_type)
all_types, default_type, series_choices, default_series, filepath = get_cn_defaults(controlnet_key)
anima_all_types, anima_default_type, anima_series_choices, anima_default_series, anima_filepath = get_anima_cn_defaults()
diffsynth_all_types, diffsynth_default_type, diffsynth_series_choices, diffsynth_default_series, diffsynth_filepath = get_diffsynth_cn_defaults(controlnet_key)
krea2_all_types, krea2_default_type, krea2_series_choices, krea2_default_series, krea2_filepath = get_krea2_cn_defaults()
updates = {}
for prefix in ["txt2img", "img2img", "inpaint", "outpaint", "hires_fix"]:
if f'controlnet_types_{prefix}' in ui_components:
for type_dd in ui_components[f'controlnet_types_{prefix}']:
updates[type_dd] = gr.update(choices=all_types, value=default_type)
for series_dd in ui_components[f'controlnet_series_{prefix}']:
updates[series_dd] = gr.update(choices=series_choices, value=default_series)
for filepath_state in ui_components[f'controlnet_filepaths_{prefix}']:
updates[filepath_state] = filepath
if f'anima_controlnet_lllite_types_{prefix}' in ui_components:
for type_dd in ui_components[f'anima_controlnet_lllite_types_{prefix}']:
updates[type_dd] = gr.update(choices=anima_all_types, value=anima_default_type)
for series_dd in ui_components[f'anima_controlnet_lllite_series_{prefix}']:
updates[series_dd] = gr.update(choices=anima_series_choices, value=anima_default_series)
for filepath_state in ui_components[f'anima_controlnet_lllite_filepaths_{prefix}']:
updates[filepath_state] = anima_filepath
if f'diffsynth_controlnet_types_{prefix}' in ui_components:
for type_dd in ui_components[f'diffsynth_controlnet_types_{prefix}']:
updates[type_dd] = gr.update(choices=diffsynth_all_types, value=diffsynth_default_type)
for series_dd in ui_components[f'diffsynth_controlnet_series_{prefix}']:
updates[series_dd] = gr.update(choices=diffsynth_series_choices, value=default_series)
for filepath_state in ui_components[f'diffsynth_controlnet_filepaths_{prefix}']:
updates[filepath_state] = diffsynth_filepath
if f'krea2_controlnet_types_{prefix}' in ui_components:
for type_dd in ui_components[f'krea2_controlnet_types_{prefix}']:
updates[type_dd] = gr.update(choices=krea2_all_types, value=krea2_default_type)
for series_dd in ui_components[f'krea2_controlnet_series_{prefix}']:
updates[series_dd] = gr.update(choices=krea2_series_choices, value=krea2_default_series)
for filepath_state in ui_components[f'krea2_controlnet_filepaths_{prefix}']:
updates[filepath_state] = krea2_filepath
return updates
def initialize_all_ipa_dropdowns(ui_components):
config = load_ipadapter_config()
if not config: return {}
default_model_name = list(MODEL_MAP_CHECKPOINT.keys())[0] if MODEL_MAP_CHECKPOINT else None
default_m_type = MODEL_TYPE_MAP.get(default_model_name, "SDXL") if default_model_name else "SDXL"
architectures_dict = ARCHITECTURES_CONFIG.get('architectures', {})
arch_model_type = architectures_dict.get(default_m_type, {}).get("model_type", default_m_type.lower().replace(" ", "").replace(".", ""))
ipa_arch_key = "SDXL" if arch_model_type in ["sdxl", "sd35"] else "SD1.5"
unified_presets = config.get("IPAdapter_presets", {}).get(ipa_arch_key, [])
faceid_presets = config.get("IPAdapter_FaceID_presets", {}).get(ipa_arch_key, [])
all_presets = unified_presets + faceid_presets
default_preset = all_presets[0] if all_presets else None
is_faceid_default = default_preset in faceid_presets
lora_strength_update = gr.update(visible=is_faceid_default)
updates = {}
for prefix in ["txt2img", "img2img", "inpaint", "outpaint", "hires_fix"]:
if f'ipadapter_final_preset_{prefix}' in ui_components:
for lora_strength_slider in ui_components[f'ipadapter_lora_strengths_{prefix}']:
updates[lora_strength_slider] = lora_strength_update
updates[ui_components[f'ipadapter_final_preset_{prefix}']] = gr.update(choices=all_presets, value=default_preset)
updates[ui_components[f'ipadapter_final_lora_strength_{prefix}']] = lora_strength_update
return updates
def run_on_load(ui_components):
cn_updates = initialize_all_cn_dropdowns(ui_components)
ipa_updates = initialize_all_ipa_dropdowns(ui_components)
return {**cn_updates, **ipa_updates}
def on_aspect_ratio_change(ratio_key, model_display_name):
m_type = MODEL_TYPE_MAP.get(model_display_name, 'SDXL')
architectures_dict = ARCHITECTURES_CONFIG.get('architectures', {})
arch_model_type = architectures_dict.get(m_type, {}).get("model_type", m_type.lower().replace(" ", "").replace(".", ""))
res_map = RESOLUTION_MAP.get(arch_model_type, RESOLUTION_MAP.get("sdxl", {}))
w, h = res_map.get(ratio_key, (1024, 1024))
return w, h11 unmodified lines1213141516171819202122231516171811 unmodified lines with gr.Blocks() as demo:
gr.Markdown("# ImageGen")
gr.Markdown(
"This demo is a streamlined version of the [Comfy web UI](https://github.com/RioShiina47/comfy-webui)'s [ImageGen](https://huggingface.co/spaces/RioShiina/ImageGen) functionality. "
"Other spaces: [ImageGen1](https://huggingface.co/spaces/RioShiina/ImageGen1), "
"[ImageGen2](https://huggingface.co/spaces/RioShiina/ImageGen2), "
"[ImageGen3](https://huggingface.co/spaces/RioShiina/ImageGen3), "
"[ImageGen4](https://huggingface.co/spaces/RioShiina/ImageGen4), "
"[ImageGen5](https://huggingface.co/spaces/RioShiina/ImageGen5), "
"[ImageGen6](https://huggingface.co/spaces/RioShiina/ImageGen6), "
"[ImageGen7](https://huggingface.co/spaces/RioShiina/ImageGen7), "
"[ImageGen8](https://huggingface.co/spaces/RioShiina/ImageGen8)"
"This demo is a streamlined version of the [Comfy web UI](https://github.com/RioShiina47/comfy-webui)'s [ImageGen](https://huggingface.co/spaces/RioShiina/ImageGen) functionality."
)
with gr.Tabs(elem_id="tabs_container") as tabs:
with gr.TabItem("Txt2Img", id=0):249 unmodified lines250251252253253254255255256257249 unmodified lines components = {}
key = lambda name: f"{name}_{prefix}"
with gr.Accordion("Anima ControlNet Lllite Settings", open=False, visible=('anima_controlnet_lllite' in default_enabled_chains)) as accordion:
with gr.Accordion("Anima ControlNet LLLite Settings", open=False, visible=('anima_controlnet_lllite' in default_enabled_chains)) as accordion:
components[key('anima_controlnet_lllite_accordion')] = accordion
gr.Markdown("💡 **Tip:** Processed using the [kohya-ss/ComfyUI-Anima-LLLite](https://github.com/kohya-ss/ComfyUI-Anima-LLLite) node.")
cn_rows, images, series, types, strengths, filepaths, start_percents, end_percents = [], [], [], [], [], [], [], []
components.update({1223445678910111213Anima_ControlNet_Lllite:
- Filepath: "anima-lllite-lineart-1.safetensors"
- Filepath: "anima-lllite-any-test-like-v2.safetensors"
Series: "kohya-ss"
Type: ["Lineart"]
Type: ["Any-Test"]
- Filepath: "anima-lllite-depth-1.safetensors"
Series: "kohya-ss"
Type: ["Depth"]
- Filepath: "anima-lllite-lineart-1.safetensors"
Series: "kohya-ss"
Type: ["Lineart"]
- Filepath: "anima-lllite-pose-1.safetensors"
Series: "kohya-ss"
Type: ["Pose"]198 unmodified lines19920020120220320420520620720820921021121244 unmodified lines257258259260261262263198 unmodified lines "3:4 (Classic Portrait)": [896, 1152]
"3:2 (Photography)": [1216, 832]
"2:3 (Photography Portrait)": [832, 1216]
auraflow:
"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]
sd35:
"1:1 (Square)": [1024, 1024]
"16:9 (Landscape)": [1344, 768]44 unmodified lines hidream-o1: 32
hidream-i1: 1
flux1: 1
auraflow: 1
sd35: 1
sdxl: 1
sd15: 113 unmodified lines1415161718192021222324100 unmodified lines12512612712812913013113213313413520 unmodified lines156157158149150151152153154155156157158159160161162163164165159160161580 unmodified lines74274374474574674774874975075175275375475575675775875976076176276376476576676776813 unmodified lines source: "hf"
repo_id: "Comfy-Org/Lumina_Image_2.0_Repackaged"
repository_file_path: "all_in_one/lumina_2.safetensors"
# AuraFlow
- filename: "aura_flow_0.3.safetensors"
source: "hf"
repo_id: "fal/AuraFlow-v0.3"
repository_file_path: "aura_flow_0.3.safetensors"
# SD3.5
- filename: "sd3.5_large_fp8_scaled.safetensors"
source: "hf"100 unmodified lines source: "hf"
repo_id: "stabilityai/stable-diffusion-xl-base-1.0"
repository_file_path: "sd_xl_base_1.0.safetensors"
# SDXL-Turbo
- filename: "sd_xl_turbo_1.0_fp16.safetensors"
source: "hf"
repo_id: "stabilityai/sdxl-turbo"
repository_file_path: "sd_xl_turbo_1.0_fp16.safetensors"
# SD1.5
- filename: "v1-5-pruned-emaonly.safetensors"
source: "hf"20 unmodified lines repo_id: "Comfy-Org/sigclip_vision_384"
repository_file_path: "sigclip_vision_patch14_384.safetensors"
controlnet:
# Anima
- filename: "anima-lllite-lineart-1.safetensors"
source: "hf"
repo_id: "kohya-ss/Anima-LLLite"
repository_file_path: "anima-lllite-lineart-1.safetensors"
- filename: "anima-lllite-depth-1.safetensors"
source: "hf"
repo_id: "kohya-ss/Anima-LLLite"
repository_file_path: "anima-lllite-depth-1.safetensors"
- filename: "anima-lllite-pose-1.safetensors"
source: "hf"
repo_id: "kohya-ss/Anima-LLLite"
repository_file_path: "anima-lllite-pose-1.safetensors"
- filename: "anima-lllite-scribble-1.safetensors"
source: "hf"
repo_id: "kohya-ss/Anima-LLLite"
repository_file_path: "anima-lllite-scribble-1.safetensors"
# SD3.5
- filename: "sd3.5_large_controlnet_blur.safetensors"
source: "hf"580 unmodified lines repo_id: "h94/IP-Adapter-FaceID"
repository_file_path: "ip-adapter-faceid-plusv2_sdxl_lora.safetensors"
model_patches:
# Anima
- filename: "anima-lllite-any-test-like-v2.safetensors"
source: "hf"
repo_id: "Comfy-Org/Anima-LLLite"
repository_file_path: "model_patches/anima-lllite-any-test-like-v2.safetensors"
- filename: "anima-lllite-lineart-1.safetensors"
source: "hf"
repo_id: "Comfy-Org/Anima-LLLite"
repository_file_path: "model_patches/anima-lllite-lineart-1.safetensors"
- filename: "anima-lllite-depth-1.safetensors"
source: "hf"
repo_id: "Comfy-Org/Anima-LLLite"
repository_file_path: "model_patches/anima-lllite-depth-1.safetensors"
- filename: "anima-lllite-pose-1.safetensors"
source: "hf"
repo_id: "Comfy-Org/Anima-LLLite"
repository_file_path: "model_patches/anima-lllite-pose-1.safetensors"
- filename: "anima-lllite-scribble-1.safetensors"
source: "hf"
repo_id: "Comfy-Org/Anima-LLLite"
repository_file_path: "model_patches/anima-lllite-scribble-1.safetensors"
# Z-Image
- filename: "Z-Image-Turbo-Fun-Controlnet-Union-2.1-8steps.safetensors"
source: "hf"161 unmodified lines162163164165166167168169170171172173161 unmodified lines - vae
- pid
auraflow:
enabled_chains:
- lora
- conditioning
- vae
sd35:
enabled_chains:
- lora22 unmodified lines2324252627282959 unmodified lines89909192939495969722 unmodified lines - "HiDream-O1"
- "HiDream-I1"
- "FLUX.1"
- "AuraFlow"
- "SD3.5"
- "SDXL"
- "SD1.5"59 unmodified lines "FLUX.1":
model_type: "flux1"
controlnet_key: "FLUX.1"
"AuraFlow":
model_type: "auraflow"
controlnet_key: "AuraFlow"
"SDXL":
model_type: "sdxl"
controlnet_key: "SDXL"242 unmodified lines2432442452462472482492502512522532542552562572582592602615 unmodified lines267268269257270271259260272273274275276277278242 unmodified lines sampler_name: "euler"
scheduler: "simple"
AuraFlow:
_defaults:
steps: 20
cfg: 3.5
sampler_name: "euler"
scheduler: "sgm_uniform"
"PurpleSmartAI/Pony-V7-Base":
steps: 40
cfg: 3.5
sampler_name: "euler"
scheduler: "simple"
positive_prompt: "special tags, factual description of image, stylistic description of image, additional content tags"
SD3.5:
_defaults:
steps: 205 unmodified lines _defaults:
steps: 25
cfg: 7.0
sampler_name: "euler"
sampler_name: "euler_ancestral"
scheduler: "simple"
positive_prompt: ""
negative_prompt: ""
"stabilityai/SDXL-Turbo-1.0":
steps: 1
cfg: 1.0
positive_prompt: "NOTE: The model generates images of size 512x512 but higher image sizes work as well."
SD1.5:
_defaults:323 unmodified lines32432532632732832933033133233333475 unmodified lines410411412408413414415416417418419420421422323 unmodified lines vae: "ae.safetensors"
clip1: "clip_l.safetensors"
clip2: "t5xxl_fp8_e4m3fn_scaled.safetensors"
AuraFlow:
latent_type: latent
models:
- display_name: "fal/AuraFlow-v0.3"
path: "aura_flow_0.3.safetensors"
SD3.5:
latent_type: sd3_latent
models:75 unmodified lines path: "CyberRealisticPony_V17.0_FP16.safetensors"
category: "Pony"
# SDXL-Base
- display_name: "stabilityai/stable-diffusion-xl-base-1.0"
- display_name: "stabilityai/SDXL-Base-1.0"
path: "sd_xl_base_1.0.safetensors"
category: "Base"
# SDXL-Turbo
- display_name: "stabilityai/SDXL-Turbo-1.0"
path: "sd_xl_turbo_1.0_fp16.safetensors"
category: "Turbo"
SD1.5:
latent_type: latent
models:.gitattributes+35-4
app.py+36-6
chain_injectors/anima_controlnet_lllite_injector.py+6-1
comfy_integration/setup.py+1-9
core/pipelines/base_pipeline.py+14-3
core/pipelines/workflow_recipes/_partials/conditioning/auraflow.yamlAdded+48
requirements.txt+2-2
ui/events/chain_handlers.py+19
ui/events/change_handlers.py+364-364
ui/layout.py+1-9
ui/shared/ui_components.py+1-2
yaml/anima_controlnet_lllite_models.yaml+5-2
yaml/constants.yaml+9
yaml/file_list.yaml+31-17
yaml/image_gen_features.yaml+6
yaml/model_architectures.yaml+4
yaml/model_defaults.yaml+18-3
yaml/model_list.yaml+10-1