Add Krea-2 architecture and Krea-2 ControlNet injector
Browse filesFiles changed (30)
- .gitattributes+4-35
- chain_injectors/krea2_controlnet_injector.pyAdded+78
- comfy_integration/setup.py+14
- core/pipelines/pipeline_input_processor.py+383-334
- core/pipelines/sd_image_pipeline.py+258-253
- core/pipelines/workflow_recipes/_partials/conditioning/krea-2.yamlAdded+63
- core/pipelines/workflow_recipes/_partials/conditioning/qwen-image.yaml+2-11
- core/settings.py+2
- core/workflow_assembler.py-1
- requirements.txt+8-7
- ui/events/__init__.py+2
- ui/events/chain_handlers.py+95-1
- ui/events/change_handlers.py+32-2
- ui/events/config_loaders.py+38-1
- ui/events/main.py+24-4
- ui/events/run_handlers.py+104-102
- ui/shared/hires_fix_ui.py+26-8
- ui/shared/img2img_ui.py+25-8
- ui/shared/inpaint_ui.py+25-8
- ui/shared/outpaint_ui.py+25-8
- ui/shared/txt2img_ui.py+2-1
- ui/shared/ui_components.py+71-14
- utils/app_utils.py+129-35
- yaml/constants.yaml+106-29
- yaml/file_list.yaml+102-32
- yaml/image_gen_features.yaml+90-41
- yaml/krea2_controlnet_models.yamlAdded+4
- yaml/model_architectures.yaml+17-3
- yaml/model_defaults.yaml+106-54
- yaml/model_list.yaml+93-18
12345678910111213141516171819202122232425262728293031323334351234*.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 -text/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 -text123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778def inject(assembler, chain_definition, chain_items):
if not chain_items:
return
ksampler_name = chain_definition.get('ksampler_node', 'ksampler')
if ksampler_name not in assembler.node_map:
print(f"Warning: Target node '{ksampler_name}' for Krea2 ControlNet chain not found. Skipping.")
return
ksampler_id = assembler.node_map[ksampler_name]
if 'model' not in assembler.workflow[ksampler_id]['inputs']:
print(f"Warning: KSampler node '{ksampler_name}' is missing 'model' input. Skipping.")
return
vae_source_str = chain_definition.get('vae_source')
vae_connection = None
if vae_source_str:
vae_node_name, vae_idx_str = vae_source_str.split(':')
if vae_node_name in assembler.node_map:
vae_connection = [assembler.node_map[vae_node_name], int(vae_idx_str)]
latent_connection = assembler.workflow[ksampler_id]['inputs'].get('latent_image')
if not latent_connection:
print(f"Warning: KSampler node '{ksampler_name}' is missing 'latent_image' input. Krea2 ControlNet requires it. Skipping.")
return
current_model_connection = assembler.workflow[ksampler_id]['inputs']['model']
for item_data in chain_items:
image_loader_id = assembler._get_unique_id()
image_loader_node = assembler._get_node_template("LoadImage")
image_loader_node['inputs']['image'] = item_data['image']
assembler.workflow[image_loader_id] = image_loader_node
image_scaler_id = assembler._get_unique_id()
image_scaler_node = assembler._get_node_template("ImageScaleToTotalPixels")
image_scaler_node['inputs']['image'] = [image_loader_id, 0]
image_scaler_node['inputs']['upscale_method'] = 'nearest-exact'
image_scaler_node['inputs']['megapixels'] = 1.0
image_scaler_node['inputs']['resolution_steps'] = 1
assembler.workflow[image_scaler_id] = image_scaler_node
lora_loader_id = assembler._get_unique_id()
lora_loader_node = assembler._get_node_template("Krea2ControlLoRALoader")
lora_loader_node['inputs']['lora_name'] = item_data['control_net_name']
lora_loader_node['inputs']['strength'] = item_data.get('strength', 1.0)
lora_loader_node['inputs']['model'] = current_model_connection
assembler.workflow[lora_loader_id] = lora_loader_node
img_encode_id = assembler._get_unique_id()
img_encode_node = assembler._get_node_template("Krea2ControlImageEncode")
img_encode_node['inputs']['resize'] = "match_latent_size"
img_encode_node['inputs']['upscale_method'] = "lanczos"
img_encode_node['inputs']['crop'] = "center"
img_encode_node['inputs']['channel_mode'] = "rgb"
img_encode_node['inputs']['normalize'] = "none"
img_encode_node['inputs']['invert'] = False
img_encode_node['inputs']['batch_mode'] = "independent_images"
img_encode_node['inputs']['control_image'] = [image_scaler_id, 0]
if vae_connection:
img_encode_node['inputs']['vae'] = vae_connection
if latent_connection:
img_encode_node['inputs']['latent'] = latent_connection
assembler.workflow[img_encode_id] = img_encode_node
apply_cn_id = assembler._get_unique_id()
apply_cn_node = assembler._get_node_template("Krea2ControlApply")
apply_cn_node['inputs']['model'] = [lora_loader_id, 0]
apply_cn_node['inputs']['control_latent'] = [img_encode_id, 0]
assembler.workflow[apply_cn_id] = apply_cn_node
current_model_connection = [apply_cn_id, 0]
assembler.workflow[ksampler_id]['inputs']['model'] = current_model_connection
print(f"Krea2 ControlNet injector applied. KSampler model input redirected through {len(chain_items)} Krea2 ControlNet nodes.")64 unmodified lines65666768697071727374757611 unmodified lines88899091929394959697989910010164 unmodified lines print("✅ ComfyUI-IPAdapter-Flux extension cloned.")
else:
print("✅ ComfyUI-IPAdapter-Flux extension already exists.")
try:
print("--- [Setup] Applying PR #108 compatibility patch for ComfyUI-IPAdapter-Flux ---")
os.system(f"git -C {ipadapter_flux_path} fetch origin pull/108/head && git -C {ipadapter_flux_path} checkout -f FETCH_HEAD")
print("✅ Successfully applied PR #108 compatibility patch.")
except Exception as e:
print(f"⚠️ Warning: Could not apply PR #108 compatibility patch for ComfyUI-IPAdapter-Flux: {e}")
# 4. ComfyUI-Newbie-Nodes
newbie_nodes_path = os.path.join(APP_DIR, "custom_nodes", "ComfyUI-Newbie-Nodes")11 unmodified lines else:
print("✅ ComfyUI-Anima-LLLite extension already exists.")
# 6. 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}")
print("✅ comfyui-krea2-controlnet extension cloned.")
else:
print("✅ comfyui-krea2-controlnet extension already exists.")
print(f"✅ Current working directory is: {os.getcwd()}")
import comfy.model_management123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383import osimport randomimport numpy as npimport gradio as grfrom PIL import Image, ImageChopsfrom typing import Dict, Any, List
from core.settings import INPUT_DIRfrom utils.app_utils import ( sanitize_filename, get_lora_path, get_embedding_path, ensure_controlnet_model_downloaded, ensure_ipadapter_models_downloaded, _ensure_model_downloaded, ensure_sd3_ipadapter_models_downloaded, get_vae_path,)
def process_pipeline_inputs(ui_inputs: Dict[str, Any], progress: gr.Progress, workflow_model_type: str) -> Dict[str, Any]: task_type = ui_inputs['task_type'] temp_files_to_clean = [] lora_data = ui_inputs.get('lora_data', []) active_loras_for_gpu, active_loras_for_meta = [], [] if lora_data: sources, ids, scales, files = lora_data[0::4], lora_data[1::4], lora_data[2::4], lora_data[3::4] for i, (source, lora_id, scale, _) in enumerate(zip(sources, ids, scales, files)): if scale > 0 and lora_id and lora_id.strip(): lora_filename = None if source == "File": lora_filename = sanitize_filename(lora_id) elif source == "Civitai": local_path, status = get_lora_path(source, lora_id, os.environ.get("CIVITAI_API_KEY", ""), progress) if local_path: lora_filename = os.path.basename(local_path) else: raise gr.Error(f"Failed to prepare LoRA {lora_id}: {status}") if lora_filename: active_loras_for_gpu.append({"lora_name": lora_filename, "strength_model": scale, "strength_clip": scale}) active_loras_for_meta.append(f"{source} {lora_id}:{scale}")
ui_inputs['denoise'] = 1.0 if task_type == 'img2img': ui_inputs['denoise'] = ui_inputs.get('img2img_denoise', 0.7) elif task_type == 'hires_fix': ui_inputs['denoise'] = ui_inputs.get('hires_denoise', 0.55) if not os.path.exists(INPUT_DIR): os.makedirs(INPUT_DIR)
if task_type == 'img2img': input_image_pil = ui_inputs.get('img2img_image') if not input_image_pil: raise gr.Error("Please upload an image for Image-to-Image.") temp_file_path = os.path.join(INPUT_DIR, f"temp_input_{random.randint(1000, 9999)}.png") input_image_pil.save(temp_file_path, "PNG") ui_inputs['input_image'] = os.path.basename(temp_file_path) temp_files_to_clean.append(temp_file_path) ui_inputs['width'] = input_image_pil.width ui_inputs['height'] = input_image_pil.height elif task_type == 'inpaint': inpaint_dict = ui_inputs.get('inpaint_image_dict') if not inpaint_dict or not inpaint_dict.get('background') or not inpaint_dict.get('layers'): raise gr.Error("Inpainting requires an input image and a drawn mask.") background_img = inpaint_dict['background'].convert("RGBA") composite_mask_pil = Image.new('L', background_img.size, 0) for layer in inpaint_dict['layers']: if layer: layer_alpha = layer.split()[-1] composite_mask_pil = ImageChops.lighter(composite_mask_pil, layer_alpha)
inverted_mask_alpha = Image.fromarray(255 - np.array(composite_mask_pil), mode='L') r, g, b, _ = background_img.split() composite_image_with_mask = Image.merge('RGBA', [r, g, b, inverted_mask_alpha]) temp_file_path = os.path.join(INPUT_DIR, f"temp_inpaint_composite_{random.randint(1000, 9999)}.png") composite_image_with_mask.save(temp_file_path, "PNG") ui_inputs['input_image'] = os.path.basename(temp_file_path) temp_files_to_clean.append(temp_file_path) ui_inputs.pop('inpaint_mask', None)
elif task_type == 'outpaint': input_image_pil = ui_inputs.get('outpaint_image') if not input_image_pil: raise gr.Error("Please upload an image for Outpainting.") temp_file_path = os.path.join(INPUT_DIR, f"temp_input_{random.randint(1000, 9999)}.png") input_image_pil.save(temp_file_path, "PNG") ui_inputs['input_image'] = os.path.basename(temp_file_path) temp_files_to_clean.append(temp_file_path) ui_inputs['megapixels'] = 0.25 ui_inputs['grow_mask_by'] = ui_inputs.get('feathering', 10)
elif task_type == 'hires_fix': input_image_pil = ui_inputs.get('hires_image') if not input_image_pil: raise gr.Error("Please upload an image for Hires Fix.") temp_file_path = os.path.join(INPUT_DIR, f"temp_input_{random.randint(1000, 9999)}.png") input_image_pil.save(temp_file_path, "PNG") ui_inputs['input_image'] = os.path.basename(temp_file_path) temp_files_to_clean.append(temp_file_path)
embedding_data = ui_inputs.get('embedding_data', []) embedding_filenames = [] if embedding_data: emb_sources, emb_ids, emb_files = embedding_data[0::3], embedding_data[1::3], embedding_data[2::3] for i, (source, emb_id, _) in enumerate(zip(emb_sources, emb_ids, emb_files)): if emb_id and emb_id.strip(): emb_filename = None if source == "File": emb_filename = sanitize_filename(emb_id) elif source == "Civitai": local_path, status = get_embedding_path(source, emb_id, os.environ.get("CIVITAI_API_KEY", ""), progress) if local_path: emb_filename = os.path.basename(local_path) else: raise gr.Error(f"Failed to prepare Embedding {emb_id}: {status}") if emb_filename: embedding_filenames.append(emb_filename) if embedding_filenames: embedding_prompt_text = " ".join([f"embedding:{f}" for f in embedding_filenames]) if ui_inputs['positive_prompt']: ui_inputs['positive_prompt'] = f"{ui_inputs['positive_prompt']}, {embedding_prompt_text}" else: ui_inputs['positive_prompt'] = embedding_prompt_text
controlnet_data = ui_inputs.get('controlnet_data', []) active_controlnets = [] if controlnet_data: (cn_images, _, _, cn_strengths, cn_filepaths) = [controlnet_data[i::5] for i in range(5)] for i in range(len(cn_images)): if cn_images[i] and cn_strengths[i] > 0 and cn_filepaths[i] and cn_filepaths[i] != "None": ensure_controlnet_model_downloaded(cn_filepaths[i], progress) if not os.path.exists(INPUT_DIR): os.makedirs(INPUT_DIR) cn_temp_path = os.path.join(INPUT_DIR, f"temp_cn_{i}_{random.randint(1000, 9999)}.png") cn_images[i].save(cn_temp_path, "PNG") temp_files_to_clean.append(cn_temp_path) active_controlnets.append({ "image": os.path.basename(cn_temp_path), "strength": cn_strengths[i], "start_percent": 0.0, "end_percent": 1.0, "control_net_name": cn_filepaths[i] }) anima_controlnet_lllite_data = ui_inputs.get('anima_controlnet_lllite_data', []) active_anima_controlnets = [] if anima_controlnet_lllite_data: (cn_images, _, _, cn_strengths, cn_filepaths, cn_starts, cn_ends) = [anima_controlnet_lllite_data[i::7] for i in range(7)] for i in range(len(cn_images)): if cn_images[i] and cn_strengths[i] > 0 and cn_filepaths[i] and cn_filepaths[i] != "None": _ensure_model_downloaded(cn_filepaths[i], progress) if not os.path.exists(INPUT_DIR): os.makedirs(INPUT_DIR) cn_temp_path = os.path.join(INPUT_DIR, f"temp_anima_cn_{i}_{random.randint(1000, 9999)}.png") cn_images[i].save(cn_temp_path, "PNG") temp_files_to_clean.append(cn_temp_path) active_anima_controlnets.append({ "image": os.path.basename(cn_temp_path), "strength": cn_strengths[i], "start_percent": cn_starts[i], "end_percent": cn_ends[i], "control_net_name": cn_filepaths[i] })
diffsynth_controlnet_data = ui_inputs.get('diffsynth_controlnet_data', []) active_diffsynth_controlnets = [] if diffsynth_controlnet_data: (cn_images, _, _, cn_strengths, cn_filepaths) = [diffsynth_controlnet_data[i::5] for i in range(5)] for i in range(len(cn_images)): if cn_images[i] and cn_strengths[i] > 0 and cn_filepaths[i] and cn_filepaths[i] != "None": ensure_controlnet_model_downloaded(cn_filepaths[i], progress) if not os.path.exists(INPUT_DIR): os.makedirs(INPUT_DIR) cn_temp_path = os.path.join(INPUT_DIR, f"temp_diffsynth_cn_{i}_{random.randint(1000, 9999)}.png") cn_images[i].save(cn_temp_path, "PNG") temp_files_to_clean.append(cn_temp_path) active_diffsynth_controlnets.append({ "image": os.path.basename(cn_temp_path), "strength": cn_strengths[i], "control_net_name": cn_filepaths[i] }) ipadapter_data = ui_inputs.get('ipadapter_data', []) active_ipadapters = [] if ipadapter_data: num_ipa_units = (len(ipadapter_data) - 5) // 3 final_preset, final_weight, final_lora_strength, final_embeds_scaling, final_combine_method = ipadapter_data[-5:] ipa_images, ipa_weights, ipa_lora_strengths = [ipadapter_data[i*num_ipa_units:(i+1)*num_ipa_units] for i in range(3)] all_presets_to_download = set() for i in range(num_ipa_units): if ipa_images[i] and ipa_weights[i] > 0 and final_preset: all_presets_to_download.add(final_preset) if not os.path.exists(INPUT_DIR): os.makedirs(INPUT_DIR) ipa_temp_path = os.path.join(INPUT_DIR, f"temp_ipa_{i}_{random.randint(1000, 9999)}.png") ipa_images[i].save(ipa_temp_path, "PNG") temp_files_to_clean.append(ipa_temp_path) active_ipadapters.append({ "image": os.path.basename(ipa_temp_path), "preset": final_preset, "weight": ipa_weights[i], "lora_strength": ipa_lora_strengths[i] }) if active_ipadapters and final_preset: all_presets_to_download.add(final_preset) for preset in all_presets_to_download: ensure_ipadapter_models_downloaded(preset, progress) model_type_key = 'sd15' if workflow_model_type == 'sd15' else 'sdxl' if active_ipadapters: active_ipadapters.append({ 'is_final_settings': True, 'model_type': model_type_key, 'final_preset': final_preset, 'final_weight': final_weight, 'final_lora_strength': final_lora_strength, 'final_embeds_scaling': final_embeds_scaling, 'final_combine_method': final_combine_method }) flux1_ipadapter_data = ui_inputs.get('flux1_ipadapter_data', []) active_flux1_ipadapters = [] if flux1_ipadapter_data: num_units = len(flux1_ipadapter_data) // 4 f_images = flux1_ipadapter_data[0*num_units : 1*num_units] f_weights = flux1_ipadapter_data[1*num_units : 2*num_units] f_starts = flux1_ipadapter_data[2*num_units : 3*num_units] f_ends = flux1_ipadapter_data[3*num_units : 4*num_units] for i in range(len(f_images)): if f_images[i] and f_weights[i] > 0: for filename in ["ip-adapter.bin"]: _ensure_model_downloaded(filename, progress) from huggingface_hub import snapshot_download progress(0.5, desc="Caching HF SigLIP model...") snapshot_download( repo_id="google/siglip-so400m-patch14-384", allow_patterns=["*.json", "*.safetensors", "*.txt"], ignore_patterns=["*.msgpack", "*.h5", "*.bin"] )
temp_path = os.path.join(INPUT_DIR, f"temp_fipa_{i}_{random.randint(1000, 9999)}.png") f_images[i].save(temp_path, "PNG") temp_files_to_clean.append(temp_path) active_flux1_ipadapters.append({ "image": os.path.basename(temp_path), "weight": f_weights[i], "start_percent": f_starts[i], "end_percent": f_ends[i] }) sd3_ipadapter_data = ui_inputs.get('sd3_ipadapter_chain', []) active_sd3_ipadapters = [] if sd3_ipadapter_data: num_units = len(sd3_ipadapter_data) // 4 s_images = sd3_ipadapter_data[0*num_units : 1*num_units] s_weights = sd3_ipadapter_data[1*num_units : 2*num_units] s_starts = sd3_ipadapter_data[2*num_units : 3*num_units] s_ends = sd3_ipadapter_data[3*num_units : 4*num_units] sd3_ipa_downloaded = False for i in range(len(s_images)): if s_images[i] and s_weights[i] > 0: if not sd3_ipa_downloaded: ensure_sd3_ipadapter_models_downloaded(progress) sd3_ipa_downloaded = True temp_path = os.path.join(INPUT_DIR, f"temp_s3ipa_{i}_{random.randint(1000, 9999)}.png") s_images[i].save(temp_path, "PNG") temp_files_to_clean.append(temp_path) active_sd3_ipadapters.append({ "image": os.path.basename(temp_path), "weight": s_weights[i], "start_percent": s_starts[i], "end_percent": s_ends[i] }) style_data = ui_inputs.get('style_data', []) active_styles = [] if style_data: num_units = len(style_data) // 2 st_images = style_data[0*num_units : 1*num_units] st_strengths = style_data[1*num_units : 2*num_units] for i in range(len(st_images)): if st_images[i] and st_strengths[i] > 0: _ensure_model_downloaded("sigclip_vision_patch14_384.safetensors", progress) temp_path = os.path.join(INPUT_DIR, f"temp_style_{i}_{random.randint(1000, 9999)}.png") st_images[i].save(temp_path, "PNG") temp_files_to_clean.append(temp_path) active_styles.append({ "image": os.path.basename(temp_path), "strength": st_strengths[i] }) reference_latent_data = ui_inputs.get('reference_latent_data', []) active_reference_latents = [] if reference_latent_data: for img in reference_latent_data: if img: if not os.path.exists(INPUT_DIR): os.makedirs(INPUT_DIR) temp_path = os.path.join(INPUT_DIR, f"temp_ref_{random.randint(1000, 9999)}.png") img.save(temp_path, "PNG") temp_files_to_clean.append(temp_path) active_reference_latents.append(os.path.basename(temp_path)) hidream_o1_reference_data = ui_inputs.get('hidream_o1_reference_data', []) active_hidream_o1_reference = [] if hidream_o1_reference_data: for img in hidream_o1_reference_data: if img: if not os.path.exists(INPUT_DIR): os.makedirs(INPUT_DIR) temp_path = os.path.join(INPUT_DIR, f"temp_ho1_ref_{random.randint(1000, 9999)}.png") img.save(temp_path, "PNG") temp_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 = None if vae_source and vae_source != "None": if vae_source == "File": vae_name_override = sanitize_filename(vae_id) elif vae_source == "Civitai" and vae_id and vae_id.strip(): local_path, status = get_vae_path(vae_source, vae_id, os.environ.get("CIVITAI_API_KEY", ""), progress) if local_path: vae_name_override = os.path.basename(local_path) else: raise gr.Error(f"Failed to prepare VAE {vae_id}: {status}") if vae_name_override: ui_inputs['vae_name'] = vae_name_override
conditioning_data = ui_inputs.get('conditioning_data', []) active_conditioning = [] if conditioning_data: num_units = len(conditioning_data) // 6 prompts, widths, heights, xs, ys, strengths = [conditioning_data[i*num_units : (i+1)*num_units] for i in range(6)] for i in range(num_units): if prompts[i] and prompts[i].strip(): active_conditioning.append({ "prompt": prompts[i], "width": int(widths[i]), "height": int(heights[i]), "x": int(xs[i]), "y": int(ys[i]), "strength": float(strengths[i]) })
return { "active_loras_for_gpu": active_loras_for_gpu, "active_loras_for_meta": active_loras_for_meta, "active_controlnets": active_controlnets, "active_anima_controlnets": active_anima_controlnets, "active_diffsynth_controlnets": active_diffsynth_controlnets, "active_ipadapters": active_ipadapters, "active_flux1_ipadapters": active_flux1_ipadapters, "active_sd3_ipadapters": active_sd3_ipadapters, "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 }import os
import random
import numpy as np
import gradio as gr
from PIL import Image, ImageChops
from typing import Dict, Any, List
from core.settings import INPUT_DIR, MULTIPLIERS_MAP
from utils.app_utils import (
sanitize_filename,
get_lora_path,
get_embedding_path,
ensure_controlnet_model_downloaded,
ensure_ipadapter_models_downloaded,
_ensure_model_downloaded,
ensure_sd3_ipadapter_models_downloaded,
get_vae_path,
)
def process_pipeline_inputs(ui_inputs: Dict[str, Any], progress: gr.Progress, workflow_model_type: str) -> Dict[str, Any]:
task_type = ui_inputs['task_type']
temp_files_to_clean = []
multiplier = MULTIPLIERS_MAP.get(workflow_model_type, 8)
img_w, img_h = 0, 0
if task_type == 'txt2img':
img_w = int(ui_inputs.get('width', 0))
img_h = int(ui_inputs.get('height', 0))
elif task_type == 'img2img':
input_image_pil = ui_inputs.get('img2img_image')
if input_image_pil:
img_w, img_h = input_image_pil.width, input_image_pil.height
elif task_type == 'inpaint':
inpaint_dict = ui_inputs.get('inpaint_image_dict')
if inpaint_dict and inpaint_dict.get('background'):
img_w, img_h = inpaint_dict['background'].width, inpaint_dict['background'].height
elif task_type == 'outpaint':
input_image_pil = ui_inputs.get('outpaint_image')
if input_image_pil:
img_w, img_h = input_image_pil.width, input_image_pil.height
elif task_type == 'hires_fix':
input_image_pil = ui_inputs.get('hires_image')
if input_image_pil:
img_w, img_h = input_image_pil.width, input_image_pil.height
if img_w > 0 and img_h > 0:
if (img_w % multiplier != 0) or (img_h % multiplier != 0):
warning_msg = f"Width and height must be multiples of {multiplier} for this model."
raise gr.Error(warning_msg)
lora_data = ui_inputs.get('lora_data', [])
active_loras_for_gpu, active_loras_for_meta = [], []
if lora_data:
sources, ids, scales, files = lora_data[0::4], lora_data[1::4], lora_data[2::4], lora_data[3::4]
for i, (source, lora_id, scale, _) in enumerate(zip(sources, ids, scales, files)):
if scale > 0 and lora_id and lora_id.strip():
lora_filename = None
if source == "File":
lora_filename = sanitize_filename(lora_id)
elif source in ("Civitai", "Hugging Face"):
local_path, status = get_lora_path(source, lora_id, os.environ.get("CIVITAI_API_KEY", ""), progress)
if local_path: lora_filename = os.path.basename(local_path)
else: raise gr.Error(f"Failed to prepare LoRA {lora_id}: {status}")
if lora_filename:
active_loras_for_gpu.append({"lora_name": lora_filename, "strength_model": scale, "strength_clip": scale})
active_loras_for_meta.append(f"{source} {lora_id}:{scale}")
ui_inputs['denoise'] = 1.0
if task_type == 'img2img': ui_inputs['denoise'] = ui_inputs.get('img2img_denoise', 0.7)
elif task_type == 'hires_fix': ui_inputs['denoise'] = ui_inputs.get('hires_denoise', 0.55)
elif task_type == 'inpaint': ui_inputs['denoise'] = ui_inputs.get('inpaint_denoise', 1.0)
if not os.path.exists(INPUT_DIR): os.makedirs(INPUT_DIR)
if task_type == 'img2img':
input_image_pil = ui_inputs.get('img2img_image')
if not input_image_pil:
raise gr.Error("Please upload an image for Image-to-Image.")
temp_file_path = os.path.join(INPUT_DIR, f"temp_input_{random.randint(1000, 9999)}.png")
input_image_pil.save(temp_file_path, "PNG")
ui_inputs['input_image'] = os.path.basename(temp_file_path)
temp_files_to_clean.append(temp_file_path)
ui_inputs['width'] = input_image_pil.width
ui_inputs['height'] = input_image_pil.height
elif task_type == 'inpaint':
inpaint_dict = ui_inputs.get('inpaint_image_dict')
if not inpaint_dict or not inpaint_dict.get('background') or not inpaint_dict.get('layers'):
raise gr.Error("Inpainting requires an input image and a drawn mask.")
background_img = inpaint_dict['background'].convert("RGBA")
composite_mask_pil = Image.new('L', background_img.size, 0)
for layer in inpaint_dict['layers']:
if layer:
layer_alpha = layer.split()[-1]
composite_mask_pil = ImageChops.lighter(composite_mask_pil, layer_alpha)
inverted_mask_alpha = Image.fromarray(255 - np.array(composite_mask_pil), mode='L')
r, g, b, _ = background_img.split()
composite_image_with_mask = Image.merge('RGBA', [r, g, b, inverted_mask_alpha])
temp_file_path = os.path.join(INPUT_DIR, f"temp_inpaint_composite_{random.randint(1000, 9999)}.png")
composite_image_with_mask.save(temp_file_path, "PNG")
ui_inputs['input_image'] = os.path.basename(temp_file_path)
temp_files_to_clean.append(temp_file_path)
ui_inputs.pop('inpaint_mask', None)
elif task_type == 'outpaint':
input_image_pil = ui_inputs.get('outpaint_image')
if not input_image_pil:
raise gr.Error("Please upload an image for Outpainting.")
temp_file_path = os.path.join(INPUT_DIR, f"temp_input_{random.randint(1000, 9999)}.png")
input_image_pil.save(temp_file_path, "PNG")
ui_inputs['input_image'] = os.path.basename(temp_file_path)
temp_files_to_clean.append(temp_file_path)
ui_inputs['megapixels'] = 0.25
ui_inputs['grow_mask_by'] = ui_inputs.get('feathering', 10)
elif task_type == 'hires_fix':
input_image_pil = ui_inputs.get('hires_image')
if not input_image_pil:
raise gr.Error("Please upload an image for Hires Fix.")
temp_file_path = os.path.join(INPUT_DIR, f"temp_input_{random.randint(1000, 9999)}.png")
input_image_pil.save(temp_file_path, "PNG")
ui_inputs['input_image'] = os.path.basename(temp_file_path)
temp_files_to_clean.append(temp_file_path)
embedding_data = ui_inputs.get('embedding_data', [])
embedding_filenames = []
if embedding_data:
emb_sources, emb_ids, emb_files = embedding_data[0::3], embedding_data[1::3], embedding_data[2::3]
for i, (source, emb_id, _) in enumerate(zip(emb_sources, emb_ids, emb_files)):
if emb_id and emb_id.strip():
emb_filename = None
if source == "File":
emb_filename = sanitize_filename(emb_id)
elif source in ("Civitai", "Hugging Face"):
local_path, status = get_embedding_path(source, emb_id, os.environ.get("CIVITAI_API_KEY", ""), progress)
if local_path: emb_filename = os.path.basename(local_path)
else: raise gr.Error(f"Failed to prepare Embedding {emb_id}: {status}")
if emb_filename:
embedding_filenames.append(emb_filename)
if embedding_filenames:
embedding_prompt_text = " ".join([f"embedding:{f}" for f in embedding_filenames])
if ui_inputs['positive_prompt']:
ui_inputs['positive_prompt'] = f"{ui_inputs['positive_prompt']}, {embedding_prompt_text}"
else:
ui_inputs['positive_prompt'] = embedding_prompt_text
controlnet_data = ui_inputs.get('controlnet_data', [])
active_controlnets = []
if controlnet_data:
(cn_images, _, _, cn_strengths, cn_filepaths) = [controlnet_data[i::5] for i in range(5)]
for i in range(len(cn_images)):
if cn_images[i] and cn_strengths[i] > 0 and cn_filepaths[i] and cn_filepaths[i] != "None":
ensure_controlnet_model_downloaded(cn_filepaths[i], progress)
if not os.path.exists(INPUT_DIR): os.makedirs(INPUT_DIR)
cn_temp_path = os.path.join(INPUT_DIR, f"temp_cn_{i}_{random.randint(1000, 9999)}.png")
cn_images[i].save(cn_temp_path, "PNG")
temp_files_to_clean.append(cn_temp_path)
active_controlnets.append({
"image": os.path.basename(cn_temp_path), "strength": cn_strengths[i],
"start_percent": 0.0, "end_percent": 1.0, "control_net_name": cn_filepaths[i]
})
anima_controlnet_lllite_data = ui_inputs.get('anima_controlnet_lllite_data', [])
active_anima_controlnets = []
if anima_controlnet_lllite_data:
(cn_images, _, _, cn_strengths, cn_filepaths, cn_starts, cn_ends) = [anima_controlnet_lllite_data[i::7] for i in range(7)]
for i in range(len(cn_images)):
if cn_images[i] and cn_strengths[i] > 0 and cn_filepaths[i] and cn_filepaths[i] != "None":
_ensure_model_downloaded(cn_filepaths[i], progress)
if not os.path.exists(INPUT_DIR): os.makedirs(INPUT_DIR)
cn_temp_path = os.path.join(INPUT_DIR, f"temp_anima_cn_{i}_{random.randint(1000, 9999)}.png")
cn_images[i].save(cn_temp_path, "PNG")
temp_files_to_clean.append(cn_temp_path)
active_anima_controlnets.append({
"image": os.path.basename(cn_temp_path), "strength": cn_strengths[i],
"start_percent": cn_starts[i], "end_percent": cn_ends[i], "control_net_name": cn_filepaths[i]
})
diffsynth_controlnet_data = ui_inputs.get('diffsynth_controlnet_data', [])
active_diffsynth_controlnets = []
if diffsynth_controlnet_data:
(cn_images, _, _, cn_strengths, cn_filepaths) = [diffsynth_controlnet_data[i::5] for i in range(5)]
for i in range(len(cn_images)):
if cn_images[i] and cn_strengths[i] > 0 and cn_filepaths[i] and cn_filepaths[i] != "None":
ensure_controlnet_model_downloaded(cn_filepaths[i], progress)
if not os.path.exists(INPUT_DIR): os.makedirs(INPUT_DIR)
cn_temp_path = os.path.join(INPUT_DIR, f"temp_diffsynth_cn_{i}_{random.randint(1000, 9999)}.png")
cn_images[i].save(cn_temp_path, "PNG")
temp_files_to_clean.append(cn_temp_path)
active_diffsynth_controlnets.append({
"image": os.path.basename(cn_temp_path), "strength": cn_strengths[i],
"control_net_name": cn_filepaths[i]
})
krea2_controlnet_data = ui_inputs.get('krea2_controlnet_data', [])
active_krea2_controlnets = []
if krea2_controlnet_data:
(cn_images, _, _, cn_strengths, cn_filepaths) = [krea2_controlnet_data[i::5] for i in range(5)]
for i in range(len(cn_images)):
if cn_images[i] and cn_strengths[i] > 0 and cn_filepaths[i] and cn_filepaths[i] != "None":
ensure_controlnet_model_downloaded(cn_filepaths[i], progress)
if not os.path.exists(INPUT_DIR): os.makedirs(INPUT_DIR)
cn_temp_path = os.path.join(INPUT_DIR, f"temp_krea2_cn_{i}_{random.randint(1000, 9999)}.png")
cn_images[i].save(cn_temp_path, "PNG")
temp_files_to_clean.append(cn_temp_path)
active_krea2_controlnets.append({
"image": os.path.basename(cn_temp_path), "strength": cn_strengths[i],
"control_net_name": cn_filepaths[i]
})
ipadapter_data = ui_inputs.get('ipadapter_data', [])
active_ipadapters = []
if ipadapter_data:
num_ipa_units = (len(ipadapter_data) - 5) // 3
final_preset, final_weight, final_lora_strength, final_embeds_scaling, final_combine_method = ipadapter_data[-5:]
ipa_images, ipa_weights, ipa_lora_strengths = [ipadapter_data[i*num_ipa_units:(i+1)*num_ipa_units] for i in range(3)]
all_presets_to_download = set()
for i in range(num_ipa_units):
if ipa_images[i] and ipa_weights[i] > 0 and final_preset:
all_presets_to_download.add(final_preset)
if not os.path.exists(INPUT_DIR): os.makedirs(INPUT_DIR)
ipa_temp_path = os.path.join(INPUT_DIR, f"temp_ipa_{i}_{random.randint(1000, 9999)}.png")
ipa_images[i].save(ipa_temp_path, "PNG")
temp_files_to_clean.append(ipa_temp_path)
active_ipadapters.append({
"image": os.path.basename(ipa_temp_path), "preset": final_preset,
"weight": ipa_weights[i], "lora_strength": ipa_lora_strengths[i]
})
if active_ipadapters and final_preset:
all_presets_to_download.add(final_preset)
for preset in all_presets_to_download:
ensure_ipadapter_models_downloaded(preset, progress)
model_type_key = 'sd15' if workflow_model_type == 'sd15' else 'sdxl'
if active_ipadapters:
active_ipadapters.append({
'is_final_settings': True, 'model_type': model_type_key, 'final_preset': final_preset,
'final_weight': final_weight, 'final_lora_strength': final_lora_strength,
'final_embeds_scaling': final_embeds_scaling, 'final_combine_method': final_combine_method
})
flux1_ipadapter_data = ui_inputs.get('flux1_ipadapter_data', [])
active_flux1_ipadapters = []
if flux1_ipadapter_data:
num_units = len(flux1_ipadapter_data) // 4
f_images = flux1_ipadapter_data[0*num_units : 1*num_units]
f_weights = flux1_ipadapter_data[1*num_units : 2*num_units]
f_starts = flux1_ipadapter_data[2*num_units : 3*num_units]
f_ends = flux1_ipadapter_data[3*num_units : 4*num_units]
for i in range(len(f_images)):
if f_images[i] and f_weights[i] > 0:
for filename in ["ip-adapter.bin"]:
_ensure_model_downloaded(filename, progress)
from huggingface_hub import snapshot_download
progress(0.5, desc="Caching HF SigLIP model...")
snapshot_download(
repo_id="google/siglip-so400m-patch14-384",
allow_patterns=["*.json", "*.safetensors", "*.txt"],
ignore_patterns=["*.msgpack", "*.h5", "*.bin"]
)
temp_path = os.path.join(INPUT_DIR, f"temp_fipa_{i}_{random.randint(1000, 9999)}.png")
f_images[i].save(temp_path, "PNG")
temp_files_to_clean.append(temp_path)
active_flux1_ipadapters.append({
"image": os.path.basename(temp_path),
"weight": f_weights[i], "start_percent": f_starts[i], "end_percent": f_ends[i]
})
sd3_ipadapter_data = ui_inputs.get('sd3_ipadapter_chain', [])
active_sd3_ipadapters = []
if sd3_ipadapter_data:
num_units = len(sd3_ipadapter_data) // 4
s_images = sd3_ipadapter_data[0*num_units : 1*num_units]
s_weights = sd3_ipadapter_data[1*num_units : 2*num_units]
s_starts = sd3_ipadapter_data[2*num_units : 3*num_units]
s_ends = sd3_ipadapter_data[3*num_units : 4*num_units]
sd3_ipa_downloaded = False
for i in range(len(s_images)):
if s_images[i] and s_weights[i] > 0:
if not sd3_ipa_downloaded:
ensure_sd3_ipadapter_models_downloaded(progress)
sd3_ipa_downloaded = True
temp_path = os.path.join(INPUT_DIR, f"temp_s3ipa_{i}_{random.randint(1000, 9999)}.png")
s_images[i].save(temp_path, "PNG")
temp_files_to_clean.append(temp_path)
active_sd3_ipadapters.append({
"image": os.path.basename(temp_path),
"weight": s_weights[i], "start_percent": s_starts[i], "end_percent": s_ends[i]
})
style_data = ui_inputs.get('style_data', [])
active_styles = []
if style_data:
num_units = len(style_data) // 2
st_images = style_data[0*num_units : 1*num_units]
st_strengths = style_data[1*num_units : 2*num_units]
style_models_downloaded = False
for i in range(len(st_images)):
if st_images[i] and st_strengths[i] > 0:
if not style_models_downloaded:
_ensure_model_downloaded("sigclip_vision_patch14_384.safetensors", progress)
_ensure_model_downloaded("flux1-redux-dev.safetensors", progress)
style_models_downloaded = True
temp_path = os.path.join(INPUT_DIR, f"temp_style_{i}_{random.randint(1000, 9999)}.png")
st_images[i].save(temp_path, "PNG")
temp_files_to_clean.append(temp_path)
active_styles.append({
"image": os.path.basename(temp_path), "strength": st_strengths[i]
})
reference_latent_data = ui_inputs.get('reference_latent_data', [])
active_reference_latents = []
if reference_latent_data:
for img in reference_latent_data:
if img:
if not os.path.exists(INPUT_DIR): os.makedirs(INPUT_DIR)
temp_path = os.path.join(INPUT_DIR, f"temp_ref_{random.randint(1000, 9999)}.png")
img.save(temp_path, "PNG")
temp_files_to_clean.append(temp_path)
active_reference_latents.append(os.path.basename(temp_path))
hidream_o1_reference_data = ui_inputs.get('hidream_o1_reference_data', [])
active_hidream_o1_reference = []
if hidream_o1_reference_data:
for img in hidream_o1_reference_data:
if img:
if not os.path.exists(INPUT_DIR): os.makedirs(INPUT_DIR)
temp_path = os.path.join(INPUT_DIR, f"temp_ho1_ref_{random.randint(1000, 9999)}.png")
img.save(temp_path, "PNG")
temp_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 = None
if vae_source and vae_source != "None":
if vae_source == "File":
vae_name_override = sanitize_filename(vae_id)
elif vae_source in ("Civitai", "Hugging Face") and vae_id and vae_id.strip():
local_path, status = get_vae_path(vae_source, vae_id, os.environ.get("CIVITAI_API_KEY", ""), progress)
if local_path: vae_name_override = os.path.basename(local_path)
else: raise gr.Error(f"Failed to prepare VAE {vae_id}: {status}")
if vae_name_override:
ui_inputs['vae_name'] = vae_name_override
conditioning_data = ui_inputs.get('conditioning_data', [])
active_conditioning = []
if conditioning_data:
num_units = len(conditioning_data) // 6
prompts, widths, heights, xs, ys, strengths = [conditioning_data[i*num_units : (i+1)*num_units] for i in range(6)]
for i in range(num_units):
if prompts[i] and prompts[i].strip():
active_conditioning.append({
"prompt": prompts[i], "width": int(widths[i]), "height": int(heights[i]),
"x": int(xs[i]), "y": int(ys[i]), "strength": float(strengths[i])
})
return {
"active_loras_for_gpu": active_loras_for_gpu,
"active_loras_for_meta": active_loras_for_meta,
"active_controlnets": active_controlnets,
"active_anima_controlnets": active_anima_controlnets,
"active_diffsynth_controlnets": active_diffsynth_controlnets,
"active_krea2_controlnets": active_krea2_controlnets,
"active_ipadapters": active_ipadapters,
"active_flux1_ipadapters": active_flux1_ipadapters,
"active_sd3_ipadapters": active_sd3_ipadapters,
"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
}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259import osimport randomimport shutilimport torchimport gradio as grfrom PIL import Imagefrom typing import List, Dict, Any
from .base_pipeline import BasePipelinefrom core.settings import *from utils.app_utils import sanitize_promptfrom core.workflow_assembler import WorkflowAssemblerfrom .workflow_executor import WorkflowExecutorfrom .pipeline_input_processor import process_pipeline_inputs
class SdImagePipeline(BasePipeline): def get_required_models(self, model_display_name: str, **kwargs) -> List[str]: model_info = ALL_MODEL_MAP.get(model_display_name) if not model_info: return [model_display_name]
path_or_components = model_info[1] if isinstance(path_or_components, dict): return [v for v in path_or_components.values() if v and v != "pixel_space"] else: return [model_display_name]
def _gpu_logic(self, ui_inputs: Dict, loras_string: str, workflow: Dict[str, Any], assembler: WorkflowAssembler, progress=gr.Progress(track_tqdm=True)): model_display_name = ui_inputs['model_display_name'] progress(0.4, desc="Executing workflow...") initial_objects = {}
decoded_images_tensor = WorkflowExecutor.execute_workflow(workflow, initial_objects=initial_objects) output_images = [] start_seed = ui_inputs['seed'] if ui_inputs['seed'] != -1 else random.randint(0, 2**64 - 1) for i in range(decoded_images_tensor.shape[0]): img_tensor = decoded_images_tensor[i] pil_image = Image.fromarray((img_tensor.cpu().numpy() * 255.0).astype("uint8")) current_seed = start_seed + i width_for_meta = ui_inputs.get('width', 'N/A') height_for_meta = ui_inputs.get('height', 'N/A')
params_string = f"{ui_inputs['positive_prompt']}\nNegative prompt: {ui_inputs['negative_prompt']}\n" params_string += f"Steps: {ui_inputs['num_inference_steps']}, Sampler: {ui_inputs['sampler']}, Scheduler: {ui_inputs['scheduler']}, CFG scale: {ui_inputs['guidance_scale']}, Seed: {current_seed}, Size: {width_for_meta}x{height_for_meta}, Base Model: {model_display_name}" if ui_inputs['task_type'] != 'txt2img': params_string += f", Denoise: {ui_inputs['denoise']}" if ui_inputs.get('clip_skip') and ui_inputs['clip_skip'] != 1: params_string += f", Clip skip: {abs(ui_inputs['clip_skip'])}" if loras_string: params_string += f", {loras_string}" pil_image.info = {'parameters': params_string.strip()} output_images.append(pil_image) return output_images
def run(self, ui_inputs: Dict, progress): progress(0, desc="Preparing models...") task_type = ui_inputs['task_type'] model_display_name = ui_inputs['model_display_name'] model_type = MODEL_TYPE_MAP.get(model_display_name, 'sdxl') architectures_dict = ARCHITECTURES_CONFIG.get('architectures', {}) workflow_model_type = architectures_dict.get(model_type, {}).get("model_type", model_type.lower().replace(" ", "").replace(".", "")) ui_inputs['positive_prompt'] = sanitize_prompt(ui_inputs.get('positive_prompt', '')) ui_inputs['negative_prompt'] = sanitize_prompt(ui_inputs.get('negative_prompt', '')) if 'clip_skip' in ui_inputs and ui_inputs['clip_skip'] is not None: ui_inputs['clip_skip'] = -int(ui_inputs['clip_skip']) else: ui_inputs['clip_skip'] = -1
required_models = self.get_required_models(model_display_name=model_display_name)
is_pid_enabled = (ui_inputs.get('pid_settings', 'OFF') == 'ON' and task_type == 'txt2img') if is_pid_enabled: import yaml pid_config_path = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))), 'yaml', 'pid.yaml') pid_unet_name = "pid_flux1_1024_to_4096_4step_mxfp8.safetensors" try: with open(pid_config_path, 'r', encoding='utf-8') as f: pid_config = yaml.safe_load(f) or {} pid_items = pid_config.get("PiD", []) for item in pid_items: archs = item.get("architectures", []) if workflow_model_type in archs: pid_unet_name = item.get("filepath") break except Exception as e: print(f"Error loading PiD config for download: {e}")
if pid_unet_name not in required_models: required_models.append(pid_unet_name) if "gemma_2_2b_it_elm_fp8_scaled.safetensors" not in required_models: required_models.append("gemma_2_2b_it_elm_fp8_scaled.safetensors")
self.model_manager.ensure_models_downloaded(required_models, progress=progress) temp_files_to_clean = [] try: processed = process_pipeline_inputs(ui_inputs, progress, workflow_model_type) temp_files_to_clean.extend(processed["temp_files_to_clean"]) active_loras_for_gpu = processed["active_loras_for_gpu"] active_loras_for_meta = processed["active_loras_for_meta"] active_controlnets = processed["active_controlnets"] active_anima_controlnets = processed["active_anima_controlnets"] active_diffsynth_controlnets = processed["active_diffsynth_controlnets"] active_ipadapters = processed["active_ipadapters"] active_flux1_ipadapters = processed["active_flux1_ipadapters"] active_sd3_ipadapters = processed["active_sd3_ipadapters"] active_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 "" progress(0.8, desc="Assembling workflow...") if ui_inputs.get('seed') == -1: ui_inputs['seed'] = random.randint(0, 2**32 - 1) model_info = ALL_MODEL_MAP[model_display_name] path_or_components = model_info[1] latent_type = model_info[3] if len(model_info) > 3 and model_info[3] else 'latent' latent_generator_template = "EmptyLatentImage" if latent_type == 'sd3_latent': latent_generator_template = "EmptySD3LatentImage" elif latent_type == 'chroma_radiance_latent': latent_generator_template = "EmptyChromaRadianceLatentImage" elif latent_type == 'hunyuan_latent': latent_generator_template = "EmptyHunyuanImageLatent"
dynamic_values = { 'task_type': ui_inputs['task_type'], 'model_type': workflow_model_type, 'latent_type': latent_type, 'latent_generator_template': latent_generator_template } recipe_path = os.path.join(os.path.dirname(__file__), "workflow_recipes", "sd_unified_recipe.yaml") assembler = WorkflowAssembler(recipe_path, dynamic_values=dynamic_values) hidream_o1_smoothing_data = [] if workflow_model_type == 'hidream-o1' and model_display_name == "HiDream-O1-Image": hidream_o1_smoothing_data.append({})
workflow_inputs = { **ui_inputs, "positive_prompt": ui_inputs['positive_prompt'], "negative_prompt": ui_inputs['negative_prompt'], "seed": ui_inputs['seed'], "steps": ui_inputs['num_inference_steps'], "cfg": ui_inputs['guidance_scale'], "sampler_name": ui_inputs['sampler'], "scheduler": ui_inputs['scheduler'], "batch_size": ui_inputs['batch_size'], "clip_skip": ui_inputs['clip_skip'], "denoise": ui_inputs['denoise'], "vae_name": ui_inputs.get('vae_name'), "guidance": ui_inputs.get('guidance', 3.5), "lora_chain": active_loras_for_gpu, "controlnet_chain": active_controlnets if not active_anima_controlnets else [], "anima_controlnet_lllite_chain": active_anima_controlnets, "diffsynth_controlnet_chain": active_diffsynth_controlnets, "ipadapter_chain": active_ipadapters, "flux1_ipadapter_chain": active_flux1_ipadapters, "sd3_ipadapter_chain": active_sd3_ipadapters, "style_chain": active_styles, "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 [], }
if isinstance(path_or_components, dict): workflow_inputs.update({ 'unet_name': path_or_components.get('unet'), 'vae_name': ui_inputs.get('vae_name') or path_or_components.get('vae'), 'clip_name': path_or_components.get('clip'), 'clip1_name': path_or_components.get('clip1'), 'clip2_name': path_or_components.get('clip2'), 'clip3_name': path_or_components.get('clip3'), 'clip4_name': path_or_components.get('clip4'), 'lora_name': path_or_components.get('lora'), }) else: workflow_inputs['model_name'] = path_or_components if task_type == 'txt2img': workflow_inputs['width'] = ui_inputs['width'] workflow_inputs['height'] = ui_inputs['height'] workflow = assembler.assemble(workflow_inputs)
progress(1.0, desc="All models ready. Requesting GPU for generation...")
results = self._execute_gpu_logic( self._gpu_logic, duration=ui_inputs['zero_gpu_duration'], default_duration=60, task_name=f"ImageGen ({task_type})", ui_inputs=ui_inputs, loras_string=loras_string, workflow=workflow, assembler=assembler, progress=progress ) import json import glob from PIL import PngImagePlugin prompt_json = json.dumps(workflow) out_dir = os.path.abspath(OUTPUT_DIR) os.makedirs(out_dir, exist_ok=True) try: existing_files = glob.glob(os.path.join(out_dir, "gen_*.png")) existing_files.sort(key=os.path.getmtime) while len(existing_files) > 50: os.remove(existing_files.pop(0)) except Exception as e: print(f"Warning: Failed to cleanup output dir: {e}")
final_results = [] for img in results: if not isinstance(img, Image.Image): final_results.append(img) continue metadata = PngImagePlugin.PngInfo() params_string = img.info.get("parameters", "") if params_string: metadata.add_text("parameters", params_string) metadata.add_text("prompt", prompt_json) filename = f"gen_{random.randint(1000000, 9999999)}.png" filepath = os.path.join(out_dir, filename) img.save(filepath, "PNG", pnginfo=metadata) final_results.append(filepath) results = final_results
finally: for temp_file in temp_files_to_clean: if temp_file and os.path.exists(temp_file): os.remove(temp_file) print(f"✅ Cleaned up temp file: {temp_file}")
import os
import random
import shutil
import torch
import gradio as gr
from PIL import Image
from typing import List, Dict, Any
from .base_pipeline import BasePipeline
from core.settings import *
from utils.app_utils import sanitize_prompt
from core.workflow_assembler import WorkflowAssembler
from .workflow_executor import WorkflowExecutor
from .pipeline_input_processor import process_pipeline_inputs
class SdImagePipeline(BasePipeline):
def get_required_models(self, model_display_name: str, **kwargs) -> List[str]:
model_info = ALL_MODEL_MAP.get(model_display_name)
if not model_info:
return [model_display_name]
path_or_components = model_info[1]
if isinstance(path_or_components, dict):
return [v for v in path_or_components.values() if v and v != "pixel_space"]
else:
return [model_display_name]
def _gpu_logic(self, ui_inputs: Dict, loras_string: str, workflow: Dict[str, Any], assembler: WorkflowAssembler, progress=gr.Progress(track_tqdm=True)):
model_display_name = ui_inputs['model_display_name']
progress(0.4, desc="Executing workflow...")
initial_objects = {}
decoded_images_tensor = WorkflowExecutor.execute_workflow(workflow, initial_objects=initial_objects)
output_images = []
start_seed = ui_inputs['seed'] if ui_inputs['seed'] != -1 else random.randint(0, 2**64 - 1)
for i in range(decoded_images_tensor.shape[0]):
img_tensor = decoded_images_tensor[i]
pil_image = Image.fromarray((img_tensor.cpu().numpy() * 255.0).astype("uint8"))
current_seed = start_seed + i
width_for_meta = ui_inputs.get('width', 'N/A')
height_for_meta = ui_inputs.get('height', 'N/A')
params_string = f"{ui_inputs['positive_prompt']}\nNegative prompt: {ui_inputs['negative_prompt']}\n"
params_string += f"Steps: {ui_inputs['num_inference_steps']}, Sampler: {ui_inputs['sampler']}, Scheduler: {ui_inputs['scheduler']}, CFG scale: {ui_inputs['guidance_scale']}, Seed: {current_seed}, Size: {width_for_meta}x{height_for_meta}, Base Model: {model_display_name}"
if ui_inputs['task_type'] != 'txt2img': params_string += f", Denoise: {ui_inputs['denoise']}"
if ui_inputs.get('clip_skip') and ui_inputs['clip_skip'] != 1: params_string += f", Clip skip: {abs(ui_inputs['clip_skip'])}"
if loras_string: params_string += f", {loras_string}"
pil_image.info = {'parameters': params_string.strip()}
output_images.append(pil_image)
return output_images
def run(self, ui_inputs: Dict, progress):
progress(0, desc="Preparing models...")
task_type = ui_inputs['task_type']
model_display_name = ui_inputs['model_display_name']
model_type = MODEL_TYPE_MAP.get(model_display_name, 'sdxl')
architectures_dict = ARCHITECTURES_CONFIG.get('architectures', {})
workflow_model_type = architectures_dict.get(model_type, {}).get("model_type", model_type.lower().replace(" ", "").replace(".", ""))
ui_inputs['positive_prompt'] = sanitize_prompt(ui_inputs.get('positive_prompt', ''))
ui_inputs['negative_prompt'] = sanitize_prompt(ui_inputs.get('negative_prompt', ''))
if 'clip_skip' in ui_inputs and ui_inputs['clip_skip'] is not None:
ui_inputs['clip_skip'] = -int(ui_inputs['clip_skip'])
else:
ui_inputs['clip_skip'] = -1
required_models = self.get_required_models(model_display_name=model_display_name)
is_pid_enabled = (ui_inputs.get('pid_settings', 'OFF') == 'ON' and task_type == 'txt2img')
if is_pid_enabled:
import yaml
pid_config_path = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))), 'yaml', 'pid.yaml')
pid_unet_name = "pid_flux1_1024_to_4096_4step_mxfp8.safetensors"
try:
with open(pid_config_path, 'r', encoding='utf-8') as f:
pid_config = yaml.safe_load(f) or {}
pid_items = pid_config.get("PiD", [])
for item in pid_items:
archs = item.get("architectures", [])
if workflow_model_type in archs:
pid_unet_name = item.get("filepath")
break
except Exception as e:
print(f"Error loading PiD config for download: {e}")
if pid_unet_name not in required_models:
required_models.append(pid_unet_name)
if "gemma_2_2b_it_elm_fp8_scaled.safetensors" not in required_models:
required_models.append("gemma_2_2b_it_elm_fp8_scaled.safetensors")
self.model_manager.ensure_models_downloaded(required_models, progress=progress)
temp_files_to_clean = []
try:
processed = process_pipeline_inputs(ui_inputs, progress, workflow_model_type)
temp_files_to_clean.extend(processed["temp_files_to_clean"])
active_loras_for_gpu = processed["active_loras_for_gpu"]
active_loras_for_meta = processed["active_loras_for_meta"]
active_controlnets = processed["active_controlnets"]
active_anima_controlnets = processed["active_anima_controlnets"]
active_diffsynth_controlnets = processed["active_diffsynth_controlnets"]
active_krea2_controlnets = processed.get("active_krea2_controlnets", [])
active_ipadapters = processed["active_ipadapters"]
active_flux1_ipadapters = processed["active_flux1_ipadapters"]
active_sd3_ipadapters = processed["active_sd3_ipadapters"]
active_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 ""
progress(0.8, desc="Assembling workflow...")
if ui_inputs.get('seed') == -1:
ui_inputs['seed'] = random.randint(0, 2**32 - 1)
model_info = ALL_MODEL_MAP[model_display_name]
path_or_components = model_info[1]
latent_type = model_info[3] if len(model_info) > 3 and model_info[3] else 'latent'
latent_generator_template = "EmptyLatentImage"
if latent_type == 'sd3_latent':
latent_generator_template = "EmptySD3LatentImage"
elif latent_type == 'chroma_radiance_latent':
latent_generator_template = "EmptyChromaRadianceLatentImage"
elif latent_type == 'hunyuan_latent':
latent_generator_template = "EmptyHunyuanImageLatent"
dynamic_values = {
'task_type': ui_inputs['task_type'],
'model_type': workflow_model_type,
'latent_type': latent_type,
'latent_generator_template': latent_generator_template
}
recipe_path = os.path.join(os.path.dirname(__file__), "workflow_recipes", "sd_unified_recipe.yaml")
assembler = WorkflowAssembler(recipe_path, dynamic_values=dynamic_values)
hidream_o1_smoothing_data = []
if workflow_model_type == 'hidream-o1' and model_display_name == "HiDream-O1-Image":
hidream_o1_smoothing_data.append({})
workflow_inputs = {
**ui_inputs,
"positive_prompt": ui_inputs['positive_prompt'], "negative_prompt": ui_inputs['negative_prompt'],
"seed": ui_inputs['seed'], "steps": ui_inputs['num_inference_steps'], "cfg": ui_inputs['guidance_scale'],
"sampler_name": ui_inputs['sampler'], "scheduler": ui_inputs['scheduler'],
"batch_size": ui_inputs['batch_size'],
"clip_skip": ui_inputs['clip_skip'],
"denoise": ui_inputs['denoise'],
"vae_name": ui_inputs.get('vae_name'),
"guidance": ui_inputs.get('guidance', 3.5),
"lora_chain": active_loras_for_gpu,
"controlnet_chain": active_controlnets if not active_anima_controlnets else [],
"anima_controlnet_lllite_chain": active_anima_controlnets,
"diffsynth_controlnet_chain": active_diffsynth_controlnets,
"krea2_controlnet_chain": active_krea2_controlnets,
"ipadapter_chain": active_ipadapters,
"flux1_ipadapter_chain": active_flux1_ipadapters,
"sd3_ipadapter_chain": active_sd3_ipadapters,
"style_chain": active_styles,
"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 [],
"scheduler_width": ui_inputs.get('width', 1024),
"scheduler_height": ui_inputs.get('height', 1024),
}
if isinstance(path_or_components, dict):
workflow_inputs.update({
'unet_name': path_or_components.get('unet'),
'unet_uncond_name': path_or_components.get('unet_uncond'),
'vae_name': ui_inputs.get('vae_name') or path_or_components.get('vae'),
'clip_name': path_or_components.get('clip'),
'clip1_name': path_or_components.get('clip1'),
'clip2_name': path_or_components.get('clip2'),
'clip3_name': path_or_components.get('clip3'),
'clip4_name': path_or_components.get('clip4'),
'lora_name': path_or_components.get('lora'),
})
else:
workflow_inputs['model_name'] = path_or_components
if task_type == 'txt2img':
workflow_inputs['width'] = ui_inputs['width']
workflow_inputs['height'] = ui_inputs['height']
workflow = assembler.assemble(workflow_inputs)
progress(1.0, desc="All models ready. Requesting GPU for generation...")
results = self._execute_gpu_logic(
self._gpu_logic,
duration=ui_inputs['zero_gpu_duration'],
default_duration=60,
task_name=f"ImageGen ({task_type})",
ui_inputs=ui_inputs,
loras_string=loras_string,
workflow=workflow,
assembler=assembler,
progress=progress
)
import json
import glob
from PIL import PngImagePlugin
prompt_json = json.dumps(workflow)
out_dir = os.path.abspath(OUTPUT_DIR)
os.makedirs(out_dir, exist_ok=True)
try:
existing_files = glob.glob(os.path.join(out_dir, "gen_*.png"))
existing_files.sort(key=os.path.getmtime)
while len(existing_files) > 50:
os.remove(existing_files.pop(0))
except Exception as e:
print(f"Warning: Failed to cleanup output dir: {e}")
final_results = []
for img in results:
if not isinstance(img, Image.Image):
final_results.append(img)
continue
metadata = PngImagePlugin.PngInfo()
params_string = img.info.get("parameters", "")
if params_string:
metadata.add_text("parameters", params_string)
metadata.add_text("prompt", prompt_json)
filename = f"gen_{random.randint(1000000, 9999999)}.png"
filepath = os.path.join(out_dir, filename)
img.save(filepath, "PNG", pnginfo=metadata)
final_results.append(filepath)
results = final_results
finally:
for temp_file in temp_files_to_clean:
if temp_file and os.path.exists(temp_file):
os.remove(temp_file)
print(f"✅ Cleaned up temp file: {temp_file}")
return results123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263nodes:
unet_loader:
class_type: UNETLoader
title: "Load Diffusion Model"
params:
weight_dtype: "default"
clip_loader:
class_type: CLIPLoader
title: "Load CLIP"
params:
type: "krea2"
device: "default"
vae_loader:
class_type: VAELoader
title: "Load VAE"
connections:
- from: "unet_loader:0"
to: "ksampler:model"
- from: "clip_loader:0"
to: "pos_prompt:clip"
- from: "clip_loader:0"
to: "neg_prompt:clip"
- from: "pos_prompt:0"
to: "ksampler:positive"
- from: "neg_prompt:0"
to: "ksampler:negative"
- from: "vae_loader:0"
to: "vae_decode:vae"
- from: "vae_loader:0"
to: "vae_encode:vae"
dynamic_lora_chains:
lora_chain:
template: "LoraLoader"
output_map:
"unet_loader:0": "model"
"clip_loader:0": "clip"
input_map:
"model": "model"
"clip": "clip"
end_input_map:
"model": ["ksampler:model"]
"clip": ["pos_prompt:clip", "neg_prompt:clip"]
dynamic_krea2_controlnet_chains:
krea2_controlnet_chain:
ksampler_node: "ksampler"
vae_source: "vae_loader:0"
dynamic_conditioning_chains:
conditioning_chain:
ksampler_node: "ksampler"
clip_source: "clip_loader:0"
dynamic_pid_chains:
pid_chain:
ksampler_node: "ksampler"
ui_map:
unet_name: "unet_loader:unet_name"
clip_name: "clip_loader:clip_name"
vae_name: "vae_loader:vae_name"12 unmodified lines1314151617181920211617182 unmodified lines212223303124252618 unmodified lines454647564849505120 unmodified lines72737483847512 unmodified lines params:
type: "qwen_image"
device: "default"
lora_loader:
class_type: LoraLoaderModelOnly
title: "Load Qwen Lightning LoRA"
params:
strength_model: 1.0
model_sampler:
class_type: ModelSamplingAuraFlow
title: "ModelSamplingAuraFlow"2 unmodified lines
connections:
- from: "unet_loader:0"
to: "lora_loader:model"
- from: "lora_loader:0"
to: "model_sampler:model"
- from: "model_sampler:0"18 unmodified lines lora_chain:
template: "LoraLoader"
output_map:
"lora_loader:0": "model"
"unet_loader:0": "model"
"clip_loader:0": "clip"
input_map:
"model": "model"20 unmodified linesui_map:
unet_name: "unet_loader:unet_name"
vae_name: "vae_loader:vae_name"
clip_name: "clip_loader:clip_name"
lora_name: "lora_loader:lora_name" clip_name: "clip_loader:clip_name"191 unmodified lines1921931941951961971982 unmodified lines201202203204205206207191 unmodified lines MAX_IPADAPTERS = _constants.get('MAX_IPADAPTERS', 5)
LORA_SOURCE_CHOICES = _constants.get('LORA_SOURCE_CHOICES', ["Civitai", "File"])
RESOLUTION_MAP = _constants.get('RESOLUTION_MAP', {})
MULTIPLIERS_MAP = _constants.get('MULTIPLIERS_MAP', {})
ARCHITECTURES_CONFIG = load_architectures_config()
FEATURES_CONFIG = load_features_config()
MODEL_DEFAULTS_CONFIG = load_model_defaults()2 unmodified lines MAX_LORAS, MAX_EMBEDDINGS, MAX_CONDITIONINGS, MAX_CONTROLNETS, MAX_IPADAPTERS = 5, 5, 10, 5, 5
LORA_SOURCE_CHOICES = ["Civitai", "File"]
RESOLUTION_MAP = {}
MULTIPLIERS_MAP = {}
ARCHITECTURES_CONFIG = {}
FEATURES_CONFIG = {}
MODEL_DEFAULTS_CONFIG = {}35 unmodified lines3637383939404135 unmodified lines module = importlib.import_module(module_path)
if hasattr(module, 'inject'):
self.global_injectors[chain_type] = module.inject
print(f"✅ Successfully registered global injector: {chain_type} from {module_path}")
else:
print(f"⚠️ Warning: Module '{module_path}' for injector '{chain_type}' does not have an 'inject' function.")
except ImportError as e:12312345615 unmodified lines222324252625262728293 unmodified lines333435363736373839404142434445comfyui-frontend-package==1.45.15
comfyui-workflow-templates==0.9.98
comfyui-embedded-docs==0.5.2
comfyui-frontend-package==1.45.21
comfyui-workflow-templates==0.11.9
comfyui-embedded-docs==0.5.8
torch
torchsde
torchvision15 unmodified linesSQLAlchemy>=2.0.0
filelock
av>=16.0.0
comfy-kitchen==0.2.10
comfy-aimdo==0.4.8
comfy-kitchen==0.2.20
comfy-aimdo==0.4.10
requests
simpleeval>=1.0.0
blake33 unmodified linesspandrel
pydantic~=2.0
pydantic-settings~=2.0
PyOpenGL
glfw
PyOpenGL>=3.1.8
comfy-angle
diffusers
protobuf
insightface
huggingface-hub
imageio
spaces5 unmodified lines67891011125 unmodified lines get_anima_cn_defaults, load_diffsynth_controlnet_config, get_diffsynth_cn_defaults, load_krea2_controlnet_config, get_krea2_cn_defaults, load_ipadapter_config)11 unmodified lines12131415161718173 unmodified lines192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290480 unmodified lines77177277368077411 unmodified lines load_controlnet_config, load_anima_controlnet_lllite_config, load_diffsynth_controlnet_config, load_krea2_controlnet_config, load_ipadapter_config)
173 unmodified lines )
def create_krea2_controlnet_event_handlers(prefix, ui_components): cn_rows = ui_components.get(f'krea2_controlnet_rows_{prefix}') if not cn_rows: return cn_types = ui_components[f'krea2_controlnet_types_{prefix}'] cn_series = ui_components[f'krea2_controlnet_series_{prefix}'] cn_filepaths = ui_components[f'krea2_controlnet_filepaths_{prefix}'] cn_images = ui_components[f'krea2_controlnet_images_{prefix}'] cn_strengths = ui_components[f'krea2_controlnet_strengths_{prefix}'] count_state = ui_components[f'krea2_controlnet_count_state_{prefix}'] add_button = ui_components[f'add_krea2_controlnet_button_{prefix}'] del_button = ui_components[f'delete_krea2_controlnet_button_{prefix}'] accordion = ui_components[f'krea2_controlnet_accordion_{prefix}']
def add_cn_row(c): c += 1 updates = { count_state: c, cn_rows[c-1]: gr.update(visible=True), add_button: gr.update(visible=c < MAX_CONTROLNETS), del_button: gr.update(visible=True) } return updates
def del_cn_row(c): c -= 1 updates = { count_state: c, cn_rows[c]: gr.update(visible=False), cn_images[c]: None, cn_strengths[c]: 1.0, add_button: gr.update(visible=True), del_button: gr.update(visible=c > 0) } return updates add_outputs = [count_state, add_button, del_button] + cn_rows del_outputs = [count_state, add_button, del_button] + cn_rows + cn_images + cn_strengths add_button.click(fn=add_cn_row, inputs=[count_state], outputs=add_outputs, show_progress=False) del_button.click(fn=del_cn_row, inputs=[count_state], outputs=del_outputs, show_progress=False) def on_cn_type_change(selected_type): cn_config = load_krea2_controlnet_config() series_choices = [] if selected_type: series_choices = sorted(list(set( model.get("Series", "Default") for model in cn_config if selected_type in model.get("Type", []) ))) default_series = series_choices[0] if series_choices else None filepath = "None" if default_series: for model in cn_config: if model.get("Series") == default_series and selected_type in model.get("Type", []): filepath = model.get("Filepath") break return gr.update(choices=series_choices, value=default_series), filepath
def on_cn_series_change(selected_series, selected_type): cn_config = load_krea2_controlnet_config() filepath = "None" if selected_series and selected_type: for model in cn_config: if model.get("Series") == selected_series and selected_type in model.get("Type", []): filepath = model.get("Filepath") break return filepath for i in range(MAX_CONTROLNETS): cn_types[i].change( fn=on_cn_type_change, inputs=[cn_types[i]], outputs=[cn_series[i], cn_filepaths[i]], show_progress=False ) cn_series[i].change( fn=on_cn_series_change, inputs=[cn_series[i], cn_types[i]], outputs=[cn_filepaths[i]], show_progress=False )
def on_accordion_expand(*images): return [gr.update() for _ in images] accordion.expand( fn=on_accordion_expand, inputs=cn_images, outputs=cn_images, show_progress=False )
def create_anima_controlnet_lllite_event_handlers(prefix, ui_components): cn_rows = ui_components.get(f'anima_controlnet_lllite_rows_{prefix}') if not cn_rows: return480 unmodified lines add_outputs = [count_state, add_button, del_button] + rows del_outputs = [count_state, add_button, del_button] + rows + prompts add_button.click(fn=add_row, inputs=[count_state], outputs=add_outputs, show_progress=False) del_button.click(fn=del_row, inputs=[count_state], outputs=del_outputs, show_progress=False) del_button.click(fn=del_row, inputs=[count_state], outputs=del_outputs, show_progress=False)12 unmodified lines13141516171819192021222335 unmodified lines596061626364653 unmodified lines6970717273747536 unmodified lines11211311411511611711811912012112212312412516 unmodified lines14214314413414514614714840 unmodified lines1891901911921931941953 unmodified lines19920020120220320420536 unmodified lines24224324424524624724824925025125225325425525 unmodified lines28128228328428528628720 unmodified lines30830931031131231331431531631731831932032112 unmodified lines 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, ipa_preset, lora_acc, cn_acc, anima_cn_acc, diffsynth_cn_acc, ipa_acc, sd3_ipa_acc, flux1_ipa_acc, style_acc, embed_acc, cond_acc, ref_latent_acc, hidream_o1_ref_acc, guidance_comp, prompt_comp, neg_prompt_comp, steps_comp, cfg_comp, sampler_comp, scheduler_comp, pid_acc=None):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]35 unmodified lines 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))3 unmodified lines 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"))36 unmodified lines 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()16 unmodified lines 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, arch_comp_ref, ipa_preset, lora_acc, cn_acc, anima_cn_acc, diffsynth_cn_acc, ipa_acc, sd3_ipa_acc, flux1_ipa_acc, style_acc, embed_acc, cond_acc, ref_latent_acc, hidream_o1_ref_acc, guidance_comp, prompt_comp, neg_prompt_comp, steps_comp, cfg_comp, sampler_comp, scheduler_comp, pid_acc=None):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 = 140 unmodified lines 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))3 unmodified lines 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"))36 unmodified lines 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()25 unmodified lines 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"]:20 unmodified lines 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
115 unmodified lines1161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571586 unmodified lines165166167131168115 unmodified lines return all_types, default_type, series_choices, default_series, filepath
@lru_cache(maxsize=1)def load_krea2_controlnet_config(): _PROJECT_ROOT = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) _CN_MODEL_LIST_PATH = os.path.join(_PROJECT_ROOT, 'yaml', 'krea2_controlnet_models.yaml') try: print("--- Loading krea2_controlnet_models.yaml ---") with open(_CN_MODEL_LIST_PATH, 'r', encoding='utf-8') as f: config = yaml.safe_load(f) print("--- ✅ krea2_controlnet_models.yaml loaded successfully ---") return config.get("Krea2_ControlNet", []) except Exception as e: print(f"Error loading krea2_controlnet_models.yaml: {e}") return []
def get_krea2_cn_defaults(): cn_config = load_krea2_controlnet_config() if not cn_config: return [], None, [], None, "None" all_types = sorted(list(set(t for model in cn_config for t in model.get("Type", [])))) default_type = all_types[0] if all_types else None series_choices = [] if default_type: series_choices = sorted(list(set(model.get("Series", "Default") for model in cn_config if default_type in model.get("Type", [])))) default_series = series_choices[0] if series_choices else None filepath = "None" if default_series and default_type: for model in cn_config: if model.get("Series") == default_series and default_type in model.get("Type", []): filepath = model.get("Filepath") break return all_types, default_type, series_choices, default_series, filepath
@lru_cache(maxsize=1)def load_ipadapter_config(): _PROJECT_ROOT = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))6 unmodified lines return config except Exception as e: print(f"Error loading ipadapter.yaml: {e}") return {} return {}3 unmodified lines4567891037 unmodified lines484950515253545556575859606162633 unmodified lines6768697071727315 unmodified lines89909192939495969798991003 unmodified lines1041051061071081091103 unmodified lines11411511611710711811910912012112212311 unmodified lines1351361371381391401411421431441451463 unmodified lines1501511521531541551568 unmodified lines1651661671681541691701561711721731741 unmodified line17617717817918018118258 unmodified lines2412422432442452462472482492503 unmodified lines create_controlnet_event_handlers, create_anima_controlnet_lllite_event_handlers, create_diffsynth_controlnet_event_handlers, create_krea2_controlnet_event_handlers, create_ipadapter_event_handlers, create_embedding_event_handlers, create_conditioning_event_handlers,37 unmodified lines diffsynth_cn_types_list = ui_components.get(f'diffsynth_controlnet_types_{prefix}', []) diffsynth_cn_series_list = ui_components.get(f'diffsynth_controlnet_series_{prefix}', []) diffsynth_cn_filepaths_list = ui_components.get(f'diffsynth_controlnet_filepaths_{prefix}', [])
krea2_cn_types_list = ui_components.get(f'krea2_controlnet_types_{prefix}', []) krea2_cn_series_list = ui_components.get(f'krea2_controlnet_series_{prefix}', []) krea2_cn_filepaths_list = ui_components.get(f'krea2_controlnet_filepaths_{prefix}', []) lora_accordion = ui_components.get(f'lora_accordion_{prefix}') cn_accordion = ui_components.get(f'controlnet_accordion_{prefix}') anima_cn_accordion = ui_components.get(f'anima_controlnet_lllite_accordion_{prefix}') diffsynth_cn_accordion = ui_components.get(f'diffsynth_controlnet_accordion_{prefix}') krea2_cn_accordion = ui_components.get(f'krea2_controlnet_accordion_{prefix}') ipa_accordion = ui_components.get(f'ipadapter_accordion_{prefix}') sd3_ipa_accordion = ui_components.get(f'sd3_ipadapter_accordion_{prefix}') flux1_ipa_accordion = ui_components.get(f'flux1_ipadapter_accordion_{prefix}')3 unmodified lines 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}') ipa_preset_list = ui_components.get(f'ipadapter_final_preset_{prefix}') 15 unmodified lines outputs.extend(cn_types_list + cn_series_list + cn_filepaths_list) outputs.extend(anima_cn_types_list + anima_cn_series_list + anima_cn_filepaths_list) outputs.extend(diffsynth_cn_types_list + diffsynth_cn_series_list + diffsynth_cn_filepaths_list) outputs.extend(krea2_cn_types_list + krea2_cn_series_list + krea2_cn_filepaths_list) if lora_accordion: outputs.append(lora_accordion) if cn_accordion: outputs.append(cn_accordion) if anima_cn_accordion: outputs.append(anima_cn_accordion) if diffsynth_cn_accordion: outputs.append(diffsynth_cn_accordion) if krea2_cn_accordion: outputs.append(krea2_cn_accordion) if ipa_accordion: outputs.append(ipa_accordion) if sd3_ipa_accordion: outputs.append(sd3_ipa_accordion) if flux1_ipa_accordion: outputs.append(flux1_ipa_accordion)3 unmodified lines 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) outputs.extend(valid_extra_comps)3 unmodified lines cn_types_list, cn_series_list, cn_filepaths_list, anima_cn_types_list, anima_cn_series_list, anima_cn_filepaths_list, diffsynth_cn_types_list, diffsynth_cn_series_list, diffsynth_cn_filepaths_list, krea2_cn_types_list, krea2_cn_series_list, krea2_cn_filepaths_list, ipa_preset_list, lora_accordion, cn_accordion, anima_cn_accordion, diffsynth_cn_accordion, ipa_accordion, sd3_ipa_accordion, flux1_ipa_accordion, style_accordion, embedding_accordion, conditioning_accordion, 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 pid_acc=pid_accordion, vae_acc=vae_accordion ) inputs = [arch_comp, cat_comp] if aspect_ratio_comp:11 unmodified lines outputs2.extend(cn_types_list + cn_series_list + cn_filepaths_list) outputs2.extend(anima_cn_types_list + anima_cn_series_list + anima_cn_filepaths_list) outputs2.extend(diffsynth_cn_types_list + diffsynth_cn_series_list + diffsynth_cn_filepaths_list) outputs2.extend(krea2_cn_types_list + krea2_cn_series_list + krea2_cn_filepaths_list) if lora_accordion: outputs2.append(lora_accordion) if cn_accordion: outputs2.append(cn_accordion) if anima_cn_accordion: outputs2.append(anima_cn_accordion) if diffsynth_cn_accordion: outputs2.append(diffsynth_cn_accordion) if krea2_cn_accordion: outputs2.append(krea2_cn_accordion) if ipa_accordion: outputs2.append(ipa_accordion) if sd3_ipa_accordion: outputs2.append(sd3_ipa_accordion) if flux1_ipa_accordion: outputs2.append(flux1_ipa_accordion)3 unmodified lines 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) outputs2.extend(valid_extra_comps)8 unmodified lines cn_types_list, cn_series_list, cn_filepaths_list, anima_cn_types_list, anima_cn_series_list, anima_cn_filepaths_list, diffsynth_cn_types_list, diffsynth_cn_series_list, diffsynth_cn_filepaths_list, krea2_cn_types_list, krea2_cn_series_list, krea2_cn_filepaths_list, arch_comp, ipa_preset_list, lora_accordion, cn_accordion, anima_cn_accordion, diffsynth_cn_accordion, ipa_accordion, sd3_ipa_accordion, flux1_ipa_accordion, style_accordion, embedding_accordion, conditioning_accordion, 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 pid_acc=pid_accordion, vae_acc=vae_accordion ) model_comp.change(fn=change_fn, inputs=inputs2, outputs=outputs2)
1 unmodified line create_controlnet_event_handlers(prefix, ui_components) create_anima_controlnet_lllite_event_handlers(prefix, ui_components) create_diffsynth_controlnet_event_handlers(prefix, ui_components) create_krea2_controlnet_event_handlers(prefix, ui_components) create_ipadapter_event_handlers(prefix, ui_components) create_embedding_event_handlers(prefix, ui_components) create_conditioning_event_handlers(prefix, ui_components)58 unmodified lines all_load_outputs.extend(ui_components[f'diffsynth_controlnet_types_{prefix}']) all_load_outputs.extend(ui_components[f'diffsynth_controlnet_series_{prefix}']) all_load_outputs.extend(ui_components[f'diffsynth_controlnet_filepaths_{prefix}']) if f'krea2_controlnet_types_{prefix}' in ui_components: all_load_outputs.extend(ui_components[f'krea2_controlnet_types_{prefix}']) all_load_outputs.extend(ui_components[f'krea2_controlnet_series_{prefix}']) all_load_outputs.extend(ui_components[f'krea2_controlnet_filepaths_{prefix}']) if f'ipadapter_final_preset_{prefix}' in ui_components: all_load_outputs.extend(ui_components[f'ipadapter_lora_strengths_{prefix}']) all_load_outputs.append(ui_components[f'ipadapter_final_preset_{prefix}'])123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105import gradio as grfrom core.generation_logic import generate_image_wrapper
def create_run_event(prefix: str, task_type: str, ui_components: dict): run_inputs_map = { 'model_display_name': ui_components[f'base_model_{prefix}'], 'positive_prompt': ui_components.get(f'prompt_{prefix}') or ui_components.get(f'{prefix}_positive_prompt'), 'negative_prompt': ui_components.get(f'neg_prompt_{prefix}') or ui_components.get(f'{prefix}_negative_prompt'), 'seed': ui_components.get(f'seed_{prefix}') or ui_components.get(f'{prefix}_seed'), 'batch_size': ui_components.get(f'batch_size_{prefix}') or ui_components.get(f'{prefix}_batch_size'), 'guidance_scale': ui_components.get(f'cfg_{prefix}') or ui_components.get(f'{prefix}_cfg'), 'num_inference_steps': ui_components.get(f'steps_{prefix}') or ui_components.get(f'{prefix}_steps'), 'sampler': ui_components.get(f'sampler_{prefix}') or ui_components.get(f'{prefix}_sampler_name'), 'scheduler': ui_components.get(f'scheduler_{prefix}') or ui_components.get(f'{prefix}_scheduler'), 'zero_gpu_duration': ui_components.get(f'zero_gpu_{prefix}'),
'clip_skip': ui_components.get(f'clip_skip_{prefix}'), 'guidance': ui_components.get(f'guidance_{prefix}'), 'task_type': gr.State(task_type) } if ui_components.get(f'pid_settings_{prefix}'): run_inputs_map['pid_settings'] = ui_components[f'pid_settings_{prefix}'] if task_type not in ['img2img', 'inpaint']: run_inputs_map.update({ 'width': ui_components.get(f'width_{prefix}') or ui_components.get(f'{prefix}_width'), 'height': ui_components.get(f'height_{prefix}') or ui_components.get(f'{prefix}_height') }) task_specific_map = { 'img2img': {'img2img_image': f'input_image_{prefix}', 'img2img_denoise': f'denoise_{prefix}'}, 'inpaint': {'inpaint_image_dict': f'input_image_dict_{prefix}', 'grow_mask_by': f'grow_mask_by_{prefix}'}, 'outpaint': {'outpaint_image': f'input_image_{prefix}', 'left': f'left_{prefix}', 'top': f'top_{prefix}', 'right': f'right_{prefix}', 'bottom': f'bottom_{prefix}', 'feathering': f'feathering_{prefix}'}, 'hires_fix': {'hires_image': f'input_image_{prefix}', 'hires_upscaler': f'hires_upscaler_{prefix}', 'hires_scale_by': f'hires_scale_by_{prefix}', 'hires_denoise': f'denoise_{prefix}'} } if task_type in task_specific_map: for key, comp_name in task_specific_map[task_type].items(): if comp_name in ui_components: run_inputs_map[key] = ui_components[comp_name] lora_data_components = ui_components.get(f'all_lora_components_flat_{prefix}', []) controlnet_data_components = ui_components.get(f'all_controlnet_components_flat_{prefix}', []) anima_controlnet_lllite_data_components = ui_components.get(f'all_anima_controlnet_lllite_components_flat_{prefix}', []) diffsynth_controlnet_data_components = ui_components.get(f'all_diffsynth_controlnet_components_flat_{prefix}', []) ipadapter_data_components = ui_components.get(f'all_ipadapter_components_flat_{prefix}', []) sd3_ipadapter_data_components = ui_components.get(f'all_sd3_ipadapter_components_flat_{prefix}', []) flux1_ipadapter_data_components = ui_components.get(f'all_flux1_ipadapter_components_flat_{prefix}', []) style_data_components = ui_components.get(f'all_style_components_flat_{prefix}', []) embedding_data_components = ui_components.get(f'all_embedding_components_flat_{prefix}', []) conditioning_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}') run_inputs_map['vae_file'] = ui_components.get(f'vae_file_{prefix}')
input_keys = list(run_inputs_map.keys()) input_list_flat = [v for v in run_inputs_map.values() if v is not None] all_chains = [ lora_data_components, controlnet_data_components, anima_controlnet_lllite_data_components, diffsynth_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: input_list_flat.extend(chain)
def create_ui_inputs_dict(*args): valid_keys = [k for k in input_keys if run_inputs_map[k] is not None] ui_dict = dict(zip(valid_keys, args[:len(valid_keys)])) arg_idx = len(valid_keys)
def assign_chain_data(chain_key, components_list): nonlocal arg_idx if components_list: ui_dict[chain_key] = list(args[arg_idx : arg_idx + len(components_list)]) arg_idx += len(components_list)
assign_chain_data('lora_data', lora_data_components) assign_chain_data('controlnet_data', controlnet_data_components) assign_chain_data('anima_controlnet_lllite_data', anima_controlnet_lllite_data_components) assign_chain_data('diffsynth_controlnet_data', diffsynth_controlnet_data_components) assign_chain_data('ipadapter_data', ipadapter_data_components) assign_chain_data('sd3_ipadapter_chain', sd3_ipadapter_data_components) assign_chain_data('flux1_ipadapter_data', flux1_ipadapter_data_components) assign_chain_data('style_data', style_data_components) assign_chain_data('embedding_data', embedding_data_components) assign_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_dict
run_btn = ui_components.get(f'run_{prefix}') or ui_components.get(f'{prefix}_run_button') res_gal = ui_components.get(f'result_{prefix}') or ui_components.get(f'{prefix}_output_gallery') if run_btn and res_gal: run_btn.click( fn=lambda *args, progress=gr.Progress(track_tqdm=True): generate_image_wrapper(create_ui_inputs_dict(*args), progress), inputs=input_list_flat, outputs=[res_gal]import gradio as gr
from core.generation_logic import generate_image_wrapper
def create_run_event(prefix: str, task_type: str, ui_components: dict):
run_inputs_map = {
'model_display_name': ui_components[f'base_model_{prefix}'],
'positive_prompt': ui_components.get(f'prompt_{prefix}') or ui_components.get(f'{prefix}_positive_prompt'),
'negative_prompt': ui_components.get(f'neg_prompt_{prefix}') or ui_components.get(f'{prefix}_negative_prompt'),
'seed': ui_components.get(f'seed_{prefix}') or ui_components.get(f'{prefix}_seed'),
'batch_size': ui_components.get(f'batch_size_{prefix}') or ui_components.get(f'{prefix}_batch_size'),
'guidance_scale': ui_components.get(f'cfg_{prefix}') or ui_components.get(f'{prefix}_cfg'),
'num_inference_steps': ui_components.get(f'steps_{prefix}') or ui_components.get(f'{prefix}_steps'),
'sampler': ui_components.get(f'sampler_{prefix}') or ui_components.get(f'{prefix}_sampler_name'),
'scheduler': ui_components.get(f'scheduler_{prefix}') or ui_components.get(f'{prefix}_scheduler'),
'zero_gpu_duration': ui_components.get(f'zero_gpu_{prefix}'),
'clip_skip': ui_components.get(f'clip_skip_{prefix}'),
'guidance': ui_components.get(f'guidance_{prefix}'),
'task_type': gr.State(task_type)
}
if ui_components.get(f'pid_settings_{prefix}'):
run_inputs_map['pid_settings'] = ui_components[f'pid_settings_{prefix}']
if task_type not in ['img2img', 'inpaint']:
run_inputs_map.update({
'width': ui_components.get(f'width_{prefix}') or ui_components.get(f'{prefix}_width'),
'height': ui_components.get(f'height_{prefix}') or ui_components.get(f'{prefix}_height')
})
task_specific_map = {
'img2img': {'img2img_image': f'input_image_{prefix}', 'img2img_denoise': f'denoise_{prefix}'},
'inpaint': {'inpaint_image_dict': f'input_image_dict_{prefix}', 'grow_mask_by': f'grow_mask_by_{prefix}', 'inpaint_denoise': f'denoise_{prefix}'},
'outpaint': {'outpaint_image': f'input_image_{prefix}', 'left': f'left_{prefix}', 'top': f'top_{prefix}', 'right': f'right_{prefix}', 'bottom': f'bottom_{prefix}', 'feathering': f'feathering_{prefix}'},
'hires_fix': {'hires_image': f'input_image_{prefix}', 'hires_upscaler': f'hires_upscaler_{prefix}', 'hires_scale_by': f'hires_scale_by_{prefix}', 'hires_denoise': f'denoise_{prefix}'}
}
if task_type in task_specific_map:
for key, comp_name in task_specific_map[task_type].items():
if comp_name in ui_components:
run_inputs_map[key] = ui_components[comp_name]
lora_data_components = ui_components.get(f'all_lora_components_flat_{prefix}', [])
controlnet_data_components = ui_components.get(f'all_controlnet_components_flat_{prefix}', [])
anima_controlnet_lllite_data_components = ui_components.get(f'all_anima_controlnet_lllite_components_flat_{prefix}', [])
diffsynth_controlnet_data_components = ui_components.get(f'all_diffsynth_controlnet_components_flat_{prefix}', [])
krea2_controlnet_data_components = ui_components.get(f'all_krea2_controlnet_components_flat_{prefix}', [])
ipadapter_data_components = ui_components.get(f'all_ipadapter_components_flat_{prefix}', [])
sd3_ipadapter_data_components = ui_components.get(f'all_sd3_ipadapter_components_flat_{prefix}', [])
flux1_ipadapter_data_components = ui_components.get(f'all_flux1_ipadapter_components_flat_{prefix}', [])
style_data_components = ui_components.get(f'all_style_components_flat_{prefix}', [])
embedding_data_components = ui_components.get(f'all_embedding_components_flat_{prefix}', [])
conditioning_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}')
run_inputs_map['vae_file'] = ui_components.get(f'vae_file_{prefix}')
input_keys = list(run_inputs_map.keys())
input_list_flat = [v for v in run_inputs_map.values() if v is not None]
all_chains = [
lora_data_components, controlnet_data_components, anima_controlnet_lllite_data_components, diffsynth_controlnet_data_components, krea2_controlnet_data_components, ipadapter_data_components,
sd3_ipadapter_data_components, flux1_ipadapter_data_components, style_data_components,
embedding_data_components, conditioning_data_components, reference_latent_data_components, hidream_o1_reference_data_components
]
for chain in all_chains:
if chain:
input_list_flat.extend(chain)
def create_ui_inputs_dict(*args):
valid_keys = [k for k in input_keys if run_inputs_map[k] is not None]
ui_dict = dict(zip(valid_keys, args[:len(valid_keys)]))
arg_idx = len(valid_keys)
def assign_chain_data(chain_key, components_list):
nonlocal arg_idx
if components_list:
ui_dict[chain_key] = list(args[arg_idx : arg_idx + len(components_list)])
arg_idx += len(components_list)
assign_chain_data('lora_data', lora_data_components)
assign_chain_data('controlnet_data', controlnet_data_components)
assign_chain_data('anima_controlnet_lllite_data', anima_controlnet_lllite_data_components)
assign_chain_data('diffsynth_controlnet_data', diffsynth_controlnet_data_components)
assign_chain_data('krea2_controlnet_data', krea2_controlnet_data_components)
assign_chain_data('ipadapter_data', ipadapter_data_components)
assign_chain_data('sd3_ipadapter_chain', sd3_ipadapter_data_components)
assign_chain_data('flux1_ipadapter_data', flux1_ipadapter_data_components)
assign_chain_data('style_data', style_data_components)
assign_chain_data('embedding_data', embedding_data_components)
assign_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_dict
run_btn = ui_components.get(f'run_{prefix}') or ui_components.get(f'{prefix}_run_button')
res_gal = ui_components.get(f'result_{prefix}') or ui_components.get(f'{prefix}_output_gallery')
if run_btn and res_gal:
run_btn.click(
fn=lambda *args, progress=gr.Progress(track_tqdm=True): generate_image_wrapper(create_ui_inputs_dict(*args), progress),
inputs=input_list_flat,
outputs=[res_gal]
)12234566789101112131415161718192021222317 unmodified lines4142433637444546474811 unmodified lines606162555663646566676869707172735859747576777812 unmodified lines9192939495969798import gradio as gr
from core.settings import MODEL_MAP_CHECKPOINT
from core.settings import MODEL_MAP_CHECKPOINT, MODEL_DEFAULTS_CONFIG
from comfy_integration.nodes import SAMPLER_CHOICES, SCHEDULER_CHOICES
from .ui_components import (
create_lora_settings_ui,
create_controlnet_ui, create_anima_controlnet_lllite_ui, create_ipadapter_ui, create_embedding_ui,
create_controlnet_ui, create_anima_controlnet_lllite_ui, create_diffsynth_controlnet_ui, create_krea2_controlnet_ui, create_ipadapter_ui, create_embedding_ui,
create_conditioning_ui, create_vae_override_ui,
create_model_architecture_filter_ui, create_category_filter_ui,
create_sd3_ipadapter_ui, create_flux1_ipadapter_ui, create_style_ui,
create_reference_latent_ui, create_hidream_o1_reference_ui
)
default_vals = MODEL_DEFAULTS_CONFIG.get('Default', {})
DEFAULT_STEPS = default_vals.get('steps', 20)
DEFAULT_CFG = default_vals.get('cfg', 5.0)
DEFAULT_SAMPLER = default_vals.get('sampler_name', 'euler')
DEFAULT_SCHEDULER = default_vals.get('scheduler', 'simple')
DEFAULT_POS_PROMPT = default_vals.get('positive_prompt', '')
DEFAULT_NEG_PROMPT = default_vals.get('negative_prompt', '')
def create_ui():
prefix = "hires_fix"
components = {}17 unmodified lines with gr.Column(scale=1):
components[f'input_image_{prefix}'] = gr.Image(type="pil", label="Input Image", height=255)
with gr.Column(scale=2):
components[f'prompt_{prefix}'] = gr.Text(label="Prompt", lines=3)
components[f'neg_prompt_{prefix}'] = gr.Text(label="Negative prompt", lines=3)
components[f'prompt_{prefix}'] = gr.Text(label="Prompt", lines=3, value=DEFAULT_POS_PROMPT)
components[f'neg_prompt_{prefix}'] = gr.Text(label="Negative prompt", lines=3, value=DEFAULT_NEG_PROMPT)
with gr.Row():
with gr.Column(scale=1):11 unmodified lines components[f'denoise_{prefix}'] = gr.Slider(label="Denoise Strength", minimum=0.0, maximum=1.0, step=0.01, value=0.55)
with gr.Row():
components[f'sampler_{prefix}'] = gr.Dropdown(label="Sampler", choices=SAMPLER_CHOICES, value='er_sde' if 'er_sde' in SAMPLER_CHOICES else SAMPLER_CHOICES[0])
components[f'scheduler_{prefix}'] = gr.Dropdown(label="Scheduler", choices=SCHEDULER_CHOICES, value='simple' if 'simple' in SCHEDULER_CHOICES else SCHEDULER_CHOICES[0])
components[f'sampler_{prefix}'] = gr.Dropdown(
label="Sampler",
choices=SAMPLER_CHOICES,
value=DEFAULT_SAMPLER if DEFAULT_SAMPLER in SAMPLER_CHOICES else (SAMPLER_CHOICES[0] if SAMPLER_CHOICES else 'euler')
)
components[f'scheduler_{prefix}'] = gr.Dropdown(
label="Scheduler",
choices=SCHEDULER_CHOICES,
value=DEFAULT_SCHEDULER if DEFAULT_SCHEDULER in SCHEDULER_CHOICES else (SCHEDULER_CHOICES[0] if SCHEDULER_CHOICES else 'simple')
)
with gr.Row():
components[f'steps_{prefix}'] = gr.Slider(label="Steps", minimum=1, maximum=100, step=1, value=30)
components[f'cfg_{prefix}'] = gr.Slider(label="CFG Scale", minimum=1.0, maximum=20.0, step=0.1, value=4.0)
components[f'steps_{prefix}'] = gr.Slider(label="Steps", minimum=1, maximum=100, step=1, value=DEFAULT_STEPS)
components[f'cfg_{prefix}'] = gr.Slider(label="CFG Scale", minimum=1.0, maximum=20.0, step=0.1, value=DEFAULT_CFG)
with gr.Row():
components[f'seed_{prefix}'] = gr.Number(label="Seed (-1 for random)", value=-1, precision=0)
components[f'batch_size_{prefix}'] = gr.Slider(label="Batch Size", minimum=1, maximum=16, step=1, value=1)12 unmodified lines components.update(create_lora_settings_ui(prefix))
components.update(create_controlnet_ui(prefix))
components.update(create_anima_controlnet_lllite_ui(prefix))
components.update(create_diffsynth_controlnet_ui(prefix))
components.update(create_krea2_controlnet_ui(prefix))
components.update(create_ipadapter_ui(prefix))
components.update(create_flux1_ipadapter_ui(prefix))
components.update(create_sd3_ipadapter_ui(prefix))12234566789101112131415161718192021222312 unmodified lines36373831323940414243444546394047484950515253545556574243585960616210 unmodified lines73747576777879import gradio as gr
from core.settings import MODEL_MAP_CHECKPOINT
from core.settings import MODEL_MAP_CHECKPOINT, MODEL_DEFAULTS_CONFIG
from comfy_integration.nodes import SAMPLER_CHOICES, SCHEDULER_CHOICES
from .ui_components import (
create_lora_settings_ui,
create_controlnet_ui, create_anima_controlnet_lllite_ui, create_diffsynth_controlnet_ui, create_ipadapter_ui, create_embedding_ui,
create_controlnet_ui, create_anima_controlnet_lllite_ui, create_diffsynth_controlnet_ui, create_krea2_controlnet_ui, create_ipadapter_ui, create_embedding_ui,
create_conditioning_ui, create_vae_override_ui,
create_model_architecture_filter_ui, create_category_filter_ui,
create_sd3_ipadapter_ui, create_flux1_ipadapter_ui, create_style_ui,
create_reference_latent_ui, create_hidream_o1_reference_ui
)
default_vals = MODEL_DEFAULTS_CONFIG.get('Default', {})
DEFAULT_STEPS = default_vals.get('steps', 20)
DEFAULT_CFG = default_vals.get('cfg', 5.0)
DEFAULT_SAMPLER = default_vals.get('sampler_name', 'euler')
DEFAULT_SCHEDULER = default_vals.get('scheduler', 'simple')
DEFAULT_POS_PROMPT = default_vals.get('positive_prompt', '')
DEFAULT_NEG_PROMPT = default_vals.get('negative_prompt', '')
def create_ui():
prefix = "img2img"
components = {}12 unmodified lines components[f'input_image_{prefix}'] = gr.Image(type="pil", label="Input Image", height=255)
with gr.Column(scale=2):
components[f'prompt_{prefix}'] = gr.Text(label="Prompt", lines=3)
components[f'neg_prompt_{prefix}'] = gr.Text(label="Negative prompt", lines=3)
components[f'prompt_{prefix}'] = gr.Text(label="Prompt", lines=3, value=DEFAULT_POS_PROMPT)
components[f'neg_prompt_{prefix}'] = gr.Text(label="Negative prompt", lines=3, value=DEFAULT_NEG_PROMPT)
with gr.Row():
with gr.Column(scale=1):
components[f'denoise_{prefix}'] = gr.Slider(label="Denoise Strength", minimum=0.0, maximum=1.0, step=0.01, value=0.7)
with gr.Row():
components[f'sampler_{prefix}'] = gr.Dropdown(label="Sampler", choices=SAMPLER_CHOICES, value='er_sde' if 'er_sde' in SAMPLER_CHOICES else SAMPLER_CHOICES[0])
components[f'scheduler_{prefix}'] = gr.Dropdown(label="Scheduler", choices=SCHEDULER_CHOICES, value='simple' if 'simple' in SCHEDULER_CHOICES else SCHEDULER_CHOICES[0])
components[f'sampler_{prefix}'] = gr.Dropdown(
label="Sampler",
choices=SAMPLER_CHOICES,
value=DEFAULT_SAMPLER if DEFAULT_SAMPLER in SAMPLER_CHOICES else (SAMPLER_CHOICES[0] if SAMPLER_CHOICES else 'euler')
)
components[f'scheduler_{prefix}'] = gr.Dropdown(
label="Scheduler",
choices=SCHEDULER_CHOICES,
value=DEFAULT_SCHEDULER if DEFAULT_SCHEDULER in SCHEDULER_CHOICES else (SCHEDULER_CHOICES[0] if SCHEDULER_CHOICES else 'simple')
)
with gr.Row():
components[f'steps_{prefix}'] = gr.Slider(label="Steps", minimum=1, maximum=100, step=1, value=30)
components[f'cfg_{prefix}'] = gr.Slider(label="CFG Scale", minimum=1.0, maximum=20.0, step=0.1, value=4.0)
components[f'steps_{prefix}'] = gr.Slider(label="Steps", minimum=1, maximum=100, step=1, value=DEFAULT_STEPS)
components[f'cfg_{prefix}'] = gr.Slider(label="CFG Scale", minimum=1.0, maximum=20.0, step=0.1, value=DEFAULT_CFG)
with gr.Row():
components[f'seed_{prefix}'] = gr.Number(label="Seed (-1 for random)", value=-1, precision=0)
components[f'batch_size_{prefix}'] = gr.Slider(label="Batch Size", minimum=1, maximum=16, step=1, value=1)10 unmodified lines components.update(create_controlnet_ui(prefix))
components.update(create_anima_controlnet_lllite_ui(prefix))
components.update(create_diffsynth_controlnet_ui(prefix))
components.update(create_krea2_controlnet_ui(prefix))
components.update(create_ipadapter_ui(prefix))
components.update(create_flux1_ipadapter_ui(prefix))
components.update(create_sd3_ipadapter_ui(prefix))122345567891011121314151617181920212232 unmodified lines555657505158596061627 unmodified lines707172656673747576777879808182836869848586878816 unmodified lines105106107108109110111import gradio as gr
from core.settings import MODEL_MAP_CHECKPOINT
from core.settings import MODEL_MAP_CHECKPOINT, MODEL_DEFAULTS_CONFIG
from .ui_components import (
create_base_parameter_ui, create_lora_settings_ui,
create_controlnet_ui, create_anima_controlnet_lllite_ui, create_diffsynth_controlnet_ui, create_ipadapter_ui, create_embedding_ui,
create_controlnet_ui, create_anima_controlnet_lllite_ui, create_diffsynth_controlnet_ui, create_krea2_controlnet_ui, create_ipadapter_ui, create_embedding_ui,
create_conditioning_ui, create_vae_override_ui,
create_model_architecture_filter_ui, create_category_filter_ui,
create_sd3_ipadapter_ui, create_flux1_ipadapter_ui, create_style_ui,
create_reference_latent_ui, create_hidream_o1_reference_ui
)
default_vals = MODEL_DEFAULTS_CONFIG.get('Default', {})
DEFAULT_STEPS = default_vals.get('steps', 20)
DEFAULT_CFG = default_vals.get('cfg', 5.0)
DEFAULT_SAMPLER = default_vals.get('sampler_name', 'euler')
DEFAULT_SCHEDULER = default_vals.get('scheduler', 'simple')
DEFAULT_POS_PROMPT = default_vals.get('positive_prompt', '')
DEFAULT_NEG_PROMPT = default_vals.get('negative_prompt', '')
def create_ui():
prefix = "inpaint"
components = {}32 unmodified lines components[f'editor_column_{prefix}'] = editor_column
with gr.Column(scale=2) as prompts_column:
components[f'prompt_{prefix}'] = gr.Text(label="Prompt", lines=6)
components[f'neg_prompt_{prefix}'] = gr.Text(label="Negative prompt", lines=6)
components[f'prompt_{prefix}'] = gr.Text(label="Prompt", lines=6, value=DEFAULT_POS_PROMPT)
components[f'neg_prompt_{prefix}'] = gr.Text(label="Negative prompt", lines=6, value=DEFAULT_NEG_PROMPT)
components[f'prompts_column_{prefix}'] = prompts_column
with gr.Row() as params_and_gallery_row:7 unmodified lines label="Grow Mask By", minimum=0, maximum=64, step=1, value=6
)
with gr.Row():
components[f'sampler_{prefix}'] = gr.Dropdown(label="Sampler", choices=SAMPLER_CHOICES, value='er_sde' if 'er_sde' in SAMPLER_CHOICES else SAMPLER_CHOICES[0])
components[f'scheduler_{prefix}'] = gr.Dropdown(label="Scheduler", choices=SCHEDULER_CHOICES, value='simple' if 'simple' in SCHEDULER_CHOICES else SCHEDULER_CHOICES[0])
components[f'sampler_{prefix}'] = gr.Dropdown(
label="Sampler",
choices=SAMPLER_CHOICES,
value=DEFAULT_SAMPLER if DEFAULT_SAMPLER in SAMPLER_CHOICES else (SAMPLER_CHOICES[0] if SAMPLER_CHOICES else 'euler')
)
components[f'scheduler_{prefix}'] = gr.Dropdown(
label="Scheduler",
choices=SCHEDULER_CHOICES,
value=DEFAULT_SCHEDULER if DEFAULT_SCHEDULER in SCHEDULER_CHOICES else (SCHEDULER_CHOICES[0] if SCHEDULER_CHOICES else 'simple')
)
with gr.Row():
components[f'steps_{prefix}'] = gr.Slider(label="Steps", minimum=1, maximum=100, step=1, value=30)
components[f'cfg_{prefix}'] = gr.Slider(label="CFG Scale", minimum=1.0, maximum=20.0, step=0.1, value=4.0)
components[f'steps_{prefix}'] = gr.Slider(label="Steps", minimum=1, maximum=100, step=1, value=DEFAULT_STEPS)
components[f'cfg_{prefix}'] = gr.Slider(label="CFG Scale", minimum=1.0, maximum=20.0, step=0.1, value=DEFAULT_CFG)
with gr.Row():
components[f'seed_{prefix}'] = gr.Number(label="Seed (-1 for random)", value=-1, precision=0)
components[f'batch_size_{prefix}'] = gr.Slider(label="Batch Size", minimum=1, maximum=16, step=1, value=1)16 unmodified lines components.update(create_controlnet_ui(prefix))
components.update(create_anima_controlnet_lllite_ui(prefix))
components.update(create_diffsynth_controlnet_ui(prefix))
components.update(create_krea2_controlnet_ui(prefix))
components.update(create_ipadapter_ui(prefix))
components.update(create_flux1_ipadapter_ui(prefix))
components.update(create_sd3_ipadapter_ui(prefix))12234566789101112131415161718192021222317 unmodified lines414243363744454647487 unmodified lines565758515259606162636465666768695455707172737413 unmodified lines88899091929394import gradio as gr
from core.settings import MODEL_MAP_CHECKPOINT
from core.settings import MODEL_MAP_CHECKPOINT, MODEL_DEFAULTS_CONFIG
from comfy_integration.nodes import SAMPLER_CHOICES, SCHEDULER_CHOICES
from .ui_components import (
create_lora_settings_ui,
create_controlnet_ui, create_anima_controlnet_lllite_ui, create_diffsynth_controlnet_ui, create_ipadapter_ui, create_embedding_ui,
create_controlnet_ui, create_anima_controlnet_lllite_ui, create_diffsynth_controlnet_ui, create_krea2_controlnet_ui, create_ipadapter_ui, create_embedding_ui,
create_conditioning_ui, create_vae_override_ui,
create_model_architecture_filter_ui, create_category_filter_ui,
create_sd3_ipadapter_ui, create_flux1_ipadapter_ui, create_style_ui,
create_reference_latent_ui, create_hidream_o1_reference_ui
)
default_vals = MODEL_DEFAULTS_CONFIG.get('Default', {})
DEFAULT_STEPS = default_vals.get('steps', 20)
DEFAULT_CFG = default_vals.get('cfg', 5.0)
DEFAULT_SAMPLER = default_vals.get('sampler_name', 'euler')
DEFAULT_SCHEDULER = default_vals.get('scheduler', 'simple')
DEFAULT_POS_PROMPT = default_vals.get('positive_prompt', '')
DEFAULT_NEG_PROMPT = default_vals.get('negative_prompt', '')
def create_ui():
prefix = "outpaint"
components = {}17 unmodified lines with gr.Column(scale=1):
components[f'input_image_{prefix}'] = gr.Image(type="pil", label="Input Image", height=255)
with gr.Column(scale=2):
components[f'prompt_{prefix}'] = gr.Text(label="Prompt", lines=3)
components[f'neg_prompt_{prefix}'] = gr.Text(label="Negative prompt", lines=3)
components[f'prompt_{prefix}'] = gr.Text(label="Prompt", lines=3, value=DEFAULT_POS_PROMPT)
components[f'neg_prompt_{prefix}'] = gr.Text(label="Negative prompt", lines=3, value=DEFAULT_NEG_PROMPT)
with gr.Row():
with gr.Column(scale=1):7 unmodified lines components[f'feathering_{prefix}'] = gr.Slider(label="Feathering / Grow Mask", minimum=0, maximum=100, step=1, value=10)
with gr.Row():
components[f'sampler_{prefix}'] = gr.Dropdown(label="Sampler", choices=SAMPLER_CHOICES, value='er_sde' if 'er_sde' in SAMPLER_CHOICES else SAMPLER_CHOICES[0])
components[f'scheduler_{prefix}'] = gr.Dropdown(label="Scheduler", choices=SCHEDULER_CHOICES, value='simple' if 'simple' in SCHEDULER_CHOICES else SCHEDULER_CHOICES[0])
components[f'sampler_{prefix}'] = gr.Dropdown(
label="Sampler",
choices=SAMPLER_CHOICES,
value=DEFAULT_SAMPLER if DEFAULT_SAMPLER in SAMPLER_CHOICES else (SAMPLER_CHOICES[0] if SAMPLER_CHOICES else 'euler')
)
components[f'scheduler_{prefix}'] = gr.Dropdown(
label="Scheduler",
choices=SCHEDULER_CHOICES,
value=DEFAULT_SCHEDULER if DEFAULT_SCHEDULER in SCHEDULER_CHOICES else (SCHEDULER_CHOICES[0] if SCHEDULER_CHOICES else 'simple')
)
with gr.Row():
components[f'steps_{prefix}'] = gr.Slider(label="Steps", minimum=1, maximum=100, step=1, value=30)
components[f'cfg_{prefix}'] = gr.Slider(label="CFG Scale", minimum=1.0, maximum=20.0, step=0.1, value=4.0)
components[f'steps_{prefix}'] = gr.Slider(label="Steps", minimum=1, maximum=100, step=1, value=DEFAULT_STEPS)
components[f'cfg_{prefix}'] = gr.Slider(label="CFG Scale", minimum=1.0, maximum=20.0, step=0.1, value=DEFAULT_CFG)
with gr.Row():
components[f'seed_{prefix}'] = gr.Number(label="Seed (-1 for random)", value=-1, precision=0)
components[f'batch_size_{prefix}'] = gr.Slider(label="Batch Size", minimum=1, maximum=16, step=1, value=1)13 unmodified lines components.update(create_controlnet_ui(prefix))
components.update(create_anima_controlnet_lllite_ui(prefix))
components.update(create_diffsynth_controlnet_ui(prefix))
components.update(create_krea2_controlnet_ui(prefix))
components.update(create_ipadapter_ui(prefix))
components.update(create_flux1_ipadapter_ui(prefix))
components.update(create_sd3_ipadapter_ui(prefix))1 unmodified line2345567836 unmodified lines454647484950511 unmodified linefrom core.settings import MODEL_MAP_CHECKPOINT
from .ui_components import (
create_base_parameter_ui, create_lora_settings_ui,
create_controlnet_ui, create_anima_controlnet_lllite_ui, create_diffsynth_controlnet_ui, create_ipadapter_ui, create_embedding_ui,
create_controlnet_ui, create_anima_controlnet_lllite_ui, create_diffsynth_controlnet_ui, create_krea2_controlnet_ui, create_ipadapter_ui, create_embedding_ui,
create_conditioning_ui, create_vae_override_ui,
create_model_architecture_filter_ui, create_category_filter_ui,
create_sd3_ipadapter_ui, create_flux1_ipadapter_ui, create_style_ui,36 unmodified lines components.update(create_controlnet_ui(prefix))
components.update(create_anima_controlnet_lllite_ui(prefix))
components.update(create_diffsynth_controlnet_ui(prefix))
components.update(create_krea2_controlnet_ui(prefix))
components.update(create_ipadapter_ui(prefix))
components.update(create_flux1_ipadapter_ui(prefix))
components.update(create_sd3_ipadapter_ui(prefix))3 unmodified lines4567789107 unmodified lines1819202122232425262728293066 unmodified lines9798999394100101102103104105106107108109110969711111211311411512 unmodified lines12812913011613113213313413513612212313713813914014161 unmodified lines203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251270 unmodified lines5225235244675255265275287 unmodified lines53653753848153954054154263 unmodified lines6066076085516096105536116126136143 unmodified lines6186196205635646216226236243 unmodified lines MAX_LORAS, LORA_SOURCE_CHOICES, MAX_EMBEDDINGS, MAX_CONDITIONINGS,
MAX_CONTROLNETS, MAX_IPADAPTERS, RESOLUTION_MAP, ARCHITECTURES_CONFIG,
MODEL_MAP_CHECKPOINT, MODEL_TYPE_MAP, FEATURES_CONFIG, ARCH_CATEGORIES_MAP,
VAE_DIR
VAE_DIR, MODEL_DEFAULTS_CONFIG
)
import yaml
import os7 unmodified linesdefault_arch_features = FEATURES_CONFIG.get(default_arch_model_type, FEATURES_CONFIG.get('default', {}))
default_enabled_chains = default_arch_features.get('enabled_chains', [])
default_vals = MODEL_DEFAULTS_CONFIG.get('Default', {})
DEFAULT_STEPS = default_vals.get('steps', 20)
DEFAULT_CFG = default_vals.get('cfg', 5.0)
DEFAULT_SAMPLER = default_vals.get('sampler_name', 'euler')
DEFAULT_SCHEDULER = default_vals.get('scheduler', 'simple')
DEFAULT_POS_PROMPT = default_vals.get('positive_prompt', '')
DEFAULT_NEG_PROMPT = default_vals.get('negative_prompt', '')
@lru_cache(maxsize=1)
def get_ipadapter_config_from_yaml():66 unmodified lines components[f'width_{prefix}'] = gr.Number(label="Width", value=defaults.get('w', 1024), interactive=True)
components[f'height_{prefix}'] = gr.Number(label="Height", value=defaults.get('h', 1024), interactive=True)
with gr.Row():
components[f'sampler_{prefix}'] = gr.Dropdown(label="Sampler", choices=SAMPLER_CHOICES, value='er_sde' if 'er_sde' in SAMPLER_CHOICES else SAMPLER_CHOICES[0])
components[f'scheduler_{prefix}'] = gr.Dropdown(label="Scheduler", choices=SCHEDULER_CHOICES, value='simple' if 'simple' in SCHEDULER_CHOICES else SCHEDULER_CHOICES[0])
components[f'sampler_{prefix}'] = gr.Dropdown(
label="Sampler",
choices=SAMPLER_CHOICES,
value=DEFAULT_SAMPLER if DEFAULT_SAMPLER in SAMPLER_CHOICES else (SAMPLER_CHOICES[0] if SAMPLER_CHOICES else 'euler')
)
components[f'scheduler_{prefix}'] = gr.Dropdown(
label="Scheduler",
choices=SCHEDULER_CHOICES,
value=DEFAULT_SCHEDULER if DEFAULT_SCHEDULER in SCHEDULER_CHOICES else (SCHEDULER_CHOICES[0] if SCHEDULER_CHOICES else 'simple')
)
with gr.Row():
components[f'steps_{prefix}'] = gr.Slider(label="Steps", minimum=1, maximum=100, step=1, value=30)
components[f'cfg_{prefix}'] = gr.Slider(label="CFG Scale", minimum=1.0, maximum=20.0, step=0.1, value=4.0)
components[f'steps_{prefix}'] = gr.Slider(label="Steps", minimum=1, maximum=100, step=1, value=DEFAULT_STEPS)
components[f'cfg_{prefix}'] = gr.Slider(label="CFG Scale", minimum=1.0, maximum=20.0, step=0.1, value=DEFAULT_CFG)
with gr.Row():
components[f'seed_{prefix}'] = gr.Number(label="Seed (-1 for random)", value=-1, precision=0)
components[f'batch_size_{prefix}'] = gr.Slider(label="Batch Size", minimum=1, maximum=16, step=1, value=1)12 unmodified lines
with gr.Accordion("LoRA Settings", open=False, visible=('lora' in default_enabled_chains)) as lora_accordion:
components[f'lora_accordion_{prefix}'] = lora_accordion
gr.Markdown("💡 **Tip:** When downloading from Civitai, please use the **Version ID**, not the Model ID. You can find the Version ID in the URL (e.g., `civitai.com/models/123?modelVersionId=456`) or under the model's download button.")
gr.Markdown("💡 **Tip:** When downloading from Civitai, please use the **Version ID**, not the Model ID. You can find the Version ID in the URL (e.g., `civitai.com/models/123?modelVersionId=456`) or under the model's download button. When downloading from Hugging Face, please use the format: `repo_id/filename.extension` or `repo_id/folder_path/filename.extension` (e.g., `lightx2v/Qwen-Image-Lightning/Qwen-Image-Lightning-4steps-V2.0-bf16.safetensors`).")
components[f'lora_count_state_{prefix}'] = gr.State(1)
for i in range(MAX_LORAS):
with gr.Row(visible=i==0) as row:
source = gr.Dropdown(label=f"LoRA Source {i+1}", choices=LORA_SOURCE_CHOICES, value=LORA_SOURCE_CHOICES[0], scale=1)
lora_id = gr.Textbox(label=f"Civitai Version ID / File", placeholder="Civitai Version ID or Filename", scale=2, type="text")
scale = gr.Slider(label=f"Scale", minimum=0.0, maximum=2.0, step=0.05, value=0.8, scale=1)
lora_id = gr.Textbox(label="Civitai Version ID / HF file / Upload File", scale=2, type="text")
scale = gr.Slider(label=f"Scale", minimum=0.0, maximum=2.0, step=0.05, value=1.0, scale=1)
upload = gr.UploadButton(label="Upload", file_types=[".safetensors"], scale=1)
lora_rows.append(row)61 unmodified lines
return components
def create_krea2_controlnet_ui(prefix: str, max_units=MAX_CONTROLNETS):
components = {}
key = lambda name: f"{name}_{prefix}"
with gr.Accordion("Krea2 ControlNet Settings", open=False, visible=('krea2_controlnet' in default_enabled_chains)) as accordion:
components[key('krea2_controlnet_accordion')] = accordion
gr.Markdown("💡 **Tip:** Processed using the [facok/comfyui-krea2-controlnet](https://github.com/facok/comfyui-krea2-controlnet) node.")
cn_rows, images, series, types, strengths, filepaths = [], [], [], [], [], []
components.update({
key('krea2_controlnet_rows'): cn_rows,
key('krea2_controlnet_images'): images,
key('krea2_controlnet_series'): series,
key('krea2_controlnet_types'): types,
key('krea2_controlnet_strengths'): strengths,
key('krea2_controlnet_filepaths'): filepaths
})
for i in range(max_units):
with gr.Row(visible=(i < 1)) as row:
with gr.Column(scale=1):
images.append(gr.Image(label=f"Control Image {i+1}", type="pil", sources=["upload"], height=256))
with gr.Column(scale=2):
types.append(gr.Dropdown(label="Type", choices=[], interactive=True, allow_custom_value=True))
series.append(gr.Dropdown(label="Series", choices=[], interactive=True, allow_custom_value=True))
strengths.append(gr.Slider(label="Strength", minimum=0.0, maximum=2.0, step=0.05, value=1.0, interactive=True))
filepaths.append(gr.State(None))
cn_rows.append(row)
with gr.Row():
components[key('add_krea2_controlnet_button')] = gr.Button("✚ Add Krea2 ControlNet")
components[key('delete_krea2_controlnet_button')] = gr.Button("➖ Delete Krea2 ControlNet", visible=False)
components[key('krea2_controlnet_count_state')] = gr.State(1)
all_cn_components_flat = []
for i in range(max_units):
all_cn_components_flat.extend([
images[i], types[i], series[i], strengths[i], filepaths[i]
])
components[key('all_krea2_controlnet_components_flat')] = all_cn_components_flat
return components
def create_anima_controlnet_lllite_ui(prefix: str, max_units=MAX_CONTROLNETS):
components = {}
key = lambda name: f"{name}_{prefix}"270 unmodified lines
with gr.Accordion("Embedding Settings", open=False, visible=('embedding' in default_enabled_chains)) as accordion:
components[key('embedding_accordion')] = accordion
gr.Markdown("💡 **Tip:** Embeddings are automatically added to your prompt using `embedding:filename` syntax. When downloading from Civitai, please use the **Version ID**, not the Model ID. You can find the Version ID in the URL (e.g., `civitai.com/models/123?modelVersionId=456`) or under the model's download button. For instance, using the Version ID `456` from the example above would automatically append `embedding:civitai_456` to your positive prompt.")
gr.Markdown("💡 **Tip:** When downloading from Civitai, please use the **Version ID**, not the Model ID. You can find the Version ID in the URL (e.g., `civitai.com/models/123?modelVersionId=456`) or under the model's download button. For example, entering the Version ID 456 will automatically save the file as \"civitai_456.safetensors\", and you will need to manually enter `embedding:civitai_456` in either your prompt or negative prompt to activate it.When downloading from Hugging Face, please use the format: repo_id/filename.extension or repo_id/folder_path/filename.extension (e.g., ilikebigturtles/lazypos/lazypos.safetensors or ilikebigturtles/lazyneg/lazyneg.safetensors). For Hugging Face files, you will need to enter embedding:filename (e.g., entering embedding:lazypos in your positive prompt, or embedding:lazyneg in your negative prompt) to activate it.")
embedding_rows, sources, ids, files, upload_buttons = [], [], [], [], []
components.update({7 unmodified lines for i in range(MAX_EMBEDDINGS):
with gr.Row(visible=(i < 1)) as row:
sources.append(gr.Dropdown(label=f"Embedding Source {i+1}", choices=LORA_SOURCE_CHOICES, value="Civitai", scale=1, interactive=True))
ids.append(gr.Textbox(label="Civitai Version ID / File", placeholder="Civitai Version ID or Filename", scale=3, interactive=True, type="text"))
ids.append(gr.Textbox(label="Civitai Version ID / HF file / Upload File", scale=3, interactive=True, type="text"))
upload_btn = gr.UploadButton("Upload", file_types=[".safetensors"], scale=1)
files.append(gr.State(None))
upload_buttons.append(upload_btn)63 unmodified lines key = lambda name: f"{name}_{prefix}"
source_choices = ["None"] + LORA_SOURCE_CHOICES
with gr.Accordion("VAE Settings (Override)", open=False) as vae_accordion:
with gr.Accordion("VAE Settings (Override)", open=False, visible=('vae' in default_enabled_chains)) as vae_accordion:
components[key('vae_accordion')] = vae_accordion
gr.Markdown("💡 **Tip:** When downloading from Civitai, please use the **Version ID**, not the Model ID. You can find the Version ID in the URL (e.g., `civitai.com/models/123?modelVersionId=456`) or under the model's download button.")
gr.Markdown("💡 **Tip:** When downloading from Civitai, please use the **Version ID**, not the Model ID. You can find the Version ID in the URL (e.g., `civitai.com/models/123?modelVersionId=456`) or under the model's download button. When downloading from Hugging Face, please use the format: `repo_id/filename.extension` or `repo_id/folder_path/filename.extension` (e.g., `madebyollin/sdxl-vae-fp16-fix/sdxl_vae.safetensors`).")
with gr.Row():
components[key('vae_source')] = gr.Dropdown(
label="VAE Source", 3 unmodified lines interactive=True
)
components[key('vae_id')] = gr.Textbox(
label="Civitai Version ID / File",
placeholder="Civitai Version ID or Filename",
label="Civitai Version ID / HF file / Upload File",
scale=3,
interactive=True,
type="text"104 unmodified lines10510610710810911011111211311411511611711818 unmodified lines13713813914014114214314413414514614713613714814915015115215315415515632 unmodified lines189190191192193194195196197198199200178201202203204205206207208209210211212213214215216217218187188219220221222223224225190191226227228193194195229230231232233234235236237238239240241242243244245246202203247248249250251252253254255256257258210259260261262263264265266267268269270271272273274275276277278279280223224281282283284285286287226227288289290229230231291292293294295296297298299300301302303304305306307308238239309310311312313314315316317318319320246321322323324325326327328329330331332333334335336337338339340341342343259260261262263344345346347348349265266267350351352353354355356357358359360361362363364365366367368187 unmodified lines5565575584625595605618 unmodified lines570571572477478573574575104 unmodified linesdef sanitize_id(input_id: str) -> str:
if not isinstance(input_id, str):
return ""
input_id = input_id.strip()
if "civitai" in input_id.lower():
version_match = re.search(r'modelVersionId=(\d+)', input_id)
if version_match:
return version_match.group(1)
model_match = re.search(r'/models/(\d+)', input_id)
if model_match:
return model_match.group(1)
return re.sub(r'[^0-9]', '', input_id)
def sanitize_url(url: str) -> str:18 unmodified lines response.raise_for_status()
data = response.json()
model_type = data.get('model', {}).get('type')
result_file = None
for file_data in data.get('files', []):
if file_data.get('type') == 'Model' and file_data['name'].endswith(('.safetensors', '.pt', '.bin')):
return file_data
result_file = file_data.copy()
break
if data.get('files'):
return data['files'][0]
if not result_file and data.get('files'):
result_file = data['files'][0].copy()
if result_file:
result_file['model_type'] = model_type
return result_file
except Exception:
return None
32 unmodified lines version_id = sanitize_id(id_or_url)
if not version_id:
return None, "Invalid Civitai ID provided. Must be numeric."
file_info = get_civitai_file_info(version_id)
if file_info:
model_type = file_info.get('model_type')
if model_type and model_type.lower() == 'checkpoint':
return None, f"Invalid Civitai model type '{model_type}' for LoRA. Checkpoint models are not allowed."
filename = sanitize_filename(f"civitai_{version_id}.safetensors")
local_path = os.path.join(LORA_DIR, filename)
file_info = get_civitai_file_info(version_id)
api_key_to_use = civitai_key
source_name = f"Civitai ID {version_id}"
elif source == "Hugging Face":
parts = id_or_url.strip().split('/')
if len(parts) < 3:
return None, "Invalid Hugging Face path. Format: repo_owner/repo_name/filename"
repo_id = f"{parts[0]}/{parts[1]}"
repo_file_path = "/".join(parts[2:])
unique_name = id_or_url.strip().replace('/', '_')
filename = sanitize_filename(unique_name)
local_path = os.path.join(LORA_DIR, filename)
source_name = f"HF {repo_file_path}"
else:
return None, "Invalid source."
except ValueError as e:
return None, f"Input validation failed: {e}"
if os.path.exists(local_path):
return local_path, "File already exists."
if os.path.lexists(local_path):
if not os.path.exists(local_path):
os.remove(local_path)
else:
return local_path, "File already exists."
if source == "Civitai":
if not file_info or not file_info.get('downloadUrl'):
return None, f"Could not get download link for {source_name}."
if not file_info or not file_info.get('downloadUrl'):
return None, f"Could not get download link for {source_name}."
status = download_file(file_info['downloadUrl'], local_path, api_key_to_use, progress=progress, desc=f"Downloading {source_name}")
return (local_path, status) if "Successfully" in status else (None, status)
status = download_file(file_info['downloadUrl'], local_path, api_key_to_use, progress=progress, desc=f"Downloading {source_name}")
return (local_path, status) if "Successfully" in status else (None, status)
elif source == "Hugging Face":
try:
if progress: progress(0, desc=f"Downloading {source_name}")
cached_path = hf_hub_download(repo_id=repo_id, filename=repo_file_path, token=os.environ.get("HF_TOKEN"))
os.makedirs(LORA_DIR, exist_ok=True)
os.symlink(cached_path, local_path)
if progress: progress(1.0, desc=f"Downloaded {source_name}")
return local_path, f"Successfully downloaded: {filename}"
except Exception as e:
return None, f"Hugging Face download failed: {e}"
def get_embedding_path(source: str, id_or_url: str, civitai_key: str, progress) -> tuple[str | None, str]:
if not id_or_url or not id_or_url.strip():
return None, "No ID/URL provided."
try:
file_ext = ".safetensors"
if source == "Civitai":
version_id = sanitize_id(id_or_url)
if not version_id:
return None, "Invalid Civitai ID. Must be numeric."
file_info = get_civitai_file_info(version_id)
if file_info:
model_type = file_info.get('model_type')
if model_type and model_type.lower() == 'checkpoint':
return None, f"Invalid Civitai model type '{model_type}' for Embedding. Checkpoint models are not allowed."
file_ext = ".safetensors"
if file_info and file_info['name'].lower().endswith(('.pt', '.bin')):
if file_info and file_info.get('name') and file_info['name'].lower().endswith(('.pt', '.bin')):
file_ext = os.path.splitext(file_info['name'])[1]
filename = sanitize_filename(f"civitai_{version_id}{file_ext}")
local_path = os.path.join(EMBEDDING_DIR, filename)
api_key_to_use = civitai_key
source_name = f"Embedding Civitai ID {version_id}"
elif source == "Hugging Face":
parts = id_or_url.strip().split('/')
if len(parts) < 3:
return None, "Invalid Hugging Face path. Format: repo_owner/repo_name/filename"
repo_id = f"{parts[0]}/{parts[1]}"
repo_file_path = "/".join(parts[2:])
filename = sanitize_filename(parts[-1])
local_path = os.path.join(EMBEDDING_DIR, filename)
source_name = f"Embedding HF {repo_file_path}"
else:
return None, "Invalid source."
except ValueError as e:
return None, f"Input validation failed: {e}"
if os.path.exists(local_path):
return local_path, "File already exists."
if os.path.lexists(local_path):
if not os.path.exists(local_path):
os.remove(local_path)
else:
return local_path, "File already exists."
if source == "Civitai":
if not file_info or not file_info.get('downloadUrl'):
return None, f"Could not get download link for {source_name}."
if not file_info or not file_info.get('downloadUrl'):
return None, f"Could not get download link for {source_name}."
status = download_file(file_info['downloadUrl'], local_path, api_key_to_use, progress=progress, desc=f"Downloading {source_name}")
return (local_path, status) if "Successfully" in status else (None, status)
status = download_file(file_info['downloadUrl'], local_path, api_key_to_use, progress=progress, desc=f"Downloading {source_name}")
return (local_path, status) if "Successfully" in status else (None, status)
elif source == "Hugging Face":
try:
if progress: progress(0, desc=f"Downloading {source_name}")
cached_path = hf_hub_download(repo_id=repo_id, filename=repo_file_path, token=os.environ.get("HF_TOKEN"))
os.makedirs(EMBEDDING_DIR, exist_ok=True)
os.symlink(cached_path, local_path)
if progress: progress(1.0, desc=f"Downloaded {source_name}")
return local_path, f"Successfully downloaded: {filename}"
except Exception as e:
return None, f"Hugging Face download failed: {e}"
def get_vae_path(source: str, id_or_url: str, civitai_key: str, progress) -> tuple[str | None, str]:
if not id_or_url or not id_or_url.strip():
return None, "No ID/URL provided."
try:
file_ext = ".safetensors"
if source == "Civitai":
version_id = sanitize_id(id_or_url)
if not version_id:
return None, "Invalid Civitai ID. Must be numeric."
file_info = get_civitai_file_info(version_id)
if file_info:
model_type = file_info.get('model_type')
if model_type and model_type.lower() == 'checkpoint':
return None, f"Invalid Civitai model type '{model_type}' for VAE. Checkpoint models are not allowed."
file_ext = ".safetensors"
if file_info and file_info['name'].lower().endswith(('.pt', '.bin')):
if file_info and file_info.get('name') and file_info['name'].lower().endswith(('.pt', '.bin')):
file_ext = os.path.splitext(file_info['name'])[1]
filename = sanitize_filename(f"civitai_{version_id}{file_ext}")
local_path = os.path.join(VAE_DIR, filename)
api_key_to_use = civitai_key
source_name = f"VAE Civitai ID {version_id}"
elif source == "Hugging Face":
parts = id_or_url.strip().split('/')
if len(parts) < 3:
return None, "Invalid Hugging Face path. Format: repo_owner/repo_name/filename"
repo_id = f"{parts[0]}/{parts[1]}"
repo_file_path = "/".join(parts[2:])
unique_name = id_or_url.strip().replace('/', '_')
filename = sanitize_filename(unique_name)
local_path = os.path.join(VAE_DIR, filename)
source_name = f"VAE HF {repo_file_path}"
else:
return None, "Invalid source."
except ValueError as e:
return None, f"Input validation failed: {e}"
if os.path.exists(local_path):
return local_path, "File already exists."
if not file_info or not file_info.get('downloadUrl'):
return None, f"Could not get download link for {source_name}."
if os.path.lexists(local_path):
if not os.path.exists(local_path):
os.remove(local_path)
else:
return local_path, "File already exists."
status = download_file(file_info['downloadUrl'], local_path, api_key_to_use, progress=progress, desc=f"Downloading {source_name}")
return (local_path, status) if "Successfully" in status else (None, status)
if source == "Civitai":
if not file_info or not file_info.get('downloadUrl'):
return None, f"Could not get download link for {source_name}."
status = download_file(file_info['downloadUrl'], local_path, api_key_to_use, progress=progress, desc=f"Downloading {source_name}")
return (local_path, status) if "Successfully" in status else (None, status)
elif source == "Hugging Face":
try:
if progress: progress(0, desc=f"Downloading {source_name}")
cached_path = hf_hub_download(repo_id=repo_id, filename=repo_file_path, token=os.environ.get("HF_TOKEN"))
os.makedirs(VAE_DIR, exist_ok=True)
os.symlink(cached_path, local_path)
if progress: progress(1.0, desc=f"Downloaded {source_name}")
return local_path, f"Successfully downloaded: {filename}"
except Exception as e:
return None, f"Hugging Face download failed: {e}"
def _ensure_model_downloaded(display_name: str, progress=gr.Progress()):
if display_name not in ALL_MODEL_MAP:187 unmodified lines except Exception as e:
print(f"❌ Error ensuring download for IPAdapter asset '{filename}': {e}")
def ensure_sd3_ipadapter_models_downloaded(progress):
_PROJECT_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
yaml_path = os.path.join(_PROJECT_ROOT, 'yaml', 'ipadapter_sd3_models.yaml')8 unmodified lines except Exception as e:
print(f"Warning: Failed to load or download sd3 ipadapter models: {e}")
def get_model_generation_defaults(model_display_name: str, model_type: str, defaults_config: dict):
final_defaults = {
'steps': 25, 'cfg': 7.0, 'sampler_name': 'euler', 'scheduler': 'simple',3 unmodified lines4567789101112131415161718192021222324252627282 unmodified lines31323334353637383940414243442 unmodified lines47484926505152539 unmodified lines6364654266676869707172737475767717 unmodified lines959697989910010110210310410510610710810 unmodified lines119120121821221231241251 unmodified line127128129901301311321331 unmodified line135136137981381391401411421431441451461471481491 unmodified line1511521531061541551561571 unmodified line1591601611141621631641651 unmodified line1671681691221701711721731 unmodified line1751761771301781791801811 unmodified line1831841851381861871881891 unmodified line1911921931461471481491501511521531541941951961971 unmodified line1992002011622022032042051 unmodified line2072082091701711721731741751761772102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532543 unmodified linesMAX_EMBEDDINGS: 5
MAX_CONDITIONINGS: 10
MAX_REFERENCE_LATENTS: 10
LORA_SOURCE_CHOICES: ["Civitai", "File"]
LORA_SOURCE_CHOICES: ["Civitai", "Hugging Face", "File"]
RESOLUTION_MAP:
krea-2:
"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]
"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]
pixeldit:
"1:1 (Square)": [1024, 1024]
"16:9 (Landscape)": [1344, 768]2 unmodified lines "3:4 (Classic Portrait)": [896, 1152]
"3:2 (Photography)": [1216, 832]
"2:3 (Photography Portrait)": [832, 1216]
ideogram-4:
"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]
lens:
"1:1 (Square)": [1024, 1024]
"16:9 (Landscape)": [1344, 768]2 unmodified lines "3:4 (Classic Portrait)": [896, 1152]
"3:2 (Photography)": [1216, 832]
"2:3 (Photography Portrait)": [832, 1216]
ernie-image:
flux2-kv:
"1:1 (Square)": [1024, 1024]
"16:9 (Landscape)": [1344, 768]
"9:16 (Portrait)": [768, 1344]9 unmodified lines "3:4 (Classic Portrait)": [896, 1152]
"3:2 (Photography)": [1216, 832]
"2:3 (Photography Portrait)": [832, 1216]
flux2-kv:
ernie-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]
z-image:
"1:1 (Square)": [1024, 1024]
"16:9 (Landscape)": [1344, 768]
"9:16 (Portrait)": [768, 1344]17 unmodified lines "3:4 (Classic Portrait)": [896, 1152]
"3:2 (Photography)": [1216, 832]
"2:3 (Photography Portrait)": [832, 1216]
cosmos-predict2:
"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]
anima:
"1:1 (Square)": [1024, 1024]
"16:9 (Landscape)": [1344, 768]10 unmodified lines "3:4 (Classic Portrait)": [896, 1152]
"3:2 (Photography)": [1216, 832]
"2:3 (Photography Portrait)": [832, 1216]
omnigen2:
kandinsky-5:
"1:1 (Square)": [1024, 1024]
"16:9 (Landscape)": [1344, 768]
"9:16 (Portrait)": [768, 1344]1 unmodified line "3:4 (Classic Portrait)": [896, 1152]
"3:2 (Photography)": [1216, 832]
"2:3 (Photography Portrait)": [832, 1216]
lumina:
ovis-image:
"1:1 (Square)": [1024, 1024]
"16:9 (Landscape)": [1344, 768]
"9:16 (Portrait)": [768, 1344]1 unmodified line "3:4 (Classic Portrait)": [896, 1152]
"3:2 (Photography)": [1216, 832]
"2:3 (Photography Portrait)": [832, 1216]
ovis-image:
hunyuanimage:
"1:1 (Square)": [2048, 2048]
"16:9 (Landscape)": [2728, 1536]
"9:16 (Portrait)": [1536, 2728]
"4:3 (Classic)": [2368, 1776]
"3:4 (Classic Portrait)": [1776, 2368]
"3:2 (Photography)": [2504, 1672]
"2:3 (Photography Portrait)": [1672, 2504]
chroma1-radiance:
"1:1 (Square)": [1024, 1024]
"16:9 (Landscape)": [1344, 768]
"9:16 (Portrait)": [768, 1344]1 unmodified line "3:4 (Classic Portrait)": [896, 1152]
"3:2 (Photography)": [1216, 832]
"2:3 (Photography Portrait)": [832, 1216]
flux1:
chroma1:
"1:1 (Square)": [1024, 1024]
"16:9 (Landscape)": [1344, 768]
"9:16 (Portrait)": [768, 1344]1 unmodified line "3:4 (Classic Portrait)": [896, 1152]
"3:2 (Photography)": [1216, 832]
"2:3 (Photography Portrait)": [832, 1216]
hidream-o1:
omnigen2:
"1:1 (Square)": [1024, 1024]
"16:9 (Landscape)": [1344, 768]
"9:16 (Portrait)": [768, 1344]1 unmodified line "3:4 (Classic Portrait)": [896, 1152]
"3:2 (Photography)": [1216, 832]
"2:3 (Photography Portrait)": [832, 1216]
hidream-i1:
lumina:
"1:1 (Square)": [1024, 1024]
"16:9 (Landscape)": [1344, 768]
"9:16 (Portrait)": [768, 1344]1 unmodified line "3:4 (Classic Portrait)": [896, 1152]
"3:2 (Photography)": [1216, 832]
"2:3 (Photography Portrait)": [832, 1216]
sd35:
hidream-o1:
"1:1 (Square)": [1024, 1024]
"16:9 (Landscape)": [1344, 768]
"9:16 (Portrait)": [768, 1344]1 unmodified line "3:4 (Classic Portrait)": [896, 1152]
"3:2 (Photography)": [1216, 832]
"2:3 (Photography Portrait)": [832, 1216]
sdxl:
hidream-i1:
"1:1 (Square)": [1024, 1024]
"16:9 (Landscape)": [1344, 768]
"9:16 (Portrait)": [768, 1344]1 unmodified line "3:4 (Classic Portrait)": [896, 1152]
"3:2 (Photography)": [1216, 832]
"2:3 (Photography Portrait)": [832, 1216]
sd15:
"1:1 (Square)": [512, 512]
"16:9 (Landscape)": [896, 512]
"9:16 (Portrait)": [512, 896]
"4:3 (Classic Landscape)": [683, 512]
"3:4 (Classic Portrait)": [512, 683]
"3:2 (Landscape)": [768, 512]
"2:3 (Portrait)": [512, 768]
chroma1-radiance:
flux1:
"1:1 (Square)": [1024, 1024]
"16:9 (Landscape)": [1344, 768]
"9:16 (Portrait)": [768, 1344]1 unmodified line "3:4 (Classic Portrait)": [896, 1152]
"3:2 (Photography)": [1216, 832]
"2:3 (Photography Portrait)": [832, 1216]
chroma1:
sd35:
"1:1 (Square)": [1024, 1024]
"16:9 (Landscape)": [1344, 768]
"9:16 (Portrait)": [768, 1344]1 unmodified line "3:4 (Classic Portrait)": [896, 1152]
"3:2 (Photography)": [1216, 832]
"2:3 (Photography Portrait)": [832, 1216]
hunyuanimage:
"1:1 (Square)": [2048, 2048]
"16:9 (Landscape)": [2728, 1536]
"9:16 (Portrait)": [1536, 2728]
"4:3 (Classic)": [2368, 1776]
"3:4 (Classic Portrait)": [1776, 2368]
"3:2 (Photography)": [2504, 1672]
"2:3 (Photography Portrait)": [1672, 2504] sdxl:
"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]
sd15:
"1:1 (Square)": [512, 512]
"16:9 (Landscape)": [896, 512]
"9:16 (Portrait)": [512, 896]
"4:3 (Classic Landscape)": [683, 512]
"3:4 (Classic Portrait)": [512, 683]
"3:2 (Landscape)": [768, 512]
"2:3 (Portrait)": [512, 768]
MULTIPLIERS_MAP:
krea-2: 1
boogu-image: 1
pixeldit: 1
ideogram-4: 1
lens: 1
flux2-kv: 1
flux2: 1
ernie-image: 1
z-image: 1
qwen-image: 1
longcat-image: 1
cosmos-predict2: 1
anima: 1
newbie-image: 1
kandinsky-5: 32
ovis-image: 1
hunyuanimage: 1
chroma1-radiance: 64
chroma1: 1
omnigen2: 1
lumina: 1
hidream-o1: 32
hidream-i1: 1
flux1: 1
sd35: 1
sdxl: 1
sd15: 1402 unmodified lines4034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344358 unmodified lines4444454464204474484494234244504514524534274284544554564574314584594604613 unmodified lines46546646746846947047147247347447547647744247847944444548048148248348448548648748848945049049149249349449549645345449749849950050150250350450550650750845750951051151262 unmodified lines57557657752657857958052958158258358458558658753158858953353459059159259359459553954054154259659759811 unmodified lines61061161261361461561616 unmodified lines63363463563663763863986 unmodified lines72672772867467567667767867972973073168168273273373473573622 unmodified lines75976076176276376476576676776876977077177277377477577677777877968 unmodified lines8488498507858518528537888548558568573 unmodified lines861862863864865866867868869870402 unmodified lines repo_id: "comfyanonymous/ControlNet-v1-1_fp16_safetensors"
repository_file_path: "control_v11u_sd15_tile_fp16.safetensors"
diffusion_models:
# Krea-2
- filename: "krea2_turbo_nvfp4.safetensors"
source: "hf"
repo_id: "Comfy-Org/Krea-2"
repository_file_path: "diffusion_models/krea2_turbo_nvfp4.safetensors"
- filename: "krea2_raw_fp8_scaled.safetensors"
source: "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"
repo_id: "Comfy-Org/Boogu-Image"
repository_file_path: "diffusion_models/boogu_image_base_nvfp4.safetensors"
- filename: "boogu_image_turbo_hotfix_nvfp4.safetensors"
source: "hf"
repo_id: "Comfy-Org/Boogu-Image"
repository_file_path: "diffusion_models/boogu_image_turbo_hotfix_nvfp4.safetensors"
# Ideogram-4
- filename: "ideogram4_nvfp4_mixed.safetensors"
source: "hf"
repo_id: "Comfy-Org/Ideogram-4"
repository_file_path: "diffusion_models/ideogram4_nvfp4_mixed.safetensors"
- filename: "ideogram4_unconditional_nvfp4_mixed.safetensors"
source: "hf"
repo_id: "Comfy-Org/Ideogram-4"
repository_file_path: "diffusion_models/ideogram4_unconditional_nvfp4_mixed.safetensors"
# PixelDiT
- filename: "pixeldit_1300m_1024px_mxfp8.safetensors"
source: "hf"8 unmodified lines source: "hf"
repo_id: "Comfy-Org/PixelDiT"
repository_file_path: "diffusion_models/pid_sd3_1024_to_4096_4step_bf16.safetensors"
- filename: "pid_flux1_1024_to_4096_4step_mxfp8.safetensors"
- filename: "pid_1.5_flux1_1024_to_4096_4step_int8_convrot.safetensors"
source: "hf"
repo_id: "Comfy-Org/PixelDiT"
repository_file_path: "diffusion_models/pid_flux1_1024_to_4096_4step_mxfp8.safetensors"
- filename: "pid_qwenimage_1024_to_4096_4step_bf16.safetensors"
repository_file_path: "diffusion_models/pid_1.5_flux1_1024_to_4096_4step_int8_convrot.safetensors"
- filename: "pid_1.5_qwenimage_1024_to_4096_4step_int8_convrot.safetensors"
source: "hf"
repo_id: "Comfy-Org/PixelDiT"
repository_file_path: "diffusion_models/pid_qwenimage_1024_to_4096_4step_bf16.safetensors"
- filename: "pid_flux2_1024_to_4096_4step_mxfp8.safetensors"
repository_file_path: "diffusion_models/pid_1.5_qwenimage_1024_to_4096_4step_int8_convrot.safetensors"
- filename: "pid_1.5_flux2_1024_to_4096_4step_int8_convrot.safetensors"
source: "hf"
repo_id: "Comfy-Org/PixelDiT"
repository_file_path: "diffusion_models/pid_flux2_1024_to_4096_4step_mxfp8.safetensors"
repository_file_path: "diffusion_models/pid_1.5_flux2_1024_to_4096_4step_int8_convrot.safetensors"
# Lens
- filename: "lens_mxfp8.safetensors"
source: "hf"3 unmodified lines source: "hf"
repo_id: "Comfy-Org/Lens"
repository_file_path: "diffusion_models/lens_turbo_mxfp8.safetensors"
# Cosmos-Predict2
- filename: "cosmos_predict2_2B_t2i.pt"
source: "hf"
repo_id: "nvidia/Cosmos-Predict2-2B-Text2Image"
repository_file_path: "model.pt"
- filename: "cosmos_predict2_14B_t2i.pt"
source: "hf"
repo_id: "nvidia/Cosmos-Predict2-14B-Text2Image"
repository_file_path: "model.pt"
# Anima
- filename: "waiANIMA_v10.safetensors"
- filename: "anima-turbo-v1.0.safetensors"
source: "hf"
repo_id: "diffusionmodels1254ani/waiANIMA"
repository_file_path: "waiANIMA_v10.safetensors"
repo_id: "circlestone-labs/Anima"
repository_file_path: "split_files/diffusion_models/anima-turbo-v1.0.safetensors"
- filename: "anima-aesthetic-v1.1.safetensors"
source: "hf"
repo_id: "circlestone-labs/Anima"
repository_file_path: "split_files/diffusion_models/anima-aesthetic-v1.1.safetensors"
- filename: "anima-base-v1.0.safetensors"
source: "hf"
repo_id: "circlestone-labs/Anima"
repository_file_path: "split_files/diffusion_models/anima-base-v1.0.safetensors"
- filename: "AnimaYume_tuned_v05.safetensors"
- filename: "waiANIMA_v10Base10.safetensors"
source: "hf"
repo_id: "diffusionmodels1254ani/waiANIMA"
repository_file_path: "waiANIMA_v10Base10.safetensors"
- filename: "AnimaYume_v10_final_base.safetensors"
source: "hf"
repo_id: "duongve/AnimaYume"
repository_file_path: "split_files/diffusion_models/AnimaYume_tuned_v05.safetensors"
- filename: "anima_pencil-v1.0.0.safetensors"
repository_file_path: "split_files/diffusion_models/AnimaYume_v10_final_base.safetensors"
- filename: "hassakuAnima_v1Style.safetensors"
source: "hf"
repo_id: "diffusionmodels1254ani/hassakuAnima"
repository_file_path: "hassakuAnima_v1Style.safetensors"
- filename: "kirazuriAnima_v30AnimaBase1.safetensors"
source: "hf"
repo_id: "diffusionmodels1254ani/kirazuriAnima_v30AnimaBase1"
repository_file_path: "kirazuriAnima_v30AnimaBase1.safetensors"
- filename: "anima_pencil-v2.1.0.safetensors"
source: "hf"
repo_id: "bluepen5805/anima-models"
repository_file_path: "anima_pencil-v1.0.0.safetensors"
repository_file_path: "anima_pencil-v2.1.0.safetensors"
# NewBie-Image
- filename: "NewBie-Image-Exp0.1-bf16.safetensors"
source: "hf"62 unmodified lines source: "hf"
repo_id: "Comfy-Org/Qwen-Image_ComfyUI"
repository_file_path: "split_files/diffusion_models/qwen_image_2512_fp8_e4m3fn.safetensors"
- filename: "qwen_image_fp8_e4m3fn.safetensors"
- filename: "qwen_image_nvfp4.safetensors"
source: "hf"
repo_id: "Comfy-Org/Qwen-Image_ComfyUI"
repository_file_path: "split_files/diffusion_models/qwen_image_fp8_e4m3fn.safetensors"
repository_file_path: "split_files/diffusion_models/qwen_image_nvfp4.safetensors"
# Kandinsky-5
- filename: "kandinsky5lite_t2i.safetensors"
source: "hf"
repo_id: "kandinskylab/Kandinsky-5.0-T2I-Lite"
repository_file_path: "model/kandinsky5lite_t2i.safetensors"
# Flux.1
- filename: "flux1-dev-fp8-e4m3fn.safetensors"
- filename: "flux1-dev-nvfp4.safetensors"
source: "hf"
repo_id: "Kijai/flux-fp8"
repository_file_path: "flux1-dev-fp8-e4m3fn.safetensors"
repo_id: "black-forest-labs/FLUX.1-dev-NVFP4"
repository_file_path: "flux1-dev-nvfp4.safetensors"
- filename: "flux1-schnell-fp8-e4m3fn.safetensors"
source: "hf"
repo_id: "Kijai/flux-fp8"
repository_file_path: "flux1-schnell-fp8-e4m3fn.safetensors"
- filename: "flux1-dev-kontext_fp8_scaled.safetensors"
source: "hf"
repo_id: "Comfy-Org/flux1-kontext-dev_ComfyUI"
repository_file_path: "split_files/diffusion_models/flux1-dev-kontext_fp8_scaled.safetensors"
- filename: "flux1-krea-dev_fp8_scaled.safetensors"
source: "hf"
repo_id: "Comfy-Org/FLUX.1-Krea-dev_ComfyUI"11 unmodified lines source: "hf"
repo_id: "Comfy-Org/HiDream-I1_ComfyUI"
repository_file_path: "split_files/diffusion_models/hidream_i1_full_fp8.safetensors"
# HunyuanImage-2.1
- filename: "hunyuanimage2.1_fp8_e4m3fn.safetensors"
source: "hf"
repo_id: "Comfy-Org/HunyuanImage_2.1_ComfyUI"16 unmodified lines source: "hf"
repo_id: "Clybius/Chroma-fp8-scaled"
repository_file_path: "Chroma1-HD/Chroma1-HD_float8_e4m3fn_scaled_learned_topk8_svd.safetensors"
# Omnigen2
- filename: "omnigen2_fp16.safetensors"
source: "hf"
repo_id: "Comfy-Org/Omnigen2_ComfyUI_repackaged"86 unmodified lines repo_id: "black-forest-labs/FLUX.1-Redux-dev"
repository_file_path: "flux1-redux-dev.safetensors"
loras:
# Qwen-Image
- filename: "Qwen-Image-2512-Lightning-4steps-V1.0-bf16.safetensors"
source: "hf"
repo_id: "lightx2v/Qwen-Image-2512-Lightning"
repository_file_path: "Qwen-Image-2512-Lightning-4steps-V1.0-bf16.safetensors"
- filename: "Qwen-Image-fp8-e4m3fn-Lightning-4steps-V1.0-bf16.safetensors"
# Krea2 ControlNet
- filename: "depth-control-lora.safetensors"
source: "hf"
repo_id: "lightx2v/Qwen-Image-Lightning"
repository_file_path: "Qwen-Image-fp8-e4m3fn-Lightning-4steps-V1.0-bf16.safetensors"
repo_id: "Patil/Krea-2-depth-controlnet"
repository_file_path: "depth-control-lora.safetensors"
# SD1.5 FaceID
- filename: "ip-adapter-faceid_sd15_lora.safetensors"
source: "hf"22 unmodified lines repo_id: "alibaba-pai/Z-Image-Turbo-Fun-Controlnet-Union-2.1"
repository_file_path: "Z-Image-Turbo-Fun-Controlnet-Tile-2.1-8steps.safetensors"
text_encoders:
# Krea-2
- filename: "qwen3vl_4b_fp8_scaled.safetensors"
source: "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"
repo_id: "comfyanonymous/cosmos_1.0_text_encoder_and_VAE_ComfyUI"
repository_file_path: "text_encoders/oldt5_xxl_fp8_e4m3fn_scaled.safetensors"
# Ideogram-4 & Boogu-Image
- filename: "qwen3vl_8b_nvfp4.safetensors"
source: "hf"
repo_id: "Comfy-Org/Ideogram-4"
repository_file_path: "text_encoders/qwen3vl_8b_nvfp4.safetensors"
# PixelDiT
- filename: "gemma_2_2b_it_elm_fp8_scaled.safetensors"
source: "hf"68 unmodified lines source: "hf"
repo_id: "Comfy-Org/HiDream-I1_ComfyUI"
repository_file_path: "split_files/text_encoders/llama_3.1_8b_instruct_fp8_scaled.safetensors"
- filename: "qwen_2.5_vl_7b_fp8_scaled.safetensors"
- filename: "qwen_2.5_vl_7b_nvfp4.safetensors"
source: "hf"
repo_id: "Comfy-Org/Qwen-Image_ComfyUI"
repository_file_path: "split_files/text_encoders/qwen_2.5_vl_7b_fp8_scaled.safetensors"
repository_file_path: "split_files/text_encoders/qwen_2.5_vl_7b_nvfp4.safetensors"
- filename: "byt5_small_glyphxl_fp16.safetensors"
source: "hf"
repo_id: "Comfy-Org/HunyuanImage_2.1_ComfyUI"3 unmodified lines repo_id: "Comfy-Org/Omnigen2_ComfyUI_repackaged"
repository_file_path: "split_files/text_encoders/qwen_2.5_vl_fp16.safetensors"
vae:
- filename: "wan_2.1_vae.safetensors"
source: "hf"
repo_id: "Comfy-Org/Wan_2.1_ComfyUI_repackaged"
repository_file_path: "split_files/vae/wan_2.1_vae.safetensors"
- filename: "qwen_image_vae.safetensors"
source: "hf"
repo_id: "Comfy-Org/Qwen-Image_ComfyUI"7 unmodified lines8910111112131415161718192021222315242526272829303132203334353624373839402741424344314546474849505152533654553839564157585960611 unmodified line63646550666768695370717273577475767760617863647966808182838485868788697071899091927593949596787997989983100101102103851048710510690107108109921109411111297113114115116117118119120121122123124991001011251031261271281291301311321331111341351361371141381391401411421431441451461471481491501511521531281541551561571581591601611621631641331651661671681691701711721731741391751761771781791801811821431831841851861871881891901911927 unmodified lines - conditioning
- vae
pixeldit:
krea-2:
enabled_chains:
- lora
- krea2_controlnet
- conditioning
- pid
boogu-image:
enabled_chains:
- lora
- conditioning
- pid
lens:
pixeldit:
enabled_chains:
- conditioning
ideogram-4:
enabled_chains:
- vae
- pid
ernie-image:
lens:
enabled_chains:
- conditioning
- pid
anima:
flux2-kv:
enabled_chains:
- lora
- anima_controlnet_lllite
- conditioning
- reference_latent
- vae
- pid
longcat-image:
flux2:
enabled_chains:
- lora
- conditioning
- reference_latent
- vae
- pid
newbie-image:
ernie-image:
enabled_chains:
- lora
- embedding
- conditioning
- vae
- pid
z-image:
enabled_chains:
- lora1 unmodified line - controlnet_model_patch
- vae
- pid
lumina:
qwen-image:
enabled_chains:
- lora
- embedding
- controlnet
- conditioning
- vae
- pid
sd35:
longcat-image:
enabled_chains:
- lora
- controlnet
- embedding
- conditioning
- sd3_ipadapter
- vae
- pid
sdxl:
cosmos-predict2:
enabled_chains:
- conditioning
- vae
anima:
enabled_chains:
- lora
- controlnet
- ipadapter
- embedding
- anima_controlnet_lllite
- conditioning
- vae
- pid
sd15:
newbie-image:
enabled_chains:
- lora
- controlnet
- ipadapter
- embedding
- conditioning
- vae
flux2:
- pid
kandinsky-5:
enabled_chains:
- lora
- conditioning
- reference_latent
- vae
- pid
flux2-kv:
ovis-image:
enabled_chains:
- lora
- conditioning
- reference_latent
- vae
- pid
flux1:
hunyuanimage:
enabled_chains:
- conditioning
- vae
chroma1-radiance:
enabled_chains:
- conditioning
chroma1:
enabled_chains:
- lora
- controlnet
- style
- conditioning
- flux1_ipadapter
- vae
- pid
omnigen2:
enabled_chains:
- conditioning
- reference_latent
- pid
qwen-image:
lumina:
enabled_chains:
- lora
- controlnet
- embedding
- conditioning
- vae
- pid
hidream-o1:
enabled_chains:
- lora
- conditioning
- hidream_o1_reference
hidream-i1:
enabled_chains:
- lora
- conditioning
- pid
hunyuanimage:
flux1:
enabled_chains:
- lora
- controlnet
- style
- conditioning
- flux1_ipadapter
- vae
- pid
ovis-image:
sd35:
enabled_chains:
- lora
- controlnet
- embedding
- conditioning
- sd3_ipadapter
- vae
- pid
chroma1:
sdxl:
enabled_chains:
- lora
- controlnet
- ipadapter
- embedding
- conditioning
- vae
- pid - pid
sd15:
enabled_chains:
- lora
- controlnet
- ipadapter
- embedding
- conditioning
- vae1234Krea2_ControlNet:
- Filepath: "depth-control-lora.safetensors"
Series: "Patil"
Type: ["Depth"]123456781 unmodified line101112131415161718198 unmodified lines2829303132333435362837383940314142344344459 unmodified lines5556575859606162639 unmodified lines737475767778798081architecture_order:
- "Krea-2"
- "Boogu-Image"
- "PixelDiT"
- "Ideogram-4"
- "Lens"
- "FLUX.2-KV"
- "FLUX.2"1 unmodified line - "Z-Image"
- "Qwen-Image"
- "LongCat-Image"
- "Cosmos-Predict2"
- "Anima"
- "NewBie-Image"
- "Kandinsky-5"
- "Ovis-Image"
- "HunyuanImage"
- "Chroma1-Radiance"8 unmodified lines - "SD1.5"
architectures:
Krea-2:
model_type: "krea-2"
"Boogu-Image":
model_type: "boogu-image"
"PixelDiT":
model_type: "pixeldit"
controlnet_key: "PixelDiT"
"Ideogram-4":
model_type: "ideogram-4"
"Lens":
model_type: "lens"
controlnet_key: "Lens"
"ERNIE-Image":
model_type: "ernie-image"
controlnet_key: "ERNIE-Image"
"FLUX.2-KV":
model_type: "flux2-kv"
controlnet_key: "FLUX.2"9 unmodified lines "LongCat-Image":
model_type: "longcat-image"
controlnet_key: "LongCat-Image"
"Cosmos-Predict2":
model_type: "cosmos-predict2"
controlnet_key: "Cosmos-Predict2"
"Anima":
model_type: "anima"
controlnet_key: "Anima"9 unmodified lines "Lumina":
model_type: "lumina"
controlnet_key: "Lumina"
"Kandinsky-5":
model_type: "kandinsky-5"
controlnet_key: "Kandinsky-5"
"Ovis-Image":
model_type: "ovis-image"
controlnet_key: "Ovis-Image"1232345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505 unmodified lines5657582659602829303132336162636411 unmodified lines76777851798081828384575885868788895 unmodified lines9596977071989910075761011021031041055 unmodified lines1111121131141151161171181191201211221232 unmodified lines1261271281291301311321331344 unmodified lines1391401411061421431081091441451461471481131491501511521531541191201551221561571241251581591601611281291621631641321651661673 unmodified lines17117217314217417514417617717814717918018118218318418514918618715115218818919019119219319415815916016116216316416519519619716816917017117217317419819920020120220320420525 unmodified lines231232233207234235236210237238239213214215240241242243244245246247248249250251252253254255256257258259260261262263264265266267Default:
steps: 20
cfg: 5.0
steps: 8
cfg: 1.0
sampler_name: "euler"
scheduler: "simple"
positive_prompt: ""
negative_prompt: ""
Krea-2:
_defaults:
steps: 52
cfg: 3.5
sampler_name: "euler"
scheduler: "simple"
"Krea-2-Turbo":
steps: 8
cfg: 1.0
sampler_name: "euler"
scheduler: "simple"
Boogu-Image:
_defaults:
steps: 25
cfg: 3.5
sampler_name: "dpmpp_2m"
scheduler: "simple"
"Boogu-Image-Turbo":
steps: 4
cfg: 1.0
sampler_name: "lcm"
scheduler: "sgm_uniform"
PixelDiT:
_defaults:
steps: 30
cfg: 4.0
sampler_name: "er_sde"
scheduler: "simple"
negative_prompt: "low quality, worst quality, over-saturated, blurry, deformed, watermark"
Ideogram-4:
_defaults:
steps: 20
cfg: 7.0
sampler_name: "res_multistep"
scheduler: "simple"
positive_prompt: "NOTE: If you see \"Image blocked by safety filter\" it is because of safety training in the model itself, ImageGen does not have any safety filter."
Lens:
_defaults:5 unmodified lines steps: 4
cfg: 1.0
ERNIE-Image:
FLUX.2-KV:
_defaults:
steps: 20
cfg: 4.0
sampler_name: "euler"
scheduler: "simple"
"baidu/ERNIE-Image-Turbo":
steps: 8
steps: 4
cfg: 1.0
sampler_name: "euler"
scheduler: "simple"11 unmodified lines steps: 4
cfg: 1.0
FLUX.2-KV:
ERNIE-Image:
_defaults:
steps: 20
cfg: 4.0
sampler_name: "euler"
scheduler: "simple"
"black-forest-labs/FLUX.2-klein-9B-KV":
steps: 4
"baidu/ERNIE-Image-Turbo":
steps: 8
cfg: 1.0
Z-Image:5 unmodified lines "Tongyi-MAI/Z Image Turbo":
steps: 9
cfg: 1.0
sampler_name: "euler"
scheduler: "simple"
Qwen-Image:
_defaults:
steps: 4
cfg: 1.0
steps: 20
cfg: 4.0
sampler_name: "euler"
scheduler: "simple"
5 unmodified lines sampler_name: "euler"
scheduler: "simple"
Cosmos-Predict2:
_defaults:
steps: 35
cfg: 4.0
sampler_name: "euler"
scheduler: "karras"
Anima:
_defaults:
steps: 302 unmodified lines scheduler: "simple"
positive_prompt: "masterpiece, best quality, score_7, safe. "
negative_prompt: "worst quality, low quality, score_1, score_2, score_3, blurry, jpeg artifacts, sepia"
"circlestone-labs/Anima-Turbo-v1.0":
steps: 10
cfg: 1.0
NewBie-Image:
_defaults:4 unmodified lines positive_prompt: "You are an assistant designed to generate high-quality anime images with the highest degree of image-text alignment based on xml format textual prompts. <Prompt Start>"
negative_prompt: "You are an assistant designed to generate low-quality images based on textual prompts. <Prompt Start>"
Ovis-Image:
Kandinsky-5:
_defaults:
steps: 20
cfg: 5.0
steps: 50
cfg: 3.5
sampler_name: "euler"
scheduler: "simple"
OmniGen2:
Ovis-Image:
_defaults:
steps: 20
cfg: 5.0
sampler_name: "euler"
scheduler: "simple"
positive_prompt: ""
negative_prompt: ""
Chroma1:
HunyuanImage:
_defaults:
steps: 30
cfg: 4.0
steps: 20
cfg: 3.5
sampler_name: "euler"
scheduler: "simple"
negative_prompt: "low quality, bad anatomy, extra digits, missing digits, extra limbs, missing limbs"
"lodestones/Chroma1-HD-Flash":
"HunyuanImage-2.1-Distilled":
steps: 8
cfg: 1.0
scheduler: "beta"
Chroma1-Radiance:
_defaults:3 unmodified lines scheduler: "simple"
negative_prompt: "low quality, bad anatomy, extra digits, missing digits, extra limbs, missing limbs, hands, fingers"
SD3.5:
Chroma1:
_defaults:
steps: 20
steps: 30
cfg: 4.0
sampler_name: "euler"
scheduler: "sgm_uniform"
scheduler: "simple"
negative_prompt: "low quality, bad anatomy, extra digits, missing digits, extra limbs, missing limbs"
"lodestones/Chroma1-HD-Flash":
steps: 8
cfg: 1.0
scheduler: "beta"
SDXL:
OmniGen2:
_defaults:
steps: 25
cfg: 7.0
steps: 20
cfg: 5.0
sampler_name: "euler"
scheduler: "simple"
positive_prompt: ""
negative_prompt: ""
SD1.5:
_defaults:
steps: 47
cfg: 7.0
sampler_name: "euler_ancestral"
scheduler: "simple"
FLUX.1:
Lumina:
_defaults:
steps: 20
cfg: 1.0
sampler_name: "euler"
scheduler: "simple"
"flux1-schnell":
steps: 4
cfg: 1.0
sampler_name: "euler"
cfg: 4.0
sampler_name: "res_multistep"
scheduler: "simple"
positive_prompt: ""
negative_prompt: ""
HiDream-O1:
_defaults:25 unmodified lines sampler_name: "lcm"
scheduler: "normal"
HunyuanImage:
FLUX.1:
_defaults:
steps: 20
cfg: 3.5
cfg: 1.0
sampler_name: "euler"
scheduler: "simple"
"HunyuanImage-2.1-Distilled":
steps: 8
cfg: 1.0 "flux1-schnell":
steps: 4
cfg: 1.0
sampler_name: "euler"
scheduler: "simple"
SD3.5:
_defaults:
steps: 20
cfg: 4.0
sampler_name: "euler"
scheduler: "sgm_uniform"
SDXL:
_defaults:
steps: 25
cfg: 7.0
sampler_name: "euler"
scheduler: "simple"
positive_prompt: ""
negative_prompt: ""
SD1.5:
_defaults:
steps: 47
cfg: 7.0
sampler_name: "euler_ancestral"
scheduler: "simple"1234567891011121314151617181920212223242526272829302 unmodified lines33343536373839404142434445464772 unmodified lines120121122881231241251269293941271281299613013198991321331341351 unmodified line1371381391071401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731131741751761161771781181791801811211821831231841851861261871881281891901911921931941951961975 unmodified lines2032042052062072082092102112122132142152162179 unmodified lines22722822915523023123223323423516123623723823968 unmodified lines308309310236311312313314Checkpoint:
Krea-2:
latent_type: latent
models:
- display_name: "Krea-2-Turbo"
components:
unet: "krea2_turbo_nvfp4.safetensors"
clip: "qwen3vl_4b_fp8_scaled.safetensors"
vae: "qwen_image_vae.safetensors"
- display_name: "Krea-2-Raw"
components:
unet: "krea2_raw_fp8_scaled.safetensors"
clip: "qwen3vl_4b_fp8_scaled.safetensors"
vae: "qwen_image_vae.safetensors"
Boogu-Image:
latent_type: latent
models:
- display_name: "Boogu-Image-Turbo"
components:
unet: "boogu_image_turbo_hotfix_nvfp4.safetensors"
clip: "qwen3vl_8b_nvfp4.safetensors"
vae: "ae.safetensors"
- display_name: "Boogu-Image-Base"
components:
unet: "boogu_image_base_nvfp4.safetensors"
clip: "qwen3vl_8b_nvfp4.safetensors"
vae: "ae.safetensors"
PixelDiT:
latent_type: chroma_radiance_latent
models:2 unmodified lines unet: "pixeldit_1300m_1024px_mxfp8.safetensors"
clip: "gemma_2_2b_it_elm_fp8_scaled.safetensors"
vae: "pixel_space"
Ideogram-4:
latent_type: flux2_latent
models:
- display_name: "ideogram-ai/ideogram-4"
components:
unet: "ideogram4_nvfp4_mixed.safetensors"
unet_uncond: "ideogram4_unconditional_nvfp4_mixed.safetensors"
clip: "qwen3vl_8b_nvfp4.safetensors"
vae: "flux2-vae.safetensors"
Lens:
latent_type: flux2_latent
models:72 unmodified lines Qwen-Image:
latent_type: sd3_latent
models:
- display_name: "Qwen/Qwen-Image-2512 + Lightning-4steps-V1.0 LoRA"
- display_name: "Qwen-Image-2512"
components:
unet: "qwen_image_2512_fp8_e4m3fn.safetensors"
vae: "qwen_image_vae.safetensors"
clip: "qwen_2.5_vl_7b_fp8_scaled.safetensors"
lora: "Qwen-Image-2512-Lightning-4steps-V1.0-bf16.safetensors"
- display_name: "Qwen/Qwen-Image + Lightning-4steps-V1.0 LoRA"
clip: "qwen_2.5_vl_7b_nvfp4.safetensors"
- display_name: "Qwen-Image"
components:
unet: "qwen_image_fp8_e4m3fn.safetensors"
unet: "qwen_image_nvfp4.safetensors"
vae: "qwen_image_vae.safetensors"
clip: "qwen_2.5_vl_7b_fp8_scaled.safetensors"
lora: "Qwen-Image-fp8-e4m3fn-Lightning-4steps-V1.0-bf16.safetensors"
clip: "qwen_2.5_vl_7b_nvfp4.safetensors"
LongCat-Image:
latent_type: sd3_latent
models:1 unmodified line components:
unet: "longcat_image_bf16.safetensors"
vae: "ae.safetensors"
clip: "qwen_2.5_vl_7b_fp8_scaled.safetensors"
clip: "qwen_2.5_vl_7b_nvfp4.safetensors"
Cosmos-Predict2:
latent_type: sd3_latent
models:
- display_name: "Cosmos-Predict2-2B-T2I"
components:
unet: "cosmos_predict2_2B_t2i.pt"
clip: "oldt5_xxl_fp8_e4m3fn_scaled.safetensors"
vae: "wan_2.1_vae.safetensors"
- display_name: "Cosmos-Predict2-14B-T2I"
components:
unet: "cosmos_predict2_14B_t2i.pt"
clip: "oldt5_xxl_fp8_e4m3fn_scaled.safetensors"
vae: "wan_2.1_vae.safetensors"
Anima:
latent_type: latent
models:
- display_name: "circlestone-labs/Anima-Turbo-v1.0"
components:
unet: "anima-turbo-v1.0.safetensors"
vae: "qwen_image_vae.safetensors"
clip: "qwen_3_06b_base.safetensors"
- display_name: "circlestone-labs/Anima-Aesthetic-v1.1"
components:
unet: "anima-aesthetic-v1.1.safetensors"
vae: "qwen_image_vae.safetensors"
clip: "qwen_3_06b_base.safetensors"
- display_name: "circlestone-labs/Anima-Base-v1.0"
components:
unet: "anima-base-v1.0.safetensors"
vae: "qwen_image_vae.safetensors"
clip: "qwen_3_06b_base.safetensors"
- display_name: "WAI0731/waiANIMA-v1.0"
components:
unet: "waiANIMA_v10.safetensors"
unet: "waiANIMA_v10Base10.safetensors"
vae: "qwen_image_vae.safetensors"
clip: "qwen_3_06b_base.safetensors"
- display_name: "duongve/AnimaYume-v0.5"
- display_name: "duongve/AnimaYume-v1.0"
components:
unet: "AnimaYume_tuned_v05.safetensors"
unet: "AnimaYume_v10_final_base.safetensors"
vae: "qwen_image_vae.safetensors"
clip: "qwen_3_06b_base.safetensors"
- display_name: "bluepen5805/Anima-pencil-v1.0"
- display_name: "bluepen5805/Anima-pencil-v2.1"
components:
unet: "anima_pencil-v1.0.0.safetensors"
unet: "anima_pencil-v2.1.0.safetensors"
vae: "qwen_image_vae.safetensors"
clip: "qwen_3_06b_base.safetensors"
- display_name: "circlestone-labs/Anima-base-v1.0"
- display_name: "Ikena/Hassaku-Anima-v1-Style"
components:
unet: "anima-base-v1.0.safetensors"
unet: "hassakuAnima_v1Style.safetensors"
vae: "qwen_image_vae.safetensors"
clip: "qwen_3_06b_base.safetensors"
- display_name: "motimalu/Kirazuri (Anima)-v3.0"
components:
unet: "hassakuAnima_v1Style.safetensors"
vae: "qwen_image_vae.safetensors"
clip: "qwen_3_06b_base.safetensors"
NewBie-Image:5 unmodified lines vae: "ae.safetensors"
clip1: "gemma_3_4b_it_bf16.safetensors"
clip2: "jina_clip_v2_bf16.safetensors"
Kandinsky-5:
latent_type: latent
models:
- display_name: "Kandinsky-5.0-T2I-Lite"
components:
unet: "kandinsky5lite_t2i.safetensors"
vae: "ae.safetensors"
clip1: "qwen_2.5_vl_7b_nvfp4.safetensors"
clip2: "clip_l.safetensors"
Ovis-Image:
latent_type: sd3_latent
models:9 unmodified lines components:
unet: "hunyuanimage2.1_fp8_e4m3fn.safetensors"
vae: "hunyuan_image_2.1_vae_fp16.safetensors"
clip1: "qwen_2.5_vl_7b_fp8_scaled.safetensors"
clip1: "qwen_2.5_vl_7b_nvfp4.safetensors"
clip2: "byt5_small_glyphxl_fp16.safetensors"
- display_name: "HunyuanImage-2.1-Distilled"
components:
unet: "hunyuanimage2.1_distilled_fp8_e4m3fn.safetensors"
vae: "hunyuan_image_2.1_vae_fp16.safetensors"
clip1: "qwen_2.5_vl_7b_fp8_scaled.safetensors"
clip1: "qwen_2.5_vl_7b_nvfp4.safetensors"
clip2: "byt5_small_glyphxl_fp16.safetensors"
Chroma1-Radiance:
latent_type: chroma_radiance_latent68 unmodified lines models:
- display_name: "flux1-dev"
components:
unet: "flux1-dev-fp8-e4m3fn.safetensors"
unet: "flux1-dev-nvfp4.safetensors"
vae: "ae.safetensors"
clip1: "clip_l.safetensors"
clip2: "t5xxl_fp8_e4m3fn_scaled.safetensors".gitattributes+4-35
chain_injectors/krea2_controlnet_injector.pyAdded+78
comfy_integration/setup.py+14
core/pipelines/pipeline_input_processor.py+383-334
core/pipelines/sd_image_pipeline.py+258-253
core/pipelines/workflow_recipes/_partials/conditioning/krea-2.yamlAdded+63
core/pipelines/workflow_recipes/_partials/conditioning/qwen-image.yaml+2-11
core/settings.py+2
core/workflow_assembler.py-1
requirements.txt+8-7
ui/events/__init__.py+2
ui/events/chain_handlers.py+95-1
ui/events/change_handlers.py+32-2
ui/events/config_loaders.py+38-1
ui/events/main.py+24-4
ui/events/run_handlers.py+104-102
ui/shared/hires_fix_ui.py+26-8
ui/shared/img2img_ui.py+25-8
ui/shared/inpaint_ui.py+25-8
ui/shared/outpaint_ui.py+25-8
ui/shared/txt2img_ui.py+2-1
ui/shared/ui_components.py+71-14
utils/app_utils.py+129-35
yaml/constants.yaml+106-29
yaml/file_list.yaml+102-32
yaml/image_gen_features.yaml+90-41
yaml/krea2_controlnet_models.yamlAdded+4
yaml/model_architectures.yaml+17-3
yaml/model_defaults.yaml+106-54
yaml/model_list.yaml+93-18