Add FLUX.1, FLUX.2-KV, SD3.5 & additional base model architecture recipes
Browse filesFiles changed (42)
- app.py+14-137
- comfy_integration/nodes.py+5
- comfy_integration/setup.py+36-13
- core/generation_logic.py-15
- core/model_manager.py+6-19
- core/pipelines/controlnet_preprocessor.pyDeleted-143
- core/pipelines/sd_image_pipeline.py+224-59
- core/pipelines/workflow_recipes/_partials/_base_sampler.yaml → core/pipelines/workflow_recipes/_partials/_base_sampler_sd.yamlRenamed+15-2
- core/pipelines/workflow_recipes/_partials/conditioning/flux1.yamlAdded+64
- core/pipelines/workflow_recipes/_partials/conditioning/flux2-kv.yamlAdded+104
- core/pipelines/workflow_recipes/_partials/conditioning/flux2.yaml+33-6
- core/pipelines/workflow_recipes/_partials/conditioning/sd35.yamlAdded+58
- core/pipelines/workflow_recipes/_partials/input/hires_fix.yaml+4-3
- core/pipelines/workflow_recipes/_partials/input/img2img.yaml+3-2
- core/pipelines/workflow_recipes/_partials/input/inpaint.yaml+6-8
- core/pipelines/workflow_recipes/_partials/input/outpaint.yaml+14-11
- core/pipelines/workflow_recipes/_partials/input/txt2img.yaml+2-8
- core/pipelines/workflow_recipes/_partials/input/txt2img_chroma_radiance_latent.yamlAdded+11
- core/pipelines/workflow_recipes/_partials/input/txt2img_flux2_latent.yamlAdded+11
- core/pipelines/workflow_recipes/_partials/input/txt2img_hunyuan_latent.yamlAdded+11
- core/pipelines/workflow_recipes/_partials/input/txt2img_latent.yamlAdded+11
- core/pipelines/workflow_recipes/_partials/input/txt2img_sd3_latent.yamlAdded+11
- core/pipelines/workflow_recipes/sd_unified_recipe.yaml+2-2
- core/settings.py+111-31
- requirements.txt+10-9
- ui/events.py+1044-286
- ui/layout.py+16-62
- ui/shared/hires_fix_ui.py+27-17
- ui/shared/img2img_ui.py+27-18
- ui/shared/inpaint_ui.py+38-20
- ui/shared/outpaint_ui.py+35-22
- ui/shared/txt2img_ui.py+26-11
- ui/shared/ui_components.py+368-57
- utils/app_utils.py+203-99
- yaml/constants.yaml+138-1
- yaml/file_list.yaml+626-6
- yaml/image_gen_features.yamlAdded+117
- yaml/injectors.yaml+26-2
- yaml/model_architectures.yaml+65-1
- yaml/model_defaults.yaml+206-22
- yaml/model_list.yaml+5-16
- yaml/private_file_list.yamlDeleted-12
123445637 unmodified lines4445464849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613747484950515253541451461475556571 unmodified line5960616263155646566671 unmodified line6970711631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941957273747576777879808119982838485201202203204205206207208868788import spaces
import os
import sys
import requests
import site
APP_DIR = os.path.dirname(os.path.abspath(__file__))37 unmodified lines print("--- [GPU Startup] Startup check passed. ---")
return "Startup check passed."
def handle_private_downloads():
"""
Checks for a private_file_list.yaml, downloads required models using HF_TOKEN,
and then clears the token from the environment.
"""
import yaml
from huggingface_hub import hf_hub_download
from core.settings import (
DIFFUSION_MODELS_DIR, TEXT_ENCODERS_DIR, VAE_DIR, CHECKPOINT_DIR,
LORA_DIR, CONTROLNET_DIR, MODEL_PATCHES_DIR, EMBEDDING_DIR
)
print("--- [Startup] Checking for private models to download... ---")
private_list_path = os.path.join(APP_DIR, 'yaml', 'private_file_list.yaml')
if not os.path.exists(private_list_path):
print("--- [Startup] No private model list found. Skipping. ---")
if 'HF_TOKEN' in os.environ:
del os.environ['HF_TOKEN']
print("--- [Startup] Cleared HF_TOKEN environment variable as it is no longer needed. ---")
print(f"--- [Startup] Verifying HF_TOKEN after clearing: {os.environ.get('HF_TOKEN')}")
return
try:
with open(private_list_path, 'r', encoding='utf-8') as f:
private_files_config = yaml.safe_load(f)
if not private_files_config or 'file' not in private_files_config:
print("--- [Startup] Private model list is empty or malformed. Skipping. ---")
return
category_to_dir_map = {
"diffusion_models": DIFFUSION_MODELS_DIR,
"text_encoders": TEXT_ENCODERS_DIR,
"vae": VAE_DIR,
"checkpoints": CHECKPOINT_DIR,
"loras": LORA_DIR,
"controlnet": CONTROLNET_DIR,
"model_patches": MODEL_PATCHES_DIR,
"embeddings": EMBEDDING_DIR,
}
files_to_download = []
for category, files in private_files_config.get('file', {}).items():
dest_dir = category_to_dir_map.get(category)
if not dest_dir:
print(f"--- [Startup] ⚠️ Unknown category '{category}' in private_file_list.yaml. Skipping. ---")
continue
if isinstance(files, list):
for file_info in files:
files_to_download.append((file_info, dest_dir))
if not files_to_download:
print("--- [Startup] No private models configured for download. ---")
return
print(f"--- [Startup] Found {len(files_to_download)} private model(s) to download. Using HF_TOKEN if available. ---")
for file_info, dest_dir in files_to_download:
filename = file_info.get("filename")
repo_id = file_info.get("repo_id")
repo_path = file_info.get("repository_file_path", filename)
if not all([filename, repo_id]):
print(f"--- [Startup] ⚠️ Skipping malformed entry in private_file_list.yaml: {file_info} ---")
continue
dest_path = os.path.join(dest_dir, filename)
if os.path.lexists(dest_path):
print(f"--- [Startup] ✅ Model '{filename}' already exists. Skipping download. ---")
continue
print(f"--- [Startup] ⏳ Downloading '{filename}' from repo '{repo_id}'... ---")
try:
cached_path = hf_hub_download(repo_id=repo_id, filename=repo_path)
os.makedirs(dest_dir, exist_ok=True)
os.symlink(cached_path, dest_path)
print(f"--- [Startup] ✅ Successfully downloaded and linked '{filename}'. ---")
except Exception as e:
print(f"--- [Startup] ❌ ERROR: Failed to download '{filename}': {e}")
print("--- [Startup] ❌ Please ensure your HF_TOKEN is set correctly and has access to the repository. ---")
finally:
if 'HF_TOKEN' in os.environ:
del os.environ['HF_TOKEN']
print("--- [Startup] ✅ Cleared HF_TOKEN environment variable. ---")
print(f"--- [Startup] Verifying HF_TOKEN after clearing: {os.environ.get('HF_TOKEN')}")
else:
print("--- [Startup] Note: HF_TOKEN environment variable was not set. Private downloads may fail without it. ---")
def main():
from utils.app_utils import print_welcome_message
from scripts import build_sage_attention
from comfy_integration import setup as setup_comfyui
print_welcome_message()
# Handle downloads that require authentication first.
handle_private_downloads()
print("--- [Setup] Attempting to build and install SageAttention... ---")
try:
build_sage_attention.install_sage_attention()1 unmodified line except Exception as e:
print(f"--- [Setup] ❌ SageAttention installation failed: {e}. Continuing with default attention. ---")
print("--- [Setup] Starting ComfyUI initialization ---")
setup_comfyui.initialize_comfyui()
print("--- [Setup] Reloading site-packages to detect newly installed packages... ---")
try:
site.main()1 unmodified line except Exception as e:
print(f"--- [Setup] ⚠️ Warning: Could not fully reload site-packages: {e} ---")
from comfy_integration import setup as setup_comfyui
from utils.app_utils import (
build_preprocessor_model_map,
build_preprocessor_parameter_map
)
from core import shared_state
from core.settings import ALL_MODEL_MAP, ALL_FILE_DOWNLOAD_MAP
def check_all_model_urls_on_startup():
print("--- [Setup] Checking all model URL validity (one-time check) ---")
for display_name, model_info in ALL_MODEL_MAP.items():
_, components, _, _ = model_info
if not components: continue
for filename in components.values():
download_info = ALL_FILE_DOWNLOAD_MAP.get(filename, {})
repo_id = download_info.get('repo_id')
if not repo_id: continue
repo_file_path = download_info.get('repository_file_path', filename)
url = f"https://huggingface.co/{repo_id}/resolve/main/{repo_file_path}"
try:
response = requests.head(url, timeout=5, allow_redirects=True)
if response.status_code >= 400:
print(f"❌ Invalid URL for '{display_name}' component '{filename}': {url} (Status: {response.status_code})")
shared_state.INVALID_MODEL_URLS[display_name] = True
break
except requests.RequestException as e:
print(f"❌ URL check failed for '{display_name}' component '{filename}': {e}")
shared_state.INVALID_MODEL_URLS[display_name] = True
break
print("--- [Setup] ✅ Finished checking model URLs. ---")
print("--- Initiating GPU Startup Check & SageAttention Patch ---")
try:
dummy_gpu_for_startup()
except Exception as e:
print(f"--- [GPU Startup] ⚠️ Warning: Startup check failed: {e} ---")
from utils.app_utils import load_ipadapter_presets
print("--- Starting Application Setup ---")
setup_comfyui.initialize_comfyui()
print("--- Loading IPAdapter presets ---")
load_ipadapter_presets()
print("--- ✅ IPAdapter setup complete. ---")
check_all_model_urls_on_startup()
print("--- Building ControlNet preprocessor maps ---")
from core.generation_logic import build_reverse_map
build_reverse_map()
build_preprocessor_model_map()
build_preprocessor_parameter_map()
print("--- ✅ ControlNet preprocessor setup complete. ---")
print("--- Environment configured. Proceeding with module imports. ---")
from ui.layout import build_ui22 unmodified lines232425262728293031323322 unmodified linesLoraLoader = NODE_CLASS_MAPPINGS['LoraLoader']
CLIPSetLastLayer = NODE_CLASS_MAPPINGS['CLIPSetLastLayer']
if 'EmptyHunyuanImageLatent' in NODE_CLASS_MAPPINGS:
EmptyHunyuanImageLatent = NODE_CLASS_MAPPINGS['EmptyHunyuanImageLatent']
else:
print("⚠️ Warning: 'EmptyHunyuanImageLatent' not found in NODE_CLASS_MAPPINGS. HunyuanImage txt2img may fail if this node is required.")
try:
KSamplerNode = NODE_CLASS_MAPPINGS['KSampler']
SAMPLER_CHOICES = KSamplerNode.INPUT_TYPES()["required"]["sampler_name"][0]38 unmodified lines3940414243434445464445464748495048515253545556575859606162636465666768697071727374757677782 unmodified lines81828358596061626364658485868788899038 unmodified lines except OSError as e:
print(f"⚠️ Could not remove temporary directory '{COMFYUI_TEMP_DIR}': {e}")
print("--- Cloning third-party extensions for ComfyUI ---")
controlnet_aux_path = os.path.join(APP_DIR, "custom_nodes", "comfyui_controlnet_aux")
if not os.path.exists(controlnet_aux_path):
os.system(f"git clone https://github.com/Fannovel16/comfyui_controlnet_aux.git {controlnet_aux_path}")
print("✅ comfyui_controlnet_aux extension cloned.")
# 1. ComfyUI_IPAdapter_plus
ipadapter_plus_path = os.path.join(APP_DIR, "custom_nodes", "ComfyUI_IPAdapter_plus")
if not os.path.exists(ipadapter_plus_path):
os.system(f"git clone https://github.com/cubiq/ComfyUI_IPAdapter_plus.git {ipadapter_plus_path}")
print("✅ ComfyUI_IPAdapter_plus extension cloned.")
else:
print("✅ comfyui_controlnet_aux extension already exists.")
print("✅ ComfyUI_IPAdapter_plus extension already exists.")
# 2. ComfyUI-InstantX-IPAdapter-SD3
ipadapter_plus_path = os.path.join(APP_DIR, "custom_nodes", "ComfyUI-InstantX-IPAdapter-SD3")
if not os.path.exists(ipadapter_plus_path):
os.system(f"git clone https://github.com/Slickytail/ComfyUI-InstantX-IPAdapter-SD3.git {ipadapter_plus_path}")
print("✅ ComfyUI-InstantX-IPAdapter-SD3 extension cloned.")
else:
print("✅ ComfyUI-InstantX-IPAdapter-SD3 extension already exists.")
# 3. ComfyUI-IPAdapter-Flux
ipadapter_flux_path = os.path.join(APP_DIR, "custom_nodes", "ComfyUI-IPAdapter-Flux")
if not os.path.exists(ipadapter_flux_path):
os.system(f"git clone https://github.com/Shakker-Labs/ComfyUI-IPAdapter-Flux.git {ipadapter_flux_path}")
print("✅ ComfyUI-IPAdapter-Flux extension cloned.")
else:
print("✅ ComfyUI-IPAdapter-Flux extension already exists.")
# 4. ComfyUI-Newbie-Nodes
newbie_nodes_path = os.path.join(APP_DIR, "custom_nodes", "ComfyUI-Newbie-Nodes")
if not os.path.exists(newbie_nodes_path):
os.system(f"git clone https://github.com/NewBieAI-Lab/ComfyUI-Newbie-Nodes.git {newbie_nodes_path}")
print("✅ ComfyUI-Newbie-Nodes extension cloned.")
else:
print("✅ ComfyUI-Newbie-Nodes extension already exists.")
print(f"✅ Current working directory is: {os.getcwd()}")
2 unmodified lines
print("✅ ComfyUI initialized with default attention mechanism.")
os.makedirs(os.path.join(APP_DIR, CHECKPOINT_DIR), exist_ok=True)
os.makedirs(os.path.join(APP_DIR, LORA_DIR), exist_ok=True)
os.makedirs(os.path.join(APP_DIR, EMBEDDING_DIR), exist_ok=True)
os.makedirs(os.path.join(APP_DIR, CONTROLNET_DIR), exist_ok=True)
os.makedirs(os.path.join(APP_DIR, MODEL_PATCHES_DIR), exist_ok=True)
os.makedirs(os.path.join(APP_DIR, DIFFUSION_MODELS_DIR), exist_ok=True)
os.makedirs(os.path.join(APP_DIR, VAE_DIR), exist_ok=True)
os.makedirs(os.path.join(APP_DIR, TEXT_ENCODERS_DIR), exist_ok=True)
for dir_path in CATEGORY_TO_DIR_MAP.values():
os.makedirs(os.path.join(APP_DIR, dir_path), exist_ok=True)
os.makedirs(os.path.join(APP_DIR, INPUT_DIR), exist_ok=True)
os.makedirs(os.path.join(APP_DIR, OUTPUT_DIR), exist_ok=True)
print("✅ All required model directories are present.")123445767811121314151617181920212223910from typing import Any, Dict
import gradio as gr
from core.pipelines.controlnet_preprocessor import ControlNetPreprocessorPipeline
from core.pipelines.sd_image_pipeline import SdImagePipeline
controlnet_preprocessor_pipeline = ControlNetPreprocessorPipeline()
sd_image_pipeline = SdImagePipeline()
def build_reverse_map():
from nodes import NODE_DISPLAY_NAME_MAPPINGS
import core.pipelines.controlnet_preprocessor as cn_module
if cn_module.REVERSE_DISPLAY_NAME_MAP is None:
cn_module.REVERSE_DISPLAY_NAME_MAP = {v: k for k, v in NODE_DISPLAY_NAME_MAPPINGS.items()}
if "Semantic Segmentor (legacy, alias for UniFormer)" not in cn_module.REVERSE_DISPLAY_NAME_MAP:
cn_module.REVERSE_DISPLAY_NAME_MAP["Semantic Segmentor (legacy, alias for UniFormer)"] = "SemSegPreprocessor"
def run_cn_preprocessor_entry(*args, **kwargs):
return controlnet_preprocessor_pipeline.run(*args, **kwargs)
def generate_image_wrapper(ui_inputs: dict, progress=gr.Progress(track_tqdm=True)):
return sd_image_pipeline.run(ui_inputs=ui_inputs, progress=progress)123454567811 unmodified lines202122242526272829303132333435232437252639272841422930443132import gc
from typing import List
import gradio as gr
from core.settings import ALL_MODEL_MAP
from utils.app_utils import _ensure_model_downloaded
from core.settings import ALL_MODEL_MAP
class ModelManager:
_instance = None11 unmodified lines
def ensure_models_downloaded(self, required_models: List[str], progress):
print(f"--- [ModelManager] Ensuring models are downloaded: {required_models} ---")
files_to_download = set()
for display_name in required_models:
if display_name in ALL_MODEL_MAP:
_, components, _, _ = ALL_MODEL_MAP[display_name]
for component_file in components.values():
files_to_download.add(component_file)
files_to_download = list(files_to_download)
total_files = len(files_to_download)
for i, filename in enumerate(files_to_download):
for i, display_name in enumerate(required_models):
if progress and hasattr(progress, '__call__'):
progress(i / total_files if total_files > 0 else 0, desc=f"Checking file: {filename}")
progress(i / max(len(required_models), 1), desc=f"Checking file: {display_name}")
try:
_ensure_model_downloaded(filename, progress)
_ensure_model_downloaded(display_name, progress)
except Exception as e:
raise gr.Error(f"Failed to download model component '{filename}'. Reason: {e}")
raise gr.Error(f"Failed to download model '{display_name}'. Reason: {e}")
print(f"--- [ModelManager] ✅ All required models are present on disk. ---")
model_manager = ModelManager()123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143from typing import Dict, Any, List
import imageio
import tempfile
import numpy as np
import torch
import gradio as gr
from PIL import Image
import spaces
from .base_pipeline import BasePipeline
from comfy_integration.nodes import NODE_CLASS_MAPPINGS
from nodes import NODE_DISPLAY_NAME_MAPPINGS
from utils.app_utils import get_value_at_index
REVERSE_DISPLAY_NAME_MAP = None
CPU_ONLY_PREPROCESSORS = {
"Binary Lines", "Canny Edge", "Color Pallete", "Fake Scribble Lines (aka scribble_hed)",
"Image Intensity", "Image Luminance", "Inpaint Preprocessor", "PyraCanny", "Scribble Lines",
"Scribble XDoG Lines", "Standard Lineart", "Content Shuffle", "Tile"
}
def run_node_by_function_name(node_instance: Any, **kwargs) -> Any:
node_class = type(node_instance)
function_name = getattr(node_class, 'FUNCTION', None)
if not function_name:
raise AttributeError(f"Node class '{node_class.__name__}' is missing the required 'FUNCTION' attribute.")
execution_method = getattr(node_instance, function_name, None)
if not callable(execution_method):
raise AttributeError(f"Method '{function_name}' not found or not callable on node '{node_class.__name__}'.")
return execution_method(**kwargs)
class ControlNetPreprocessorPipeline(BasePipeline):
def get_required_models(self, **kwargs) -> List[str]:
return []
def _gpu_logic(
self, pil_images: List[Image.Image], preprocessor_name: str, model_name: str,
params: Dict[str, Any], progress=gr.Progress(track_tqdm=True)
) -> List[Image.Image]:
global REVERSE_DISPLAY_NAME_MAP
if REVERSE_DISPLAY_NAME_MAP is None:
raise RuntimeError("REVERSE_DISPLAY_NAME_MAP has not been initialized. `build_reverse_map` must be called on startup.")
class_name = REVERSE_DISPLAY_NAME_MAP.get(preprocessor_name)
if not class_name or class_name not in NODE_CLASS_MAPPINGS:
raise ValueError(f"Preprocessor '{preprocessor_name}' not found.")
preprocessor_instance = NODE_CLASS_MAPPINGS[class_name]()
call_args = {**params, 'ckpt_name': model_name}
processed_pil_images = []
total_frames = len(pil_images)
for i, frame_pil in enumerate(pil_images):
progress(i / total_frames, desc=f"Processing frame {i+1}/{total_frames} with {preprocessor_name}...")
frame_tensor = torch.from_numpy(np.array(frame_pil).astype(np.float32) / 255.0).unsqueeze(0)
resolution_arg = {'resolution': max(frame_tensor.shape[2], frame_tensor.shape[3])}
result_tuple = run_node_by_function_name(
preprocessor_instance,
image=frame_tensor,
**resolution_arg,
**call_args
)
processed_tensor = get_value_at_index(result_tuple, 0)
processed_np = (processed_tensor.squeeze(0).cpu().numpy().clip(0, 1) * 255.0).astype(np.uint8)
processed_pil_images.append(Image.fromarray(processed_np))
return processed_pil_images
def run(self, input_type, image_input, video_input, preprocessor_name, model_name, zero_gpu_duration, *args, progress=gr.Progress(track_tqdm=True)):
from utils import app_utils
pil_images, is_video, fps = [], False, 30
progress(0, desc="Reading input file...")
if input_type == "Image":
if image_input is None: raise gr.Error("Please provide an input image.")
pil_images = [image_input]
elif input_type == "Video":
if video_input is None: raise gr.Error("Please provide an input video.")
try:
video_reader = imageio.get_reader(video_input)
meta = video_reader.get_meta_data()
fps = meta.get('fps', 30)
pil_images = [Image.fromarray(frame) for frame in video_reader]
is_video = True
video_reader.close()
except Exception as e: raise gr.Error(f"Failed to read video file: {e}")
else:
raise gr.Error("Invalid input type selected.")
if not pil_images: raise gr.Error("Could not extract any frames from the input.")
if app_utils.PREPROCESSOR_PARAMETER_MAP is None:
raise RuntimeError("Preprocessor parameter map is not built. Check startup logs.")
params_config = app_utils.PREPROCESSOR_PARAMETER_MAP.get(preprocessor_name, [])
sliders_params = [p for p in params_config if p['type'] in ["INT", "FLOAT"]]
dropdown_params = [p for p in params_config if isinstance(p['type'], list)]
checkbox_params = [p for p in params_config if p['type'] == "BOOLEAN"]
ordered_params_config = sliders_params + dropdown_params + checkbox_params
param_names = [p['name'] for p in ordered_params_config]
provided_params = {param_names[i]: args[i] for i in range(len(param_names))}
if preprocessor_name not in CPU_ONLY_PREPROCESSORS:
print(f"--- '{preprocessor_name}' requires GPU, requesting ZeroGPU. ---")
try:
processed_pil_images = self._execute_gpu_logic(
self._gpu_logic,
duration=zero_gpu_duration,
default_duration=60,
task_name=f"Preprocessor '{preprocessor_name}'",
pil_images=pil_images,
preprocessor_name=preprocessor_name,
model_name=model_name,
params=provided_params,
progress=progress
)
except Exception as e:
import traceback; traceback.print_exc()
raise gr.Error(f"Failed to run preprocessor '{preprocessor_name}' on GPU: {e}")
else:
print(f"--- Running '{preprocessor_name}' on CPU, no ZeroGPU requested. ---")
try:
processed_pil_images = self._gpu_logic(pil_images, preprocessor_name, model_name, provided_params, progress=progress)
except Exception as e:
import traceback; traceback.print_exc()
raise gr.Error(f"Failed to run preprocessor '{preprocessor_name}' on CPU: {e}")
if not processed_pil_images: raise gr.Error("Processing returned no frames.")
progress(0.9, desc="Finalizing output...")
if is_video:
frames_np = [np.array(img) for img in processed_pil_images]
frames_tensor = torch.from_numpy(np.stack(frames_np)).to(torch.float32) / 255.0
video_path = self._encode_video_from_frames(frames_tensor, fps, progress)
return [video_path]
else:
progress(1.0, desc="Done!")
return processed_pil_images10 unmodified lines1112131414151617181920192122232425262728293024 unmodified lines5556575058596065 unmodified lines1261271281221291301311329 unmodified lines1421431441451461471485 unmodified lines15415515615715815916016116216316416515315416616716816917017117217317417517617716117817918018118218316818418518618718818919017519119219319419519618119719819912 unmodified lines2122132142002152162177 unmodified lines2252262272142282292302314 unmodified lines23623723823924024124224324413 unmodified lines2582592602442612622632647 unmodified lines2722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214222614232634244254264272684284294302714314324331 unmodified line4354364372792802812822832842854384394404412892902912922932944424434444452972982993003013023033043053064464474484494504514524534544554564574584594604614624633144644654664674684694704714724733193203213223233244744754764774784793303313323333343353363373383394804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135143505155165175188 unmodified lines52752852936553053153253310 unmodified linesfrom .base_pipeline import BasePipeline
from core.settings import *
from comfy_integration.nodes import *
from utils.app_utils import get_value_at_index, sanitize_prompt, get_lora_path, get_embedding_path, ensure_controlnet_model_downloaded, sanitize_filename
from utils.app_utils import get_value_at_index, sanitize_prompt, get_lora_path, get_embedding_path, ensure_controlnet_model_downloaded, ensure_ipadapter_models_downloaded, sanitize_filename
from core.workflow_assembler import WorkflowAssembler
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]
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 _topological_sort(self, workflow: Dict[str, Any]) -> List[str]:
graph = defaultdict(list)24 unmodified lines
return sorted_nodes
def _execute_workflow(self, workflow: Dict[str, Any], initial_objects: Dict[str, Any]):
with torch.no_grad():
computed_outputs = initial_objects65 unmodified lines progress(0.4, desc="Executing workflow...")
initial_objects = {}
decoded_images_tensor = self._execute_workflow(workflow, initial_objects=initial_objects)
output_images = []9 unmodified lines 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()}5 unmodified lines 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", "sdxl")
ui_inputs['positive_prompt'] = sanitize_prompt(ui_inputs.get('positive_prompt', ''))
ui_inputs['negative_prompt'] = sanitize_prompt(ui_inputs.get('negative_prompt', ''))
required_models = self.get_required_models(model_display_name=ui_inputs['model_display_name'])
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)
self.model_manager.ensure_models_downloaded(required_models, progress=progress)
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, ui_inputs['civitai_api_key'], progress)
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)
temp_files_to_clean = []
if not os.path.exists(INPUT_DIR): os.makedirs(INPUT_DIR)
if task_type == 'img2img':12 unmodified lines 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:7 unmodified lines 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['inpaint_image'] = os.path.basename(temp_file_path)
ui_inputs['input_image'] = os.path.basename(temp_file_path)
temp_files_to_clean.append(temp_file_path)
ui_inputs.pop('inpaint_mask', None)
4 unmodified lines 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')13 unmodified lines if source == "File":
emb_filename = sanitize_filename(emb_id)
elif source == "Civitai":
local_path, status = get_embedding_path(source, emb_id, ui_inputs['civitai_api_key'], progress)
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}")
7 unmodified lines 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]
})
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:
from utils.app_utils import _ensure_model_downloaded
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:
from utils.app_utils import ensure_sd3_ipadapter_models_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:
from utils.app_utils import _ensure_model_downloaded
_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))
from utils.app_utils import get_vae_path
vae_source = ui_inputs.get('vae_source')
vae_id = ui_inputs.get('vae_id')
vae_file = ui_inputs.get('vae_file')
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, ui_inputs.get('civitai_api_key'), progress)
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
1 unmodified line active_conditioning = []
if conditioning_data:
num_units = len(conditioning_data) // 6
prompts = conditioning_data[0*num_units : 1*num_units]
widths = conditioning_data[1*num_units : 2*num_units]
heights = conditioning_data[2*num_units : 3*num_units]
xs = conditioning_data[3*num_units : 4*num_units]
ys = conditioning_data[4*num_units : 5*num_units]
strengths = conditioning_data[5*num_units : 6*num_units]
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])
"prompt": prompts[i], "width": int(widths[i]), "height": int(heights[i]),
"x": int(xs[i]), "y": int(ys[i]), "strength": float(strengths[i])
})
reference_latent_data = ui_inputs.get('reference_latent_data', [])
active_reference_latents = []
if reference_latent_data:
for img_pil in reference_latent_data:
if img_pil is not None:
temp_file_path = os.path.join(INPUT_DIR, f"temp_ref_{random.randint(1000, 9999)}.png")
img_pil.save(temp_file_path, "PNG")
active_reference_latents.append(os.path.basename(temp_file_path))
temp_files_to_clean.append(temp_file_path)
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']}
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)
model_display_name = ui_inputs['model_display_name']
if model_display_name not in ALL_MODEL_MAP:
raise gr.Error(f"Model '{model_display_name}' is not configured in model_list.yaml.")
_, components, _, _ = ALL_MODEL_MAP[model_display_name]
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'],
"denoise": ui_inputs['denoise'],
"input_image": ui_inputs.get('input_image'),
"inpaint_image": ui_inputs.get('inpaint_image'),
"inpaint_mask": ui_inputs.get('inpaint_mask'),
"left": ui_inputs.get('outpaint_left'), "top": ui_inputs.get('outpaint_top'),
"right": ui_inputs.get('outpaint_right'), "bottom": ui_inputs.get('outpaint_bottom'),
"hires_upscaler": ui_inputs.get('hires_upscaler'), "hires_scale_by": ui_inputs.get('hires_scale_by'),
"unet_name": components['unet'],
"clip_name": components['clip'],
"vae_name": ui_inputs.get('vae_name', components['vae']),
"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,
"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,
"vae_chain": [ui_inputs.get('vae_name')] if ui_inputs.get('vae_name') 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...")
try:8 unmodified lines assembler=assembler,
progress=progress
)
import json
import glob
from PIL import PngImagePlugin12345678941011121314151617181920213 unmodified lines25262728293031323334233536nodes:
pos_prompt:
class_type: CLIPTextEncode
title: "CLIP Text Encode (Positive)"
neg_prompt:
class_type: CLIPTextEncode
title: "CLIP Text Encode (Negative)"
ksampler:
class_type: KSampler
title: "KSampler"
params:
denoise: 1.0
vae_decode:
class_type: VAEDecode
title: "VAE Decode"
save_image:
class_type: SaveImage
title: "Save Image"
params: {}
connections:3 unmodified lines to: "save_image:images"
ui_map:
positive_prompt: "pos_prompt:text"
negative_prompt: "neg_prompt:text"
seed: "ksampler:seed"
steps: "ksampler:steps"
cfg: "ksampler:cfg"
sampler_name: "ksampler:sampler_name"
scheduler: "ksampler:scheduler"
denoise: "ksampler:denoise" denoise: "ksampler:denoise"
filename_prefix: "save_image:filename_prefix"12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364nodes:
unet_loader:
class_type: UNETLoader
title: "Load FLUX UNET"
params:
weight_dtype: "default"
vae_loader:
class_type: VAELoader
title: "Load FLUX VAE"
clip_loader:
class_type: DualCLIPLoader
title: "Load FLUX Dual CLIP"
params:
type: "flux"
device: "default"
flux_guidance:
class_type: FluxGuidance
title: "FluxGuidance"
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: "vae_loader:0"
to: "vae_decode:vae"
- from: "vae_loader:0"
to: "vae_encode:vae"
- from: "pos_prompt:0"
to: "flux_guidance:conditioning"
- from: "flux_guidance:0"
to: "ksampler:positive"
- from: "neg_prompt:0"
to: "ksampler:negative"
dynamic_controlnet_chains:
controlnet_chain:
template: "ControlNetApplyAdvanced"
ksampler_node: "ksampler"
vae_source: "vae_loader:0"
dynamic_flux1_ipadapter_chains:
flux1_ipadapter_chain:
ksampler_node: "ksampler"
dynamic_style_chains:
style_chain:
flux_guidance_node: "flux_guidance"
ksampler_node: "ksampler"
dynamic_conditioning_chains:
conditioning_chain:
flux_guidance_node: "flux_guidance"
ksampler_node: "ksampler"
clip_source: "clip_loader:0"
ui_map:
unet_name: "unet_loader:unet_name"
vae_name: "vae_loader:vae_name"
clip1_name: "clip_loader:clip_name1"
clip2_name: "clip_loader:clip_name2"
guidance: "flux_guidance:guidance"123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104nodes:
unet_loader:
class_type: UNETLoader
title: "Load Diffusion Model"
params:
weight_dtype: "default"
clip_loader:
class_type: CLIPLoader
title: "Load CLIP"
params:
type: "flux2"
device: "default"
vae_loader:
class_type: VAELoader
title: "Load VAE"
flux_kv_cache:
class_type: FluxKVCache
title: "Flux KV Cache"
pos_prompt:
class_type: CLIPTextEncode
title: "CLIP Text Encode (Positive)"
neg_prompt:
class_type: CLIPTextEncode
title: "CLIP Text Encode (Negative)"
ksampler:
class_type: KSampler
title: "KSampler"
params:
denoise: 1.0
vae_decode:
class_type: VAEDecode
title: "VAE Decode"
save_image:
class_type: SaveImage
title: "Save Image"
connections:
- from: "unet_loader:0"
to: "flux_kv_cache:model"
- from: "flux_kv_cache:0"
to: "ksampler:model"
- from: "clip_loader:0"
to: "pos_prompt:clip"
- from: "clip_loader:0"
to: "neg_prompt:clip"
- from: "vae_loader:0"
to: "vae_decode:vae"
- from: "vae_loader:0"
to: "vae_encode:vae"
- from: "pos_prompt:0"
to: "ksampler:positive"
- from: "neg_prompt:0"
to: "ksampler:negative"
- from: "latent_source:0"
to: "ksampler:latent_image"
- from: "ksampler:0"
to: "vae_decode:samples"
- from: "vae_decode:0"
to: "save_image:images"
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": ["flux_kv_cache:model"]
"clip": ["pos_prompt:clip", "neg_prompt:clip"]
dynamic_reference_latent_chains:
reference_latent_chain:
ksampler_node: "ksampler"
vae_node: "vae_loader"
ui_map:
unet_name: "unet_loader:unet_name"
clip_name: "clip_loader:clip_name"
vae_name: "vae_loader:vae_name"
positive_prompt: "pos_prompt:text"
negative_prompt: "neg_prompt:text"
seed: "ksampler:seed"
steps: "ksampler:steps"
cfg: "ksampler:cfg"
sampler_name: "ksampler:sampler_name"
scheduler: "ksampler:scheduler"
denoise: "ksampler:denoise"
filename_prefix: "save_image:filename_prefix"19 unmodified lines202122232425262728293031323334353637383911 unmodified lines51525354555657585960616263648 unmodified lines73747554555657587677783 unmodified lines8283848586698788899091929394959619 unmodified lines neg_prompt:
class_type: CLIPTextEncode
title: "CLIP Text Encode (Negative)"
ksampler:
class_type: KSampler
title: "KSampler"
params:
denoise: 1.0
vae_decode:
class_type: VAEDecode
title: "VAE Decode"
save_image:
class_type: SaveImage
title: "Save Image"
connections:
- from: "unet_loader:0"11 unmodified lines to: "ksampler:positive"
- from: "neg_prompt:0"
to: "ksampler:negative"
- from: "latent_source:0"
to: "ksampler:latent_image"
- from: "ksampler:0"
to: "vae_decode:samples"
- from: "vae_decode:0"
to: "save_image:images"
dynamic_lora_chains:
lora_chain:8 unmodified lines "model": ["ksampler:model"]
"clip": ["pos_prompt:clip", "neg_prompt:clip"]
dynamic_conditioning_chains:
conditioning_chain:
ksampler_node: "ksampler"
clip_source: "clip_loader:0"
dynamic_reference_latent_chains:
reference_latent_chain:
ksampler_node: "ksampler"3 unmodified lines unet_name: "unet_loader:unet_name"
clip_name: "clip_loader:clip_name"
vae_name: "vae_loader:vae_name"
positive_prompt: "pos_prompt:text"
negative_prompt: "neg_prompt:text" negative_prompt: "neg_prompt:text"
seed: "ksampler:seed"
steps: "ksampler:steps"
cfg: "ksampler:cfg"
sampler_name: "ksampler:sampler_name"
scheduler: "ksampler:scheduler"
denoise: "ksampler:denoise"
filename_prefix: "save_image:filename_prefix"12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758nodes:
ckpt_loader:
class_type: CheckpointLoaderSimple
title: "Load Checkpoint"
connections:
- from: "ckpt_loader:0"
to: "ksampler:model"
- from: "ckpt_loader:1"
to: "pos_prompt:clip"
- from: "ckpt_loader:1"
to: "neg_prompt:clip"
- from: "pos_prompt:0"
to: "ksampler:positive"
- from: "neg_prompt:0"
to: "ksampler:negative"
- from: "ckpt_loader:2"
to: "vae_decode:vae"
- from: "ckpt_loader:2"
to: "vae_encode:vae"
dynamic_vae_chains:
vae_chain:
targets:
- "vae_decode:vae"
- "vae_encode:vae"
dynamic_lora_chains:
lora_chain:
template: "LoraLoader"
start: "ckpt_loader"
output_map:
"0": "model"
"1": "clip"
input_map:
"model": "model"
"clip": "clip"
end_input_map:
"model": ["ksampler:model"]
"clip": ["pos_prompt:clip", "neg_prompt:clip"]
dynamic_controlnet_chains:
controlnet_chain:
template: "ControlNetApplyAdvanced"
ksampler_node: "ksampler"
vae_source: "ckpt_loader:2"
dynamic_sd3_ipadapter_chains:
sd3_ipadapter_chain:
ksampler_node: "ksampler"
dynamic_conditioning_chains:
conditioning_chain:
ksampler_node: "ksampler"
clip_source: "ckpt_loader:1"
ui_map:
model_name: "ckpt_loader:ckpt_name"123445677891010111213141516nodes:
input_image_loader:
class_type: LoadImage
title: "Load Input Image"
vae_encode:
class_type: VAEEncode
title: "VAE Encode (Hires Pre-step)"
latent_upscaler:
class_type: LatentUpscaleBy
title: "Upscale Latent By"
latent_source:
class_type: RepeatLatentBatch
title: "Repeat Latent Batch for Hires"
connections:
- from: "input_image_loader:0"1234456778910111213nodes:
input_image_loader:
class_type: LoadImage
title: "Load Input Image"
vae_encode:
class_type: VAEEncode
title: "VAE Encode (Img2Img)"
latent_source:
class_type: RepeatLatentBatch
title: "Repeat Latent Batch"
connections:
- from: "input_image_loader:0"1 unmodified line23455689107891013111213141516191718192024252122231 unmodified line inpaint_loader:
class_type: LoadImage
title: "Load Inpaint Image+Mask"
vae_encode:
class_type: VAEEncodeForInpaint
params:
grow_mask_by: 6
title: "VAE Encode (for Inpainting)"
latent_source:
class_type: RepeatLatentBatch
title: "Repeat Latent Batch"
connections:
- from: "inpaint_loader:0"
to: "vae_encode:pixels"
- from: "inpaint_loader:1"
to: "vae_encode:mask"
- from: "vae_encode:0"
to: "latent_source:samples"
ui_map:
inpaint_image: "inpaint_loader:image"
batch_size: "latent_source:amount" input_image: "inpaint_loader:image"
batch_size: "latent_source:amount"
grow_mask_by: "vae_encode:grow_mask_by"1234456789101178912131412131415161718192021222324212526272826293031323332343536373837394041nodes:
input_image_loader:
class_type: LoadImage
title: "Load Image for Outpaint"
scale_image:
class_type: ImageScaleToTotalPixels
title: "Scale Image to Total Pixels"
params:
upscale_method: "nearest-exact"
pad_image:
class_type: ImagePadForOutpaint
params:
feathering: 10
title: "Pad Image for Outpainting"
vae_encode:
class_type: VAEEncodeForInpaint
params:
grow_mask_by: 6
title: "VAE Encode (for Inpainting)"
latent_source:
class_type: RepeatLatentBatch
title: "Repeat Latent Batch"
connections:
- from: "input_image_loader:0"
to: "scale_image:image"
- from: "scale_image:0"
to: "pad_image:image"
- from: "pad_image:0"
to: "vae_encode:pixels"
- from: "pad_image:1"
to: "vae_encode:mask"
- from: "vae_encode:0"
to: "latent_source:samples"
ui_map:
input_image: "input_image_loader:image"
megapixels: "scale_image:megapixels"
left: "pad_image:left"
top: "pad_image:top"
right: "pad_image:right"
bottom: "pad_image:bottom"
feathering: "pad_image:feathering"
grow_mask_by: "vae_encode:grow_mask_by"
batch_size: "latent_source:amount"1234567812nodes:
latent_source:
class_type: EmptyFlux2LatentImage
ui_map:
width: "latent_source:width"
height: "latent_source:height"
batch_size: "latent_source:batch_size"imports:
- "txt2img_{{ latent_type }}.yaml"1234567891011nodes:
latent_source:
class_type: "EmptyChromaRadianceLatentImage"
title: "EmptyChromaRadianceLatentImage"
connections: []
ui_map:
width: "latent_source:width"
height: "latent_source:height"
batch_size: "latent_source:batch_size"1234567891011nodes:
latent_source:
class_type: "EmptyFlux2LatentImage"
title: "Empty Flux 2 Latent"
connections: []
ui_map:
width: "latent_source:width"
height: "latent_source:height"
batch_size: "latent_source:batch_size"1234567891011nodes:
latent_source:
class_type: "EmptyHunyuanImageLatent"
title: "EmptyHunyuanImageLatent"
connections: []
ui_map:
width: "latent_source:width"
height: "latent_source:height"
batch_size: "latent_source:batch_size"1234567891011nodes:
latent_source:
class_type: "{{ latent_generator_template }}"
title: "Empty Latent Image"
connections: []
ui_map:
width: "latent_source:width"
height: "latent_source:height"
batch_size: "latent_source:batch_size"1234567891011nodes:
latent_source:
class_type: "EmptySD3LatentImage"
title: "EmptySD3LatentImage"
connections: []
ui_map:
width: "latent_source:width"
height: "latent_source:height"
batch_size: "latent_source:batch_size"122344567imports:
- "_partials/_base_sampler.yaml"
- "_partials/_base_sampler_sd.yaml"
- "_partials/input/{{ task_type }}.yaml"
- "_partials/conditioning/flux2.yaml"
- "_partials/conditioning/{{ model_type }}.yaml"
connections:
- from: "latent_source:0"9 unmodified lines10111213141516171819202122232425262728293031323334353637383940414243224445461 unmodified line48495051525354555657585960616263646566676869707172737426 unmodified lines10110210310410510664107108109676869707172737475767778791101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391408384858687888914114214314414514614714814915015115215315415515615715815916016116216316416516616797981681691701711721731741751761771781791801811821051831841851862 unmodified lines1891901911141921931941951961971981991191202002012021231241252032042059 unmodified linesDIFFUSION_MODELS_DIR = "models/diffusion_models"
VAE_DIR = "models/vae"
TEXT_ENCODERS_DIR = "models/text_encoders"
STYLE_MODELS_DIR = "models/style_models"
CLIP_VISION_DIR = "models/clip_vision"
IPADAPTER_DIR = "models/ipadapter"
IPADAPTER_FLUX_DIR = "models/ipadapter-flux"
INPUT_DIR = "input"
OUTPUT_DIR = "output"
CATEGORY_TO_DIR_MAP = {
"diffusion_models": DIFFUSION_MODELS_DIR,
"text_encoders": TEXT_ENCODERS_DIR,
"vae": VAE_DIR,
"checkpoints": CHECKPOINT_DIR,
"loras": LORA_DIR,
"controlnet": CONTROLNET_DIR,
"model_patches": MODEL_PATCHES_DIR,
"embeddings": EMBEDDING_DIR,
"style_models": STYLE_MODELS_DIR,
"clip_vision": CLIP_VISION_DIR,
"ipadapter": IPADAPTER_DIR,
"ipadapter-flux": IPADAPTER_FLUX_DIR
}
_PROJECT_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
_MODEL_LIST_PATH = os.path.join(_PROJECT_ROOT, 'yaml', 'model_list.yaml')
_FILE_LIST_PATH = os.path.join(_PROJECT_ROOT, 'yaml', 'file_list.yaml')
_IPADAPTER_LIST_PATH = os.path.join(_PROJECT_ROOT, 'yaml', 'ipadapter.yaml')
_CONSTANTS_PATH = os.path.join(_PROJECT_ROOT, 'yaml', 'constants.yaml')
_MODEL_ARCHITECTURES_PATH = os.path.join(_PROJECT_ROOT, 'yaml', 'model_architectures.yaml')
_IMAGE_GEN_FEATURES_PATH = os.path.join(_PROJECT_ROOT, 'yaml', 'image_gen_features.yaml')
_MODEL_DEFAULTS_PATH = os.path.join(_PROJECT_ROOT, 'yaml', 'model_defaults.yaml')
def load_constants_from_yaml(filepath=_CONSTANTS_PATH):
if not os.path.exists(filepath):
print(f"Warning: Constants file not found at {filepath}. Using fallback values.")1 unmodified line with open(filepath, 'r', encoding='utf-8') as f:
return yaml.safe_load(f)
def load_architectures_config(filepath=_MODEL_ARCHITECTURES_PATH):
if not os.path.exists(filepath):
print(f"Warning: Architectures file not found at {filepath}.")
return {}
with open(filepath, 'r', encoding='utf-8') as f:
return yaml.safe_load(f)
def load_features_config(filepath=_IMAGE_GEN_FEATURES_PATH):
if not os.path.exists(filepath):
print(f"Warning: Features file not found at {filepath}.")
return {}
with open(filepath, 'r', encoding='utf-8') as f:
return yaml.safe_load(f)
def load_model_defaults(filepath=_MODEL_DEFAULTS_PATH):
if not os.path.exists(filepath):
print(f"Warning: Model defaults file not found at {filepath}.")
return {}
with open(filepath, 'r', encoding='utf-8') as f:
return yaml.safe_load(f)
def load_file_download_map(filepath=_FILE_LIST_PATH):
if not os.path.exists(filepath):
raise FileNotFoundError(f"The file list (for downloads) was not found at: {filepath}")26 unmodified lines }
category_map_names = {
"Checkpoint": "MODEL_MAP_CHECKPOINT",
"Checkpoints": "MODEL_MAP_CHECKPOINT"
}
for category, models in model_data.items():
for category, architectures in model_data.items():
if category in category_map_names:
map_name = category_map_names[category]
if not isinstance(models, list): continue
for model in models:
display_name = model['display_name']
components = model.get('components', {})
model_tuple = (
None,
components,
"SDXL",
None
)
model_maps[map_name][display_name] = model_tuple
model_maps["ALL_MODEL_MAP"][display_name] = model_tuple
if not isinstance(architectures, dict): continue
for arch, arch_data in architectures.items():
if not isinstance(arch_data, dict): continue
latent_type = arch_data.get('latent_type', 'latent')
models = arch_data.get('models', [])
if not isinstance(models, list): continue
for model in models:
display_name = model['display_name']
path_or_components = model.get('path') or model.get('components')
mod_category = model.get('category', None)
repo_id = ''
if isinstance(path_or_components, str):
download_info = download_map.get(path_or_components, {})
repo_id = download_info.get('repo_id', '')
model_tuple = (
repo_id,
path_or_components,
arch,
latent_type,
mod_category
)
model_maps[map_name][display_name] = model_tuple
model_maps["ALL_MODEL_MAP"][display_name] = model_tuple
return model_maps
def load_model_defaults(filepath=_MODEL_DEFAULTS_PATH):
if not os.path.exists(filepath):
print(f"Warning: Model defaults file not found at {filepath}. Using empty defaults.")
return {}
with open(filepath, 'r', encoding='utf-8') as f:
return yaml.safe_load(f)
try:
ALL_FILE_DOWNLOAD_MAP = load_file_download_map()
loaded_maps = load_models_from_yaml(download_map=ALL_FILE_DOWNLOAD_MAP)
MODEL_MAP_CHECKPOINT = loaded_maps["MODEL_MAP_CHECKPOINT"]
ALL_MODEL_MAP = loaded_maps["ALL_MODEL_MAP"]
category_to_model_type = {
"diffusion_models": "UNET",
"text_encoders": "TEXT_ENCODER",
"vae": "VAE",
"checkpoints": "SDXL",
"loras": "LORA",
"controlnet": "CONTROLNET",
"model_patches": "MODEL_PATCH",
"style_models": "STYLE",
"clip_vision": "CLIP_VISION",
"ipadapter": "IPADAPTER",
"ipadapter-flux": "IPADAPTER_FLUX"
}
for filename, file_info in ALL_FILE_DOWNLOAD_MAP.items():
if filename not in ALL_MODEL_MAP:
category = file_info.get('category')
model_type = category_to_model_type.get(category, 'UNKNOWN')
repo_id = file_info.get('repo_id', '')
ALL_MODEL_MAP[filename] = (repo_id, filename, model_type, None, None)
MODEL_TYPE_MAP = {k: v[2] for k, v in ALL_MODEL_MAP.items()}
ALL_MODEL_DEFAULTS = load_model_defaults()
ARCH_CATEGORIES_MAP = {}
for display_name, info in MODEL_MAP_CHECKPOINT.items():
arch = info[2]
cat = info[4] if len(info) > 4 else None
if arch not in ARCH_CATEGORIES_MAP:
ARCH_CATEGORIES_MAP[arch] = []
if cat and cat not in ARCH_CATEGORIES_MAP[arch]:
ARCH_CATEGORIES_MAP[arch].append(cat)
except Exception as e:
print(f"FATAL: Could not load model configuration from YAML. Error: {e}")
ALL_FILE_DOWNLOAD_MAP = {}
MODEL_MAP_CHECKPOINT, ALL_MODEL_MAP = {}, {}
MODEL_TYPE_MAP = {}
ALL_MODEL_DEFAULTS = {}
ARCH_CATEGORIES_MAP = {}
try:2 unmodified lines MAX_EMBEDDINGS = _constants.get('MAX_EMBEDDINGS', 5)
MAX_CONDITIONINGS = _constants.get('MAX_CONDITIONINGS', 10)
MAX_CONTROLNETS = _constants.get('MAX_CONTROLNETS', 5)
MAX_REFERENCE_LATENTS = _constants.get('MAX_REFERENCE_LATENTS', 10)
MAX_IPADAPTERS = _constants.get('MAX_IPADAPTERS', 5)
LORA_SOURCE_CHOICES = _constants.get('LORA_SOURCE_CHOICES', ["Civitai", "File"])
RESOLUTION_MAP = _constants.get('RESOLUTION_MAP', {})
ARCHITECTURES_CONFIG = load_architectures_config()
FEATURES_CONFIG = load_features_config()
MODEL_DEFAULTS_CONFIG = load_model_defaults()
except Exception as e:
print(f"FATAL: Could not load constants from YAML. Error: {e}")
MAX_LORAS, MAX_EMBEDDINGS, MAX_CONDITIONINGS, MAX_CONTROLNETS = 5, 5, 10, 5
MAX_REFERENCE_LATENTS = 10
MAX_LORAS, MAX_EMBEDDINGS, MAX_CONDITIONINGS, MAX_CONTROLNETS, MAX_IPADAPTERS = 5, 5, 10, 5, 5
LORA_SOURCE_CHOICES = ["Civitai", "File"]
RESOLUTION_MAP = {}
DEFAULT_NEGATIVE_PROMPT = "" ARCHITECTURES_CONFIG = {}
FEATURES_CONFIG = {}
MODEL_DEFAULTS_CONFIG = {}123412345676789108 unmodified lines1920212222232425262627282928 unmodified lines585960616162comfyui-frontend-package==1.42.10
comfyui-workflow-templates==0.9.47
comfyui-embedded-docs==0.4.3
torch
comfyui-frontend-package==1.42.15
comfyui-workflow-templates==0.9.66
comfyui-embedded-docs==0.4.4
torch==2.10.0
torchsde
torchvision
torchaudio
torchvision==0.25.0
torchaudio==2.10.0
numpy>=1.25.0
einops
transformers>=4.50.38 unmodified linestqdm
psutil
alembic
SQLAlchemy
SQLAlchemy>=2.0.0
filelock
av>=14.2.0
comfy-kitchen>=0.2.8
comfy-aimdo>=0.2.12
comfy-aimdo==0.3.0
requests
simpleeval>=1.0.0
blake328 unmodified linestrimesh[easy]
yacs
yapf
onnxruntime-gpuonnxruntime-gpu
diffusers7 unmodified lines8910111213111213141617181920211516171819202122232425262728293031323323242526272829303132333435363738393536404142434445464748495051525354555657585960616263646566673839686970714172737475767778798081828384858687888990914344454647484950515253929394959697989910010110210310410510610710810911011111211311411555565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611611711811912012112212312412512612712812911811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015113013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419515419619719819920032 unmodified lines23323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858919459059159259359426 unmodified lines62162262322762462562662762822 unmodified lines65165265325625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528665465565620 unmodified lines6776786793133143153163173183193203213223236806816826836846856866876886896906916926936946953286966976986997007017023323337037047057067077087093387107117127137147157167177187197203437217227237241 unmodified line72672772835172973073173273373473573673773873974074135735835936036136236336474274374474574674774874975075175275375475575675775875976076176276376436937037137237376576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898938038138238338438538638738838999039139239339439539639739839940040140299199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064404405406407408409410411412413414415416417418419420421422423424425426427428429430106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112435436437438439111344144244344444544644744811141115111611171118454455111911201121112211231124112511261127112811291130113111321133113411351136113711381139462463464114011411142114311444664671145114611471148114911501151115211534694701154115511561157115811591160472473474116111621163476477478479116411651166116711681169117011711172117311741175117611771178117911801181118211834814824831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220487488489490491492493494122112221223122412251226122712281229123012311232123312341235123612371238123950012401241124212431244124512461247124812491250125112521253125412551256125712587 unmodified linesfrom core.generation_logic import *
from comfy_integration.nodes import SAMPLER_CHOICES, SCHEDULER_CHOICES
from core.pipelines.controlnet_preprocessor import CPU_ONLY_PREPROCESSORS
from utils.app_utils import PREPROCESSOR_MODEL_MAP, PREPROCESSOR_PARAMETER_MAP, save_uploaded_file_with_hash
from ui.shared.ui_components import RESOLUTION_MAP, MAX_CONTROLNETS, MAX_EMBEDDINGS, MAX_CONDITIONINGS, MAX_LORAS, MAX_REFERENCE_LATENTS
from utils.app_utils import save_uploaded_file_with_hash
from ui.shared.ui_components import RESOLUTION_MAP, MAX_CONTROLNETS, MAX_IPADAPTERS, MAX_EMBEDDINGS, MAX_CONDITIONINGS, MAX_LORAS
def on_model_change(model_display_name):
"""
Callback function to update UI elements when the base model changes.
It loads default values for steps and cfg from model_defaults.yaml.
"""
defaults = ALL_MODEL_DEFAULTS.get('Default', {}).copy()
@lru_cache(maxsize=1)
def load_controlnet_config():
_PROJECT_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
_CN_MODEL_LIST_PATH = os.path.join(_PROJECT_ROOT, 'yaml', 'controlnet_models.yaml')
try:
print("--- Loading controlnet_models.yaml ---")
with open(_CN_MODEL_LIST_PATH, 'r', encoding='utf-8') as f:
config = yaml.safe_load(f)
print("--- ✅ controlnet_models.yaml loaded successfully ---")
return config.get("ControlNet", {})
except Exception as e:
print(f"Error loading controlnet_models.yaml: {e}")
return {}
def get_cn_defaults(arch_val):
cn_full_config = load_controlnet_config()
cn_config = cn_full_config.get(arch_val, [])
model_found = False
for category, models_in_category in ALL_MODEL_DEFAULTS.items():
if category == 'Default' or not isinstance(models_in_category, dict):
continue
if model_display_name in models_in_category:
if '_defaults' in models_in_category:
defaults.update(models_in_category['_defaults'])
defaults.update(models_in_category[model_display_name])
model_found = True
break
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
if not model_found:
print(f"No specific defaults found for '{model_display_name}'. Using category or global defaults.")
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_diffsynth_controlnet_config():
_PROJECT_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
_CN_MODEL_LIST_PATH = os.path.join(_PROJECT_ROOT, 'yaml', 'diffsynth_controlnet_models.yaml')
try:
print("--- Loading diffsynth_controlnet_models.yaml ---")
with open(_CN_MODEL_LIST_PATH, 'r', encoding='utf-8') as f:
config = yaml.safe_load(f)
print("--- ✅ diffsynth_controlnet_models.yaml loaded successfully ---")
return config.get("DiffSynth_ControlNet", {})
except Exception as e:
print(f"Error loading diffsynth_controlnet_models.yaml: {e}")
return {}
steps_update = gr.update(value=defaults.get('steps'))
cfg_update = gr.update(value=defaults.get('cfg'))
def get_diffsynth_cn_defaults(arch_val):
cn_full_config = load_diffsynth_controlnet_config()
cn_config = cn_full_config.get(arch_val, [])
return steps_update, cfg_update
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
def attach_event_handlers(ui_components, demo):
def update_cn_input_visibility(choice):
return {
ui_components["cn_image_input"]: gr.update(visible=choice == "Image"),
ui_components["cn_video_input"]: gr.update(visible=choice == "Video")
}
ui_components["cn_input_type"].change(
fn=update_cn_input_visibility,
inputs=[ui_components["cn_input_type"]],
outputs=[ui_components["cn_image_input"], ui_components["cn_video_input"]]
)
@lru_cache(maxsize=1)
def load_ipadapter_config():
_PROJECT_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
_IPA_MODEL_LIST_PATH = os.path.join(_PROJECT_ROOT, 'yaml', 'ipadapter.yaml')
try:
print("--- Loading ipadapter.yaml ---")
with open(_IPA_MODEL_LIST_PATH, 'r', encoding='utf-8') as f:
config = yaml.safe_load(f)
print("--- ✅ ipadapter.yaml loaded successfully ---")
return config
except Exception as e:
print(f"Error loading ipadapter.yaml: {e}")
return {}
def apply_data_to_ui(data, prefix, ui_components):
final_sampler = data.get('sampler') if data.get('sampler') in SAMPLER_CHOICES else SAMPLER_CHOICES[0]
default_scheduler = 'normal' if 'normal' in SCHEDULER_CHOICES else SCHEDULER_CHOICES[0]
final_scheduler = data.get('scheduler') if data.get('scheduler') in SCHEDULER_CHOICES else default_scheduler
updates = {}
base_model_name = data.get('base_model')
def update_preprocessor_models_dropdown(preprocessor_name):
models = PREPROCESSOR_MODEL_MAP.get(preprocessor_name)
if models:
model_filenames = [m[1] for m in models]
return gr.update(choices=model_filenames, value=model_filenames[0], visible=True)
else:
return gr.update(choices=[], value=None, visible=False)
def update_preprocessor_settings_ui(preprocessor_name):
from ui.layout import MAX_DYNAMIC_CONTROLS
params = PREPROCESSOR_PARAMETER_MAP.get(preprocessor_name, [])
slider_updates, dropdown_updates, checkbox_updates = [], [], []
s_idx, d_idx, c_idx = 0, 0, 0
for param in params:
if s_idx + d_idx + c_idx >= MAX_DYNAMIC_CONTROLS: break
name = param["name"]
ptype = param["type"]
config = param["config"]
label = name.replace('_', ' ').title()
if ptype == "INT" or ptype == "FLOAT":
if s_idx < MAX_DYNAMIC_CONTROLS:
slider_updates.append(gr.update(
label=label,
minimum=config.get('min', 0),
maximum=config.get('max', 255),
step=config.get('step', 0.1 if ptype == "FLOAT" else 1),
value=config.get('default', 0),
visible=True
))
s_idx += 1
elif isinstance(ptype, list):
if d_idx < MAX_DYNAMIC_CONTROLS:
dropdown_updates.append(gr.update(
label=label,
choices=ptype,
value=config.get('default', ptype[0] if ptype else None),
visible=True
))
d_idx += 1
elif ptype == "BOOLEAN":
if c_idx < MAX_DYNAMIC_CONTROLS:
checkbox_updates.append(gr.update(
label=label,
value=config.get('default', False),
visible=True
))
c_idx += 1
for _ in range(s_idx, MAX_DYNAMIC_CONTROLS): slider_updates.append(gr.update(visible=False))
for _ in range(d_idx, MAX_DYNAMIC_CONTROLS): dropdown_updates.append(gr.update(visible=False))
for _ in range(c_idx, MAX_DYNAMIC_CONTROLS): checkbox_updates.append(gr.update(visible=False))
return slider_updates + dropdown_updates + checkbox_updates
def update_run_button_for_cpu(preprocessor_name):
if preprocessor_name in CPU_ONLY_PREPROCESSORS:
return gr.update(value="Run Preprocessor CPU Only", variant="primary"), gr.update(visible=False)
model_map = MODEL_MAP_CHECKPOINT
if f'base_model_{prefix}' in ui_components:
model_dropdown_component = ui_components[f'base_model_{prefix}']
if base_model_name and base_model_name in model_map:
updates[model_dropdown_component] = base_model_name
if f'model_arch_{prefix}' in ui_components:
m_type = MODEL_TYPE_MAP.get(base_model_name, "SDXL")
updates[ui_components[f'model_arch_{prefix}']] = m_type
if f'model_cat_{prefix}' in ui_components:
m_info = model_map.get(base_model_name)
m_cat = m_info[4] if m_info and len(m_info) > 4 else None
updates[ui_components[f'model_cat_{prefix}']] = m_cat if m_cat else "ALL"
else:
return gr.update(value="Run Preprocessor", variant="primary"), gr.update(visible=True)
ui_components["preprocessor_cn"].change(
fn=update_preprocessor_models_dropdown,
inputs=[ui_components["preprocessor_cn"]],
outputs=[ui_components["preprocessor_model_cn"]]
).then(
fn=update_preprocessor_settings_ui,
inputs=[ui_components["preprocessor_cn"]],
outputs=ui_components["cn_sliders"] + ui_components["cn_dropdowns"] + ui_components["cn_checkboxes"]
).then(
fn=update_run_button_for_cpu,
inputs=[ui_components["preprocessor_cn"]],
outputs=[ui_components["run_cn"], ui_components["zero_gpu_cn"]]
)
all_dynamic_inputs = (
ui_components["cn_sliders"] +
ui_components["cn_dropdowns"] +
ui_components["cn_checkboxes"]
)
ui_components["run_cn"].click(
fn=run_cn_preprocessor_entry,
inputs=[
ui_components["cn_input_type"],
ui_components["cn_image_input"],
ui_components["cn_video_input"],
ui_components["preprocessor_cn"],
ui_components["preprocessor_model_cn"],
ui_components["zero_gpu_cn"],
] + all_dynamic_inputs,
outputs=[ui_components["output_gallery_cn"]]
)
updates[model_dropdown_component] = gr.update()
common_params = {
f'prompt_{prefix}': data.get('prompt', ''),
f'neg_prompt_{prefix}': data.get('negative_prompt', ''),
f'seed_{prefix}': data.get('seed', -1),
f'cfg_{prefix}': data.get('cfg_scale', 7.5),
f'steps_{prefix}': data.get('steps', 28),
f'sampler_{prefix}': final_sampler,
f'scheduler_{prefix}': final_scheduler,
}
for comp_name, value in common_params.items():
if comp_name in ui_components:
updates[ui_components[comp_name]] = value
if prefix == 'txt2img':
if f'width_{prefix}' in ui_components:
updates[ui_components[f'width_{prefix}']] = data.get('width', 1024)
if f'height_{prefix}' in ui_components:
updates[ui_components[f'height_{prefix}']] = data.get('height', 1024)
tab_indices = {"txt2img": 0, "img2img": 1, "inpaint": 2, "outpaint": 3, "hires_fix": 4}
tab_index = tab_indices.get(prefix, 0)
updates[ui_components['tabs']] = gr.Tabs(selected=tab_index)
return updates
def send_info_to_tab(image, prefix, ui_components):
if not image or not image.info.get('parameters', ''):
all_comps = [comp for comp_or_list in ui_components.values() for comp in (comp_or_list if isinstance(comp_or_list, list) else [comp_or_list])]
return {comp: gr.update() for comp in all_comps}
data = parse_parameters(image.info['parameters'])
image_input_map = {
"img2img": 'input_image_img2img',
"inpaint": 'input_image_dict_inpaint',
"outpaint": 'input_image_outpaint',
"hires_fix": 'input_image_hires_fix'
}
updates = apply_data_to_ui(data, prefix, ui_components)
if prefix in image_input_map and image_input_map[prefix] in ui_components:
component_key = image_input_map[prefix]
updates[ui_components[component_key]] = gr.update(value=image)
return updates
def send_info_by_hash(image, ui_components):
if not image or not image.info.get('parameters', ''):
all_comps = [comp for comp_or_list in ui_components.values() for comp in (comp_or_list if isinstance(comp_or_list, list) else [comp_or_list])]
return {comp: gr.update() for comp in all_comps}
data = parse_parameters(image.info['parameters'])
return apply_data_to_ui(data, "txt2img", ui_components)
def attach_event_handlers(ui_components, demo):
def create_lora_event_handlers(prefix):
lora_rows = ui_components[f'lora_rows_{prefix}']
lora_rows = ui_components.get(f'lora_rows_{prefix}')
if not lora_rows: return
lora_ids = ui_components[f'lora_ids_{prefix}']
lora_scales = ui_components[f'lora_scales_{prefix}']
lora_uploads = ui_components[f'lora_uploads_{prefix}']32 unmodified lines add_button.click(add_lora_row, [count_state], add_outputs, show_progress=False)
del_button.click(del_lora_row, [count_state], del_outputs, show_progress=False)
def create_controlnet_event_handlers(prefix):
cn_rows = ui_components.get(f'controlnet_rows_{prefix}')
if not cn_rows: return
cn_types = ui_components[f'controlnet_types_{prefix}']
cn_series = ui_components[f'controlnet_series_{prefix}']
cn_filepaths = ui_components[f'controlnet_filepaths_{prefix}']
cn_images = ui_components[f'controlnet_images_{prefix}']
cn_strengths = ui_components[f'controlnet_strengths_{prefix}']
count_state = ui_components[f'controlnet_count_state_{prefix}']
add_button = ui_components[f'add_controlnet_button_{prefix}']
del_button = ui_components[f'delete_controlnet_button_{prefix}']
accordion = ui_components[f'controlnet_accordion_{prefix}']
arch_comp = ui_components.get(f'model_arch_{prefix}')
actual_arch_comp = arch_comp if arch_comp else gr.State("SDXL")
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, arch_val):
cn_full_config = load_controlnet_config()
architectures_dict = ARCHITECTURES_CONFIG.get('architectures', {})
controlnet_key = architectures_dict.get(arch_val, {}).get("controlnet_key", arch_val)
cn_config = cn_full_config.get(controlnet_key, [])
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, arch_val):
cn_full_config = load_controlnet_config()
architectures_dict = ARCHITECTURES_CONFIG.get('architectures', {})
controlnet_key = architectures_dict.get(arch_val, {}).get("controlnet_key", arch_val)
cn_config = cn_full_config.get(controlnet_key, [])
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], actual_arch_comp],
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], actual_arch_comp],
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_diffsynth_controlnet_event_handlers(prefix):
cn_rows = ui_components.get(f'diffsynth_controlnet_rows_{prefix}')
if not cn_rows: return
cn_types = ui_components[f'diffsynth_controlnet_types_{prefix}']
cn_series = ui_components[f'diffsynth_controlnet_series_{prefix}']
cn_filepaths = ui_components[f'diffsynth_controlnet_filepaths_{prefix}']
cn_images = ui_components[f'diffsynth_controlnet_images_{prefix}']
cn_strengths = ui_components[f'diffsynth_controlnet_strengths_{prefix}']
count_state = ui_components[f'diffsynth_controlnet_count_state_{prefix}']
add_button = ui_components[f'add_diffsynth_controlnet_button_{prefix}']
del_button = ui_components[f'delete_diffsynth_controlnet_button_{prefix}']
accordion = ui_components[f'diffsynth_controlnet_accordion_{prefix}']
arch_comp = ui_components.get(f'model_arch_{prefix}')
actual_arch_comp = arch_comp if arch_comp else gr.State("Z-Image")
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, arch_val):
cn_full_config = load_diffsynth_controlnet_config()
architectures_dict = ARCHITECTURES_CONFIG.get('architectures', {})
controlnet_key = architectures_dict.get(arch_val, {}).get("controlnet_key", arch_val)
cn_config = cn_full_config.get(controlnet_key, [])
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, arch_val):
cn_full_config = load_diffsynth_controlnet_config()
architectures_dict = ARCHITECTURES_CONFIG.get('architectures', {})
controlnet_key = architectures_dict.get(arch_val, {}).get("controlnet_key", arch_val)
cn_config = cn_full_config.get(controlnet_key, [])
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], actual_arch_comp],
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], actual_arch_comp],
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_flux1_ipadapter_event_handlers(prefix):
fipa_rows = ui_components.get(f'flux1_ipadapter_rows_{prefix}')
if not fipa_rows: return
count_state = ui_components[f'flux1_ipadapter_count_state_{prefix}']
add_button = ui_components[f'add_flux1_ipadapter_button_{prefix}']
del_button = ui_components[f'delete_flux1_ipadapter_button_{prefix}']
def add_fipa_row(c):
c += 1
return {
count_state: c,
fipa_rows[c - 1]: gr.update(visible=True),
add_button: gr.update(visible=c < MAX_IPADAPTERS),
del_button: gr.update(visible=True),
}
def del_fipa_row(c):
c -= 1
return {
count_state: c,
fipa_rows[c]: gr.update(visible=False),
add_button: gr.update(visible=True),
del_button: gr.update(visible=c > 0),
}
add_outputs = [count_state, add_button, del_button] + fipa_rows
del_outputs = [count_state, add_button, del_button] + fipa_rows
add_button.click(fn=add_fipa_row, inputs=[count_state], outputs=add_outputs, show_progress=False)
del_button.click(fn=del_fipa_row, inputs=[count_state], outputs=del_outputs, show_progress=False)
def create_style_event_handlers(prefix):
style_rows = ui_components.get(f'style_rows_{prefix}')
if not style_rows: return
count_state = ui_components[f'style_count_state_{prefix}']
add_button = ui_components[f'add_style_button_{prefix}']
del_button = ui_components[f'delete_style_button_{prefix}']
def add_style_row(c):
c += 1
return {
count_state: c,
style_rows[c - 1]: gr.update(visible=True),
add_button: gr.update(visible=c < 5),
del_button: gr.update(visible=True),
}
def del_style_row(c):
c -= 1
return {
count_state: c,
style_rows[c]: gr.update(visible=False),
add_button: gr.update(visible=True),
del_button: gr.update(visible=c > 0),
}
add_outputs = [count_state, add_button, del_button] + style_rows
del_outputs = [count_state, add_button, del_button] + style_rows
add_button.click(fn=add_style_row, inputs=[count_state], outputs=add_outputs, show_progress=False)
del_button.click(fn=del_style_row, inputs=[count_state], outputs=del_outputs, show_progress=False)
def create_ipadapter_event_handlers(prefix):
ipa_rows = ui_components.get(f'ipadapter_rows_{prefix}')
if not ipa_rows: return
ipa_lora_strengths = ui_components[f'ipadapter_lora_strengths_{prefix}']
ipa_final_preset = ui_components[f'ipadapter_final_preset_{prefix}']
ipa_final_lora_strength = ui_components[f'ipadapter_final_lora_strength_{prefix}']
count_state = ui_components[f'ipadapter_count_state_{prefix}']
add_button = ui_components[f'add_ipadapter_button_{prefix}']
del_button = ui_components[f'delete_ipadapter_button_{prefix}']
accordion = ui_components[f'ipadapter_accordion_{prefix}']
def add_ipa_row(c):
c += 1
return {
count_state: c,
ipa_rows[c - 1]: gr.update(visible=True),
add_button: gr.update(visible=c < MAX_IPADAPTERS),
del_button: gr.update(visible=True),
}
def del_ipa_row(c):
c -= 1
return {
count_state: c,
ipa_rows[c]: gr.update(visible=False),
add_button: gr.update(visible=True),
del_button: gr.update(visible=c > 0),
}
add_outputs = [count_state, add_button, del_button] + ipa_rows
del_outputs = [count_state, add_button, del_button] + ipa_rows
add_button.click(fn=add_ipa_row, inputs=[count_state], outputs=add_outputs, show_progress=False)
del_button.click(fn=del_ipa_row, inputs=[count_state], outputs=del_outputs, show_progress=False)
def on_preset_change(preset_value):
config = load_ipadapter_config()
faceid_presets = []
if config:
faceid_presets.extend(config.get("IPAdapter_FaceID_presets", {}).get("SDXL", []))
faceid_presets.extend(config.get("IPAdapter_FaceID_presets", {}).get("SD1.5", []))
is_visible = preset_value in faceid_presets
updates = [gr.update(visible=is_visible)] * (MAX_IPADAPTERS + 1)
return updates
all_lora_strength_sliders = [ipa_final_lora_strength] + ipa_lora_strengths
ipa_final_preset.change(fn=on_preset_change, inputs=[ipa_final_preset], outputs=all_lora_strength_sliders, show_progress=False)
accordion.expand(fn=lambda *imgs: [gr.update() for _ in imgs], inputs=ui_components[f'ipadapter_images_{prefix}'], outputs=ui_components[f'ipadapter_images_{prefix}'], show_progress=False)
def create_reference_latent_event_handlers(prefix):
ref_rows = ui_components.get(f'reference_latent_rows_{prefix}')
if not ref_rows: return
count_state = ui_components[f'reference_latent_count_state_{prefix}']
add_button = ui_components[f'add_reference_latent_button_{prefix}']
del_button = ui_components[f'delete_reference_latent_button_{prefix}']
images = ui_components[f'reference_latent_images_{prefix}']
def add_ref_row(c):
c += 1
return {
count_state: c,
ref_rows[c - 1]: gr.update(visible=True),
add_button: gr.update(visible=c < 10),
del_button: gr.update(visible=True),
}
def del_ref_row(c):
c -= 1
return {
count_state: c,
ref_rows[c]: gr.update(visible=False),
images[c]: None,
add_button: gr.update(visible=True),
del_button: gr.update(visible=c > 0),
}
add_outputs = [count_state, add_button, del_button] + ref_rows
del_outputs = [count_state, add_button, del_button] + ref_rows + images
add_button.click(fn=add_ref_row, inputs=[count_state], outputs=add_outputs, show_progress=False)
del_button.click(fn=del_ref_row, inputs=[count_state], outputs=del_outputs, show_progress=False)
def create_embedding_event_handlers(prefix):
rows = ui_components[f'embedding_rows_{prefix}']
rows = ui_components.get(f'embedding_rows_{prefix}')
if not rows: return
ids = ui_components[f'embeddings_ids_{prefix}']
files = ui_components[f'embeddings_files_{prefix}']
count_state = ui_components[f'embedding_count_state_{prefix}']26 unmodified lines del_button.click(fn=del_row, inputs=[count_state], outputs=del_outputs, show_progress=False)
def create_conditioning_event_handlers(prefix):
rows = ui_components[f'conditioning_rows_{prefix}']
rows = ui_components.get(f'conditioning_rows_{prefix}')
if not rows: return
prompts = ui_components[f'conditioning_prompts_{prefix}']
count_state = ui_components[f'conditioning_count_state_{prefix}']
add_button = ui_components[f'add_conditioning_button_{prefix}']22 unmodified lines 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)
def create_reference_latent_event_handlers(prefix):
rows = ui_components[f'reference_latent_rows_{prefix}']
images = ui_components[f'reference_latent_images_{prefix}']
count_state = ui_components[f'reference_latent_count_state_{prefix}']
add_button = ui_components[f'add_reference_latent_button_{prefix}']
del_button = ui_components[f'delete_reference_latent_button_{prefix}']
def add_row(c):
c += 1
return {
count_state: c,
rows[c - 1]: gr.update(visible=True),
add_button: gr.update(visible=c < MAX_REFERENCE_LATENTS),
del_button: gr.update(visible=True),
}
def del_row(c):
c -= 1
return {
count_state: c,
rows[c]: gr.update(visible=False),
images[c]: None,
add_button: gr.update(visible=True),
del_button: gr.update(visible=c > 0),
}
add_outputs = [count_state, add_button, del_button] + rows
del_outputs = [count_state, add_button, del_button] + rows + images
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)
def on_vae_upload(file_obj):
if not file_obj:20 unmodified lines def create_run_event(prefix: str, task_type: str):
run_inputs_map = {
'model_display_name': ui_components[f'base_model_{prefix}'],
'positive_prompt': ui_components[f'prompt_{prefix}'],
'negative_prompt': ui_components[f'neg_prompt_{prefix}'],
'seed': ui_components[f'seed_{prefix}'],
'batch_size': ui_components[f'batch_size_{prefix}'],
'guidance_scale': ui_components[f'cfg_{prefix}'],
'num_inference_steps': ui_components[f'steps_{prefix}'],
'sampler': ui_components[f'sampler_{prefix}'],
'scheduler': ui_components[f'scheduler_{prefix}'],
'zero_gpu_duration': ui_components[f'zero_gpu_{prefix}'],
'civitai_api_key': ui_components.get(f'civitai_api_key_{prefix}'),
'clip_skip': ui_components[f'clip_skip_{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 task_type not in ['img2img', 'inpaint']:
run_inputs_map.update({'width': ui_components[f'width_{prefix}'], 'height': ui_components[f'height_{prefix}']})
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}'},
'outpaint': {'outpaint_image': f'input_image_{prefix}', 'outpaint_left': f'outpaint_left_{prefix}', 'outpaint_top': f'outpaint_top_{prefix}', 'outpaint_right': f'outpaint_right_{prefix}', 'outpaint_bottom': f'outpaint_bottom_{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]
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}', [])
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_components = ui_components.get(f'all_reference_latent_components_flat_{prefix}', [])
reference_latent_data_components = ui_components.get(f'all_reference_latent_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}')1 unmodified line
input_keys = list(run_inputs_map.keys())
input_list_flat = [v for v in run_inputs_map.values() if v is not None]
input_list_flat += lora_data_components + embedding_data_components + conditioning_data_components + reference_latent_components
all_chains = [
lora_data_components, controlnet_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
]
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)
ui_dict['lora_data'] = list(args[arg_idx : arg_idx + len(lora_data_components)])
arg_idx += len(lora_data_components)
ui_dict['embedding_data'] = list(args[arg_idx : arg_idx + len(embedding_data_components)])
arg_idx += len(embedding_data_components)
ui_dict['conditioning_data'] = list(args[arg_idx : arg_idx + len(conditioning_data_components)])
arg_idx += len(conditioning_data_components)
ui_dict['reference_latent_data'] = list(args[arg_idx : arg_idx + len(reference_latent_components)])
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('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)
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:
ui_components[f'run_{prefix}'].click(
fn=lambda *args, progress=gr.Progress(track_tqdm=True): generate_image_wrapper(create_ui_inputs_dict(*args), progress),
inputs=input_list_flat,
outputs=[ui_components[f'result_{prefix}']]
)
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]
)
def make_update_fn(m_comp, cat_comp, cs_comp, ar_comp, width_comp, height_comp, cn_types, cn_series, cn_filepaths, diffsynth_cn_types, diffsynth_cn_series, diffsynth_cn_filepaths, ipa_preset, lora_acc, cn_acc, diffsynth_cn_acc, ipa_acc, sd3_ipa_acc, flux1_ipa_acc, style_acc, embed_acc, cond_acc, ref_latent_acc, guidance_comp, prompt_comp, neg_prompt_comp, steps_comp, cfg_comp, sampler_comp, scheduler_comp):
def update_fn(*args):
arch = args[0]
category = args[1]
current_ar = args[2] if len(args) > 2 else None
from core.settings import MODEL_TYPE_MAP, MODEL_MAP_CHECKPOINT, FEATURES_CONFIG, ARCHITECTURES_CONFIG, MODEL_DEFAULTS_CONFIG, ARCH_CATEGORIES_MAP
from utils.app_utils import get_model_generation_defaults
if arch == "ALL":
valid_cats = list(set(cat for cats in ARCH_CATEGORIES_MAP.values() for cat in cats))
else:
valid_cats = ARCH_CATEGORIES_MAP.get(arch, [])
cat_choices = ["ALL"] + sorted(valid_cats)
new_category = category if category in cat_choices else "ALL"
choices = []
for name, info in MODEL_MAP_CHECKPOINT.items():
m_arch = info[2]
m_cat = info[4] if len(info) > 4 else None
arch_match = (arch == "ALL" or m_arch == arch)
cat_match = (new_category == "ALL" or m_cat == new_category)
if arch_match and cat_match:
choices.append(name)
val = choices[0] if choices else None
updates = {
m_comp: gr.update(choices=choices, value=val),
cat_comp: gr.update(choices=cat_choices, value=new_category)
}
m_type = MODEL_TYPE_MAP.get(val, "SDXL") if val else "SDXL"
architectures_dict = ARCHITECTURES_CONFIG.get('architectures', {})
arch_model_type = architectures_dict.get(m_type, {}).get("model_type", m_type.lower().replace(" ", "").replace(".", ""))
arch_features = FEATURES_CONFIG.get(arch_model_type, FEATURES_CONFIG.get('default', {}))
enabled_chains = arch_features.get('enabled_chains', [])
if lora_acc: updates[lora_acc] = gr.update(visible=('lora' in enabled_chains))
if cn_acc: updates[cn_acc] = gr.update(visible=('controlnet' in enabled_chains))
if diffsynth_cn_acc: updates[diffsynth_cn_acc] = gr.update(visible=('controlnet_model_patch' in enabled_chains))
if ipa_acc: updates[ipa_acc] = gr.update(visible=('ipadapter' in enabled_chains))
if flux1_ipa_acc: updates[flux1_ipa_acc] = gr.update(visible=('flux1_ipadapter' in enabled_chains))
if sd3_ipa_acc: updates[sd3_ipa_acc] = gr.update(visible=('sd3_ipadapter' in enabled_chains))
if style_acc: updates[style_acc] = gr.update(visible=('style' in enabled_chains))
if embed_acc: updates[embed_acc] = gr.update(visible=('embedding' in enabled_chains))
if cond_acc: updates[cond_acc] = gr.update(visible=('conditioning' in enabled_chains))
if ref_latent_acc: updates[ref_latent_acc] = gr.update(visible=('reference_latent' in enabled_chains))
if cs_comp:
updates[cs_comp] = gr.update(visible=(arch_model_type == "sd15"))
if guidance_comp:
updates[guidance_comp] = gr.update(visible=(arch_model_type == "flux1"))
if ar_comp:
res_key = arch_model_type
if res_key not in RESOLUTION_MAP:
res_key = 'sdxl'
res_map = RESOLUTION_MAP.get(res_key, {})
target_ar = current_ar if current_ar in res_map else (list(res_map.keys())[0] if res_map else "1:1 (Square)")
updates[ar_comp] = gr.update(choices=list(res_map.keys()), value=target_ar)
if width_comp and height_comp and target_ar in res_map:
updates[width_comp] = gr.update(value=res_map[target_ar][0])
updates[height_comp] = gr.update(value=res_map[target_ar][1])
controlnet_key = architectures_dict.get(m_type, {}).get("controlnet_key", m_type)
all_types, default_type, series_choices, default_series, filepath = get_cn_defaults(controlnet_key)
for t_comp in cn_types:
updates[t_comp] = gr.update(choices=all_types, value=default_type)
for s_comp in cn_series:
updates[s_comp] = gr.update(choices=series_choices, value=default_series)
for f_comp in cn_filepaths:
updates[f_comp] = filepath
diffsynth_all_types, diffsynth_default_type, diffsynth_series_choices, diffsynth_default_series, diffsynth_filepath = get_diffsynth_cn_defaults(controlnet_key)
for t_comp in diffsynth_cn_types:
updates[t_comp] = gr.update(choices=diffsynth_all_types, value=diffsynth_default_type)
for s_comp in diffsynth_cn_series:
updates[s_comp] = gr.update(choices=diffsynth_series_choices, value=diffsynth_default_series)
for f_comp in diffsynth_cn_filepaths:
updates[f_comp] = diffsynth_filepath
if ipa_preset and (arch_model_type in ["sdxl", "sd15", "sd35"]):
config = load_ipadapter_config()
ipa_arch_key = "SDXL" if arch_model_type in ["sdxl", "sd35"] else "SD1.5"
std_presets = config.get("IPAdapter_presets", {}).get(ipa_arch_key, [])
face_presets = config.get("IPAdapter_FaceID_presets", {}).get(ipa_arch_key, [])
all_ipa_presets = std_presets + face_presets
default_ipa = all_ipa_presets[0] if all_ipa_presets else None
updates[ipa_preset] = gr.update(choices=all_ipa_presets, value=default_ipa)
defaults = get_model_generation_defaults(val, arch_model_type, MODEL_DEFAULTS_CONFIG)
if steps_comp: updates[steps_comp] = gr.update(value=defaults.get('steps'))
if cfg_comp: updates[cfg_comp] = gr.update(value=defaults.get('cfg'))
if sampler_comp: updates[sampler_comp] = gr.update(value=defaults.get('sampler_name'))
if scheduler_comp: updates[scheduler_comp] = gr.update(value=defaults.get('scheduler'))
if prompt_comp: updates[prompt_comp] = gr.update(value=defaults.get('positive_prompt'))
if neg_prompt_comp: updates[neg_prompt_comp] = gr.update(value=defaults.get('negative_prompt'))
return updates
return update_fn
def make_model_change_fn(cat_comp_ref, cs_comp, ar_comp, width_comp, height_comp, cn_types, cn_series, cn_filepaths, diffsynth_cn_types, diffsynth_cn_series, diffsynth_cn_filepaths, arch_comp_ref, ipa_preset, lora_acc, cn_acc, diffsynth_cn_acc, ipa_acc, sd3_ipa_acc, flux1_ipa_acc, style_acc, embed_acc, cond_acc, ref_latent_acc, guidance_comp, prompt_comp, neg_prompt_comp, steps_comp, cfg_comp, sampler_comp, scheduler_comp):
def change_fn(*args):
model_name = args[0]
idx = 1
current_arch = args[idx] if arch_comp_ref and idx < len(args) else None
if arch_comp_ref: idx += 1
current_cat = args[idx] if cat_comp_ref and idx < len(args) else None
if cat_comp_ref: idx += 1
current_ar = args[idx] if idx < len(args) else None
from core.settings import MODEL_TYPE_MAP, FEATURES_CONFIG, ARCHITECTURES_CONFIG, MODEL_DEFAULTS_CONFIG, ARCH_CATEGORIES_MAP, MODEL_MAP_CHECKPOINT
from utils.app_utils import get_model_generation_defaults
m_type = MODEL_TYPE_MAP.get(model_name, "SDXL")
m_info = MODEL_MAP_CHECKPOINT.get(model_name)
m_cat = m_info[4] if m_info and len(m_info) > 4 else None
if not m_cat: m_cat = "ALL"
updates = {}
target_arch = m_type
if arch_comp_ref:
if current_arch == "ALL":
updates[arch_comp_ref] = gr.update()
target_arch = "ALL"
else:
updates[arch_comp_ref] = m_type
if cat_comp_ref:
if target_arch == "ALL":
valid_cats = list(set(cat for cats in ARCH_CATEGORIES_MAP.values() for cat in cats))
else:
valid_cats = ARCH_CATEGORIES_MAP.get(target_arch, [])
cat_choices = ["ALL"] + sorted(valid_cats)
if current_cat == "ALL":
updates[cat_comp_ref] = gr.update(choices=cat_choices)
else:
updates[cat_comp_ref] = gr.update(choices=cat_choices, value=m_cat)
architectures_dict = ARCHITECTURES_CONFIG.get('architectures', {})
arch_model_type = architectures_dict.get(m_type, {}).get("model_type", m_type.lower().replace(" ", "").replace(".", ""))
arch_features = FEATURES_CONFIG.get(arch_model_type, FEATURES_CONFIG.get('default', {}))
enabled_chains = arch_features.get('enabled_chains', [])
if lora_acc: updates[lora_acc] = gr.update(visible=('lora' in enabled_chains))
if cn_acc: updates[cn_acc] = gr.update(visible=('controlnet' in enabled_chains))
if diffsynth_cn_acc: updates[diffsynth_cn_acc] = gr.update(visible=('controlnet_model_patch' in enabled_chains))
if ipa_acc: updates[ipa_acc] = gr.update(visible=('ipadapter' in enabled_chains))
if flux1_ipa_acc: updates[flux1_ipa_acc] = gr.update(visible=('flux1_ipadapter' in enabled_chains))
if sd3_ipa_acc: updates[sd3_ipa_acc] = gr.update(visible=('sd3_ipadapter' in enabled_chains))
if style_acc: updates[style_acc] = gr.update(visible=('style' in enabled_chains))
if embed_acc: updates[embed_acc] = gr.update(visible=('embedding' in enabled_chains))
if cond_acc: updates[cond_acc] = gr.update(visible=('conditioning' in enabled_chains))
if ref_latent_acc: updates[ref_latent_acc] = gr.update(visible=('reference_latent' in enabled_chains))
if cs_comp:
updates[cs_comp] = gr.update(visible=(arch_model_type == "sd15"))
if guidance_comp:
updates[guidance_comp] = gr.update(visible=(arch_model_type == "flux1"))
if ar_comp:
res_key = arch_model_type
if res_key not in RESOLUTION_MAP:
res_key = 'sdxl'
res_map = RESOLUTION_MAP.get(res_key, {})
target_ar = current_ar if current_ar in res_map else (list(res_map.keys())[0] if res_map else "1:1 (Square)")
updates[ar_comp] = gr.update(choices=list(res_map.keys()), value=target_ar)
if width_comp and height_comp and target_ar in res_map:
updates[width_comp] = gr.update(value=res_map[target_ar][0])
updates[height_comp] = gr.update(value=res_map[target_ar][1])
controlnet_key = architectures_dict.get(m_type, {}).get("controlnet_key", m_type)
all_types, default_type, series_choices, default_series, filepath = get_cn_defaults(controlnet_key)
for t_comp in cn_types:
updates[t_comp] = gr.update(choices=all_types, value=default_type)
for s_comp in cn_series:
updates[s_comp] = gr.update(choices=series_choices, value=default_series)
for f_comp in cn_filepaths:
updates[f_comp] = filepath
diffsynth_all_types, diffsynth_default_type, diffsynth_series_choices, diffsynth_default_series, diffsynth_filepath = get_diffsynth_cn_defaults(controlnet_key)
for t_comp in diffsynth_cn_types:
updates[t_comp] = gr.update(choices=diffsynth_all_types, value=diffsynth_default_type)
for s_comp in diffsynth_cn_series:
updates[s_comp] = gr.update(choices=diffsynth_series_choices, value=diffsynth_default_series)
for f_comp in diffsynth_cn_filepaths:
updates[f_comp] = diffsynth_filepath
if ipa_preset and (arch_model_type in ["sdxl", "sd15", "sd35"]):
config = load_ipadapter_config()
ipa_arch_key = "SDXL" if arch_model_type in ["sdxl", "sd35"] else "SD1.5"
std_presets = config.get("IPAdapter_presets", {}).get(ipa_arch_key, [])
face_presets = config.get("IPAdapter_FaceID_presets", {}).get(ipa_arch_key, [])
all_ipa_presets = std_presets + face_presets
default_ipa = all_ipa_presets[0] if all_ipa_presets else None
updates[ipa_preset] = gr.update(choices=all_ipa_presets, value=default_ipa)
defaults = get_model_generation_defaults(model_name, arch_model_type, MODEL_DEFAULTS_CONFIG)
if steps_comp: updates[steps_comp] = gr.update(value=defaults.get('steps'))
if cfg_comp: updates[cfg_comp] = gr.update(value=defaults.get('cfg'))
if sampler_comp: updates[sampler_comp] = gr.update(value=defaults.get('sampler_name'))
if scheduler_comp: updates[scheduler_comp] = gr.update(value=defaults.get('scheduler'))
if prompt_comp: updates[prompt_comp] = gr.update(value=defaults.get('positive_prompt'))
if neg_prompt_comp: updates[neg_prompt_comp] = gr.update(value=defaults.get('negative_prompt'))
return updates
return change_fn
for prefix, task_type in [
("txt2img", "txt2img"), ("img2img", "img2img"), ("inpaint", "inpaint"),
("outpaint", "outpaint"), ("hires_fix", "hires_fix"),
]:
model_dropdown = ui_components.get(f'base_model_{prefix}')
steps_slider = ui_components.get(f'steps_{prefix}')
cfg_slider = ui_components.get(f'cfg_{prefix}')
if all([model_dropdown, steps_slider, cfg_slider]):
model_dropdown.change(
fn=on_model_change,
inputs=[model_dropdown],
outputs=[steps_slider, cfg_slider],
show_progress=False
)
if f'add_lora_button_{prefix}' in ui_components:
create_lora_event_handlers(prefix)
lora_uploads = ui_components[f'lora_uploads_{prefix}']
lora_ids = ui_components[f'lora_ids_{prefix}']
lora_sources = ui_components[f'lora_sources_{prefix}']
for i in range(MAX_LORAS):
lora_uploads[i].upload(
fn=on_lora_upload,
inputs=[lora_uploads[i]],
outputs=[lora_ids[i], lora_sources[i]],
show_progress=False
)
arch_comp = ui_components.get(f'model_arch_{prefix}')
cat_comp = ui_components.get(f'model_cat_{prefix}')
model_comp = ui_components.get(f'base_model_{prefix}')
clip_skip_comp = ui_components.get(f'clip_skip_{prefix}') or ui_components.get(f'{prefix}_clip_skip')
guidance_comp = ui_components.get(f'guidance_{prefix}') or ui_components.get(f'{prefix}_guidance')
aspect_ratio_comp = ui_components.get(f'aspect_ratio_{prefix}') or ui_components.get(f'{prefix}_aspect_ratio_dropdown')
width_comp = ui_components.get(f'width_{prefix}') or ui_components.get(f'{prefix}_width')
height_comp = ui_components.get(f'height_{prefix}') or ui_components.get(f'{prefix}_height')
cn_types_list = ui_components.get(f'controlnet_types_{prefix}', [])
cn_series_list = ui_components.get(f'controlnet_series_{prefix}', [])
cn_filepaths_list = ui_components.get(f'controlnet_filepaths_{prefix}', [])
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}', [])
lora_accordion = ui_components.get(f'lora_accordion_{prefix}')
cn_accordion = ui_components.get(f'controlnet_accordion_{prefix}')
diffsynth_cn_accordion = ui_components.get(f'diffsynth_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}')
style_accordion = ui_components.get(f'style_accordion_{prefix}')
embedding_accordion = ui_components.get(f'embedding_accordion_{prefix}')
conditioning_accordion = ui_components.get(f'conditioning_accordion_{prefix}')
ref_latent_accordion = ui_components.get(f'reference_latent_accordion_{prefix}')
ipa_preset_list = ui_components.get(f'ipadapter_final_preset_{prefix}')
prompt_comp = ui_components.get(f'prompt_{prefix}') or ui_components.get(f'{prefix}_positive_prompt')
neg_prompt_comp = ui_components.get(f'neg_prompt_{prefix}') or ui_components.get(f'{prefix}_negative_prompt')
steps_comp = ui_components.get(f'steps_{prefix}') or ui_components.get(f'{prefix}_steps')
cfg_comp = ui_components.get(f'cfg_{prefix}') or ui_components.get(f'{prefix}_cfg')
sampler_comp = ui_components.get(f'sampler_{prefix}') or ui_components.get(f'{prefix}_sampler_name')
scheduler_comp = ui_components.get(f'scheduler_{prefix}') or ui_components.get(f'{prefix}_scheduler')
extra_comps = [prompt_comp, neg_prompt_comp, steps_comp, cfg_comp, sampler_comp, scheduler_comp, width_comp, height_comp]
valid_extra_comps = [c for c in extra_comps if c is not None]
if arch_comp and cat_comp and model_comp:
outputs = [model_comp, cat_comp]
if clip_skip_comp: outputs.append(clip_skip_comp)
if guidance_comp: outputs.append(guidance_comp)
if aspect_ratio_comp: outputs.append(aspect_ratio_comp)
outputs.extend(cn_types_list + cn_series_list + cn_filepaths_list)
outputs.extend(diffsynth_cn_types_list + diffsynth_cn_series_list + diffsynth_cn_filepaths_list)
if lora_accordion: outputs.append(lora_accordion)
if cn_accordion: outputs.append(cn_accordion)
if diffsynth_cn_accordion: outputs.append(diffsynth_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)
if style_accordion: outputs.append(style_accordion)
if embedding_accordion: outputs.append(embedding_accordion)
if conditioning_accordion: outputs.append(conditioning_accordion)
if ref_latent_accordion: outputs.append(ref_latent_accordion)
if ipa_preset_list: outputs.append(ipa_preset_list)
outputs.extend(valid_extra_comps)
update_fn = make_update_fn(
model_comp, cat_comp, clip_skip_comp, aspect_ratio_comp, width_comp, height_comp,
cn_types_list, cn_series_list, cn_filepaths_list,
diffsynth_cn_types_list, diffsynth_cn_series_list, diffsynth_cn_filepaths_list,
ipa_preset_list, lora_accordion, cn_accordion, diffsynth_cn_accordion, ipa_accordion, sd3_ipa_accordion, flux1_ipa_accordion, style_accordion, embedding_accordion, conditioning_accordion,
ref_latent_accordion, guidance_comp, prompt_comp, neg_prompt_comp, steps_comp, cfg_comp, sampler_comp, scheduler_comp
)
inputs = [arch_comp, cat_comp]
if aspect_ratio_comp:
inputs.append(aspect_ratio_comp)
arch_comp.change(fn=update_fn, inputs=inputs, outputs=outputs)
cat_comp.change(fn=update_fn, inputs=inputs, outputs=outputs)
if f'add_embedding_button_{prefix}' in ui_components:
create_embedding_event_handlers(prefix)
if f'embeddings_uploads_{prefix}' in ui_components:
emb_uploads = ui_components[f'embeddings_uploads_{prefix}']
emb_ids = ui_components[f'embeddings_ids_{prefix}']
emb_sources = ui_components[f'embeddings_sources_{prefix}']
emb_files = ui_components[f'embeddings_files_{prefix}']
for i in range(MAX_EMBEDDINGS):
emb_uploads[i].upload(
fn=on_embedding_upload,
inputs=[emb_uploads[i]],
outputs=[emb_ids[i], emb_sources[i], emb_files[i]],
show_progress=False
)
if f'add_conditioning_button_{prefix}' in ui_components: create_conditioning_event_handlers(prefix)
if f'add_reference_latent_button_{prefix}' in ui_components: create_reference_latent_event_handlers(prefix)
if f'vae_source_{prefix}' in ui_components:
upload_button = ui_components.get(f'vae_upload_button_{prefix}')
if upload_button:
upload_button.upload(
fn=on_vae_upload,
inputs=[upload_button],
outputs=[
ui_components[f'vae_id_{prefix}'],
ui_components[f'vae_source_{prefix}'],
ui_components[f'vae_file_{prefix}']
]
if model_comp:
outputs2 = []
if arch_comp: outputs2.append(arch_comp)
if cat_comp: outputs2.append(cat_comp)
if clip_skip_comp: outputs2.append(clip_skip_comp)
if guidance_comp: outputs2.append(guidance_comp)
if aspect_ratio_comp: outputs2.append(aspect_ratio_comp)
outputs2.extend(cn_types_list + cn_series_list + cn_filepaths_list)
outputs2.extend(diffsynth_cn_types_list + diffsynth_cn_series_list + diffsynth_cn_filepaths_list)
if lora_accordion: outputs2.append(lora_accordion)
if cn_accordion: outputs2.append(cn_accordion)
if diffsynth_cn_accordion: outputs2.append(diffsynth_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)
if style_accordion: outputs2.append(style_accordion)
if embedding_accordion: outputs2.append(embedding_accordion)
if conditioning_accordion: outputs2.append(conditioning_accordion)
if ref_latent_accordion: outputs2.append(ref_latent_accordion)
if ipa_preset_list: outputs2.append(ipa_preset_list)
outputs2.extend(valid_extra_comps)
if outputs2:
inputs2 = [model_comp]
if arch_comp: inputs2.append(arch_comp)
if cat_comp: inputs2.append(cat_comp)
if aspect_ratio_comp: inputs2.append(aspect_ratio_comp)
change_fn = make_model_change_fn(
cat_comp, clip_skip_comp, aspect_ratio_comp, width_comp, height_comp,
cn_types_list, cn_series_list, cn_filepaths_list,
diffsynth_cn_types_list, diffsynth_cn_series_list, diffsynth_cn_filepaths_list,
arch_comp, ipa_preset_list, lora_accordion, cn_accordion, diffsynth_cn_accordion, ipa_accordion, sd3_ipa_accordion, flux1_ipa_accordion, style_accordion, embedding_accordion, conditioning_accordion,
ref_latent_accordion, guidance_comp, prompt_comp, neg_prompt_comp, steps_comp, cfg_comp, sampler_comp, scheduler_comp
)
model_comp.change(fn=change_fn, inputs=inputs2, outputs=outputs2)
create_lora_event_handlers(prefix)
create_controlnet_event_handlers(prefix)
create_diffsynth_controlnet_event_handlers(prefix)
create_ipadapter_event_handlers(prefix)
create_embedding_event_handlers(prefix)
create_conditioning_event_handlers(prefix)
create_flux1_ipadapter_event_handlers(prefix)
create_style_event_handlers(prefix)
create_reference_latent_event_handlers(prefix)
create_run_event(prefix, task_type)
def on_aspect_ratio_change(ratio_key, model_display_name):
model_type = MODEL_TYPE_MAP.get(model_display_name, 'sdxl').lower()
res_map = RESOLUTION_MAP.get(model_type, RESOLUTION_MAP.get("sdxl", {}))
w, h = res_map.get(ratio_key, (1024, 1024))
return w, h
for prefix in ["txt2img", "img2img", "inpaint", "outpaint", "hires_fix"]:
if f'aspect_ratio_{prefix}' in ui_components:
aspect_ratio_dropdown = ui_components[f'aspect_ratio_{prefix}']
width_component = ui_components[f'width_{prefix}']
height_component = ui_components[f'height_{prefix}']
model_dropdown = ui_components[f'base_model_{prefix}']
aspect_ratio_dropdown.change(fn=on_aspect_ratio_change, inputs=[aspect_ratio_dropdown, model_dropdown], outputs=[width_component, height_component], show_progress=False)
if 'view_mode_inpaint' in ui_components:
def toggle_inpaint_fullscreen_view(view_mode):
is_fullscreen = (view_mode == "Fullscreen View")
other_elements_visible = not is_fullscreen
editor_height = 800 if is_fullscreen else 272
return {
ui_components['model_and_run_row_inpaint']: gr.update(visible=other_elements_visible),
updates = {
ui_components['prompts_column_inpaint']: gr.update(visible=other_elements_visible),
ui_components['params_and_gallery_row_inpaint']: gr.update(visible=other_elements_visible),
ui_components['accordion_wrapper_inpaint']: gr.update(visible=other_elements_visible),
ui_components['input_image_dict_inpaint']: gr.update(height=editor_height),
}
model_and_run_rows = ui_components.get('model_and_run_row_inpaint', [])
for row in model_and_run_rows:
updates[row] = gr.update(visible=other_elements_visible)
return updates
output_components = []
model_and_run_rows = ui_components.get('model_and_run_row_inpaint', [])
if isinstance(model_and_run_rows, list):
output_components.extend(model_and_run_rows)
else:
output_components.append(model_and_run_rows)
output_components = [
ui_components['model_and_run_row_inpaint'], ui_components['prompts_column_inpaint'],
ui_components['params_and_gallery_row_inpaint'], ui_components['accordion_wrapper_inpaint'],
output_components.extend([
ui_components['prompts_column_inpaint'],
ui_components['params_and_gallery_row_inpaint'],
ui_components['accordion_wrapper_inpaint'],
ui_components['input_image_dict_inpaint']
]
ui_components['view_mode_inpaint'].change(fn=toggle_inpaint_fullscreen_view, inputs=[ui_components['view_mode_inpaint']], outputs=output_components, show_progress=False)
])
ui_components['view_mode_inpaint'].change(
fn=toggle_inpaint_fullscreen_view,
inputs=[ui_components['view_mode_inpaint']],
outputs=output_components,
show_progress=False
)
def run_on_load():
all_updates = {}
def initialize_all_cn_dropdowns():
from core.settings import MODEL_TYPE_MAP, MODEL_MAP_CHECKPOINT, ARCHITECTURES_CONFIG
default_model_name = list(MODEL_MAP_CHECKPOINT.keys())[0] if MODEL_MAP_CHECKPOINT else None
default_m_type = MODEL_TYPE_MAP.get(default_model_name, "SDXL") if default_model_name else "SDXL"
architectures_dict = ARCHITECTURES_CONFIG.get('architectures', {})
controlnet_key = architectures_dict.get(default_m_type, {}).get("controlnet_key", default_m_type)
default_preprocessor = "Canny Edge"
model_update = update_preprocessor_models_dropdown(default_preprocessor)
all_updates[ui_components["preprocessor_model_cn"]] = model_update
all_types, default_type, series_choices, default_series, filepath = get_cn_defaults(controlnet_key)
diffsynth_all_types, diffsynth_default_type, diffsynth_series_choices, diffsynth_default_series, diffsynth_filepath = get_diffsynth_cn_defaults(controlnet_key)
settings_outputs = update_preprocessor_settings_ui(default_preprocessor)
dynamic_outputs = ui_components["cn_sliders"] + ui_components["cn_dropdowns"] + ui_components["cn_checkboxes"]
for i, comp in enumerate(dynamic_outputs):
all_updates[comp] = settings_outputs[i]
updates = {}
for prefix in ["txt2img", "img2img", "inpaint", "outpaint", "hires_fix"]:
if f'controlnet_types_{prefix}' in ui_components:
for type_dd in ui_components[f'controlnet_types_{prefix}']:
updates[type_dd] = gr.update(choices=all_types, value=default_type)
for series_dd in ui_components[f'controlnet_series_{prefix}']:
updates[series_dd] = gr.update(choices=series_choices, value=default_series)
for filepath_state in ui_components[f'controlnet_filepaths_{prefix}']:
updates[filepath_state] = filepath
if f'diffsynth_controlnet_types_{prefix}' in ui_components:
for type_dd in ui_components[f'diffsynth_controlnet_types_{prefix}']:
updates[type_dd] = gr.update(choices=diffsynth_all_types, value=diffsynth_default_type)
for series_dd in ui_components[f'diffsynth_controlnet_series_{prefix}']:
updates[series_dd] = gr.update(choices=diffsynth_series_choices, value=diffsynth_default_series)
for filepath_state in ui_components[f'diffsynth_controlnet_filepaths_{prefix}']:
updates[filepath_state] = diffsynth_filepath
return updates
run_button_update, zero_gpu_update = update_run_button_for_cpu(default_preprocessor)
all_updates[ui_components["run_cn"]] = run_button_update
all_updates[ui_components["zero_gpu_cn"]] = zero_gpu_update
def initialize_all_ipa_dropdowns():
config = load_ipadapter_config()
if not config: return {}
from core.settings import MODEL_TYPE_MAP, MODEL_MAP_CHECKPOINT, ARCHITECTURES_CONFIG
default_model_name = list(MODEL_MAP_CHECKPOINT.keys())[0] if MODEL_MAP_CHECKPOINT else None
default_m_type = MODEL_TYPE_MAP.get(default_model_name, "SDXL") if default_model_name else "SDXL"
architectures_dict = ARCHITECTURES_CONFIG.get('architectures', {})
arch_model_type = architectures_dict.get(default_m_type, {}).get("model_type", default_m_type.lower().replace(" ", "").replace(".", ""))
ipa_arch_key = "SDXL" if arch_model_type in ["sdxl", "sd35"] else "SD1.5"
unified_presets = config.get("IPAdapter_presets", {}).get(ipa_arch_key, [])
faceid_presets = config.get("IPAdapter_FaceID_presets", {}).get(ipa_arch_key, [])
all_presets = unified_presets + faceid_presets
default_preset = all_presets[0] if all_presets else None
is_faceid_default = default_preset in faceid_presets
lora_strength_update = gr.update(visible=is_faceid_default)
updates = {}
for prefix in ["txt2img", "img2img", "inpaint", "outpaint", "hires_fix"]:
if f'ipadapter_final_preset_{prefix}' in ui_components:
for lora_strength_slider in ui_components[f'ipadapter_lora_strengths_{prefix}']:
updates[lora_strength_slider] = lora_strength_update
updates[ui_components[f'ipadapter_final_preset_{prefix}']] = gr.update(choices=all_presets, value=default_preset)
updates[ui_components[f'ipadapter_final_lora_strength_{prefix}']] = lora_strength_update
return updates
def run_on_load():
cn_updates = initialize_all_cn_dropdowns()
ipa_updates = initialize_all_ipa_dropdowns()
all_updates = {**cn_updates, **ipa_updates}
return all_updates
all_load_outputs = [
ui_components["preprocessor_model_cn"],
*ui_components["cn_sliders"],
*ui_components["cn_dropdowns"],
*ui_components["cn_checkboxes"],
ui_components["run_cn"],
ui_components["zero_gpu_cn"]
]
all_load_outputs = []
for prefix in ["txt2img", "img2img", "inpaint", "outpaint", "hires_fix"]:
if f'controlnet_types_{prefix}' in ui_components:
all_load_outputs.extend(ui_components[f'controlnet_types_{prefix}'])
all_load_outputs.extend(ui_components[f'controlnet_series_{prefix}'])
all_load_outputs.extend(ui_components[f'controlnet_filepaths_{prefix}'])
if f'diffsynth_controlnet_types_{prefix}' in ui_components:
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'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}'])
all_load_outputs.append(ui_components[f'ipadapter_final_lora_strength_{prefix}'])
if all_load_outputs:
demo.load(
fn=run_on_load,
outputs=all_load_outputs
) )
def on_aspect_ratio_change(ratio_key, model_display_name):
from core.settings import MODEL_TYPE_MAP, ARCHITECTURES_CONFIG
m_type = MODEL_TYPE_MAP.get(model_display_name, 'SDXL')
architectures_dict = ARCHITECTURES_CONFIG.get('architectures', {})
arch_model_type = architectures_dict.get(m_type, {}).get("model_type", m_type.lower().replace(" ", "").replace(".", ""))
res_map = RESOLUTION_MAP.get(arch_model_type, RESOLUTION_MAP.get("sdxl", {}))
w, h = res_map.get(ratio_key, (1024, 1024))
return w, h
for prefix in ["txt2img", "img2img", "inpaint", "outpaint", "hires_fix"]:
aspect_ratio_dropdown = ui_components.get(f'aspect_ratio_{prefix}') or ui_components.get(f'{prefix}_aspect_ratio_dropdown')
width_component = ui_components.get(f'width_{prefix}') or ui_components.get(f'{prefix}_width')
height_component = ui_components.get(f'height_{prefix}') or ui_components.get(f'{prefix}_height')
model_dropdown = ui_components.get(f'base_model_{prefix}')
if aspect_ratio_dropdown and width_component and height_component and model_dropdown:
aspect_ratio_dropdown.change(fn=on_aspect_ratio_change, inputs=[aspect_ratio_dropdown, model_dropdown], outputs=[width_component, height_component], show_progress=False)5 unmodified lines67891011121314151617181991011122413142615162829173118193334202122373839404142432324252627284546293031484932333451525354353637565758596061626364656667686970717273747576777879808182838438394041425 unmodified lines
MAX_DYNAMIC_CONTROLS = 10
def get_preprocessor_choices():
from nodes import NODE_DISPLAY_NAME_MAPPINGS
preprocessor_names = [
display_name for class_name, display_name in NODE_DISPLAY_NAME_MAPPINGS.items()
if "Preprocessor" in class_name or "Segmentor" in class_name or
"Estimator" in class_name or "Detector" in class_name
]
return sorted(list(set(preprocessor_names)))
def build_ui(event_handler_function):
ui_components = {}
with gr.Blocks() as demo:
gr.Markdown("# ImageGen - FLUX.2")
gr.Markdown("# ImageGen - FLUX.2-KV")
gr.Markdown(
"This demo is a streamlined version of the [Comfy web UI](https://github.com/RioShiina47/comfy-webui)'s ImgGen functionality. "
"This demo is a streamlined version of the [Comfy web UI](https://github.com/RioShiina47/comfy-webui)'s [ImageGen](https://huggingface.co/spaces/RioShiina/ImageGen) functionality. "
"Other versions are also available: "
"[Z-Image](https://huggingface.co/spaces/RioShiina/ImageGen-Z-Image), "
"[Qwen-Image](https://huggingface.co/spaces/RioShiina/ImageGen-Qwen-Image), "
"[Anima](https://huggingface.co/spaces/RioShiina/ImageGen-Anima), "
"[Illstrious](https://huggingface.co/spaces/RioShiina/ImageGen-Illstrious), "
"[Illustrious](https://huggingface.co/spaces/RioShiina/ImageGen-Illustrious), "
"[NoobAI](https://huggingface.co/spaces/RioShiina/ImageGen-NoobAI), "
"[Pony](https://huggingface.co/spaces/RioShiina/ImageGen-Pony1), "
"[SDXL](https://huggingface.co/spaces/RioShiina/ImageGen-SDXL)"
"[Pony](https://huggingface.co/spaces/RioShiina/ImageGen-Pony)"
)
with gr.Tabs(elem_id="tabs_container") as tabs:
with gr.TabItem("FLUX.2", id=0):
with gr.Tabs(elem_id="image_gen_tabs") as image_gen_tabs:
with gr.TabItem("Txt2Img", id=0):
ui_components.update(txt2img_ui.create_ui())
with gr.TabItem("Img2Img", id=1):
ui_components.update(img2img_ui.create_ui())
with gr.TabItem("Txt2Img", id=0):
ui_components.update(txt2img_ui.create_ui())
with gr.TabItem("Img2Img", id=1):
ui_components.update(img2img_ui.create_ui())
with gr.TabItem("Inpaint", id=2):
ui_components.update(inpaint_ui.create_ui())
with gr.TabItem("Inpaint", id=2):
ui_components.update(inpaint_ui.create_ui())
with gr.TabItem("Outpaint", id=3):
ui_components.update(outpaint_ui.create_ui())
with gr.TabItem("Outpaint", id=3):
ui_components.update(outpaint_ui.create_ui())
with gr.TabItem("Hires. Fix", id=4):
ui_components.update(hires_fix_ui.create_ui())
ui_components['image_gen_tabs'] = image_gen_tabs
with gr.TabItem("Hires. Fix", id=4):
ui_components.update(hires_fix_ui.create_ui())
with gr.TabItem("Controlnet Preprocessors", id=1):
gr.Markdown("## ControlNet Auxiliary Preprocessors")
gr.Markdown("Powered by [Fannovel16/comfyui_controlnet_aux](https://github.com/Fannovel16/comfyui_controlnet_aux).")
gr.Markdown("Upload an image or video to process it with a ControlNet preprocessor.")
with gr.Row():
with gr.Column(scale=1):
cn_input_type = gr.Radio(["Image", "Video"], label="Input Type", value="Image")
cn_image_input = gr.Image(type="pil", label="Input Image", visible=True, height=384)
cn_video_input = gr.Video(label="Input Video", visible=False)
preprocessor_cn = gr.Dropdown(label="Preprocessor", choices=get_preprocessor_choices(), value="Canny Edge")
preprocessor_model_cn = gr.Dropdown(label="Preprocessor Model", choices=[], value=None, visible=False)
with gr.Column() as preprocessor_settings_ui:
cn_sliders, cn_dropdowns, cn_checkboxes = [], [], []
for i in range(MAX_DYNAMIC_CONTROLS):
cn_sliders.append(gr.Slider(visible=False, label=f"dyn_slider_{i}"))
cn_dropdowns.append(gr.Dropdown(visible=False, label=f"dyn_dropdown_{i}"))
cn_checkboxes.append(gr.Checkbox(visible=False, label=f"dyn_checkbox_{i}"))
run_cn = gr.Button("Run Preprocessor", variant="primary")
with gr.Column(scale=1):
output_gallery_cn = gr.Gallery(label="Output", show_label=False, object_fit="contain", height=512)
zero_gpu_cn = gr.Number(label="ZeroGPU Duration (s)", value=None, placeholder="Default: 60, Max: 120", info="Optional")
ui_components.update({
"cn_input_type": cn_input_type, "cn_image_input": cn_image_input, "cn_video_input": cn_video_input,
"preprocessor_cn": preprocessor_cn, "preprocessor_model_cn": preprocessor_model_cn, "run_cn": run_cn,
"zero_gpu_cn": zero_gpu_cn, "output_gallery_cn": output_gallery_cn,
"preprocessor_settings_ui": preprocessor_settings_ui, "cn_sliders": cn_sliders,
"cn_dropdowns": cn_dropdowns, "cn_checkboxes": cn_checkboxes
})
ui_components["tabs"] = tabs
ui_components["image_gen_tabs"] = tabs
gr.Markdown("<div style='text-align: center; margin-top: 20px;'>Made by RioShiina with ❤️<br><a href='https://github.com/RioShiina47' target='_blank'>GitHub</a> | <a href='https://huggingface.co/RioShiina' target='_blank'>Hugging Face</a> | <a href='https://civitai.com/user/RioShiina' target='_blank'>Civitai</a></div>")
2 unmodified lines3456767891011122 unmodified lines15161718192021222324252126272829302 unmodified lines3334353031363738394011 unmodified lines52535449505556575253585960616263646558666760686970717273677475697071727677787980818283748485862 unmodified linesfrom comfy_integration.nodes import SAMPLER_CHOICES, SCHEDULER_CHOICES
from .ui_components import (
create_lora_settings_ui,
create_embedding_ui,
create_conditioning_ui, create_vae_override_ui, create_api_key_ui,
create_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
)
2 unmodified lines components = {}
with gr.Column():
components.update(create_model_architecture_filter_ui(prefix))
with gr.Row():
components.update(create_category_filter_ui(prefix))
components[f'base_model_{prefix}'] = gr.Dropdown(
label="Base Model",
choices=list(MODEL_MAP_CHECKPOINT.keys()),
value=list(MODEL_MAP_CHECKPOINT.keys())[0],
scale=3
scale=3,
allow_custom_value=True
)
with gr.Column(scale=1):
components[f'run_{prefix}'] = gr.Button("Run Hires. Fix", variant="primary")2 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, placeholder="Describe the final image...")
components[f'neg_prompt_{prefix}'] = gr.Text(label="Negative prompt", lines=3, value="")
components[f'prompt_{prefix}'] = gr.Text(label="Prompt", lines=3)
components[f'neg_prompt_{prefix}'] = gr.Text(label="Negative prompt", lines=3)
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="euler")
components[f'scheduler_{prefix}'] = gr.Dropdown(label="Scheduler", choices=SCHEDULER_CHOICES, value="simple")
components[f'sampler_{prefix}'] = gr.Dropdown(label="Sampler", choices=SAMPLER_CHOICES, value=SAMPLER_CHOICES[0])
components[f'scheduler_{prefix}'] = gr.Dropdown(label="Scheduler", choices=SCHEDULER_CHOICES, value='normal' if 'normal' in SCHEDULER_CHOICES else SCHEDULER_CHOICES[0])
with gr.Row():
components[f'steps_{prefix}'] = gr.Slider(label="Steps", minimum=1, maximum=100, step=1, value=4)
components[f'cfg_{prefix}'] = gr.Slider(label="CFG Scale", minimum=1.0, maximum=20.0, step=0.1, value=1.0)
components[f'steps_{prefix}'] = gr.Slider(label="Steps", minimum=1, maximum=100, step=1, value=28)
components[f'cfg_{prefix}'] = gr.Slider(label="CFG Scale", minimum=1.0, maximum=20.0, step=0.1, value=7.5)
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)
with gr.Row():
components[f'clip_skip_{prefix}'] = gr.Slider(label="Clip Skip", minimum=1, maximum=2, step=1, value=1, visible=False, interactive=True)
components[f'guidance_{prefix}'] = gr.Slider(label="Guidance (FLUX)", minimum=1.0, maximum=10.0, step=0.1, value=3.5, visible=False, interactive=True)
components[f'zero_gpu_{prefix}'] = gr.Number(label="ZeroGPU Duration (s)", value=None, placeholder="Default: 60, Max: 120", info="Optional: Set how long to reserve the GPU.")
components[f'zero_gpu_{prefix}'] = gr.Number(label="ZeroGPU Duration (s)", value=None, placeholder="Default: 60s, Max: 120s", info="Optional: Set how long to reserve the GPU.")
components[f'clip_skip_{prefix}'] = gr.State(value=1)
components[f'width_{prefix}'] = gr.State(value=512)
components[f'height_{prefix}'] = gr.State(value=512)
with gr.Column(scale=1):
components[f'result_{prefix}'] = gr.Gallery(label="Result", show_label=False, columns=1, object_fit="contain", height=610)
components.update(create_api_key_ui(prefix))
components.update(create_lora_settings_ui(prefix))
# components.update(create_diffsynth_controlnet_ui(prefix))
# components.update(create_controlnet_ui(prefix))
# components.update(create_embedding_ui(prefix))
components.update(create_reference_latent_ui(prefix))
components.update(create_controlnet_ui(prefix))
components.update(create_ipadapter_ui(prefix))
components.update(create_flux1_ipadapter_ui(prefix))
components.update(create_sd3_ipadapter_ui(prefix))
components.update(create_style_ui(prefix))
components.update(create_embedding_ui(prefix))
components.update(create_conditioning_ui(prefix))
components.update(create_reference_latent_ui(prefix))
# components.update(create_vae_override_ui(prefix))
components.update(create_vae_override_ui(prefix))
return components2 unmodified lines3456767891011122 unmodified lines1516171819202117222324252 unmodified lines28293026273132333435363738343539404137384243444546474344454849505152535450555652535455575859606162636465576667682 unmodified linesfrom comfy_integration.nodes import SAMPLER_CHOICES, SCHEDULER_CHOICES
from .ui_components import (
create_lora_settings_ui,
create_embedding_ui,
create_conditioning_ui, create_vae_override_ui, create_api_key_ui,
create_controlnet_ui, create_diffsynth_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
)
2 unmodified lines components = {}
with gr.Column():
components.update(create_model_architecture_filter_ui(prefix))
with gr.Row():
components.update(create_category_filter_ui(prefix))
components[f'base_model_{prefix}'] = gr.Dropdown(label="Base Model", choices=list(MODEL_MAP_CHECKPOINT.keys()), value=list(MODEL_MAP_CHECKPOINT.keys())[0], scale=3)
components[f'base_model_{prefix}'] = gr.Dropdown(label="Base Model", choices=list(MODEL_MAP_CHECKPOINT.keys()), value=list(MODEL_MAP_CHECKPOINT.keys())[0], scale=3, allow_custom_value=True)
with gr.Column(scale=1):
components[f'run_{prefix}'] = gr.Button("Run", variant="primary")
2 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, placeholder="Enter your prompt")
components[f'neg_prompt_{prefix}'] = gr.Text(label="Negative prompt", lines=3, value="")
components[f'prompt_{prefix}'] = gr.Text(label="Prompt", lines=3)
components[f'neg_prompt_{prefix}'] = gr.Text(label="Negative prompt", lines=3)
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="euler")
components[f'scheduler_{prefix}'] = gr.Dropdown(label="Scheduler", choices=SCHEDULER_CHOICES, value="simple")
components[f'sampler_{prefix}'] = gr.Dropdown(label="Sampler", choices=SAMPLER_CHOICES, value=SAMPLER_CHOICES[0])
components[f'scheduler_{prefix}'] = gr.Dropdown(label="Scheduler", choices=SCHEDULER_CHOICES, value='normal' if 'normal' in SCHEDULER_CHOICES else SCHEDULER_CHOICES[0])
with gr.Row():
components[f'steps_{prefix}'] = gr.Slider(label="Steps", minimum=1, maximum=100, step=1, value=4)
components[f'cfg_{prefix}'] = gr.Slider(label="CFG Scale", minimum=1.0, maximum=20.0, step=0.1, value=1.0)
components[f'steps_{prefix}'] = gr.Slider(label="Steps", minimum=1, maximum=100, step=1, value=28)
components[f'cfg_{prefix}'] = gr.Slider(label="CFG Scale", minimum=1.0, maximum=20.0, step=0.1, value=7.5)
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)
with gr.Row():
components[f'zero_gpu_{prefix}'] = gr.Number(label="ZeroGPU Duration (s)", value=None, placeholder="Default: 60, Max: 120", info="Optional: Set how long to reserve the GPU. Longer jobs may need more time.")
components[f'clip_skip_{prefix}'] = gr.State(value=1)
components[f'clip_skip_{prefix}'] = gr.Slider(label="Clip Skip", minimum=1, maximum=2, step=1, value=1, visible=False, interactive=True)
components[f'guidance_{prefix}'] = gr.Slider(label="Guidance (FLUX)", minimum=1.0, maximum=10.0, step=0.1, value=3.5, visible=False, interactive=True)
components[f'zero_gpu_{prefix}'] = gr.Number(label="ZeroGPU Duration (s)", value=None, placeholder="Default: 60s, Max: 120s", info="Optional: Set how long to reserve the GPU. Longer jobs may need more time.")
with gr.Column(scale=1):
components[f'result_{prefix}'] = gr.Gallery(label="Result", show_label=False, columns=1, object_fit="contain", height=505)
components.update(create_api_key_ui(prefix))
components.update(create_lora_settings_ui(prefix))
# components.update(create_diffsynth_controlnet_ui(prefix))
# components.update(create_controlnet_ui(prefix))
# components.update(create_embedding_ui(prefix))
components.update(create_reference_latent_ui(prefix))
components.update(create_controlnet_ui(prefix))
components.update(create_diffsynth_controlnet_ui(prefix))
components.update(create_ipadapter_ui(prefix))
components.update(create_flux1_ipadapter_ui(prefix))
components.update(create_sd3_ipadapter_ui(prefix))
components.update(create_embedding_ui(prefix))
components.update(create_style_ui(prefix))
components.update(create_conditioning_ui(prefix))
components.update(create_reference_latent_ui(prefix))
# components.update(create_vae_override_ui(prefix))
components.update(create_vae_override_ui(prefix))
return components1 unmodified line234565678910112 unmodified lines14151617181920212223242520262728293031253233343511 unmodified lines4748494344505152535455495657585960616263645253656667555668697071727374756176776378798081688283848586738788757677788990919293949596978098991001011 unmodified linefrom core.settings import MODEL_MAP_CHECKPOINT
from .ui_components import (
create_base_parameter_ui, create_lora_settings_ui,
create_embedding_ui,
create_conditioning_ui, create_vae_override_ui, create_api_key_ui,
create_controlnet_ui, create_diffsynth_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
)
2 unmodified lines components = {}
with gr.Column():
with gr.Row() as arch_row:
components.update(create_model_architecture_filter_ui(prefix))
with gr.Row() as model_and_run_row:
components.update(create_category_filter_ui(prefix))
components[f'base_model_{prefix}'] = gr.Dropdown(
label="Base Model",
choices=list(MODEL_MAP_CHECKPOINT.keys()),
value=list(MODEL_MAP_CHECKPOINT.keys())[0],
scale=3
scale=3,
allow_custom_value=True
)
with gr.Column(scale=1):
components[f'run_{prefix}'] = gr.Button("Run Inpaint", variant="primary")
components[f'model_and_run_row_{prefix}'] = model_and_run_row
components[f'model_and_run_row_{prefix}'] = [arch_row, model_and_run_row]
with gr.Row() as main_content_row:
with gr.Column(scale=1) as editor_column:11 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, placeholder="Describe what to fill in the mask...")
components[f'neg_prompt_{prefix}'] = gr.Text(label="Negative prompt", lines=6, value="")
components[f'prompt_{prefix}'] = gr.Text(label="Prompt", lines=6)
components[f'neg_prompt_{prefix}'] = gr.Text(label="Negative prompt", lines=6)
components[f'prompts_column_{prefix}'] = prompts_column
with gr.Row() as params_and_gallery_row:
with gr.Column(scale=1):
param_defaults = {'w': 1024, 'h': 1024, 'cs_vis': False, 'cs_val': 1}
from comfy_integration.nodes import SAMPLER_CHOICES, SCHEDULER_CHOICES
with gr.Row():
components[f'denoise_{prefix}'] = gr.Slider(
label="Denoise", minimum=0.0, maximum=1.0, step=0.05, value=1.0
)
components[f'grow_mask_by_{prefix}'] = gr.Slider(
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="euler")
components[f'scheduler_{prefix}'] = gr.Dropdown(label="Scheduler", choices=SCHEDULER_CHOICES, value="simple")
components[f'sampler_{prefix}'] = gr.Dropdown(label="Sampler", choices=SAMPLER_CHOICES, value=SAMPLER_CHOICES[0])
components[f'scheduler_{prefix}'] = gr.Dropdown(label="Scheduler", choices=SCHEDULER_CHOICES, value='normal' if 'normal' in SCHEDULER_CHOICES else SCHEDULER_CHOICES[0])
with gr.Row():
components[f'steps_{prefix}'] = gr.Slider(label="Steps", minimum=1, maximum=100, step=1, value=4)
components[f'cfg_{prefix}'] = gr.Slider(label="CFG Scale", minimum=1.0, maximum=20.0, step=0.1, value=1.0)
components[f'steps_{prefix}'] = gr.Slider(label="Steps", minimum=1, maximum=100, step=1, value=28)
components[f'cfg_{prefix}'] = gr.Slider(label="CFG Scale", minimum=1.0, maximum=20.0, step=0.1, value=7.5)
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)
with gr.Row():
components[f'clip_skip_{prefix}'] = gr.Slider(label="Clip Skip", minimum=1, maximum=2, step=1, value=1, visible=False, interactive=True)
components[f'guidance_{prefix}'] = gr.Slider(label="Guidance (FLUX)", minimum=1.0, maximum=10.0, step=0.1, value=3.5, visible=False, interactive=True)
components[f'zero_gpu_{prefix}'] = gr.Number(label="ZeroGPU Duration (s)", value=None, placeholder="Default: 60, Max: 120", info="Optional: Set how long to reserve the GPU.")
components[f'zero_gpu_{prefix}'] = gr.Number(label="ZeroGPU Duration (s)", value=None, placeholder="Default: 60s, Max: 120s", info="Optional: Set how long to reserve the GPU.")
components[f'clip_skip_{prefix}'] = gr.State(value=1)
components[f'width_{prefix}'] = gr.State(value=512)
components[f'height_{prefix}'] = gr.State(value=512)
with gr.Column(scale=1):
components[f'result_{prefix}'] = gr.Gallery(label="Result", show_label=False, columns=1, object_fit="contain", height=414)
components[f'result_{prefix}'] = gr.Gallery(label="Result", show_label=False, columns=1, object_fit="contain", height=510)
components[f'params_and_gallery_row_{prefix}'] = params_and_gallery_row
with gr.Column() as accordion_wrapper:
components.update(create_api_key_ui(prefix))
components.update(create_lora_settings_ui(prefix))
# components.update(create_diffsynth_controlnet_ui(prefix))
# components.update(create_controlnet_ui(prefix))
# components.update(create_embedding_ui(prefix))
components.update(create_reference_latent_ui(prefix))
components.update(create_controlnet_ui(prefix))
components.update(create_diffsynth_controlnet_ui(prefix))
components.update(create_ipadapter_ui(prefix))
components.update(create_flux1_ipadapter_ui(prefix))
components.update(create_sd3_ipadapter_ui(prefix))
components.update(create_style_ui(prefix))
components.update(create_embedding_ui(prefix))
components.update(create_conditioning_ui(prefix))
components.update(create_reference_latent_ui(prefix))
# components.update(create_vae_override_ui(prefix))
components.update(create_vae_override_ui(prefix))
components[f'accordion_wrapper_{prefix}'] = accordion_wrapper
return components2 unmodified lines3456767891011122 unmodified lines15161718192021222324252126272829302 unmodified lines333435303136373839404136374243443940454647484950434451525346475455565758596061526263546465666759686961707163646566727374757677787980688182832 unmodified linesfrom comfy_integration.nodes import SAMPLER_CHOICES, SCHEDULER_CHOICES
from .ui_components import (
create_lora_settings_ui,
create_embedding_ui,
create_conditioning_ui, create_vae_override_ui, create_api_key_ui,
create_controlnet_ui, create_diffsynth_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
)
2 unmodified lines components = {}
with gr.Column():
components.update(create_model_architecture_filter_ui(prefix))
with gr.Row():
components.update(create_category_filter_ui(prefix))
components[f'base_model_{prefix}'] = gr.Dropdown(
label="Base Model",
choices=list(MODEL_MAP_CHECKPOINT.keys()),
value=list(MODEL_MAP_CHECKPOINT.keys())[0],
scale=3
scale=3,
allow_custom_value=True
)
with gr.Column(scale=1):
components[f'run_{prefix}'] = gr.Button("Run Outpaint", variant="primary")2 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, placeholder="Describe the content for the expanded areas...")
components[f'neg_prompt_{prefix}'] = gr.Text(label="Negative prompt", lines=3, value="")
components[f'prompt_{prefix}'] = gr.Text(label="Prompt", lines=3)
components[f'neg_prompt_{prefix}'] = gr.Text(label="Negative prompt", lines=3)
with gr.Row():
with gr.Column(scale=1):
with gr.Row():
components[f'outpaint_left_{prefix}'] = gr.Slider(label="Pad Left", minimum=0, maximum=512, step=64, value=0)
components[f'outpaint_right_{prefix}'] = gr.Slider(label="Pad Right", minimum=0, maximum=512, step=64, value=256)
components[f'left_{prefix}'] = gr.Slider(label="Pad Left", minimum=0, maximum=512, step=64, value=64)
components[f'right_{prefix}'] = gr.Slider(label="Pad Right", minimum=0, maximum=512, step=64, value=64)
with gr.Row():
components[f'outpaint_top_{prefix}'] = gr.Slider(label="Pad Top", minimum=0, maximum=512, step=64, value=0)
components[f'outpaint_bottom_{prefix}'] = gr.Slider(label="Pad Bottom", minimum=0, maximum=512, step=64, value=0)
components[f'top_{prefix}'] = gr.Slider(label="Pad Top", minimum=0, maximum=512, step=64, value=64)
components[f'bottom_{prefix}'] = gr.Slider(label="Pad Bottom", minimum=0, maximum=512, step=64, value=64)
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="euler")
components[f'scheduler_{prefix}'] = gr.Dropdown(label="Scheduler", choices=SCHEDULER_CHOICES, value="simple")
components[f'sampler_{prefix}'] = gr.Dropdown(label="Sampler", choices=SAMPLER_CHOICES, value=SAMPLER_CHOICES[0])
components[f'scheduler_{prefix}'] = gr.Dropdown(label="Scheduler", choices=SCHEDULER_CHOICES, value='normal' if 'normal' in SCHEDULER_CHOICES else SCHEDULER_CHOICES[0])
with gr.Row():
components[f'steps_{prefix}'] = gr.Slider(label="Steps", minimum=1, maximum=100, step=1, value=4)
components[f'cfg_{prefix}'] = gr.Slider(label="CFG Scale", minimum=1.0, maximum=20.0, step=0.1, value=1.0)
components[f'steps_{prefix}'] = gr.Slider(label="Steps", minimum=1, maximum=100, step=1, value=28)
components[f'cfg_{prefix}'] = gr.Slider(label="CFG Scale", minimum=1.0, maximum=20.0, step=0.1, value=7.5)
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)
with gr.Row():
components[f'clip_skip_{prefix}'] = gr.Slider(label="Clip Skip", minimum=1, maximum=2, step=1, value=1, visible=False, interactive=True)
components[f'guidance_{prefix}'] = gr.Slider(label="Guidance (FLUX)", minimum=1.0, maximum=10.0, step=0.1, value=3.5, visible=False, interactive=True)
components[f'zero_gpu_{prefix}'] = gr.Number(label="ZeroGPU Duration (s)", value=None, placeholder="Default: 60, Max: 120", info="Optional: Set how long to reserve the GPU.")
components[f'zero_gpu_{prefix}'] = gr.Number(label="ZeroGPU Duration (s)", value=None, placeholder="Default: 60s, Max: 120s", info="Optional: Set how long to reserve the GPU.")
components[f'clip_skip_{prefix}'] = gr.State(value=1)
components[f'width_{prefix}'] = gr.State(value=512)
components[f'height_{prefix}'] = gr.State(value=512)
with gr.Column(scale=1):
components[f'result_{prefix}'] = gr.Gallery(label="Result", show_label=False, columns=1, object_fit="contain", height=595)
components[f'result_{prefix}'] = gr.Gallery(label="Result", show_label=False, columns=1, object_fit="contain", height=685)
components.update(create_api_key_ui(prefix))
components.update(create_lora_settings_ui(prefix))
# components.update(create_diffsynth_controlnet_ui(prefix))
# components.update(create_controlnet_ui(prefix))
# components.update(create_embedding_ui(prefix))
components.update(create_reference_latent_ui(prefix))
components.update(create_controlnet_ui(prefix))
components.update(create_diffsynth_controlnet_ui(prefix))
components.update(create_ipadapter_ui(prefix))
components.update(create_flux1_ipadapter_ui(prefix))
components.update(create_sd3_ipadapter_ui(prefix))
components.update(create_style_ui(prefix))
components.update(create_embedding_ui(prefix))
components.update(create_conditioning_ui(prefix))
components.update(create_reference_latent_ui(prefix))
# components.update(create_vae_override_ui(prefix))
components.update(create_vae_override_ui(prefix))
return components1 unmodified line234565678910113 unmodified lines151617181920172122232425262728293031212232333435362 unmodified lines39404131424333343536444546474849505152385354551 unmodified linefrom core.settings import MODEL_MAP_CHECKPOINT
from .ui_components import (
create_base_parameter_ui, create_lora_settings_ui,
create_embedding_ui,
create_conditioning_ui, create_vae_override_ui, create_api_key_ui,
create_controlnet_ui, create_diffsynth_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
)
3 unmodified lines components = {}
with gr.Column():
components.update(create_model_architecture_filter_ui(prefix))
with gr.Row():
components[f'base_model_{prefix}'] = gr.Dropdown(label="Base Model", choices=list(MODEL_MAP_CHECKPOINT.keys()), value=list(MODEL_MAP_CHECKPOINT.keys())[0], scale=3)
components.update(create_category_filter_ui(prefix))
components[f'base_model_{prefix}'] = gr.Dropdown(
label="Base Model",
choices=list(MODEL_MAP_CHECKPOINT.keys()),
value=list(MODEL_MAP_CHECKPOINT.keys())[0],
scale=3,
allow_custom_value=True
)
with gr.Column(scale=1):
components[f'run_{prefix}'] = gr.Button("Run", variant="primary")
components[f'prompt_{prefix}'] = gr.Text(label="Prompt", lines=3, placeholder="Enter your prompt")
components[f'neg_prompt_{prefix}'] = gr.Text(label="Negative prompt", lines=3, value="")
components[f'prompt_{prefix}'] = gr.Text(label="Prompt", lines=3)
components[f'neg_prompt_{prefix}'] = gr.Text(label="Negative prompt", lines=3)
with gr.Row():
with gr.Column(scale=1):2 unmodified lines with gr.Column(scale=1):
components[f'result_{prefix}'] = gr.Gallery(label="Result", show_label=False, columns=2, object_fit="contain", height=627)
components.update(create_api_key_ui(prefix))
components.update(create_lora_settings_ui(prefix))
# components.update(create_diffsynth_controlnet_ui(prefix))
# components.update(create_controlnet_ui(prefix))
# components.update(create_embedding_ui(prefix))
components.update(create_reference_latent_ui(prefix))
components.update(create_controlnet_ui(prefix))
components.update(create_diffsynth_controlnet_ui(prefix))
components.update(create_ipadapter_ui(prefix))
components.update(create_flux1_ipadapter_ui(prefix))
components.update(create_sd3_ipadapter_ui(prefix))
components.update(create_embedding_ui(prefix))
components.update(create_style_ui(prefix))
components.update(create_conditioning_ui(prefix))
components.update(create_reference_latent_ui(prefix))
# components.update(create_vae_override_ui(prefix))
components.update(create_vae_override_ui(prefix))
return components1 unmodified line2345567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374753 unmodified lines7980812082832284858687888990282991929331329495969798993738391001011021031041051064445464748495051525354555657107108109110111631121131141152 unmodified lines1181191207212112212312419 unmodified lines14414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141210241341441541631 unmodified lines44844945014045145245345429 unmodified lines48448548617617717817918018118218318418518618718818919019119219319419519619719819920020120220320448748848925 unmodified lines5155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465471 unmodified linefrom comfy_integration.nodes import SAMPLER_CHOICES, SCHEDULER_CHOICES
from core.settings import (
MAX_LORAS, LORA_SOURCE_CHOICES, MAX_EMBEDDINGS, MAX_CONDITIONINGS,
MAX_CONTROLNETS, RESOLUTION_MAP, MAX_REFERENCE_LATENTS
MAX_CONTROLNETS, MAX_IPADAPTERS, RESOLUTION_MAP, ARCHITECTURES_CONFIG,
MODEL_MAP_CHECKPOINT, MODEL_TYPE_MAP, FEATURES_CONFIG, ARCH_CATEGORIES_MAP
)
import yaml
import os
from functools import lru_cache
default_model_name = list(MODEL_MAP_CHECKPOINT.keys())[0] if MODEL_MAP_CHECKPOINT else None
default_m_type = MODEL_TYPE_MAP.get(default_model_name, "SDXL") if default_model_name else "SDXL"
default_architectures_dict = ARCHITECTURES_CONFIG.get('architectures', {})
default_arch_model_type = default_architectures_dict.get(default_m_type, {}).get("model_type", default_m_type.lower().replace(" ", "").replace(".", ""))
default_arch_features = FEATURES_CONFIG.get(default_arch_model_type, FEATURES_CONFIG.get('default', {}))
default_enabled_chains = default_arch_features.get('enabled_chains', [])
@lru_cache(maxsize=1)
def get_ipadapter_config_from_yaml():
try:
_PROJECT_ROOT = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
_IPADAPTER_LIST_PATH = os.path.join(_PROJECT_ROOT, 'yaml', 'ipadapter.yaml')
with open(_IPADAPTER_LIST_PATH, 'r', encoding='utf-8') as f:
config = yaml.safe_load(f)
return config
except Exception as e:
print(f"Warning: Could not load ipadapter.yaml for UI components: {e}")
return {}
def get_ipadapter_presets(arch="SDXL"):
config = get_ipadapter_config_from_yaml()
presets = []
if config:
std_presets = config.get("IPAdapter_presets", {}).get(arch, [])
face_presets = config.get("IPAdapter_FaceID_presets", {}).get(arch, [])
if std_presets:
presets.extend(std_presets)
if face_presets:
presets.extend(face_presets)
return presets if presets else ["STANDARD (medium strength)"]
def create_model_architecture_filter_ui(prefix):
components = {}
ordered_architectures = ARCHITECTURES_CONFIG.get("architecture_order", [])
choices = ["ALL"] + ordered_architectures
components[f'model_arch_{prefix}'] = gr.Radio(
label="Model Architecture",
choices=choices,
value="ALL",
interactive=True,
visible=False
)
return components
def create_category_filter_ui(prefix):
valid_cats = list(set(cat for cats in ARCH_CATEGORIES_MAP.values() for cat in cats))
cat_choices = ["ALL"] + sorted(valid_cats)
components = {}
components[f'model_cat_{prefix}'] = gr.Dropdown(
label="Filter Models",
choices=cat_choices,
value="ALL",
interactive=True,
scale=1,
allow_custom_value=True
)
return components
def create_base_parameter_ui(prefix, defaults=None):
if defaults is None:
defaults = {}3 unmodified lines with gr.Row():
components[f'aspect_ratio_{prefix}'] = gr.Dropdown(
label="Aspect Ratio",
choices=list(RESOLUTION_MAP['sdxl'].keys()),
choices=list(RESOLUTION_MAP.get('sdxl', {}).keys()),
value="1:1 (Square)",
interactive=True
interactive=True,
allow_custom_value=True
)
with gr.Row():
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="euler")
components[f'scheduler_{prefix}'] = gr.Dropdown(label="Scheduler", choices=SCHEDULER_CHOICES, value="simple")
components[f'sampler_{prefix}'] = gr.Dropdown(label="Sampler", choices=SAMPLER_CHOICES, value=SAMPLER_CHOICES[0])
components[f'scheduler_{prefix}'] = gr.Dropdown(label="Scheduler", choices=SCHEDULER_CHOICES, value='normal' if 'normal' in SCHEDULER_CHOICES else SCHEDULER_CHOICES[0])
with gr.Row():
components[f'steps_{prefix}'] = gr.Slider(label="Steps", minimum=1, maximum=100, step=1, value=4)
components[f'cfg_{prefix}'] = gr.Slider(label="CFG Scale", minimum=1.0, maximum=20.0, step=0.1, value=1.0)
components[f'steps_{prefix}'] = gr.Slider(label="Steps", minimum=1, maximum=100, step=1, value=28)
components[f'cfg_{prefix}'] = gr.Slider(label="CFG Scale", minimum=1.0, maximum=20.0, step=0.1, value=7.5)
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)
with gr.Row():
components[f'zero_gpu_{prefix}'] = gr.Number(label="ZeroGPU Duration (s)", value=None, placeholder="Default: 60, Max: 120", info="Optional: Set how long to reserve the GPU. Longer jobs may need more time.")
components[f'clip_skip_{prefix}'] = gr.State(value=1)
components[f'clip_skip_{prefix}'] = gr.Slider(label="Clip Skip", minimum=1, maximum=2, step=1, value=1, visible=False, interactive=True)
components[f'guidance_{prefix}'] = gr.Slider(label="Guidance (FLUX)", minimum=1.0, maximum=10.0, step=0.1, value=3.5, visible=False, interactive=True)
components[f'zero_gpu_{prefix}'] = gr.Number(label="ZeroGPU Duration (s)", value=None, placeholder="Default: 60s, Max: 120s", info="Optional: Set how long to reserve the GPU.")
return components
def create_api_key_ui(prefix: str):
components = {}
with gr.Accordion("API Key Settings", open=False) as api_key_accordion:
components[f'api_key_accordion_{prefix}'] = api_key_accordion
gr.Markdown("💡 **Tip:** Enter API key (optional). An API key is required for resources that need a login to download. The key will be used for all Civitai downloads on this tab. You can also manually upload the corresponding files to avoid API Key leakage caused by potential vulnerabilities.")
with gr.Row():
components[f'civitai_api_key_{prefix}'] = gr.Textbox(
label="Civitai API Key",
type="password",
placeholder="Enter your Civitai API key here (optional)"
)
return components
def create_lora_settings_ui(prefix: str):
components = {}
lora_rows, lora_sources, lora_ids, lora_scales, lora_uploads = [], [], [], [], []
with gr.Accordion("LoRA Settings", open=False) as lora_accordion:
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.")
components[f'lora_count_state_{prefix}'] = gr.State(1)2 unmodified lines 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=-2.0, maximum=2.0, step=0.05, value=0.8, scale=1)
scale = gr.Slider(label=f"Scale", minimum=0.0, maximum=2.0, step=0.05, value=0.8, scale=1)
upload = gr.UploadButton(label="Upload", file_types=[".safetensors"], scale=1)
lora_rows.append(row)19 unmodified lines
return components
def create_controlnet_ui(prefix: str, max_units=MAX_CONTROLNETS):
components = {}
key = lambda name: f"{name}_{prefix}"
with gr.Accordion("ControlNet Settings", open=False, visible=('controlnet' in default_enabled_chains)) as accordion:
components[key('controlnet_accordion')] = accordion
cn_rows, images, series, types, strengths, filepaths = [], [], [], [], [], []
components.update({
key('controlnet_rows'): cn_rows,
key('controlnet_images'): images,
key('controlnet_series'): series,
key('controlnet_types'): types,
key('controlnet_strengths'): strengths,
key('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_controlnet_button')] = gr.Button("✚ Add ControlNet")
components[key('delete_controlnet_button')] = gr.Button("➖ Delete ControlNet", visible=False)
components[key('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_controlnet_components_flat')] = all_cn_components_flat
return components
def create_diffsynth_controlnet_ui(prefix: str, max_units=MAX_CONTROLNETS):
components = {}
key = lambda name: f"{name}_{prefix}"
with gr.Accordion("DiffSynth ControlNet Settings", open=False, visible=('controlnet_model_patch' in default_enabled_chains)) as accordion:
components[key('diffsynth_controlnet_accordion')] = accordion
cn_rows, images, series, types, strengths, filepaths = [], [], [], [], [], []
components.update({
key('diffsynth_controlnet_rows'): cn_rows,
key('diffsynth_controlnet_images'): images,
key('diffsynth_controlnet_series'): series,
key('diffsynth_controlnet_types'): types,
key('diffsynth_controlnet_strengths'): strengths,
key('diffsynth_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_diffsynth_controlnet_button')] = gr.Button("✚ Add DiffSynth ControlNet")
components[key('delete_diffsynth_controlnet_button')] = gr.Button("➖ Delete DiffSynth ControlNet", visible=False)
components[key('diffsynth_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_diffsynth_controlnet_components_flat')] = all_cn_components_flat
return components
def create_ipadapter_ui(prefix: str, max_units=MAX_IPADAPTERS):
components = {}
key = lambda name: f"{name}_{prefix}"
sdxl_presets = get_ipadapter_presets("SDXL")
default_preset = sdxl_presets[0] if sdxl_presets else None
with gr.Accordion("IPAdapter Settings", open=False, visible=('ipadapter' in default_enabled_chains)) as accordion:
components[key('ipadapter_accordion')] = accordion
gr.Markdown("Powered by [cubiq/ComfyUI_IPAdapter_plus](https://github.com/cubiq/ComfyUI_IPAdapter_plus).")
with gr.Row():
components[key('ipadapter_final_preset')] = gr.Dropdown(
label="Preset (for all images)",
choices=sdxl_presets,
value=default_preset,
interactive=True,
allow_custom_value=True
)
components[key('ipadapter_embeds_scaling')] = gr.Dropdown(
label="Embeds Scaling",
choices=['V only', 'K+V', 'K+V w/ C penalty', 'K+mean(V) w/ C penalty'],
value='V only',
interactive=True
)
with gr.Row():
components[key('ipadapter_combine_method')] = gr.Dropdown(
label="Combine Method",
choices=["concat", "add", "subtract", "average", "norm average", "max", "min"],
value="concat",
interactive=True
)
components[key('ipadapter_final_weight')] = gr.Slider(label="Final Weight", minimum=0.0, maximum=2.0, step=0.05, value=1.0, interactive=True)
components[key('ipadapter_final_lora_strength')] = gr.Slider(label="Final LoRA Strength", minimum=0.0, maximum=2.0, step=0.05, value=0.6, interactive=True, visible=False)
gr.Markdown("---")
ipa_rows, images, weights, lora_strengths = [], [], [], []
components.update({
key('ipadapter_rows'): ipa_rows,
key('ipadapter_images'): images,
key('ipadapter_weights'): weights,
key('ipadapter_lora_strengths'): lora_strengths
})
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"IPAdapter Image {i+1}", type="pil", sources=["upload"], height=256))
with gr.Column(scale=2):
weights.append(gr.Slider(label="Weight", minimum=0.0, maximum=2.0, step=0.05, value=1.0, interactive=True))
lora_strengths.append(gr.Slider(label="LoRA Strength", minimum=0.0, maximum=2.0, step=0.05, value=0.6, interactive=True, visible=False))
ipa_rows.append(row)
with gr.Row():
components[key('add_ipadapter_button')] = gr.Button("✚ Add IPAdapter")
components[key('delete_ipadapter_button')] = gr.Button("➖ Delete IPAdapter", visible=False)
components[key('ipadapter_count_state')] = gr.State(1)
all_ipa_components_flat = images + weights + lora_strengths
all_ipa_components_flat += [
components[key('ipadapter_final_preset')],
components[key('ipadapter_final_weight')],
components[key('ipadapter_final_lora_strength')],
components[key('ipadapter_embeds_scaling')],
components[key('ipadapter_combine_method')],
]
components[key('all_ipadapter_components_flat')] = all_ipa_components_flat
return components
def create_flux1_ipadapter_ui(prefix: str, max_units=MAX_IPADAPTERS):
components = {}
key = lambda name: f"{name}_{prefix}"
with gr.Accordion("IPAdapter Settings (FLUX.1)", open=False, visible=('flux1_ipadapter' in default_enabled_chains)) as accordion:
components[key('flux1_ipadapter_accordion')] = accordion
ipa_rows, images, weights, start_percents, end_percents = [], [], [], [], []
components.update({
key('flux1_ipadapter_rows'): ipa_rows,
key('flux1_ipadapter_images'): images,
key('flux1_ipadapter_weights'): weights,
key('flux1_ipadapter_start_percents'): start_percents,
key('flux1_ipadapter_end_percents'): end_percents,
})
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"IPAdapter Image {i+1}", type="pil", sources=["upload"], height=256))
with gr.Column(scale=2):
weights.append(gr.Slider(label="Weight", minimum=0.0, maximum=2.0, step=0.05, value=0.6, interactive=True))
with gr.Row():
start_percents.append(gr.Slider(label="Start At", minimum=0.0, maximum=1.0, step=0.01, value=0.0, interactive=True))
end_percents.append(gr.Slider(label="End At", minimum=0.0, maximum=1.0, step=0.01, value=0.6, interactive=True))
ipa_rows.append(row)
with gr.Row():
components[key('add_flux1_ipadapter_button')] = gr.Button("✚ Add IPAdapter (FLUX)")
components[key('delete_flux1_ipadapter_button')] = gr.Button("➖ Delete IPAdapter (FLUX)", visible=False)
components[key('flux1_ipadapter_count_state')] = gr.State(1)
all_flux1_ipa_components_flat = images + weights + start_percents + end_percents
components[key('all_flux1_ipadapter_components_flat')] = all_flux1_ipa_components_flat
return components
def create_sd3_ipadapter_ui(prefix: str, max_units=MAX_IPADAPTERS):
components = {}
key = lambda name: f"{name}_{prefix}"
with gr.Accordion("IPAdapter Settings (SD3)", open=False, visible=('sd3_ipadapter' in default_enabled_chains)) as accordion:
components[key('sd3_ipadapter_accordion')] = accordion
ipa_rows, images, weights, start_percents, end_percents = [], [], [], [], []
components.update({
key('sd3_ipadapter_rows'): ipa_rows,
key('sd3_ipadapter_images'): images,
key('sd3_ipadapter_weights'): weights,
key('sd3_ipadapter_start_percents'): start_percents,
key('sd3_ipadapter_end_percents'): end_percents,
})
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"IPAdapter Image {i+1}", type="pil", sources=["upload"], height=256))
with gr.Column(scale=2):
weights.append(gr.Slider(label="Weight", minimum=0.0, maximum=2.0, step=0.05, value=0.5, interactive=True))
with gr.Row():
start_percents.append(gr.Slider(label="Start At", minimum=0.0, maximum=1.0, step=0.01, value=0.0, interactive=True))
end_percents.append(gr.Slider(label="End At", minimum=0.0, maximum=1.0, step=0.01, value=1.0, interactive=True))
ipa_rows.append(row)
with gr.Row():
components[key('add_sd3_ipadapter_button')] = gr.Button("✚ Add IPAdapter (SD3)")
components[key('delete_sd3_ipadapter_button')] = gr.Button("➖ Delete IPAdapter (SD3)", visible=False)
components[key('sd3_ipadapter_count_state')] = gr.State(1)
all_sd3_ipa_components_flat = images + weights + start_percents + end_percents
components[key('all_sd3_ipadapter_components_flat')] = all_sd3_ipa_components_flat
return components
def create_style_ui(prefix: str):
components = {}
key = lambda name: f"{name}_{prefix}"
with gr.Accordion("Style Settings (FLUX.1)", open=False, visible=('style' in default_enabled_chains)) as accordion:
components[key('style_accordion')] = accordion
style_rows, images, strengths = [], [], []
components.update({
key('style_rows'): style_rows,
key('style_images'): images,
key('style_strengths'): strengths
})
for i in range(5):
with gr.Row(visible=(i < 1)) as row:
with gr.Column(scale=1):
images.append(gr.Image(label=f"Style Image {i+1}", type="pil", sources=["upload"], height=256))
with gr.Column(scale=2):
strengths.append(gr.Slider(label="Strength", minimum=0.0, maximum=2.0, step=0.05, value=1.0, interactive=True))
style_rows.append(row)
with gr.Row():
components[key('add_style_button')] = gr.Button("✚ Add Style (FLUX)")
components[key('delete_style_button')] = gr.Button("➖ Delete Style (FLUX)", visible=False)
components[key('style_count_state')] = gr.State(1)
all_style_components_flat = images + strengths
components[key('all_style_components_flat')] = all_style_components_flat
return components
def create_embedding_ui(prefix: str):
components = {}
key = lambda name: f"{name}_{prefix}"
with gr.Accordion("Embedding Settings", open=False, visible=True) as accordion:
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.")
31 unmodified lines components = {}
key = lambda name: f"{name}_{prefix}"
with gr.Accordion("Conditioning Settings", open=False) as accordion:
with gr.Accordion("Conditioning Settings", open=False, visible=('conditioning' in default_enabled_chains)) as accordion:
components[key('conditioning_accordion')] = accordion
gr.Markdown("💡 **Tip:** Define rectangular areas and assign specific prompts to them. Coordinates (X, Y) start from the top-left corner.")
29 unmodified lines
return components
def create_reference_latent_ui(prefix: str):
components = {}
key = lambda name: f"{name}_{prefix}"
with gr.Accordion("Reference Edit", open=False) as accordion:
components[key('reference_latent_accordion')] = accordion
gr.Markdown("💡 **Tip:** For multimodal models (like FLUX.2), this feature enables powerful editing and combining capabilities. In txt2img mode, adding a single reference image performs an **Image Edit**, while adding multiple images performs an **Image Combine**.")
ref_rows, ref_images = [], []
components.update({
key('reference_latent_rows'): ref_rows,
key('reference_latent_images'): ref_images,
})
with gr.Row():
for i in range(MAX_REFERENCE_LATENTS):
with gr.Column(visible=(i < 1), min_width=160) as row_wrapper:
ref_images.append(gr.Image(type="pil", label=f"Reference {i+1}", sources=["upload"], height=150))
ref_rows.append(row_wrapper)
with gr.Row():
components[key('add_reference_latent_button')] = gr.Button("✚ Add Reference Image")
components[key('delete_reference_latent_button')] = gr.Button("➖ Delete Reference Image", visible=False)
components[key('reference_latent_count_state')] = gr.State(1)
components[key('all_reference_latent_components_flat')] = ref_images
return components
def create_vae_override_ui(prefix: str):
components = {}
key = lambda name: f"{name}_{prefix}"25 unmodified lines components[key('vae_upload_button')] = upload_btn
components[key('vae_file')] = gr.State(None)
return components
def create_reference_latent_ui(prefix: str, max_units=10):
components = {}
key = lambda name: f"{name}_{prefix}"
with gr.Accordion("Reference Edit Settings", open=False, visible=('reference_latent' in default_enabled_chains)) as ref_accordion:
components[key('reference_latent_accordion')] = ref_accordion
gr.Markdown("💡 **Tip:** For multimodal models (like FLUX.2 or OmniGen), this feature enables powerful editing and combining capabilities. In txt2img mode, adding a single reference image performs an **Image Edit**, while adding multiple images performs an **Image Combine**.")
ref_image_groups = []
ref_image_inputs = []
with gr.Row():
for i in range(max_units):
with gr.Column(visible=(i < 1), min_width=160) as img_col:
img_comp = gr.Image(type="pil", label=f"Ref. {i+1}", sources=["upload"], height=150)
ref_image_groups.append(img_col)
ref_image_inputs.append(img_comp)
components[key('reference_latent_rows')] = ref_image_groups
components[key('reference_latent_images')] = ref_image_inputs
with gr.Row():
components[key('add_reference_latent_button')] = gr.Button("✚ Add Reference Image")
components[key('delete_reference_latent_button')] = gr.Button("➖ Delete Reference Image", visible=False)
components[key('reference_latent_count_state')] = gr.State(1)
components[key('all_reference_latent_components_flat')] = ref_image_inputs
return components10 unmodified lines11121314141516171819202122232122232425262728293031323334353637383940414243444546474821 unmodified lines7071725173747561 unmodified lines13713813911914014114228 unmodified lines17117217315417417517610 unmodified lines18718818917119019119222 unmodified lines21521621720021821922097 unmodified lines3183193203043053213223233243253263273283293303073083093103113123133143153163173183313323333343353203213363233373383253393403413423433443453323463473483493363503513523533403543553423563573443583593603611 unmodified line36336436535236636736836937037137235937337437537637736437837936638038138238338438538637338738837538939039139239338039439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650738338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642750842943043143243343443543643743843950951044144244351151251351451551651751851952052152252352452552652752852953012 unmodified lines54354454546254654754854955055155255355455555655755855956056156256356456556610 unmodified linesimport torch
import numpy as np
from PIL import Image, ImageChops
import yaml
from core.settings import *
DISK_LIMIT_GB = 120
MODELS_ROOT_DIR = "ComfyUI/models"
PREPROCESSOR_MODEL_MAP = None
PREPROCESSOR_PARAMETER_MAP = None
IPADAPTER_PRESETS = None
class UniqueKeyLoader(yaml.SafeLoader):
"""
A custom YAML loader that handles duplicate keys by grouping their values into a list.
"""
def construct_mapping(self, node, deep=False):
mapping = []
for key_node, value_node in node.value:
key = self.construct_object(key_node, deep=deep)
value = self.construct_object(value_node, deep=deep)
mapping.append((key, value))
result = {}
for k, v in mapping:
if k in result:
if isinstance(result[k], list):
result[k].append(v)
else:
result[k] = [result[k], v]
else:
result[k] = v
return result
UniqueKeyLoader.add_constructor(yaml.resolver.BaseResolver.DEFAULT_MAPPING_TAG, UniqueKeyLoader.construct_mapping)
def save_uploaded_file_with_hash(file_obj: gr.File, target_dir: str) -> str:
if not file_obj:21 unmodified lines
return hashed_filename
def bytes_to_gb(byte_size: int) -> float:
if byte_size is None or byte_size == 0:
return 0.061 unmodified lines except Exception as e:
print(f"--- [Storage Manager] An unexpected error occurred: {e} ---")
def get_value_at_index(obj: Union[Sequence, Mapping], index: int) -> Any:
try:
return obj[index]28 unmodified lines sanitized = re.sub(r'[^\w\.\-]', '_', sanitized)
return sanitized.lstrip('/\\')
def get_civitai_file_info(version_id: str) -> dict | None:
api_url = f"https://civitai.com/api/v1/model-versions/{version_id}"
try:10 unmodified lines except Exception:
return None
def download_file(url: str, save_path: str, api_key: str = None, progress=None, desc: str = "") -> str:
enforce_disk_limit()
22 unmodified lines os.remove(save_path)
return f"Download failed for {os.path.basename(save_path)}: {e}"
def get_lora_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."97 unmodified lines return (local_path, status) if "Successfully" in status else (None, status)
def _ensure_model_downloaded(filename: str, progress=gr.Progress()):
download_info = ALL_FILE_DOWNLOAD_MAP.get(filename)
def _ensure_model_downloaded(display_name: str, progress=gr.Progress()):
if display_name not in ALL_MODEL_MAP:
raise ValueError(f"Model '{display_name}' not found in configuration.")
model_info = ALL_MODEL_MAP[display_name]
repo_filename = model_info[1]
base_filename = os.path.basename(repo_filename)
download_info = ALL_FILE_DOWNLOAD_MAP.get(base_filename)
if not download_info:
raise gr.Error(f"Model component '{filename}' not found in file_list.yaml. Cannot download.")
category_to_dir_map = {
"diffusion_models": DIFFUSION_MODELS_DIR,
"text_encoders": TEXT_ENCODERS_DIR,
"vae": VAE_DIR,
"checkpoints": CHECKPOINT_DIR,
"loras": LORA_DIR,
"controlnet": CONTROLNET_DIR,
"model_patches": MODEL_PATCHES_DIR,
"clip_vision": os.path.join(os.path.dirname(LORA_DIR), "clip_vision")
}
raise gr.Error(f"Model '{base_filename}' not found in file_list.yaml. Cannot download.")
category = download_info.get("category")
dest_dir = CATEGORY_TO_DIR_MAP.get(category)
category = download_info.get('category')
dest_dir = category_to_dir_map.get(category)
if not dest_dir:
raise ValueError(f"Unknown model category '{category}' for file '{filename}'.")
raise ValueError(f"Unknown YAML category '{category}' for '{base_filename}'.")
dest_path = os.path.join(dest_dir, filename)
dest_path = os.path.join(dest_dir, base_filename)
if os.path.lexists(dest_path):
if not os.path.exists(dest_path):
print(f"⚠️ Found and removed broken symlink: {dest_path}")
os.remove(dest_path)
else:
return filename
return base_filename
source = download_info.get("source")
try:
progress(0, desc=f"Downloading: {filename}")
progress(0, desc=f"Downloading: {base_filename}")
if source == "hf":
repo_id = download_info.get("repo_id")
hf_filename = download_info.get("repository_file_path", filename)
hf_filename = download_info.get("repository_file_path", base_filename)
if not repo_id:
raise ValueError(f"repo_id is missing for HF model '{filename}'")
raise ValueError(f"repo_id is missing for HF model '{base_filename}'")
cached_path = hf_hub_download(repo_id=repo_id, filename=hf_filename)
cached_path = hf_hub_download(repo_id=repo_id, filename=hf_filename, token=os.environ.get("HF_TOKEN"))
os.makedirs(dest_dir, exist_ok=True)
os.symlink(cached_path, dest_path)
print(f"✅ Symlinked '{cached_path}' to '{dest_path}'")1 unmodified line elif source == "civitai":
model_version_id = download_info.get("model_version_id")
if not model_version_id:
raise ValueError(f"model_version_id is missing for Civitai model '{filename}'")
raise ValueError(f"model_version_id is missing for Civitai model '{base_filename}'")
file_info = get_civitai_file_info(model_version_id)
if not file_info or not file_info.get('downloadUrl'):
raise ConnectionError(f"Could not get download URL for Civitai model version ID {model_version_id}")
status = download_file(
file_info['downloadUrl'], dest_path, progress=progress, desc=f"Downloading: {filename}"
file_info['downloadUrl'], dest_path, api_key=os.environ.get("CIVITAI_API_KEY", ""), progress=progress, desc=f"Downloading: {base_filename}"
)
if "Failed" in status:
raise ConnectionError(status)
else:
raise NotImplementedError(f"Download source '{source}' is not implemented for '{filename}'")
raise NotImplementedError(f"Download source '{source}' is not implemented for '{base_filename}'")
progress(1.0, desc=f"Downloaded: {filename}")
progress(1.0, desc=f"Downloaded: {base_filename}")
except Exception as e:
if os.path.lexists(dest_path):
try:
os.remove(dest_path)
except OSError: pass
raise gr.Error(f"Failed to download and link '{filename}': {e}")
raise gr.Error(f"Failed to download and link '{display_name}': {e}")
return filename
return base_filename
def ensure_controlnet_model_downloaded(filename: str, progress):
if not filename or filename == "None":
return
_ensure_model_downloaded(filename, progress)
download_info = ALL_FILE_DOWNLOAD_MAP.get(filename)
if not download_info:
raise gr.Error(f"ControlNet model '{filename}' not found in configuration (file_list.yaml). Cannot download.")
category = download_info.get("category", "controlnet")
dest_dir = CATEGORY_TO_DIR_MAP.get(category, CONTROLNET_DIR)
dest_path = os.path.join(dest_dir, filename)
if os.path.lexists(dest_path):
if not os.path.exists(dest_path):
print(f"⚠️ Found and removed broken symlink: {dest_path}")
os.remove(dest_path)
else:
return
source = download_info.get("source")
try:
if source == "hf":
repo_id = download_info.get("repo_id")
repo_filename = download_info.get("repository_file_path", filename)
if not repo_id:
raise ValueError("repo_id is missing for Hugging Face download.")
progress(0, desc=f"Downloading CN: {filename}")
cached_path = hf_hub_download(repo_id=repo_id, filename=repo_filename, token=os.environ.get("HF_TOKEN"))
os.makedirs(dest_dir, exist_ok=True)
os.symlink(cached_path, dest_path)
print(f"✅ Symlinked ControlNet '{cached_path}' to '{dest_path}'")
progress(1.0, desc=f"Downloaded CN: {filename}")
elif source == "civitai":
model_version_id = download_info.get("model_version_id")
if not model_version_id:
raise ValueError("model_version_id is missing for Civitai download.")
file_info = get_civitai_file_info(model_version_id)
if not file_info or not file_info.get('downloadUrl'):
raise ConnectionError(f"Could not get download URL for Civitai model version ID {model_version_id}")
status = download_file(
file_info['downloadUrl'],
dest_path,
api_key=os.environ.get("CIVITAI_API_KEY", ""),
progress=progress,
desc=f"Downloading CN: {filename}"
)
if "Failed" in status:
raise ConnectionError(status)
else:
raise NotImplementedError(f"Download source '{source}' is not implemented for ControlNets.")
except Exception as e:
if os.path.lexists(dest_path):
try:
os.remove(dest_path)
except OSError:
pass
raise gr.Error(f"Failed to download ControlNet model '{filename}': {e}")
def load_ipadapter_presets():
global IPADAPTER_PRESETS
if IPADAPTER_PRESETS is not None:
return
_PROJECT_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
_IPADAPTER_MODELS_PATH = os.path.join(_PROJECT_ROOT, 'yaml', 'ipadapter_models.yaml')
try:
with open(_IPADAPTER_MODELS_PATH, 'r', encoding='utf-8') as f:
presets_list = yaml.load(f, Loader=UniqueKeyLoader)
IPADAPTER_PRESETS = {item['preset_name']: item for item in presets_list}
print("✅ IPAdapter presets loaded successfully.")
except Exception as e:
print(f"❌ FATAL: Could not load or parse ipadapter_models.yaml. IPAdapter will not work. Error: {e}")
IPADAPTER_PRESETS = {}
def ensure_ipadapter_models_downloaded(preset_name: str, progress):
if not preset_name:
return
if IPADAPTER_PRESETS is None:
raise RuntimeError("IPAdapter presets have not been loaded. `load_ipadapter_presets` must be called on startup.")
preset_info = IPADAPTER_PRESETS.get(preset_name)
if not preset_info:
print(f"⚠️ Warning: IPAdapter preset '{preset_name}' not found in configuration. Skipping download.")
return
model_files_to_check = []
def add_files(value, type_name):
if not value: return
if isinstance(value, list):
for v in value:
model_files_to_check.append((v, type_name))
else:
model_files_to_check.append((value, type_name))
add_files(preset_info.get('clip_vision'), 'CLIP_VISION')
add_files(preset_info.get('ipadapter'), 'IPADAPTER')
add_files(preset_info.get('loras'), 'LORA')
for filename, model_type in model_files_to_check:
if not filename:
continue
temp_display_name = f"ipadapter_asset_{filename}"
if temp_display_name not in ALL_MODEL_MAP:
ALL_MODEL_MAP[temp_display_name] = (None, filename, model_type, None, None)
def build_preprocessor_model_map():
global PREPROCESSOR_MODEL_MAP
if PREPROCESSOR_MODEL_MAP is not None: return PREPROCESSOR_MODEL_MAP
print("--- Building ControlNet Preprocessor model map ---")
manual_map = {
"dwpose": [("yzd-v/DWPose", "yolox_l.onnx"), ("yzd-v/DWPose", "dw-ll_ucoco_384.onnx"), ("hr16/UnJIT-DWPose", "dw-ll_ucoco.onnx"), ("hr16/DWPose-TorchScript-BatchSize5", "dw-ll_ucoco_384_bs5.torchscript.pt"), ("hr16/DWPose-TorchScript-BatchSize5", "rtmpose-m_ap10k_256_bs5.torchscript.pt"), ("hr16/yolo-nas-fp16", "yolo_nas_l_fp16.onnx"), ("hr16/yolo-nas-fp16", "yolo_nas_m_fp16.onnx"), ("hr16/yolo-nas-fp16", "yolo_nas_s_fp16.onnx")],
"densepose": [("LayerNorm/DensePose-TorchScript-with-hint-image", "densepose_r50_fpn_dl.torchscript"), ("LayerNorm/DensePose-TorchScript-with-hint-image", "densepose_r101_fpn_dl.torchscript")]
}
temp_map = {}
from nodes import NODE_DISPLAY_NAME_MAPPINGS
wrappers_dir = Path("./custom_nodes/comfyui_controlnet_aux/node_wrappers/")
if not wrappers_dir.exists():
print("⚠️ ControlNet AUX wrappers directory not found. Cannot build model map.")
PREPROCESSOR_MODEL_MAP = {}; return PREPROCESSOR_MODEL_MAP
for wrapper_file in wrappers_dir.glob("*.py"):
if wrapper_file.name == "__init__.py": continue
with open(wrapper_file, 'r', encoding='utf-8') as f:
content = f.read()
display_name_matches = re.findall(r'NODE_DISPLAY_NAME_MAPPINGS\s*=\s*{(?:.|\n)*?["\'](.*?)["\']\s*:\s*["\'](.*?)["\']', content)
for _, display_name in display_name_matches:
if display_name not in temp_map: temp_map[display_name] = []
manual_key = wrapper_file.stem
if manual_key in manual_map: temp_map[display_name].extend(manual_map[manual_key])
matches = re.findall(r"from_pretrained\s*\(\s*(?:filename=)?\s*f?[\"']([^\"']+)[\"']", content)
for model_filename in matches:
repo_id = "lllyasviel/Annotators"
if "depth_anything" in model_filename and "v2" in model_filename: repo_id = "LiheYoung/Depth-Anything-V2"
elif "depth_anything" in model_filename: repo_id = "LiheYoung/Depth-Anything"
elif "diffusion_edge" in model_filename: repo_id = "hr16/Diffusion-Edge"
temp_map[display_name].append((repo_id, model_filename))
final_map = {name: sorted(list(set(models))) for name, models in temp_map.items() if models}
PREPROCESSOR_MODEL_MAP = final_map
print("✅ ControlNet Preprocessor model map built."); return PREPROCESSOR_MODEL_MAP
def build_preprocessor_parameter_map():
global PREPROCESSOR_PARAMETER_MAP
if PREPROCESSOR_PARAMETER_MAP is not None: return
print("--- Building ControlNet Preprocessor parameter map ---")
param_map = {}
from nodes import NODE_CLASS_MAPPINGS, NODE_DISPLAY_NAME_MAPPINGS
for class_name, node_class in NODE_CLASS_MAPPINGS.items():
if not hasattr(node_class, "INPUT_TYPES"): continue
if hasattr(node_class, '__module__') and 'comfyui_controlnet_aux.node_wrappers' not in node_class.__module__: continue
display_name = NODE_DISPLAY_NAME_MAPPINGS.get(class_name)
if not display_name: continue
try:
input_types = node_class.INPUT_TYPES()
all_inputs = {**input_types.get('required', {}), **input_types.get('optional', {})}
params = []
for name, details in all_inputs.items():
if name in ['image', 'resolution', 'pose_kps']: continue
if not isinstance(details, (list, tuple)) or not details: continue
param_type = details[0]
param_config = details[1] if len(details) > 1 and isinstance(details[1], dict) else {}
param_info = {"name": name, "type": param_type, "config": param_config}
params.append(param_info)
if params: param_map[display_name] = params
_ensure_model_downloaded(temp_display_name, progress)
except Exception as e:
print(f"⚠️ Could not parse parameters for {display_name}: {e}")
PREPROCESSOR_PARAMETER_MAP = param_map
print("✅ ControlNet Preprocessor parameter map built.")
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')
try:
with open(yaml_path, 'r', encoding='utf-8') as f:
sd3_models = yaml.safe_load(f)
if sd3_models:
if 'ipadapter' in sd3_models:
_ensure_model_downloaded(sd3_models['ipadapter'], progress)
if 'clip_vision' in sd3_models:
_ensure_model_downloaded(sd3_models['clip_vision'], progress)
except Exception as e:
print(f"Warning: Failed to load or download sd3 ipadapter models: {e}")
def print_welcome_message():
author_name = "RioShiina"12 unmodified lines f"{border}\n"
)
print(message) print(message)
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',
'positive_prompt': '', 'negative_prompt': ''
}
if 'Default' in defaults_config:
final_defaults.update(defaults_config['Default'])
model_type_key = next((key for key in defaults_config if key.lower().replace(" ", "-").replace(".", "") == model_type.lower()), None)
if model_type_key:
model_type_config = defaults_config[model_type_key]
if '_defaults' in model_type_config:
final_defaults.update(model_type_config['_defaults'])
if model_display_name in model_type_config:
final_defaults.update(model_type_config[model_display_name])
return final_defaults1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161 unmodified line11811912016121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153MAX_LORAS: 5
MAX_CONTROLNETS: 5
MAX_IPADAPTERS: 5
MAX_EMBEDDINGS: 5
MAX_CONDITIONINGS: 10
MAX_REFERENCE_LATENTS: 10
LORA_SOURCE_CHOICES: ["Civitai", "File"]
RESOLUTION_MAP:
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]
flux2:
"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]
flux2-kv:
"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]
qwen-image:
"1:1 (Square)": [1328, 1328]
"16:9 (Landscape)": [1664, 928]
"9:16 (Portrait)": [928, 1664]
"4:3 (Classic)": [1472, 1104]
"3:4 (Classic Portrait)": [1104, 1472]
"3:2 (Photography)": [1536, 1024]
"2:3 (Photography Portrait)": [1024, 1536]
longcat-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]
anima:
"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]
newbie-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]
omnigen2:
"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]
lumina:
"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]
ovis-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]
flux1:
"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]
hidream:
"1:1 (Square)": [1024, 1024]
"16:9 (Landscape)": [1344, 768]
"9:16 (Portrait)": [768, 1344]
"4:3 (Classic)": [1152, 896]
"3:4 (Classic Portrait)": [896, 1152]
"3:2 (Photography)": [1216, 832]
"2:3 (Photography Portrait)": [832, 1216]
sd35:
"1:1 (Square)": [1024, 1024]
"16:9 (Landscape)": [1344, 768]
"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]
sdxl:
"1:1 (Square)": [1024, 1024]
"16:9 (Landscape)": [1344, 768]1 unmodified line "4:3 (Classic)": [1152, 896]
"3:4 (Classic Portrait)": [896, 1152]
"3:2 (Photography)": [1216, 832]
"2:3 (Photography Portrait)": [832, 1216] "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:
"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]
chroma1:
"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]
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]1212345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027111272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547165485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236242162562662762862963063163263363463563663763863964064164264364425645file:
checkpoints:
file:
checkpoints:
# Lumina
- filename: "lumina_2.safetensors"
source: "hf"
repo_id: "Comfy-Org/Lumina_Image_2.0_Repackaged"
repository_file_path: "all_in_one/lumina_2.safetensors"
# SD3.5
- filename: "sd3.5_large_fp8_scaled.safetensors"
source: "hf"
repo_id: "Comfy-Org/stable-diffusion-3.5-fp8"
repository_file_path: "sd3.5_large_fp8_scaled.safetensors"
- filename: "sd3.5_medium_incl_clips_t5xxlfp8scaled.safetensors"
source: "hf"
repo_id: "Comfy-Org/stable-diffusion-3.5-fp8"
repository_file_path: "sd3.5_medium_incl_clips_t5xxlfp8scaled.safetensors"
# SDXL-NoobAI
- filename: "NoobAI-XL-Vpred-v1.0.safetensors"
source: hf
repo_id: "Laxhar/noobai-XL-Vpred-1.0"
repository_file_path: "NoobAI-XL-Vpred-v1.0.safetensors"
- filename: "NoobAI-XL-v1.1.safetensors"
source: hf
repo_id: "Laxhar/noobai-XL-1.1"
repository_file_path: "NoobAI-XL-v1.1.safetensors"
- filename: "noob_v_pencil-XL-v3.0.0.safetensors"
source: hf
repo_id: "bluepen5805/noob_v_pencil-XL"
repository_file_path: "noob_v_pencil-XL-v3.0.0.safetensors"
- filename: "Hikari_Noob_v-pred_1.2.4.safetensors"
source: hf
repo_id: "RedRayz/hikari_noob_v-pred_1.2.4"
repository_file_path: "Hikari_Noob_v-pred_1.2.4.safetensors"
- filename: "ChenkinNoob-XL-V0.5.safetensors"
source: hf
repo_id: "ChenkinNoob/ChenkinNoob-XL-V0.5"
repository_file_path: "ChenkinNoob-XL-V0.5.safetensors"
# SDXL-Illustrious
- filename: "waiIllustriousSDXL_v170.safetensors"
source: hf
repo_id: "zhenshipo/waiIllustriousSDXL_v170"
repository_file_path: "waiIllustriousSDXL_v170.safetensors"
- filename: "mellow_pencil-XL-v1.0.0.safetensors"
source: hf
repo_id: "bluepen5805/mellow_pencil-XL"
repository_file_path: "mellow_pencil-XL-v1.0.0.safetensors"
- filename: "illustrious_pencil-XL-v5.0.0.safetensors"
source: hf
repo_id: "bluepen5805/illustrious_pencil-XL"
repository_file_path: "illustrious_pencil-XL-v5.0.0.safetensors"
- filename: "hassakuXLIllustrious_v34.safetensors"
source: hf
repo_id: "oldhag88/hassakuXLIllustrious_v34.safetensors"
repository_file_path: "hassakuXLIllustrious_v34.safetensors"
- filename: "novaAnimeXL_ilV160.safetensors"
source: hf
repo_id: "Yevrey921/novaAnimeXL_ilV160"
repository_file_path: "novaAnimeXL_ilV160.safetensors"
- filename: "Illustrious-XL-v2.0.safetensors"
source: hf
repo_id: "OnomaAIResearch/Illustrious-XL-v2.0"
- filename: "Illustrious-XL-v2.0.safetensors"
source: hf
repo_id: "OnomaAIResearch/Illustrious-XL-v2.0"
repository_file_path: "Illustrious-XL-v2.0.safetensors"
- filename: "Illustrious-XL-v1.1.safetensors"
source: hf
repo_id: "OnomaAIResearch/Illustrious-XL-v1.1"
repository_file_path: "Illustrious-XL-v1.1.safetensors"
- filename: "Illustrious-XL-v1.0.safetensors"
source: hf
repo_id: "OnomaAIResearch/Illustrious-XL-v1.0"
repository_file_path: "Illustrious-XL-v1.0.safetensors"
- filename: "illustriousXL_v01.safetensors"
source: hf
repo_id: "AiAF/Illustrious-XL-v0.1.safetensors"
repository_file_path: "illustriousXL_v01.safetensors"
# SDXL-Animate
- filename: "animagine-xl-4.0.safetensors"
source: hf
repo_id: "cagliostrolab/animagine-xl-4.0"
repository_file_path: "animagine-xl-4.0.safetensors"
- filename: "animagine-xl-3.1.safetensors"
source: hf
repo_id: "cagliostrolab/animagine-xl-3.1"
repository_file_path: "animagine-xl-3.1.safetensors"
- filename: "4nima_pencil-XL-v1.0.1.safetensors"
source: hf
repo_id: "bluepen5805/4nima_pencil-XL"
repository_file_path: "4nima_pencil-XL-v1.0.1.safetensors"
- filename: "anima_pencil-XL-v5.0.0.safetensors"
source: hf
repo_id: "bluepen5805/anima_pencil-XL"
repository_file_path: "anima_pencil-XL-v5.0.0.safetensors"
- filename: "blue_pencil-XL-v7.0.0.safetensors"
source: hf
repo_id: "bluepen5805/blue_pencil-XL"
repository_file_path: "blue_pencil-XL-v7.0.0.safetensors"
# SDXL-Pony
- filename: "ponyDiffusionV6XL_v6StartWithThisOne.safetensors"
source: hf
repo_id: "LyliaEngine/Pony_Diffusion_V6_XL"
repository_file_path: "ponyDiffusionV6XL_v6StartWithThisOne.safetensors"
- filename: "pony_pencil-XL-v2.0.0.safetensors"
source: hf
repo_id: "bluepen5805/pony_pencil-XL"
repository_file_path: "pony_pencil-XL-v2.0.0.safetensors"
- filename: "CyberRealisticPony_V14.0.safetensors"
source: hf
repo_id: "cyberdelia/CyberRealisticPony"
repository_file_path: "CyberRealisticPony_V14.0.safetensors"
# SDXL-Base
- filename: "sd_xl_base_1.0.safetensors"
source: "hf"
repo_id: "stabilityai/stable-diffusion-xl-base-1.0"
repository_file_path: "sd_xl_base_1.0.safetensors"
# SD1.5
- filename: "v1-5-pruned-emaonly.safetensors"
source: "hf"
repo_id: "stable-diffusion-v1-5/stable-diffusion-v1-5"
repository_file_path: "v1-5-pruned-emaonly.safetensors"
clip_vision:
# style_injector
- filename: "sigclip_vision_patch14_384.safetensors"
source: "hf"
repo_id: "Comfy-Org/sigclip_vision_384"
repository_file_path: "sigclip_vision_patch14_384.safetensors"
# IPAdapter
- filename: "CLIP-ViT-H-14-laion2B-s32B-b79K.safetensors"
source: "hf"
repo_id: "h94/IP-Adapter"
repository_file_path: "models/image_encoder/model.safetensors"
- filename: "CLIP-ViT-bigG-14-laion2B-39B-b160k.safetensors"
source: "hf"
repo_id: "h94/IP-Adapter"
repository_file_path: "sdxl_models/image_encoder/model.safetensors"
# IPAdapter-SD3
- filename: "sigclip_vision_patch14_384.safetensors"
source: "hf"
repo_id: "Comfy-Org/sigclip_vision_384"
repository_file_path: "sigclip_vision_patch14_384.safetensors"
controlnet:
# SD3.5
- filename: "sd3.5_large_controlnet_blur.safetensors"
source: "hf"
repo_id: "stabilityai/stable-diffusion-3.5-controlnets"
repository_file_path: "sd3.5_large_controlnet_blur.safetensors"
- filename: "sd3.5_large_controlnet_canny.safetensors"
source: "hf"
repo_id: "stabilityai/stable-diffusion-3.5-controlnets"
repository_file_path: "sd3.5_large_controlnet_canny.safetensors"
- filename: "sd3.5_large_controlnet_depth.safetensors"
source: "hf"
repo_id: "stabilityai/stable-diffusion-3.5-controlnets"
repository_file_path: "sd3.5_large_controlnet_depth.safetensors"
# Qwen-Image
- filename: "Qwen-Image-InstantX-ControlNet-Union.safetensors"
source: "hf"
repo_id: "InstantX/Qwen-Image-ControlNet-Union"
repository_file_path: "diffusion_pytorch_model.safetensors"
- filename: "Qwen-Image-InstantX-ControlNet-Inpainting.safetensors"
source: "hf"
repo_id: "InstantX/Qwen-Image-ControlNet-Inpainting"
repository_file_path: "diffusion_pytorch_model.safetensors"
# FLUX.1
- filename: "FLUX.1-dev-ControlNet-Union-Pro-2.0.safetensors"
source: "hf"
repo_id: "Shakker-Labs/FLUX.1-dev-ControlNet-Union-Pro-2.0"
repository_file_path: "diffusion_pytorch_model.safetensors"
- filename: "flux-canny-controlnet-v3.safetensors"
source: "hf"
repo_id: "XLabs-AI/flux-controlnet-collections"
repository_file_path: "flux-canny-controlnet-v3.safetensors"
- filename: "flux-depth-controlnet-v3.safetensors"
source: "hf"
repo_id: "XLabs-AI/flux-controlnet-collections"
repository_file_path: "flux-depth-controlnet-v3.safetensors"
- filename: "flux-hed-controlnet-v3.safetensors"
source: "hf"
repo_id: "XLabs-AI/flux-controlnet-collections"
repository_file_path: "flux-hed-controlnet-v3.safetensors"
# SDXL
- filename: "controlnet-union-sdxl-1.0_promax.safetensors"
source: "hf"
repo_id: "xinsir/controlnet-union-sdxl-1.0"
repository_file_path: "diffusion_pytorch_model_promax.safetensors"
- filename: "controlnet-tile-sdxl-1.0.safetensors"
source: "hf"
repo_id: "xinsir/controlnet-tile-sdxl-1.0"
repository_file_path: "diffusion_pytorch_model.safetensors"
- filename: "controlnet-canny-sdxl-1.0_V2.safetensors"
source: "hf"
repo_id: "xinsir/controlnet-canny-sdxl-1.0"
repository_file_path: "diffusion_pytorch_model_V2.safetensors"
- filename: "controlnet-openpose-sdxl-1.0.safetensors"
source: "hf"
repo_id: "xinsir/controlnet-openpose-sdxl-1.0"
repository_file_path: "diffusion_pytorch_model.safetensors"
- filename: "controlnet-depth-sdxl-1.0.safetensors"
source: "hf"
repo_id: "xinsir/controlnet-depth-sdxl-1.0"
repository_file_path: "diffusion_pytorch_model.safetensors"
- filename: "controlnet-scribble-sdxl-1.0.safetensors"
source: "hf"
repo_id: "xinsir/controlnet-scribble-sdxl-1.0"
repository_file_path: "diffusion_pytorch_model.safetensors"
- filename: "anime-painter.safetensors"
source: "hf"
repo_id: "xinsir/anime-painter"
repository_file_path: "diffusion_pytorch_model.safetensors"
# SD1.5
- filename: "control_v11e_sd15_ip2p_fp16.safetensors"
source: "hf"
repo_id: "comfyanonymous/ControlNet-v1-1_fp16_safetensors"
repository_file_path: "control_v11e_sd15_ip2p_fp16.safetensors"
- filename: "control_v11e_sd15_shuffle_fp16.safetensors"
source: "hf"
repo_id: "comfyanonymous/ControlNet-v1-1_fp16_safetensors"
repository_file_path: "control_v11e_sd15_shuffle_fp16.safetensors"
- filename: "control_v11f1e_sd15_tile_fp16.safetensors"
source: "hf"
repo_id: "comfyanonymous/ControlNet-v1-1_fp16_safetensors"
repository_file_path: "control_v11f1e_sd15_tile_fp16.safetensors"
- filename: "control_v11f1p_sd15_depth_fp16.safetensors"
source: "hf"
repo_id: "comfyanonymous/ControlNet-v1-1_fp16_safetensors"
repository_file_path: "control_v11f1p_sd15_depth_fp16.safetensors"
- filename: "control_v11p_sd15_canny_fp16.safetensors"
source: "hf"
repo_id: "comfyanonymous/ControlNet-v1-1_fp16_safetensors"
repository_file_path: "control_v11p_sd15_canny_fp16.safetensors"
- filename: "control_v11p_sd15_inpaint_fp16.safetensors"
source: "hf"
repo_id: "comfyanonymous/ControlNet-v1-1_fp16_safetensors"
repository_file_path: "control_v11p_sd15_inpaint_fp16.safetensors"
- filename: "control_v11p_sd15_lineart_fp16.safetensors"
source: "hf"
repo_id: "comfyanonymous/ControlNet-v1-1_fp16_safetensors"
repository_file_path: "control_v11p_sd15_lineart_fp16.safetensors"
- filename: "control_v11p_sd15_mlsd_fp16.safetensors"
source: "hf"
repo_id: "comfyanonymous/ControlNet-v1-1_fp16_safetensors"
repository_file_path: "control_v11p_sd15_mlsd_fp16.safetensors"
- filename: "control_v11p_sd15_normalbae_fp16.safetensors"
source: "hf"
repo_id: "comfyanonymous/ControlNet-v1-1_fp16_safetensors"
repository_file_path: "control_v11p_sd15_normalbae_fp16.safetensors"
- filename: "control_v11p_sd15_openpose_fp16.safetensors"
source: "hf"
repo_id: "comfyanonymous/ControlNet-v1-1_fp16_safetensors"
repository_file_path: "control_v11p_sd15_openpose_fp16.safetensors"
- filename: "control_v11p_sd15_scribble_fp16.safetensors"
source: "hf"
repo_id: "comfyanonymous/ControlNet-v1-1_fp16_safetensors"
repository_file_path: "control_v11p_sd15_scribble_fp16.safetensors"
- filename: "control_v11p_sd15_seg_fp16.safetensors"
source: "hf"
repo_id: "comfyanonymous/ControlNet-v1-1_fp16_safetensors"
repository_file_path: "control_v11p_sd15_seg_fp16.safetensors"
- filename: "control_v11p_sd15_softedge_fp16.safetensors"
source: "hf"
repo_id: "comfyanonymous/ControlNet-v1-1_fp16_safetensors"
repository_file_path: "control_v11p_sd15_softedge_fp16.safetensors"
- filename: "control_v11p_sd15s2_lineart_anime_fp16.safetensors"
source: "hf"
repo_id: "comfyanonymous/ControlNet-v1-1_fp16_safetensors"
repository_file_path: "control_v11p_sd15s2_lineart_anime_fp16.safetensors"
- filename: "control_v11u_sd15_tile_fp16.safetensors"
source: "hf"
repo_id: "comfyanonymous/ControlNet-v1-1_fp16_safetensors"
repository_file_path: "control_v11u_sd15_tile_fp16.safetensors"
diffusion_models:
diffusion_models:
# FLUX.2-klein-9B
- filename: "flux-2-klein-9b-fp8.safetensors"
source: "hf"
repo_id: "black-forest-labs/FLUX.2-klein-9b-fp8"
repository_file_path: "flux-2-klein-9b-fp8.safetensors"
# FLUX.2-klein-base-9B
- filename: "flux-2-klein-base-9b-fp8.safetensors"
source: "hf"
repo_id: "black-forest-labs/FLUX.2-klein-base-9b-fp8"
repository_file_path: "flux-2-klein-base-9b-fp8.safetensors"
# Anima
- filename: "anima-preview3-base.safetensors"
source: "hf"
repo_id: "circlestone-labs/Anima"
repository_file_path: "split_files/diffusion_models/anima-preview3-base.safetensors"
- filename: "AnimaYume_tuned_v04.safetensors"
source: "hf"
repo_id: "duongve/AnimaYume"
repository_file_path: "split_files/diffusion_models/AnimaYume_tuned_v04.safetensors"
# NewBie-Image
- filename: "NewBie-Image-Exp0.1-bf16.safetensors"
source: "hf"
repo_id: "Comfy-Org/NewBie-image-Exp0.1_repackaged"
repository_file_path: "split_files/diffusion_models/NewBie-Image-Exp0.1-bf16.safetensors"
# ERNIE-Image
- filename: "ernie-image.safetensors"
source: "hf"
repo_id: "Comfy-Org/ERNIE-Image"
repository_file_path: "diffusion_models/ernie-image.safetensors"
- filename: "ernie-image-turbo.safetensors"
source: "hf"
repo_id: "Comfy-Org/ERNIE-Image"
repository_file_path: "diffusion_models/ernie-image-turbo.safetensors"
# FLUX.2-klein-9B-KV
- filename: "flux-2-klein-9b-kv-fp8.safetensors"
source: "hf"
repo_id: "black-forest-labs/FLUX.2-klein-9b-kv-fp8"
repository_file_path: "flux-2-klein-9b-kv-fp8.safetensors"
# FLUX.2-klein-4B
- filename: "flux-2-klein-4b-fp8.safetensors"
source: "hf"
repo_id: "black-forest-labs/FLUX.2-klein-4b-fp8"
repository_file_path: "flux-2-klein-4b-fp8.safetensors"
# FLUX.2-klein-base-4B
- filename: "flux-2-klein-base-4b-fp8.safetensors"
source: "hf"
repo_id: "black-forest-labs/FLUX.2-klein-base-4b-fp8"
repository_file_path: "flux-2-klein-base-4b-fp8.safetensors"
# FLUX.2-klein-9B
- filename: "flux-2-klein-9b-fp8.safetensors"
source: "hf"
repo_id: "black-forest-labs/FLUX.2-klein-9b-fp8"
repository_file_path: "flux-2-klein-9b-fp8.safetensors"
# FLUX.2-klein-base-9B
- filename: "flux-2-klein-base-9b-fp8.safetensors"
source: "hf"
repo_id: "black-forest-labs/FLUX.2-klein-base-9b-fp8"
repository_file_path: "flux-2-klein-base-9b-fp8.safetensors"
# FLUX.2-dev
- filename: "flux2_dev_fp8mixed.safetensors"
source: "hf"
repo_id: "Comfy-Org/flux2-dev"
repository_file_path: "split_files/diffusion_models/flux2_dev_fp8mixed.safetensors"
# LongCat-Image
- filename: "longcat_image_bf16.safetensors"
source: "hf"
repo_id: "Comfy-Org/LongCat-Image"
repository_file_path: "split_files/diffusion_models/longcat_image_bf16.safetensors"
# Ovis-Image
- filename: "ovis_image_bf16.safetensors"
source: "hf"
repo_id: "Comfy-Org/Ovis-Image"
repository_file_path: "split_files/diffusion_models/ovis_image_bf16.safetensors"
# Z-Image
- filename: "z_image_turbo_bf16.safetensors"
source: "hf"
repo_id: "Comfy-Org/z_image_turbo"
repository_file_path: "split_files/diffusion_models/z_image_turbo_bf16.safetensors"
- filename: "z_image_bf16.safetensors"
source: "hf"
repo_id: "Comfy-Org/z_image"
repository_file_path: "split_files/diffusion_models/z_image_bf16.safetensors"
# Qwen-Image
- filename: "qwen_image_2512_fp8_e4m3fn.safetensors"
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"
source: "hf"
repo_id: "Comfy-Org/Qwen-Image_ComfyUI"
repository_file_path: "split_files/diffusion_models/qwen_image_fp8_e4m3fn.safetensors"
# Flux.1
- filename: "flux1-dev-fp8-e4m3fn.safetensors"
source: "hf"
repo_id: "Kijai/flux-fp8"
repository_file_path: "flux1-dev-fp8-e4m3fn.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"
repository_file_path: "split_files/diffusion_models/flux1-krea-dev_fp8_scaled.safetensors"
# HiDream
- filename: "hidream_i1_dev_fp8.safetensors"
source: "hf"
repo_id: "Comfy-Org/HiDream-I1_ComfyUI"
repository_file_path: "split_files/diffusion_models/hidream_i1_dev_fp8.safetensors"
- filename: "hidream_i1_fast_fp8.safetensors"
source: "hf"
repo_id: "Comfy-Org/HiDream-I1_ComfyUI"
repository_file_path: "split_files/diffusion_models/hidream_i1_fast_fp8.safetensors"
- filename: "hidream_i1_full_fp8.safetensors"
source: "hf"
repo_id: "Comfy-Org/HiDream-I1_ComfyUI"
repository_file_path: "split_files/diffusion_models/hidream_i1_full_fp8.safetensors"
- filename: "hunyuanimage2.1_fp8_e4m3fn.safetensors"
source: "hf"
repo_id: "Comfy-Org/HunyuanImage_2.1_ComfyUI"
repository_file_path: "split_files/diffusion_models/hunyuanimage2.1_fp8_e4m3fn.safetensors"
- filename: "hunyuanimage2.1_distilled_fp8_e4m3fn.safetensors"
source: "hf"
repo_id: "Comfy-Org/HunyuanImage_2.1_ComfyUI"
repository_file_path: "split_files/diffusion_models/hunyuanimage2.1_distilled_fp8_e4m3fn.safetensors"
- filename: "hunyuanimage2.1_refiner_fp8_e4m3fn.safetensors"
source: "hf"
repo_id: "Comfy-Org/HunyuanImage_2.1_ComfyUI"
repository_file_path: "split_files/diffusion_models/hunyuanimage2.1_refiner_fp8_e4m3fn.safetensors"
# Chroma1-Radiance
- filename: "Chroma1-Radiance-x0-fp8mixed_fullmm-20260104.safetensors"
source: "hf"
repo_id: "silveroxides/Chroma1-Radiance-fp8-scaled"
repository_file_path: "Chroma1-Radiance-x0-fp8mixed_fullmm-20260104.safetensors"
# Chroma1
- filename: "Chroma1-HD-Flash_float8_e4m3fn_scaled_learned_topk8_svd.safetensors"
source: "hf"
repo_id: "Clybius/Chroma-fp8-scaled"
repository_file_path: "Chroma1-HD/Chroma1-HD-Flash_float8_e4m3fn_scaled_learned_topk8_svd.safetensors"
- filename: "Chroma1-HD_float8_e4m3fn_scaled_learned_topk8_svd.safetensors"
source: "hf"
repo_id: "Clybius/Chroma-fp8-scaled"
repository_file_path: "Chroma1-HD/Chroma1-HD_float8_e4m3fn_scaled_learned_topk8_svd.safetensors"
- filename: "omnigen2_fp16.safetensors"
source: "hf"
repo_id: "Comfy-Org/Omnigen2_ComfyUI_repackaged"
repository_file_path: "split_files/diffusion_models/omnigen2_fp16.safetensors"
ipadapter:
# SD3.5
- filename: "ip-adapter_sd35l_instantx.bin"
source: "hf"
repo_id: "InstantX/SD3.5-Large-IP-Adapter"
repository_file_path: "ip-adapter.bin"
# SD1.5
- filename: "ip-adapter_sd15.safetensors"
source: "hf"
repo_id: "h94/IP-Adapter"
repository_file_path: "models/ip-adapter_sd15.safetensors"
- filename: "ip-adapter_sd15_light_v11.bin"
source: "hf"
repo_id: "h94/IP-Adapter"
repository_file_path: "models/ip-adapter_sd15_light_v11.bin"
- filename: "ip-adapter-plus_sd15.safetensors"
source: "hf"
repo_id: "h94/IP-Adapter"
repository_file_path: "models/ip-adapter-plus_sd15.safetensors"
- filename: "ip-adapter-plus-face_sd15.safetensors"
source: "hf"
repo_id: "h94/IP-Adapter"
repository_file_path: "models/ip-adapter-plus-face_sd15.safetensors"
- filename: "ip-adapter-full-face_sd15.safetensors"
source: "hf"
repo_id: "h94/IP-Adapter"
repository_file_path: "models/ip-adapter-full-face_sd15.safetensors"
- filename: "ip-adapter_sd15_vit-G.safetensors"
source: "hf"
repo_id: "h94/IP-Adapter"
repository_file_path: "models/ip-adapter_sd15_vit-G.safetensors"
# SDXL
- filename: "ip-adapter_sdxl_vit-h.safetensors"
source: "hf"
repo_id: "h94/IP-Adapter"
repository_file_path: "sdxl_models/ip-adapter_sdxl_vit-h.safetensors"
- filename: "ip-adapter-plus_sdxl_vit-h.safetensors"
source: "hf"
repo_id: "h94/IP-Adapter"
repository_file_path: "sdxl_models/ip-adapter-plus_sdxl_vit-h.safetensors"
- filename: "ip-adapter-plus-face_sdxl_vit-h.safetensors"
source: "hf"
repo_id: "h94/IP-Adapter"
repository_file_path: "sdxl_models/ip-adapter-plus-face_sdxl_vit-h.safetensors"
- filename: "ip-adapter_sdxl.safetensors"
source: "hf"
repo_id: "h94/IP-Adapter"
repository_file_path: "sdxl_models/ip-adapter_sdxl.safetensors"
- filename: "ip-adapter-faceid_sd15.bin"
source: "hf"
repo_id: "h94/IP-Adapter-FaceID"
repository_file_path: "ip-adapter-faceid_sd15.bin"
- filename: "ip-adapter-faceid-plusv2_sd15.bin"
source: "hf"
repo_id: "h94/IP-Adapter-FaceID"
repository_file_path: "ip-adapter-faceid-plusv2_sd15.bin"
- filename: "ip-adapter-faceid-portrait-v11_sd15.bin"
source: "hf"
repo_id: "h94/IP-Adapter-FaceID"
repository_file_path: "ip-adapter-faceid-portrait-v11_sd15.bin"
- filename: "ip-adapter-faceid_sdxl.bin"
source: "hf"
repo_id: "h94/IP-Adapter-FaceID"
repository_file_path: "ip-adapter-faceid_sdxl.bin"
- filename: "ip-adapter-faceid-plusv2_sdxl.bin"
source: "hf"
repo_id: "h94/IP-Adapter-FaceID"
repository_file_path: "ip-adapter-faceid-plusv2_sdxl.bin"
- filename: "ip-adapter-faceid-portrait_sdxl.bin"
source: "hf"
repo_id: "h94/IP-Adapter-FaceID"
repository_file_path: "ip-adapter-faceid-portrait_sdxl.bin"
- filename: "ip-adapter-faceid-portrait_sdxl_unnorm.bin"
source: "hf"
repo_id: "h94/IP-Adapter-FaceID"
repository_file_path: "ip-adapter-faceid-portrait_sdxl_unnorm.bin"
ipadapter-flux:
- filename: "ip-adapter.bin"
source: "hf"
repo_id: "InstantX/FLUX.1-dev-IP-Adapter"
repository_file_path: "ip-adapter.bin"
style_models:
# FLUX.1-Redux-dev
- filename: "flux1-redux-dev.safetensors"
source: "hf"
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"
source: "hf"
repo_id: "lightx2v/Qwen-Image-Lightning"
repository_file_path: "Qwen-Image-fp8-e4m3fn-Lightning-4steps-V1.0-bf16.safetensors"
# SD1.5 FaceID
- filename: "ip-adapter-faceid_sd15_lora.safetensors"
source: "hf"
repo_id: "h94/IP-Adapter-FaceID"
repository_file_path: "ip-adapter-faceid_sd15_lora.safetensors"
- filename: "ip-adapter-faceid-plusv2_sd15_lora.safetensors"
source: "hf"
repo_id: "h94/IP-Adapter-FaceID"
repository_file_path: "ip-adapter-faceid-plusv2_sd15_lora.safetensors"
- filename: "ip-adapter-faceid_sdxl_lora.safetensors"
source: "hf"
repo_id: "h94/IP-Adapter-FaceID"
repository_file_path: "ip-adapter-faceid_sdxl_lora.safetensors"
- filename: "ip-adapter-faceid-plusv2_sdxl_lora.safetensors"
source: "hf"
repo_id: "h94/IP-Adapter-FaceID"
repository_file_path: "ip-adapter-faceid-plusv2_sdxl_lora.safetensors"
model_patches:
# Z-Image
- filename: "Z-Image-Turbo-Fun-Controlnet-Union-2.1-8steps.safetensors"
source: "hf"
repo_id: "alibaba-pai/Z-Image-Turbo-Fun-Controlnet-Union-2.1"
repository_file_path: "Z-Image-Turbo-Fun-Controlnet-Union-2.1-8steps.safetensors"
- filename: "Z-Image-Turbo-Fun-Controlnet-Tile-2.1-8steps.safetensors"
source: "hf"
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:
text_encoders:
# Anima
- filename: "qwen_3_06b_base.safetensors"
source: "hf"
repo_id: "circlestone-labs/Anima"
repository_file_path: "split_files/text_encoders/qwen_3_06b_base.safetensors"
# NewBie-Image
- filename: "gemma_3_4b_it_bf16.safetensors"
source: "hf"
repo_id: "Comfy-Org/NewBie-image-Exp0.1_repackaged"
repository_file_path: "split_files/text_encoders/gemma_3_4b_it_bf16.safetensors"
- filename: "jina_clip_v2_bf16.safetensors"
source: "hf"
repo_id: "Comfy-Org/NewBie-image-Exp0.1_repackaged"
repository_file_path: "split_files/text_encoders/jina_clip_v2_bf16.safetensors"
# ERNIE-Image
- filename: "ministral-3-3b.safetensors"
source: "hf"
repo_id: "Comfy-Org/ERNIE-Image"
repository_file_path: "text_encoders/ministral-3-3b.safetensors"
# FLUX.2-klein-4B & base
- filename: "qwen_3_4b.safetensors"
source: "hf"
repo_id: "Comfy-Org/vae-text-encorder-for-flux-klein-4b"
repository_file_path: "split_files/text_encoders/qwen_3_4b.safetensors"
# FLUX.2-klein-9B & base
- filename: "qwen_3_8b_fp8mixed.safetensors"
source: "hf"
repo_id: "Comfy-Org/vae-text-encorder-for-flux-klein-9b"
repository_file_path: "split_files/text_encoders/qwen_3_8b_fp8mixed.safetensors"
# FLUX.2-dev
- filename: "mistral_3_small_flux2_fp8.safetensors"
source: "hf"
repo_id: "Comfy-Org/flux2-dev"
repository_file_path: "split_files/text_encoders/mistral_3_small_flux2_fp8.safetensors"
# Ovis-Image
- filename: "ovis_2.5.safetensors"
source: "hf"
repo_id: "Comfy-Org/Ovis-Image"
repository_file_path: "split_files/text_encoders/ovis_2.5.safetensors"
# Z-Image
- filename: "qwen_3_4b_fp8_mixed.safetensors"
source: "hf"
repo_id: "Comfy-Org/z_image_turbo"
repository_file_path: "split_files/text_encoders/qwen_3_4b_fp8_mixed.safetensors"
- filename: "clip_l.safetensors"
source: "hf"
repo_id: "comfyanonymous/flux_text_encoders"
repository_file_path: "clip_l.safetensors"
- filename: "t5xxl_fp8_e4m3fn_scaled.safetensors"
source: "hf"
repo_id: "comfyanonymous/flux_text_encoders"
repository_file_path: "t5xxl_fp8_e4m3fn_scaled.safetensors"
- filename: "clip_l_hidream.safetensors"
source: "hf"
repo_id: "Comfy-Org/HiDream-I1_ComfyUI"
repository_file_path: "split_files/text_encoders/clip_l_hidream.safetensors"
- filename: "clip_g_hidream.safetensors"
source: "hf"
repo_id: "Comfy-Org/HiDream-I1_ComfyUI"
repository_file_path: "split_files/text_encoders/clip_g_hidream.safetensors"
- filename: "llama_3.1_8b_instruct_fp8_scaled.safetensors"
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"
source: "hf"
repo_id: "Comfy-Org/Qwen-Image_ComfyUI"
repository_file_path: "split_files/text_encoders/qwen_2.5_vl_7b_fp8_scaled.safetensors"
- filename: "byt5_small_glyphxl_fp16.safetensors"
source: "hf"
repo_id: "Comfy-Org/HunyuanImage_2.1_ComfyUI"
repository_file_path: "split_files/text_encoders/byt5_small_glyphxl_fp16.safetensors"
- filename: "qwen_2.5_vl_fp16.safetensors"
source: "hf"
repo_id: "Comfy-Org/Omnigen2_ComfyUI_repackaged"
repository_file_path: "split_files/text_encoders/qwen_2.5_vl_fp16.safetensors"
vae:
vae:
- filename: "qwen_image_vae.safetensors"
source: "hf"
repo_id: "Comfy-Org/Qwen-Image_ComfyUI"
repository_file_path: "split_files/vae/qwen_image_vae.safetensors"
- filename: "hunyuan_image_2.1_vae_fp16.safetensors"
source: "hf"
repo_id: "Comfy-Org/HunyuanImage_2.1_ComfyUI"
repository_file_path: "split_files/vae/hunyuan_image_2.1_vae_fp16.safetensors"
- filename: "hunyuan_image_refiner_vae_fp16.safetensors"
source: "hf"
repo_id: "Comfy-Org/HunyuanImage_2.1_ComfyUI"
repository_file_path: "split_files/vae/hunyuan_image_refiner_vae_fp16.safetensors"
- filename: "ae.safetensors"
source: "hf"
repo_id: "Comfy-Org/Lumina_Image_2.0_Repackaged"
repository_file_path: "split_files/vae/ae.safetensors"
- filename: "flux2-vae.safetensors"
source: "hf"
repo_id: "Comfy-Org/flux2-dev"
repository_file_path: "split_files/vae/flux2-vae.safetensors" repository_file_path: "split_files/vae/flux2-vae.safetensors"123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117default:
enabled_chains:
- lora
- controlnet
- ipadapter
- embedding
- style
- conditioning
ernie-image:
enabled_chains:
- lora
- conditioning
flux2:
enabled_chains:
- lora
- conditioning
- reference_latent
flux2-kv:
enabled_chains:
- lora
- conditioning
- reference_latent
z-image:
enabled_chains:
- lora
- conditioning
- controlnet_model_patch
qwen-image:
enabled_chains:
- lora
- controlnet
- conditioning
longcat-image:
enabled_chains:
- lora
- conditioning
anima:
enabled_chains:
- lora
- conditioning
newbie-image:
enabled_chains:
- lora
- embedding
- conditioning
omnigen2:
enabled_chains:
- conditioning
- reference_latent
lumina:
enabled_chains:
- lora
- embedding
- conditioning
ovis-image:
enabled_chains:
- conditioning
sd35:
enabled_chains:
- lora
- controlnet
- embedding
- conditioning
- sd3_ipadapter
sdxl:
enabled_chains:
- lora
- controlnet
- ipadapter
- embedding
- conditioning
sd15:
enabled_chains:
- lora
- controlnet
- ipadapter
- embedding
- conditioning
flux1:
enabled_chains:
- lora
- controlnet
- style
- conditioning
- flux1_ipadapter
hidream:
enabled_chains:
- lora
- conditioning
chroma1:
enabled_chains:
- conditioning
chroma1-radiance:
enabled_chains:
- conditioning
hunyuanimage:
enabled_chains:
- conditioning122345678910111213141516171819202122232425262728293031323334351236injector_definitions:
dynamic_lora_chains:
dynamic_vae_chains:
module: "chain_injectors.vae_injector"
dynamic_lora_chains:
module: "chain_injectors.lora_injector"
dynamic_newbie_lora_chains:
module: "chain_injectors.newbie_lora_injector"
dynamic_controlnet_chains:
module: "chain_injectors.controlnet_injector"
dynamic_diffsynth_controlnet_chains:
module: "chain_injectors.diffsynth_controlnet_injector"
dynamic_ipadapter_chains:
module: "chain_injectors.ipadapter_injector"
dynamic_flux1_ipadapter_chains:
module: "chain_injectors.flux1_ipadapter_injector"
dynamic_sd3_ipadapter_chains:
module: "chain_injectors.sd3_ipadapter_injector"
dynamic_style_chains:
module: "chain_injectors.style_injector"
dynamic_conditioning_chains:
module: "chain_injectors.conditioning_injector"
dynamic_reference_latent_chains:
module: "chain_injectors.reference_latent_injector"
injector_order:
- dynamic_vae_chains
- dynamic_lora_chains
- dynamic_newbie_lora_chains
- dynamic_diffsynth_controlnet_chains
- dynamic_ipadapter_chains
- dynamic_flux1_ipadapter_chains
- dynamic_sd3_ipadapter_chains
- dynamic_style_chains
- dynamic_conditioning_chains
- dynamic_reference_latent_chains
- dynamic_conditioning_chains - dynamic_controlnet_chains1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677781579architecture_order:
- "FLUX.2-KV"
- "FLUX.2"
- "ERNIE-Image"
- "Z-Image"
- "Qwen-Image"
- "LongCat-Image"
- "Anima"
- "NewBie-Image"
- "Ovis-Image"
- "HunyuanImage"
- "Chroma1-Radiance"
- "Chroma1"
- "OmniGen2"
- "Lumina"
- "HiDream"
- "FLUX.1"
- "SD3.5"
- "SDXL"
- "SD1.5"
architectures:
"ERNIE-Image":
model_type: "ernie-image"
controlnet_key: "ERNIE-Image"
"FLUX.2-KV":
model_type: "flux2-kv"
controlnet_key: "FLUX.2"
"FLUX.2":
model_type: "flux2"
controlnet_key: "FLUX.2"
"Z-Image":
model_type: "z-image"
controlnet_key: "Z-Image"
"Qwen-Image":
model_type: "qwen-image"
controlnet_key: "Qwen-Image"
"LongCat-Image":
model_type: "longcat-image"
controlnet_key: "LongCat-Image"
"Anima":
model_type: "anima"
controlnet_key: "Anima"
"Chroma1-Radiance":
model_type: "chroma1-radiance"
controlnet_key: "Chroma1-Radiance"
"Chroma1":
model_type: "chroma1"
controlnet_key: "Chroma1"
"OmniGen2":
model_type: "omnigen2"
controlnet_key: "OmniGen2"
"Lumina":
model_type: "lumina"
controlnet_key: "Lumina"
"Ovis-Image":
model_type: "ovis-image"
controlnet_key: "Ovis-Image"
"HunyuanImage":
model_type: "hunyuanimage"
controlnet_key: "HunyuanImage"
"NewBie-Image":
model_type: "newbie-image"
controlnet_key: "NewBie-Image"
"FLUX.1":
model_type: "flux1"
controlnet_key: "FLUX.1"
"SDXL":
model_type: "sdxl"
controlnet_key: "SDXL"
"SD3.5":
model_type: "sd35"
controlnet_key: "SD3.5"
"HiDream":
model_type: "hidream"
controlnet_key: "HiDream"
"SD1.5":
model_type: "sd15"
controlnet_key: "SD1.5" controlnet_key: "SD1.5"12345678910111213141516171819202122123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206defaults:
FLUX.2:
width: 1024
height: 1024
num_inference_steps: 28
guidance_scale: 3.5
sampler: "Euler"
schedule_type: "Default"
SDXL:
width: 1024
height: 1024
num_inference_steps: 28
guidance_scale: 7.0
sampler: "Euler a"
schedule_type: "Default"
SD1.5:
width: 512
height: 512
num_inference_steps: 20
guidance_scale: 7.0
sampler: "Euler a"
schedule_type: "Default"Default:
steps: 25
cfg: 7.0
sampler_name: "euler"
scheduler: "simple"
total_pixels: 1048576
positive_prompt: ""
negative_prompt: ""
ERNIE-Image:
_defaults:
steps: 20
cfg: 4.0
sampler_name: "euler"
scheduler: "simple"
total_pixels: 1048576
"baidu/ERNIE-Image-Turbo":
steps: 8
cfg: 1.0
sampler_name: "euler"
scheduler: "simple"
total_pixels: 1048576
FLUX.2:
_defaults:
steps: 20
cfg: 4.0
sampler_name: "euler"
scheduler: "simple"
total_pixels: 1048576
"black-forest-labs/FLUX.2-klein-4B":
steps: 4
cfg: 1.0
"black-forest-labs/FLUX.2-klein-9B":
steps: 4
cfg: 1.0
FLUX.2-KV:
_defaults:
steps: 20
cfg: 4.0
sampler_name: "euler"
scheduler: "simple"
total_pixels: 1048576
"black-forest-labs/FLUX.2-klein-9B-KV":
steps: 4
cfg: 1.0
Z-Image:
_defaults:
steps: 25
cfg: 4.0
sampler_name: "euler"
scheduler: "simple"
total_pixels: 1048576
"Tongyi-MAI/Z Image Turbo":
steps: 9
cfg: 1.0
sampler_name: "euler"
scheduler: "simple"
total_pixels: 1048576
Qwen-Image:
_defaults:
steps: 4
cfg: 1.0
sampler_name: "euler"
scheduler: "simple"
total_pixels: 1763584
LongCat-Image:
_defaults:
steps: 20
cfg: 4.0
guidance: 4.0
sampler_name: "euler"
scheduler: "simple"
total_pixels: 1048576
Anima:
_defaults:
steps: 30
cfg: 4.0
sampler_name: "er_sde"
scheduler: "simple"
total_pixels: 1048576
positive_prompt: "masterpiece, best quality, score_7, safe. "
negative_prompt: "worst quality, low quality, score_1, score_2, score_3, blurry, jpeg artifacts, sepia"
NewBie-Image:
_defaults:
steps: 20
cfg: 5.5
sampler_name: "res_multistep"
scheduler: "simple"
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:
_defaults:
steps: 20
cfg: 5.0
sampler_name: "euler"
scheduler: "simple"
total_pixels: 1048576
OmniGen2:
_defaults:
steps: 20
cfg: 5.0
sampler_name: "euler"
scheduler: "simple"
total_pixels: 1048576
positive_prompt: ""
negative_prompt: ""
Chroma1:
_defaults:
steps: 30
cfg: 4.0
sampler_name: "euler"
scheduler: "simple"
total_pixels: 1048576
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"
Chroma1-Radiance:
_defaults:
steps: 30
cfg: 4.0
sampler_name: "euler"
scheduler: "simple"
total_pixels: 1048576
negative_prompt: "low quality, bad anatomy, extra digits, missing digits, extra limbs, missing limbs, hands, fingers"
SD3.5:
_defaults:
steps: 20
cfg: 4.0
sampler_name: "euler"
scheduler: "sgm_uniform"
total_pixels: 1048576
SDXL:
_defaults:
steps: 25
cfg: 7.0
sampler_name: "euler"
scheduler: "simple"
total_pixels: 1048576
positive_prompt: ""
negative_prompt: ""
SD1.5:
_defaults:
steps: 47
cfg: 7.0
sampler_name: "euler_ancestral"
scheduler: "simple"
total_pixels: 393216
FLUX.1:
_defaults:
steps: 20
cfg: 1.0
sampler_name: "euler"
scheduler: "simple"
total_pixels: 1048576
"flux1-schnell":
steps: 4
cfg: 1.0
sampler_name: "euler"
scheduler: "simple"
HiDream:
_defaults:
steps: 50
cfg: 3.0
sampler_name: "uni_pc"
scheduler: "simple"
total_pixels: 1048576
negative_prompt: "bad ugly jpeg artifacts"
"HiDream_i1_Dev":
steps: 28
cfg: 1.0
sampler_name: "lcm"
scheduler: "normal"
"HiDream_i1_Fast":
steps: 16
cfg: 1.0
sampler_name: "lcm"
scheduler: "normal"
HunyuanImage:
_defaults:
steps: 20
cfg: 3.5
sampler_name: "euler"
scheduler: "simple"
total_pixels: 4194304
"HunyuanImage-2.1-Distilled":
steps: 8
cfg: 1.0122345567891011121314151617181920789Checkpoint:
FLUX.2:
FLUX.2-KV:
latent_type: flux2_latent
models:
- display_name: "Comfy-Org/flux2-dev"
- display_name: "black-forest-labs/FLUX.2-klein-9B-KV"
components:
unet: "flux2_dev_fp8mixed.safetensors"
clip: "mistral_3_small_flux2_fp8.safetensors"
vae: "flux2-vae.safetensors"
SDXL:
latent_type: latent
models:
- display_name: "stabilityai/SDXL-Base-1.0"
path: "sd_xl_base_1.0.safetensors"
category: "Base"
SD1.5:
latent_type: latent
models:
- display_name: "stable-diffusion-v1-5/stable-diffusion-v1-5"
path: "v1-5-pruned-emaonly.safetensors" unet: "flux-2-klein-9b-kv-fp8.safetensors"
clip: "qwen_3_8b_fp8mixed.safetensors"
vae: "flux2-vae.safetensors"123456789101112file:
diffusion_models:
# FLUX.2-klein-9B
- filename: "flux-2-klein-9b-fp8.safetensors"
source: "hf"
repo_id: "black-forest-labs/FLUX.2-klein-9b-fp8"
repository_file_path: "flux-2-klein-9b-fp8.safetensors"
# FLUX.2-klein-base-9B
- filename: "flux-2-klein-base-9b-fp8.safetensors"
source: "hf"
repo_id: "black-forest-labs/FLUX.2-klein-base-9b-fp8"
repository_file_path: "flux-2-klein-base-9b-fp8.safetensors"app.py+14-137
comfy_integration/nodes.py+5
comfy_integration/setup.py+36-13
core/generation_logic.py-15
core/model_manager.py+6-19
core/pipelines/controlnet_preprocessor.pyDeleted-143
core/pipelines/sd_image_pipeline.py+224-59
core/pipelines/workflow_recipes/_partials/_base_sampler.yaml → core/pipelines/workflow_recipes/_partials/_base_sampler_sd.yamlRenamed+15-2
core/pipelines/workflow_recipes/_partials/conditioning/flux1.yamlAdded+64
core/pipelines/workflow_recipes/_partials/conditioning/flux2-kv.yamlAdded+104
core/pipelines/workflow_recipes/_partials/conditioning/flux2.yaml+33-6
core/pipelines/workflow_recipes/_partials/conditioning/sd35.yamlAdded+58
core/pipelines/workflow_recipes/_partials/input/hires_fix.yaml+4-3
core/pipelines/workflow_recipes/_partials/input/img2img.yaml+3-2
core/pipelines/workflow_recipes/_partials/input/inpaint.yaml+6-8
core/pipelines/workflow_recipes/_partials/input/outpaint.yaml+14-11
core/pipelines/workflow_recipes/_partials/input/txt2img.yaml+2-8
core/pipelines/workflow_recipes/_partials/input/txt2img_chroma_radiance_latent.yamlAdded+11
core/pipelines/workflow_recipes/_partials/input/txt2img_flux2_latent.yamlAdded+11
core/pipelines/workflow_recipes/_partials/input/txt2img_hunyuan_latent.yamlAdded+11
core/pipelines/workflow_recipes/_partials/input/txt2img_latent.yamlAdded+11
core/pipelines/workflow_recipes/_partials/input/txt2img_sd3_latent.yamlAdded+11
core/pipelines/workflow_recipes/sd_unified_recipe.yaml+2-2
core/settings.py+111-31
requirements.txt+10-9
ui/events.py+1044-286
ui/layout.py+16-62
ui/shared/hires_fix_ui.py+27-17
ui/shared/img2img_ui.py+27-18
ui/shared/inpaint_ui.py+38-20
ui/shared/outpaint_ui.py+35-22
ui/shared/txt2img_ui.py+26-11
ui/shared/ui_components.py+368-57
utils/app_utils.py+203-99
yaml/constants.yaml+138-1
yaml/file_list.yaml+626-6
yaml/image_gen_features.yamlAdded+117
yaml/injectors.yaml+26-2
yaml/model_architectures.yaml+65-1
yaml/model_defaults.yaml+206-22
yaml/model_list.yaml+5-16
yaml/private_file_list.yamlDeleted-12