mirror of
https://github.com/vladmandic/sdnext.git
synced 2026-10-12 02:24:13 +00:00
SDNQ compiles its helpers for static shapes, so an encode at a new prompt length or condition-image size recompiles them; on a long-running server each new length costs tens of seconds and logs the long-encode warning. With torch_skip_compile_te on (Compute Settings, next to the Triton autotune skips, off by default), hijack_encode_prompt runs the encoder under torch.compiler.set_stance("force_eager"): warm encodes are as fast as compiled ones and the denoiser keeps its compiled kernels. An encoder ticked under Compile Model keeps its compile.
898 lines
77 KiB
Python
898 lines
77 KiB
Python
from __future__ import annotations
|
|
import os
|
|
import sys
|
|
import gradio as gr
|
|
from modules import paths, shared_items, devices, theme
|
|
from modules.options import OptionInfo, options_section
|
|
from modules.ui_components import DropdownEditable
|
|
from modules.memstats import memory_stats
|
|
from modules.shared_defaults import get_default_modes
|
|
from modules.shared_items import sdnq_quant_modes, sdnq_matmul_modes
|
|
import modules.caption.openclip
|
|
import modules.caption.vqa
|
|
|
|
|
|
options_templates = {}
|
|
|
|
|
|
def list_onnx_providers():
|
|
try:
|
|
from modules.onnx_impl import execution_providers
|
|
providers = execution_providers.available_execution_providers
|
|
default_provider = execution_providers.get_default_execution_provider().value
|
|
return default_provider, providers
|
|
except Exception:
|
|
return "CPU", []
|
|
|
|
|
|
def list_checkpoint_titles():
|
|
from modules.sd_models import checkpoint_titles # pylint: disable=redefined-outer-name
|
|
return checkpoint_titles()
|
|
|
|
|
|
def refresh_checkpoints():
|
|
from modules.sd_models import list_models # pylint: disable=redefined-outer-name
|
|
return list_models()
|
|
|
|
|
|
def refresh_vaes():
|
|
from modules.sd_vae import refresh_vae_list # pylint: disable=redefined-outer-name
|
|
refresh_vae_list()
|
|
|
|
|
|
def refresh_upscalers():
|
|
from modules.modelloader import load_upscalers # pylint: disable=redefined-outer-name
|
|
load_upscalers()
|
|
|
|
|
|
def list_samplers():
|
|
import modules.sd_samplers # pylint: disable=redefined-outer-name
|
|
modules.sd_samplers.set_samplers()
|
|
return modules.sd_samplers.all_samplers
|
|
|
|
|
|
def list_upscalers():
|
|
from modules import shared # pylint: disable=redefined-outer-name
|
|
return [upscaler.name for upscaler in shared.sd_upscalers]
|
|
|
|
|
|
def get_openvino_device_list():
|
|
try:
|
|
import modules.intel.openvino # pylint: disable=redefined-outer-name
|
|
return modules.intel.openvino.get_device_list()
|
|
except Exception:
|
|
return []
|
|
|
|
|
|
def create_settings(cmd_opts):
|
|
|
|
# Calculate default modes
|
|
mem_stat = memory_stats()
|
|
startup_offload_mode, startup_offload_min_gpu, startup_offload_max_gpu, startup_cross_attention, startup_sdp_options, startup_sdp_choices, startup_offload_always, startup_offload_never = get_default_modes(cmd_opts=cmd_opts, mem_stat=mem_stat)
|
|
|
|
# System variables
|
|
gpu_memory = round(mem_stat['gpu']['total'] if "gpu" in mem_stat else 0)
|
|
if gpu_memory == 0:
|
|
gpu_memory = round(mem_stat['ram']['total'] if "ram" in mem_stat else 0)
|
|
|
|
default_hfcache_dir = os.environ.get("SD_HFCACHEDIR", None) or os.path.join(paths.models_path, 'huggingface')
|
|
default_checkpoint = list_checkpoint_titles()[0] if len(list_checkpoint_titles()) > 0 else "model.safetensors"
|
|
default_xetcache_dir = os.environ.get("HF_XET_CACHE", None) or os.path.join(paths.models_path, 'xet')
|
|
|
|
default_onnx_execution_provider, default_onnx_execution_providers = list_onnx_providers()
|
|
|
|
hide_dirs = {"visible": not cmd_opts.hide_ui_dir_config}
|
|
|
|
# --- SD Model Loading ---
|
|
options_templates.update(options_section(('sd', "Model Loading"), {
|
|
"sd_backend": OptionInfo('diffusers', "Execution backend", gr.Radio, {"choices": ['diffusers', 'original'], "visible": False }),
|
|
"diffusers_pipeline": OptionInfo('Autodetect', 'Model pipeline', gr.Dropdown, lambda: {"choices": list(shared_items.get_pipelines())}),
|
|
"sd_model_checkpoint": OptionInfo(default_checkpoint, "Base model", DropdownEditable, lambda: {"choices": list_checkpoint_titles()}, refresh=refresh_checkpoints),
|
|
"sd_model_refiner": OptionInfo('None', "Refiner model", gr.Dropdown, lambda: {"choices": ['None'] + list_checkpoint_titles()}, refresh=refresh_checkpoints),
|
|
"sd_unet": OptionInfo("Default", "UNET model", gr.Dropdown, lambda: {"choices": shared_items.sd_unet_items()}, refresh=shared_items.refresh_unet_list),
|
|
"sd_unet_secondary": OptionInfo("Default", "UNET model secondary", gr.Dropdown, lambda: {"choices": shared_items.sd_unet_items()}, refresh=shared_items.refresh_unet_list),
|
|
"latent_history": OptionInfo(20, "Latent history size", gr.Slider, {"minimum": 0, "maximum": 100, "step": 1}),
|
|
|
|
"advanced_sep": OptionInfo("<h2>Advanced Options</h2>", "", gr.HTML),
|
|
"sd_checkpoint_autoload": OptionInfo(True, "Model auto-load on start"),
|
|
"model_modular_enable": OptionInfo(False, "Model convert to modular pipelines"),
|
|
"sd_parallel_load": OptionInfo(True, "Model load using multiple threads"),
|
|
"sd_checkpoint_autodownload": OptionInfo(True, "Model auto-download on demand"),
|
|
"stream_load": OptionInfo(False, "Model load using streams", gr.Checkbox),
|
|
"diffusers_to_gpu": OptionInfo(False, "Model load model direct to GPU"),
|
|
"offload_state_dict": OptionInfo(False, "Model load offload state dict", gr.Checkbox),
|
|
"runai_streamer_diffusers": OptionInfo(False, "Diffusers load using Run:ai streamer", gr.Checkbox),
|
|
"runai_streamer_transformers": OptionInfo(False, "Transformers load using Run:ai streamer", gr.Checkbox),
|
|
"diffusers_eval": OptionInfo(False, "Force model eval", gr.Checkbox, {"visible": True }),
|
|
"allow_incomplete_model": OptionInfo(False, "Attempt to load incomplete model", gr.Checkbox),
|
|
"device_map": OptionInfo('default', "Model load device map", gr.Radio, {"choices": ['default', 'gpu', 'cpu'] }),
|
|
"disable_accelerate": OptionInfo(False, "Disable accelerate", gr.Checkbox, {"visible": False }),
|
|
"sd_checkpoint_cache": OptionInfo(0, "Cached models", gr.Slider, {"minimum": 0, "maximum": 10, "step": 1, "visible": False }),
|
|
}))
|
|
|
|
# --- Model Options ---
|
|
options_templates.update(options_section(('model_options', "Model Options"), {
|
|
"model_modular_sep": OptionInfo("<h2>Modular Pipelines</h2>", "", gr.HTML),
|
|
"model_google_sep": OptionInfo("<h2>Google GenAI</h2>", "", gr.HTML),
|
|
"google_use_vertexai": OptionInfo(False, "Google cloud use VertexAI endpoints"),
|
|
"google_api_key": OptionInfo("", "Google cloud API key", gr.Textbox, secret=True, env_var='GOOGLE_API_KEY'),
|
|
"google_project_id": OptionInfo("", "Google Cloud project ID", gr.Textbox, secret=True, env_var='GOOGLE_PROJECT_ID'),
|
|
"google_location_id": OptionInfo("", "Google Cloud location ID", gr.Textbox),
|
|
"model_xai_sep": OptionInfo("<h2>XAI Grok</h2>", "", gr.HTML),
|
|
"xai_api_key": OptionInfo("", "XAI Grok API key", gr.Textbox, secret=True, env_var='XAI_API_KEY'),
|
|
"model_krea2_sep": OptionInfo("<h2>Krea 2</h2>", "", gr.HTML),
|
|
"model_krea2_dense": OptionInfo(False, "Use dense masking"),
|
|
"model_sd3_sep": OptionInfo("<h2>Stable Diffusion 3.x</h2>", "", gr.HTML),
|
|
"model_sd3_disable_te5": OptionInfo(False, "Disable T5 text encoder"),
|
|
"model_h1_sep": OptionInfo("<h2>HiDream</h2>", "", gr.HTML),
|
|
"model_h1_llama_repo": OptionInfo("Default", "LLama repo", gr.Textbox),
|
|
"model_wan_sep": OptionInfo("<h2>WanAI</h2>", "", gr.HTML),
|
|
"model_wan_stage": OptionInfo("low noise", "Processing stage", gr.Radio, {"choices": ['high noise', 'low noise', 'combined'] }),
|
|
"model_wan_boundary": OptionInfo(-1, "Stage boundary ratio", gr.Slider, {"minimum": -1, "maximum": 1.0, "step": 0.05 }),
|
|
"model_chrono_sep": OptionInfo("<h2>ChronoEdit</h2>", "", gr.HTML),
|
|
"model_chrono_temporal_steps": OptionInfo(0, "Temporal steps", gr.Slider, {"minimum": 0, "maximum": 50, "step": 1 }),
|
|
"model_qwen_layer_sep": OptionInfo("<h2>Qwen layered</h2>", "", gr.HTML),
|
|
"model_qwen_layers": OptionInfo(2, "Qwen layered number of layers", gr.Slider, {"minimum": 2, "maximum": 9, "step": 1 }),
|
|
"model_ernie_sep": OptionInfo("<h2>ERNIE-Image</h2>", "", gr.HTML),
|
|
"model_ernie_enable_pe": OptionInfo(False, "Enable prompt-enhance"),
|
|
"model_lens_sep": OptionInfo("<h2>Lens</h2>", "", gr.HTML),
|
|
"model_lens_enable_pe": OptionInfo(False, "Enable prompt-enhance"),
|
|
"model_ideogram4_sep": OptionInfo("<h2>Ideogram 4</h2>", "", gr.HTML),
|
|
"model_ideogram4_enable_pe": OptionInfo(True, "Enable prompt-enhance"),
|
|
"model_ideogram4_enable_cg": OptionInfo(True, "Enable conditioning guidance"),
|
|
"model_ideogram4_pin": OptionInfo(False, "Pin transformers to VRAM"),
|
|
}))
|
|
|
|
# --- Model Offloading ---
|
|
options_templates.update(options_section(('offload', "Model Offloading"), {
|
|
"offload_sep": OptionInfo("<h2>Model Offloading</h2>", "", gr.HTML),
|
|
"diffusers_offload_mode": OptionInfo(startup_offload_mode, "Model offload mode", gr.Radio, {"choices": ['none', 'balanced', 'group', 'model', 'sequential']}),
|
|
"diffusers_offload_nonblocking": OptionInfo(False, "Non-blocking move operations"),
|
|
"offload_overrides_sep": OptionInfo("<h2>Offload Overrides</h2>", "", gr.HTML),
|
|
"models_not_to_offload": OptionInfo("", "Model types not to offload"),
|
|
"diffusers_offload_always": OptionInfo(startup_offload_always, "Modules to always offload"),
|
|
"diffusers_offload_never": OptionInfo(startup_offload_never, "Modules to never offload"),
|
|
"offload_balanced_sep": OptionInfo("<h2>Balanced Offload</h2>", "", gr.HTML),
|
|
"diffusers_offload_pre": OptionInfo(True, "Offload during pre-forward", gr.Checkbox, {"visible": False}),
|
|
"diffusers_offload_streams": OptionInfo(False, "Offload using streams"),
|
|
"diffusers_offload_min_gpu_memory": OptionInfo(startup_offload_min_gpu, "Offload low watermark", gr.Slider, {"minimum": 0, "maximum": 1, "step": 0.01 }),
|
|
"diffusers_offload_max_gpu_memory": OptionInfo(startup_offload_max_gpu, "Offload GPU high watermark", gr.Slider, {"minimum": 0.1, "maximum": 1, "step": 0.01 }),
|
|
"diffusers_offload_max_cpu_memory": OptionInfo(0.90, "Offload CPU high watermark", gr.Slider, {"minimum": 0, "maximum": 1, "step": 0.01, "visible": False }),
|
|
"offload_group_sep": OptionInfo("<h2>Group Offload</h2>", "", gr.HTML),
|
|
"group_offload_type": OptionInfo("leaf_level", "Group offload type", gr.Radio, {"choices": ['leaf_level', 'block_level']}),
|
|
"group_offload_stream": OptionInfo(False, "Prefetch with streams", gr.Checkbox),
|
|
'group_offload_record': OptionInfo(False, "Overlap stream transfers", gr.Checkbox),
|
|
'group_offload_pin': OptionInfo(False, "Pin offload memory", gr.Checkbox),
|
|
'group_offload_blocks': OptionInfo(1, "Group offload blocks", gr.Number),
|
|
"caption_offload_sep": OptionInfo("<h2>Caption Model Offloading</h2>", "", gr.HTML),
|
|
"caption_offload": OptionInfo(True, "Offload caption models"),
|
|
"caption_to_gpu": OptionInfo(True, "Load caption models direct to GPU"),
|
|
}))
|
|
|
|
# --- Model Quantization ---
|
|
options_templates.update(options_section(("quantization", "Model Quantization"), {
|
|
"quantize_sep": OptionInfo("<h2>Quantization General</h2>", "", gr.HTML),
|
|
"models_not_to_quant": OptionInfo("", "Model types not to quantize"),
|
|
|
|
"sdnq_quantize_sep": OptionInfo("<h2>SDNQ: SD.Next Quantization</h2>", "", gr.HTML),
|
|
"sdnq_quantize_weights": OptionInfo([], "Quantization enabled", gr.CheckboxGroup, {"choices": ["Model", "TE", "LLM", "Control", "VAE"]}),
|
|
"sdnq_quantize_mode": OptionInfo("auto", "Quantization mode", gr.Dropdown, {"choices": ["auto", "pre", "post"]}),
|
|
"sdnq_quantize_weights_mode": OptionInfo("int8", "Quantization type", gr.Dropdown, {"choices": sdnq_quant_modes}),
|
|
"sdnq_quantize_matmul_mode": OptionInfo("disabled", "Quantized MatMul type", gr.Dropdown, {"choices": sdnq_matmul_modes}),
|
|
"sdnq_quantize_weights_mode_te": OptionInfo("Same as model", "Quantization type for Text Encoders", gr.Dropdown, {"choices": ['Same as model'] + sdnq_quant_modes}),
|
|
"sdnq_quantize_matmul_mode_te": OptionInfo("disabled", "Quantized MatMul type for Text Encoders", gr.Dropdown, {"choices": ['Same as model'] + sdnq_matmul_modes}),
|
|
"sdnq_quantize_scale_mode": OptionInfo("none", "Double-Quantization type", gr.Dropdown, {"choices": ["none"] + sdnq_quant_modes}),
|
|
"sdnq_modules_to_not_convert": OptionInfo("", "Modules to not convert"),
|
|
"sdnq_modules_dtype_dict": OptionInfo("{}", "Modules dtype dict"),
|
|
"sdnq_group_size": OptionInfo(0, "Group size", gr.Slider, {"minimum": -2, "maximum": 4096, "step": 1}),
|
|
"sdnq_hadamard_group_size": OptionInfo(256, "Hadamard group size", gr.Slider, {"minimum": 4, "maximum": 4096, "step": 1}),
|
|
"sdnq_svd_rank": OptionInfo(32, "SVD rank size", gr.Slider, {"minimum": 1, "maximum": 512, "step": 1}),
|
|
"sdnq_svd_steps": OptionInfo(8, "SVD steps", gr.Slider, {"minimum": 1, "maximum": 128, "step": 1}),
|
|
"sdnq_codebook_steps": OptionInfo(24, "Lloyd-Max Codebook steps", gr.Slider, {"minimum": 1, "maximum": 128, "step": 1}),
|
|
"sdnq_dynamic_loss_threshold": OptionInfo(-1, "Dynamic loss threshold", gr.Slider, {"minimum": -1, "maximum": 0.1, "step": 1e-4}),
|
|
"sdnq_use_svd": OptionInfo(False, "Use SVD quantization", gr.Checkbox),
|
|
"sdnq_use_hadamard": OptionInfo(False, "Use Hadamard rotations", gr.Checkbox),
|
|
"sdnq_use_codebook": OptionInfo(False, "Use Lloyd-Max Codebook quantization", gr.Checkbox),
|
|
"sdnq_use_codebook_scale": OptionInfo(False, "Use Lloyd-Max Codebook quantization with double quantization", gr.Checkbox),
|
|
"sdnq_use_dynamic_quantization": OptionInfo(False, "Use Dynamic quantization", gr.Checkbox),
|
|
"sdnq_quantize_conv_layers": OptionInfo(False, "Quantize convolutional layers", gr.Checkbox),
|
|
"sdnq_quantize_embedding_layers": OptionInfo(False, "Quantize embedding layers", gr.Checkbox),
|
|
"sdnq_use_quantized_matmul_conv": OptionInfo(False, "Use quantized MatMul with conv", gr.Checkbox),
|
|
"sdnq_quantize_with_gpu": OptionInfo(True, "Quantize using GPU", gr.Checkbox),
|
|
"sdnq_dequantize_fp32": OptionInfo(True, "Dequantize using full precision", gr.Checkbox),
|
|
"sdnq_quantize_shuffle_weights": OptionInfo(False, "Shuffle weights in post mode", gr.Checkbox),
|
|
|
|
"nunchaku_sep": OptionInfo("<h2>Nunchaku Engine</h2>", "", gr.HTML),
|
|
"nunchaku_attention": OptionInfo(True, "Nunchaku attention", gr.Checkbox),
|
|
"nunchaku_offload": OptionInfo(True, "Nunchaku offloading", gr.Checkbox),
|
|
|
|
"layerwise_quantization_sep": OptionInfo("<h2>Layerwise Casting</h2>", "", gr.HTML),
|
|
"layerwise_quantization": OptionInfo([], "Layerwise casting enabled", gr.CheckboxGroup, {"choices": ["Model", "TE"]}),
|
|
"layerwise_quantization_storage": OptionInfo("float8_e4m3fn", "Layerwise casting storage", gr.Dropdown, {"choices": ["float8_e4m3fn", "float8_e5m2"]}),
|
|
"layerwise_quantization_nonblocking": OptionInfo(False, "Layerwise non-blocking operations", gr.Checkbox),
|
|
|
|
"trt_quantization_sep": OptionInfo("<h2>TensorRT</h2>", "", gr.HTML),
|
|
"trt_quantization": OptionInfo([], "Quantization enabled", gr.CheckboxGroup, {"choices": ["Model"]}),
|
|
"trt_quantization_type": OptionInfo("int8", "Quantization type", gr.Dropdown, {"choices": ["int8", "int4", "fp8", "nf4", "nvfp4"]}),
|
|
}))
|
|
|
|
# --- VAE & Text Encoder ---
|
|
options_templates.update(options_section(('vae_encoder', "Variational Auto Encoder"), {
|
|
"sd_vae": OptionInfo("Automatic", "VAE model", gr.Dropdown, lambda: {"choices": shared_items.sd_vae_items()}, refresh=shared_items.refresh_vae_list),
|
|
"diffusers_vae_upcast": OptionInfo("default", "VAE upcasting", gr.Radio, {"choices": ['default', 'true', 'false']}),
|
|
"no_half_vae": OptionInfo(False, "Full precision (--no-half-vae)"),
|
|
"diffusers_vae_slicing": OptionInfo(True, "VAE slicing", gr.Checkbox),
|
|
"diffusers_vae_tiling": OptionInfo(cmd_opts.lowvram, "VAE tiling", gr.Checkbox),
|
|
"diffusers_vae_tile_size": OptionInfo(0, "VAE tile size", gr.Slider, {"minimum": 0, "maximum": 4096, "step": 8 }),
|
|
"diffusers_vae_tile_overlap": OptionInfo(0.25, "VAE tile overlap", gr.Slider, {"minimum": 0, "maximum": 0.95, "step": 0.05 }),
|
|
"remote_vae_type": OptionInfo('raw', "Remote VAE image type", gr.Dropdown, {"choices": ['raw', 'jpg', 'png']}),
|
|
"remote_vae_encode": OptionInfo(False, "Remote VAE for encode"),
|
|
}))
|
|
|
|
options_templates.update(options_section(('text_encoder', "Text Encoder"), {
|
|
"sd_text_encoder": OptionInfo('Default', "Text encoder model", DropdownEditable, lambda: {"choices": shared_items.sd_te_items()}, refresh=shared_items.refresh_te_list),
|
|
"prompt_attention": OptionInfo("native", "Prompt attention parser", gr.Radio, {"choices": ["native", "compel", "xhinker", "a1111", "fixed"] }),
|
|
"prompt_mean_norm": OptionInfo(False, "Prompt attention normalization", gr.Checkbox),
|
|
"sd_textencoder_cache_size": OptionInfo(4, "Text encoder cache size", gr.Slider, {"minimum": 0, "maximum": 16, "step": 1}),
|
|
"sd_textencder_linebreak": OptionInfo(True, "Use line break as prompt segment marker", gr.Checkbox),
|
|
"diffusers_zeros_prompt_pad": OptionInfo(False, "Use zeros for prompt padding", gr.Checkbox),
|
|
"te_optional_sep": OptionInfo("<h2>Optional</h2>", "", gr.HTML),
|
|
"te_shared_te": OptionInfo(True, "Use shared instance of text encoder"),
|
|
"te_pooled_embeds": OptionInfo(False, "SDXL: Use weighted pooled embeds"),
|
|
"te_complex_human_instruction": OptionInfo(True, "Sana: Use complex human instructions"),
|
|
"te_use_mask": OptionInfo(True, "Lumina: Use mask in transformers"),
|
|
}))
|
|
|
|
# --- Compute Settings ---
|
|
options_templates.update(options_section(('cuda', "Cross Attention"), {
|
|
"cross_attention_optimization": OptionInfo(startup_cross_attention, "Attention method", gr.Radio, lambda: {"choices": shared_items.list_crossattention()}),
|
|
# "sdp_overrides": OptionInfo(startup_sdp_override_options, "SDP overrides", gr.CheckboxGroup, {"choices": startup_sdp_override_choices}),
|
|
|
|
"attention_slicing_sep": OptionInfo("<h2>Attention Slicing</h2>", "", gr.HTML),
|
|
"attention_slicing": OptionInfo('Default', "Attention slicing", gr.Radio, {"choices": ['Default', 'Enabled', 'Disabled']}),
|
|
"dynamic_attention_slice_rate": OptionInfo(0.5, "Dynamic Attention slicing rate", gr.Slider, {"minimum": 0.01, "maximum": max(gpu_memory,4), "step": 0.01}),
|
|
"dynamic_attention_trigger_rate": OptionInfo(1, "Dynamic Attention trigger rate", gr.Slider, {"minimum": 0.01, "maximum": max(gpu_memory,4)*2, "step": 0.01}),
|
|
|
|
"sdp_attention_sep": OptionInfo("<h2>SDP Attention</h2>", "", gr.HTML),
|
|
"sdp_options": OptionInfo(startup_sdp_options, "SDP kernels", gr.CheckboxGroup, {"choices": startup_sdp_choices}),
|
|
|
|
"sdnq_attention_sep": OptionInfo("<h2>SDNQ Attention</h2>", "", gr.HTML),
|
|
"sdnq_attention_smooth_k": OptionInfo(True, "SDNQ Attention use Smooth K", gr.Checkbox),
|
|
"sdnq_attention_use_hadamard": OptionInfo(False, "SDNQ Attention use Hadamard", gr.Checkbox),
|
|
"sdnq_attention_use_fp16_accum": OptionInfo(False, "SDNQ Attention use FP16 Accumulation", gr.Checkbox),
|
|
"sdnq_attention_quantize_fp32": OptionInfo(True, "SDNQ Attention Quantize FP32", gr.Checkbox),
|
|
"sdnq_attention_matmul_type": OptionInfo("enabled", "SDNQ Attention MatMul type", gr.Radio, {"choices": sdnq_matmul_modes}),
|
|
"sdnq_attention_pv_matmul_type": OptionInfo("disabled", "SDNQ Attention PV MatMul type", gr.Radio, {"choices": sdnq_matmul_modes}),
|
|
"sdnq_attention_hadamard_group_size": OptionInfo(256, "SDNQ Attention Hadamard Group Size", gr.Slider, {"minimum": 4, "maximum": 1024, "step": 1}),
|
|
|
|
"sparse_attention_sep": OptionInfo("<h2>Sparse Attention</h2>", "", gr.HTML),
|
|
"sparse_attention_enabled": OptionInfo(False, "Sparse Attention", gr.Checkbox),
|
|
"sparse_attention_budget": OptionInfo(30, "Sparse Attention KV budget", gr.Slider, {"minimum": 5, "maximum": 100, "step": 5}),
|
|
"sparse_attention_min_tokens": OptionInfo(8192, "Sparse Attention minimum sequence", gr.Slider, {"minimum": 0, "maximum": 32768, "step": 1024}),
|
|
"sparse_attention_schedule_steps": OptionInfo(0, "Sparse Attention dense steps", gr.Slider, {"minimum": 0, "maximum": 10, "step": 1}),
|
|
"sparse_attention_schedule_bump": OptionInfo(30, "Sparse Attention dense step bonus", gr.Slider, {"minimum": 0, "maximum": 70, "step": 5}),
|
|
"sparse_attention_head_shared": OptionInfo(False, "Sparse Attention share selection across heads", gr.Checkbox),
|
|
"sparse_attention_exclude": OptionInfo("CosmosTransformer3DModel", "Sparse Attention excluded models", gr.Textbox),
|
|
|
|
"hf_attention_sep": OptionInfo("<h2>Attention Dispatcher</h2>", "", gr.HTML),
|
|
"hf_attention": OptionInfo('', "Attention dispatcher kernel", gr.Textbox),
|
|
}))
|
|
|
|
# --- Backend Settings ---
|
|
options_templates.update(options_section(('backends', "Compute Settings"), {
|
|
"math_sep": OptionInfo("<h2>Execution Precision</h2>", "", gr.HTML),
|
|
"precision": OptionInfo("Autocast", "Precision type", gr.Radio, {"choices": ["Autocast", "Full"], "visible": False}),
|
|
"cuda_dtype": OptionInfo("Auto", "Device precision type", gr.Radio, {"choices": ["Auto", "FP32", "FP16", "BF16"]}),
|
|
"force_dtype": OptionInfo(False, "Force dtype on load", None, None, None),
|
|
"no_half": OptionInfo(False, "Force full precision (--no-half)", None, None, None),
|
|
"upcast_sampling": OptionInfo(False if sys.platform != "darwin" else True, "Upcast sampling", gr.Checkbox, {"visible": False}),
|
|
|
|
"generator_sep": OptionInfo("<h2>Noise Options</h2>", "", gr.HTML),
|
|
"diffusers_generator_device": OptionInfo("GPU", "Generator device", gr.Radio, {"choices": ["GPU", "CPU", "Unset"]}),
|
|
|
|
"other_sep": OptionInfo("<h2>Torch Options</h2>", "", gr.HTML),
|
|
"opt_channelslast": OptionInfo(False, "Channels last "),
|
|
"cudnn_deterministic": OptionInfo(False, "Deterministic mode"),
|
|
"diffusers_fuse_projections": OptionInfo(False, "Fused projections"),
|
|
"torch_expandable_segments": OptionInfo(False, "Expandable segments"),
|
|
"torch_sync": OptionInfo(True, "Force synchronize"),
|
|
"triton_skip_autotune": OptionInfo(False, "Skip Triton autotune", gr.Checkbox),
|
|
"triton_skip_autotune_te": OptionInfo(False, "Skip Triton autotune for TE", gr.Checkbox),
|
|
"torch_skip_compile_te": OptionInfo(False, "Skip Torch compile for TE", gr.Checkbox),
|
|
"cudnn_enabled": OptionInfo("default", "cuDNN enabled", gr.Radio, {"choices": ["default", "true", "false"]}),
|
|
"cudnn_benchmark": OptionInfo(devices.backend != "rocm", "cuDNN full-depth benchmark"),
|
|
"cudnn_benchmark_limit": OptionInfo(10, "cuDNN benchmark limit", gr.Slider, {"minimum": 0, "maximum": 100, "step": 1}),
|
|
"torch_tunable_ops": OptionInfo("default", "Tunable ops", gr.Radio, {"choices": ["default", "true", "false"]}),
|
|
"torch_tunable_limit": OptionInfo(30, "Tunable ops limit", gr.Slider, {"minimum": 1, "maximum": 100, "step": 1}),
|
|
"cuda_mem_fraction": OptionInfo(0.0, "Memory limit", gr.Slider, {"minimum": 0, "maximum": 1.0, "step": 0.05}),
|
|
"torch_gc_threshold": OptionInfo(70, "GC threshold", gr.Slider, {"minimum": 1, "maximum": 100, "step": 1}),
|
|
"inference_mode": OptionInfo("no-grad", "Inference mode", gr.Radio, {"choices": ["no-grad", "inference-mode", "none"]}),
|
|
"torch_malloc": OptionInfo("native", "Memory allocator", gr.Radio, {"choices": ['native', 'cudaMallocAsync'] }),
|
|
|
|
"onnx_sep": OptionInfo("<h2>ONNX</h2>", "", gr.HTML),
|
|
"onnx_execution_provider": OptionInfo(default_onnx_execution_provider, 'ONNX Execution Provider', gr.Dropdown, lambda: {"choices": default_onnx_execution_providers}),
|
|
"onnx_cpu_fallback": OptionInfo(True, 'ONNX allow fallback to CPU'),
|
|
"onnx_cache_converted": OptionInfo(True, 'ONNX cache converted models'),
|
|
"onnx_unload_base": OptionInfo(False, 'ONNX unload base model when processing refiner', gr.Checkbox, {"visible": False}),
|
|
|
|
"olive_sep": OptionInfo("<h2>Olive</h2>", "", gr.HTML),
|
|
"olive_float16": OptionInfo(True, 'Olive use FP16 on optimization'),
|
|
"olive_vae_encoder_float32": OptionInfo(False, 'Olive force FP32 for VAE Encoder'),
|
|
"olive_static_dims": OptionInfo(True, 'Olive use static dimensions'),
|
|
"olive_cache_optimized": OptionInfo(True, 'Olive cache optimized models'),
|
|
|
|
"ipex_sep": OptionInfo("<h2>IPEX</h2>", "", gr.HTML, {"visible": devices.backend == "ipex"}),
|
|
"ipex_optimize": OptionInfo([], "IPEX Optimize", gr.CheckboxGroup, {"choices": ["Model", "TE", "VAE", "Upscaler"], "visible": devices.backend == "ipex"}),
|
|
|
|
"openvino_sep": OptionInfo("<h2>OpenVINO</h2>", "", gr.HTML, {"visible": cmd_opts.use_openvino}),
|
|
"openvino_devices": OptionInfo([], "OpenVINO device", gr.CheckboxGroup, {"choices": get_openvino_device_list() if cmd_opts.use_openvino else [], "visible": cmd_opts.use_openvino}),
|
|
"openvino_accuracy": OptionInfo("default", "OpenVINO accuracy mode", gr.Radio, {"choices": ["default", "performance", "accuracy"], "visible": cmd_opts.use_openvino}),
|
|
"openvino_compile_backend": OptionInfo("openvino_fx", "OpenVINO compile backend", gr.Radio, {"choices": ["openvino", "openvino_fx"], "visible": cmd_opts.use_openvino}),
|
|
"openvino_disable_model_caching": OptionInfo(True, "OpenVINO disable model caching", gr.Checkbox, {"visible": cmd_opts.use_openvino}),
|
|
"openvino_disable_memory_cleanup": OptionInfo(True, "OpenVINO disable memory cleanup", gr.Checkbox, {"visible": cmd_opts.use_openvino}),
|
|
}))
|
|
|
|
# --- Compute Add-ons ---
|
|
options_templates.update(options_section(('advanced', "Compute Add-ons"), {
|
|
"clip_skip_sep": OptionInfo("<h2>CLiP Skip</h2>", "", gr.HTML),
|
|
"clip_skip_enabled": OptionInfo(False, "CLiP skip enabled"),
|
|
|
|
"token_merging_sep": OptionInfo("<h2>Token Merging</h2>", "", gr.HTML),
|
|
"token_merging_method": OptionInfo("None", "Token merging enabled", gr.Radio, {"choices": ['None', 'ToMe', 'ToDo']}),
|
|
"tome_ratio": OptionInfo(0.0, "ToMe token merging ratio", gr.Slider, {"minimum": 0.0, "maximum": 1.0, "step": 0.05}),
|
|
"todo_ratio": OptionInfo(0.0, "ToDo token merging ratio", gr.Slider, {"minimum": 0.0, "maximum": 1.0, "step": 0.05}),
|
|
|
|
"freeu_sep": OptionInfo("<h2>FreeU</h2>", "", gr.HTML),
|
|
"freeu_enabled": OptionInfo(False, "FreeU enabled"),
|
|
"freeu_b1": OptionInfo(1.2, "FreeU 1st stage backbone", gr.Slider, {"minimum": 1.0, "maximum": 2.0, "step": 0.01}),
|
|
"freeu_b2": OptionInfo(1.4, "FreeU 2nd stage backbone", gr.Slider, {"minimum": 1.0, "maximum": 2.0, "step": 0.01}),
|
|
"freeu_s1": OptionInfo(0.9, "FreeU 1st stage skip", gr.Slider, {"minimum": 0.0, "maximum": 1.0, "step": 0.01}),
|
|
"freeu_s2": OptionInfo(0.2, "FreeU 2nd stage skip", gr.Slider, {"minimum": 0.0, "maximum": 1.0, "step": 0.01}),
|
|
|
|
"pag_sep": OptionInfo("<h2>PAG: Perturbed attention guidance</h2>", "", gr.HTML),
|
|
"pag_apply_layers": OptionInfo("m0", "PAG layer names"),
|
|
|
|
"pab_sep": OptionInfo("<h2>PAB: Pyramid attention broadcast </h2>", "", gr.HTML),
|
|
"pab_enabled": OptionInfo(False, "PAB cache enabled"),
|
|
"pab_spacial_skip_range": OptionInfo(0, "PAB spacial skip range", gr.Slider, {"minimum": 0, "maximum": 4, "step": 1}),
|
|
"pab_spacial_skip_start": OptionInfo(100, "PAB spacial skip start", gr.Slider, {"minimum": 0, "maximum": 1000, "step": 1}),
|
|
"pab_spacial_skip_end": OptionInfo(800, "PAB spacial skip end", gr.Slider, {"minimum": 0, "maximum": 1000, "step": 1}),
|
|
|
|
"fb_sep": OptionInfo("<h2>FBC: First Block Cache</h2>", "", gr.HTML),
|
|
"fb_enabled": OptionInfo(False, "First Block cache enabled"),
|
|
"fb_threshold": OptionInfo(0.05, "First Block cache threshold", gr.Slider, {"minimum": 0.0, "maximum": 1.0, "step": 0.01}),
|
|
|
|
"fc_sep": OptionInfo("<h2>FC: Faster Cache</h2>", "", gr.HTML),
|
|
"fc_enabled": OptionInfo(False, "FasterCache cache enabled"),
|
|
"fc_spacial_skip_range": OptionInfo(2, "FasterCache spacial skip range", gr.Slider, {"minimum": 1, "maximum": 4, "step": 1}),
|
|
"fc_spacial_skip_start": OptionInfo(0, "FasterCache spacial skip start", gr.Slider, {"minimum": 0, "maximum": 1000, "step": 1}),
|
|
"fc_spacial_skip_end": OptionInfo(681, "FasterCache spacial skip end", gr.Slider, {"minimum": 0, "maximum": 1.0, "step": 0.01}),
|
|
"fc_uncond_skip_range": OptionInfo(5, "FasterCache uncond skip range", gr.Slider, {"minimum": 1, "maximum": 4, "step": 1}),
|
|
"fc_uncond_skip_start": OptionInfo(0, "FasterCache uncond skip start", gr.Slider, {"minimum": 0.0, "maximum": 1.0, "step": 0.01}),
|
|
"fc_uncond_skip_end": OptionInfo(781, "FasterCache uncond skip end", gr.Slider, {"minimum": 0, "maximum": 1, "step": 1}),
|
|
"fc_attention_weight": OptionInfo(0.5, "FasterCache spacial skip range", gr.Slider, {"minimum": 0.0, "maximum": 1.0, "step": 0.05}),
|
|
"fc_tensor_format": OptionInfo("BCFHW", "FasterCache tensor format", gr.Radio, {"choices": ["BCFHW", "BFCHW", "BCHW"]}),
|
|
"fc_guidance_distilled": OptionInfo(False, "FasterCache guidance distilled", gr.Checkbox),
|
|
|
|
"ls_sep": OptionInfo("<h2>LS: Layer Skip</h2>", "", gr.HTML),
|
|
"ls_enabled": OptionInfo(False, "Layer Skip enabled"),
|
|
"ls_indices": OptionInfo('', "Layer Skip indices", gr.Textbox, {"placeholder": "e.g. 0,1,2-5"}),
|
|
"ls_fqn": OptionInfo("auto", "Layer Skip FQN", gr.Textbox, {"placeholder": "e.g. model.diffusion_model.input_blocks.0"}),
|
|
"ls_skip_attention": OptionInfo(True, "Layer Skip skip attention", gr.Checkbox),
|
|
"ls_skip_attention_scores": OptionInfo(False, "Layer Skip skip attention scores", gr.Checkbox),
|
|
"ls_skip_ff": OptionInfo(True, "Layer Skip skip feedforward", gr.Checkbox),
|
|
"ls_dropout": OptionInfo(1.0, "Layer Skip dropout", gr.Slider, {"minimum": 0.0, "maximum": 1.0, "step": 0.01}),
|
|
|
|
"mc_sep": OptionInfo("<h2>MC: Mag Cache</h2>", "", gr.HTML),
|
|
"mc_enabled": OptionInfo(False, "Mag Cache enabled"),
|
|
"mc_threshold": OptionInfo(0.06, "Mag Cache threshold", gr.Slider, {"minimum": 0.0, "maximum": 1.0, "step": 0.01}),
|
|
"mc_max_skip_steps": OptionInfo(3, "Mag Cache max skip steps", gr.Slider, {"minimum": 1, "maximum": 10, "step": 1}),
|
|
"mc_retention_ratio": OptionInfo(0.2, "Mag Cache retention ratio", gr.Slider, {"minimum": 0.0, "maximum": 1.0, "step": 0.01}),
|
|
|
|
"ts_sep": OptionInfo("<h2>TS: TaylorSeer</h2>", "", gr.HTML),
|
|
"ts_enabled": OptionInfo(False, "TaylorSeer enabled"),
|
|
"ts_cache_interval": OptionInfo(5, "TaylorSeer cache interval", gr.Slider, {"minimum": 1, "maximum": 20, "step": 1}),
|
|
"ts_disable_cache_before_step": OptionInfo(3, "TaylorSeer disable cache before step", gr.Slider, {"minimum": 0, "maximum": 20, "step": 1}),
|
|
"ts_disable_cache_after_step": OptionInfo(-1, "TaylorSeer disable cache after step", gr.Slider, {"minimum": -1, "maximum": 20, "step": 1}),
|
|
"ts_max_order": OptionInfo(1, "TaylorSeer max order", gr.Slider, {"minimum": 1, "maximum": 5, "step": 1}),
|
|
"ts_skip_predict_identifiers": OptionInfo("", "TaylorSeer skip predict identifiers", gr.Textbox, {"placeholder": "e.g. model.diffusion_model.input_blocks.0,model.diffusion_model.middle_block"}),
|
|
"ts_cache_identifiers": OptionInfo("", "TaylorSeer cache identifiers", gr.Textbox, {"placeholder": "e.g. model.diffusion_model.input_blocks.0,model.diffusion_model.middle_block"}),
|
|
"ts_use_lite_mode": OptionInfo(False, "TaylorSeer use lite mode", gr.Checkbox),
|
|
|
|
"cache_dit_sep": OptionInfo("<h2>Cache-DiT</h2>", "", gr.HTML),
|
|
"cache_dit_enabled": OptionInfo(False, "Cache-DiT enabled"),
|
|
"cache_dit_calibrator": OptionInfo("None", "Cache-DiT calibrator", gr.Radio, {"choices": ["None", "TaylorSeer", "FoCa"]}),
|
|
"cache_dit_fcompute": OptionInfo(-1, "Cache-DiT F-compute blocks", gr.Slider, {"minimum": -1, "maximum": 32, "step": 1}),
|
|
"cache_dit_bcompute": OptionInfo(-1, "Cache-DiT B-compute blocks", gr.Slider, {"minimum": -1, "maximum": 32, "step": 1}),
|
|
"cache_dit_threshold": OptionInfo(-1, "Cache-DiT residual diff threshold", gr.Slider, {"minimum": -1.0, "maximum": 1.0, "step": 0.01}),
|
|
"cache_dit_warmup": OptionInfo(-1, "Cache-DiT warmup steps", gr.Slider, {"minimum": -1, "maximum": 50, "step": 1}),
|
|
|
|
"para_sep": OptionInfo("<h2>Para-attention</h2>", "", gr.HTML),
|
|
"para_cache_enabled": OptionInfo(False, "ParaAttention first-block cache enabled"),
|
|
"para_diff_threshold": OptionInfo(0.1, "ParaAttention residual diff threshold", gr.Slider, {"minimum": 0.0, "maximum": 1.0, "step": 0.01}),
|
|
|
|
"teacache_sep": OptionInfo("<h2>TeaCache</h2>", "", gr.HTML),
|
|
"teacache_enabled": OptionInfo(False, "TeaCache cache enabled"),
|
|
"teacache_thresh": OptionInfo(0.15, "TeaCache L1 threshold", gr.Slider, {"minimum": 0.0, "maximum": 1.0, "step": 0.01}),
|
|
|
|
"hypertile_sep": OptionInfo("<h2>HyperTile</h2>", "", gr.HTML),
|
|
"hypertile_unet_enabled": OptionInfo(False, "Hypertile UNet Enabled"),
|
|
"hypertile_hires_only": OptionInfo(False, "Hypertile HiRes pass only"),
|
|
"hypertile_unet_tile": OptionInfo(0, "Hypertile UNet max tile size", gr.Slider, {"minimum": 0, "maximum": 1024, "step": 8}),
|
|
"hypertile_unet_min_tile": OptionInfo(0, "Hypertile UNet min tile size", gr.Slider, {"minimum": 0, "maximum": 1024, "step": 8}),
|
|
"hypertile_unet_swap_size": OptionInfo(1, "Hypertile UNet swap size", gr.Slider, {"minimum": 1, "maximum": 10, "step": 1}),
|
|
"hypertile_unet_depth": OptionInfo(0, "Hypertile UNet depth", gr.Slider, {"minimum": 0, "maximum": 4, "step": 1}),
|
|
"hypertile_vae_enabled": OptionInfo(False, "Hypertile VAE Enabled", gr.Checkbox),
|
|
"hypertile_vae_tile": OptionInfo(128, "Hypertile VAE tile size", gr.Slider, {"minimum": 0, "maximum": 1024, "step": 8}),
|
|
"hypertile_vae_swap_size": OptionInfo(1, "Hypertile VAE swap size", gr.Slider, {"minimum": 1, "maximum": 10, "step": 1}),
|
|
|
|
"hidiffusion_sep": OptionInfo("<h2>HiDiffusion</h2>", "", gr.HTML),
|
|
"hidiffusion_raunet": OptionInfo(True, "HiDiffusion apply RAU-Net"),
|
|
"hidiffusion_attn": OptionInfo(True, "HiDiffusion apply MSW-MSA"),
|
|
"hidiffusion_steps": OptionInfo(8, "HiDiffusion aggressive at step", gr.Slider, {"minimum": 1, "maximum": 10, "step": 1}),
|
|
"hidiffusion_t1": OptionInfo(-1, "HiDiffusion override T1 ratio", gr.Slider, {"minimum": -1, "maximum": 1.0, "step": 0.05}),
|
|
"hidiffusion_t2": OptionInfo(-1, "HiDiffusion override T2 ratio", gr.Slider, {"minimum": -1, "maximum": 1.0, "step": 0.05}),
|
|
|
|
"linfusion_sep": OptionInfo("<h2>LinFusion</h2>", "", gr.HTML),
|
|
"enable_linfusion": OptionInfo(False, "LinFusion apply distillation on load"),
|
|
|
|
"ras_sep": OptionInfo("<h2>RAS: Region-Adaptive Sampling</h2>", "", gr.HTML),
|
|
"ras_enable": OptionInfo(False, "RAS enabled"),
|
|
|
|
"cfgzero_sep": OptionInfo("<h2>CFG-Zero</h2>", "", gr.HTML),
|
|
"cfgzero_enabled": OptionInfo(False, "CFG-Zero enabled"),
|
|
"cfgzero_star": OptionInfo(False, "CFG-Zero star"),
|
|
"cfgzero_steps": OptionInfo(0, "CFG-Zero steps", gr.Slider, {"minimum": 0, "maximum": 3, "step": 1}),
|
|
|
|
"inference_batch_sep": OptionInfo("<h2>Batch</h2>", "", gr.HTML),
|
|
"sequential_seed": OptionInfo(True, "Batch mode uses sequential seeds"),
|
|
"batch_frame_mode": OptionInfo(False, "Parallel process images in batch"),
|
|
}))
|
|
|
|
# --- Model Compile ---
|
|
options_templates.update(options_section(('compile', "Model Compile"), {
|
|
"cuda_compile_sep": OptionInfo("<h2>Model Compile</h2>", "", gr.HTML),
|
|
"cuda_compile": OptionInfo([] if not cmd_opts.use_openvino else ["Model", "VAE", "Upscaler", "Control"], "Compile Model", gr.CheckboxGroup, {"choices": ["Model", "TE", "VAE", "LLM", "Control", "Upscaler"]}),
|
|
"cuda_compile_backend": OptionInfo("inductor" if not cmd_opts.use_openvino else "openvino_fx", "Model compile backend", gr.Radio, {"choices": ['none', 'inductor', 'cudagraphs', 'aot_ts_nvfuser', 'hidet', 'migraphx', 'ipex', 'onediff', 'stable-fast', 'deep-cache', 'olive-ai', 'openvino', 'openvino_fx', 'pruna']}),
|
|
"torch_compile_sep": OptionInfo("<h2>Torch Compile</h2>", "", gr.HTML),
|
|
"cuda_compile_mode": OptionInfo("default", "Model compile mode", gr.Radio, {"choices": ['default', 'reduce-overhead', 'max-autotune', 'max-autotune-no-cudagraphs']}),
|
|
"cuda_compile_options": OptionInfo(["repeated", "dynamic", "components"] if not cmd_opts.use_openvino else [], "Torch compile options", gr.CheckboxGroup, {"choices": ["components", "precompile", "repeated", "fullgraph", "dynamic", "verbose"]}),
|
|
"deepcache_compile_sep": OptionInfo("<h2>DeepCache</h2>", "", gr.HTML),
|
|
"deep_cache_interval": OptionInfo(3, "DeepCache cache interval", gr.Slider, {"minimum": 1, "maximum": 10, "step": 1}),
|
|
"pruna_compile_sep": OptionInfo("<h2>Pruna</h2>", "", gr.HTML),
|
|
"pruna_experimental": OptionInfo(False, "Pruna experimental features", gr.Checkbox),
|
|
"pruna_cachers": OptionInfo([], "Pruna cachers", gr.CheckboxGroup, {"choices": ["fastercache", "deepcache", "fora", "pab"]}),
|
|
"pruna_compilers": OptionInfo([], "Pruna compilers", gr.CheckboxGroup, {"choices": ["stable_fast", "x_fast", "torch_compile"]}),
|
|
"pruna_factorizers": OptionInfo([], "Pruna factorizers", gr.CheckboxGroup, {"choices": ["qkv_diffusers"]}),
|
|
"pruna_pruners": OptionInfo([], "Pruna pruners", gr.CheckboxGroup, {"choices": ["kvpress", "padding_pruning", "token_merging", "torch_structured", "torch_unstructured"]}),
|
|
}))
|
|
|
|
# --- Server Settings ---
|
|
options_templates.update(options_section(('server', "Server Settings"), {
|
|
"server_listen": OptionInfo(False, "Listen on all interfaces", gr.Checkbox),
|
|
"server_status": OptionInfo(120, "Automatic server status monitor rate", gr.Number, {"minimum": 0, "maximum": 1000, "step": 1}),
|
|
"server_monitor": OptionInfo(0, "Automatic server memory monitor rate", gr.Number, {"minimum": 0, "maximum": 1000, "step": 1}),
|
|
"server_rate_limit": OptionInfo(300, "API base rate limit rate", gr.Number, {"minimum": 0, "maximum": 1000, "step": 1}),
|
|
}))
|
|
|
|
# --- System Paths ---
|
|
options_templates.update(options_section(('system-paths', "System Paths"), {
|
|
"models_paths_sep_options": OptionInfo("<h2>Models root folder</h2>", "", gr.HTML),
|
|
"models_dir": OptionInfo('models', "Root model folder", folder=True),
|
|
"model_paths_sep_options": OptionInfo("<h2>Folders for specific models</h2>", "", gr.HTML),
|
|
"ckpt_dir": OptionInfo(os.path.join(paths.models_path, 'Stable-diffusion'), "Folder with stable diffusion models", folder=True),
|
|
"diffusers_dir": OptionInfo(os.path.join(paths.models_path, 'Diffusers'), "Folder with Huggingface models", folder=True),
|
|
"hfcache_dir": OptionInfo(default_hfcache_dir, "Folder for Huggingface cache", folder=True),
|
|
"xetcache_dir": OptionInfo(default_xetcache_dir, "Folder for XET cache", folder=True),
|
|
"tunable_dir": OptionInfo(os.path.join(paths.models_path, 'tunable'), "Folder for Tunable ops cache", folder=True),
|
|
"vae_dir": OptionInfo(os.path.join(paths.models_path, 'VAE'), "Folder with VAE files", folder=True),
|
|
"unet_dir": OptionInfo(os.path.join(paths.models_path, 'UNET'), "Folder with UNET files", folder=True),
|
|
"te_dir": OptionInfo(os.path.join(paths.models_path, 'Text-encoder'), "Folder with Text encoder files", folder=True),
|
|
"lora_dir": OptionInfo(os.path.join(paths.models_path, 'Lora'), "Folder with LoRA network(s)", folder=True),
|
|
"styles_dir": OptionInfo(os.path.join(paths.models_path, 'styles'), "File or Folder with user-defined styles", folder=True),
|
|
"wildcards_dir": OptionInfo(os.path.join(paths.models_path, 'wildcards'), "Folder with user-defined wildcards", folder=True),
|
|
"autocomplete_dir": OptionInfo(os.path.join(paths.models_path, 'autocomplete'), "Folder with tag autocomplete files", folder=True),
|
|
"embeddings_dir": OptionInfo(os.path.join(paths.models_path, 'embeddings'), "Folder with textual inversion embeddings", folder=True),
|
|
"control_dir": OptionInfo(os.path.join(paths.models_path, 'control'), "Folder with Control models", folder=True),
|
|
"yolo_dir": OptionInfo(os.path.join(paths.models_path, 'yolo'), "Folder with Yolo models", folder=True),
|
|
"esrgan_models_path": OptionInfo(os.path.join(paths.models_path, 'ESRGAN'), "Folder with ESRGAN models", folder=True),
|
|
"bsrgan_models_path": OptionInfo(os.path.join(paths.models_path, 'BSRGAN'), "Folder with BSRGAN models", folder=True),
|
|
"realesrgan_models_path": OptionInfo(os.path.join(paths.models_path, 'RealESRGAN'), "Folder with RealESRGAN models", folder=True),
|
|
"scunet_models_path": OptionInfo(os.path.join(paths.models_path, 'SCUNet'), "Folder with SCUNet models", folder=True),
|
|
"swinir_models_path": OptionInfo(os.path.join(paths.models_path, 'SwinIR'), "Folder with SwinIR models", folder=True),
|
|
"clip_models_path": OptionInfo(os.path.join(paths.models_path, 'CLIP'), "Folder with CLIP models", folder=True),
|
|
|
|
"allowed_paths_sep_options": OptionInfo("<h2>Allowed folders</h2>", "", gr.HTML),
|
|
"allowed_paths": OptionInfo('', "Additional folders with access permissions", folder=True),
|
|
|
|
"other_paths_sep_options": OptionInfo("<h2>Cache folders</h2>", "", gr.HTML),
|
|
"clean_temp_dir_at_start": OptionInfo(True, "Cleanup temporary folder on startup"),
|
|
"temp_dir": OptionInfo("", "Directory for temporary files; leave empty for default", folder=True),
|
|
"accelerate_offload_path": OptionInfo('cache/accelerate', "Folder for disk offload", folder=True),
|
|
"openvino_cache_path": OptionInfo('cache', "Folder for OpenVINO cache", folder=True),
|
|
"onnx_cached_models_path": OptionInfo(os.path.join(paths.models_path, 'ONNX', 'cache'), "Folder for ONNX cached models", folder=True),
|
|
"onnx_temp_dir": OptionInfo(os.path.join(paths.models_path, 'ONNX', 'temp'), "Folder for ONNX conversion", folder=True),
|
|
"dlss_pkg_path": OptionInfo('', "Folder with DLSS package", gr.Textbox, { "visible": False}),
|
|
}))
|
|
|
|
# --- Image Options ---
|
|
options_templates.update(options_section(('saving-images', "Image Options"), {
|
|
"samples_save": OptionInfo(True, "Save all generated images"),
|
|
"keep_incomplete": OptionInfo(True, "Save interrupted images"),
|
|
"samples_format": OptionInfo('jpg', 'File format', gr.Dropdown, {"choices": ["jpg", "png", "webp", "tiff", "jp2", "jxl", "heif"]}),
|
|
"jpeg_quality": OptionInfo(90, "Image quality", gr.Slider, {"minimum": 1, "maximum": 100, "step": 1}),
|
|
"img_max_size_mp": OptionInfo(1000, "Maximum image size (MP)", gr.Slider, {"minimum": 10, "maximum": 2000, "step": 1}),
|
|
"webp_lossless": OptionInfo(False, "WebP lossless compression"),
|
|
"save_selected_only": OptionInfo(True, "UI save only saves selected image"),
|
|
"include_mask": OptionInfo(False, "Include mask in outputs"),
|
|
"samples_save_zip": OptionInfo(False, "Create ZIP archive for multiple images"),
|
|
"image_background": OptionInfo("#000000", "Resize background color", gr.ColorPicker, {}),
|
|
|
|
"image_sep_grid": OptionInfo("<h2>Grid Options</h2>", "", gr.HTML),
|
|
"grid_save": OptionInfo(True, "Save all generated image grids"),
|
|
"grid_format": OptionInfo('jpg', 'File format', gr.Dropdown, {"choices": ["jpg", "png", "webp", "tiff", "jp2", "jxl"]}),
|
|
"n_rows": OptionInfo(-1, "Grid max rows count", gr.Slider, {"minimum": -1, "maximum": 16, "step": 1}),
|
|
"n_cols": OptionInfo(-1, "Grid max columns count", gr.Slider, {"minimum": -1, "maximum": 16, "step": 1}),
|
|
"grid_background": OptionInfo("#000000", "Grid background color", gr.ColorPicker, {}),
|
|
"font": OptionInfo("", "Font file"),
|
|
"font_color": OptionInfo("#FFFFFF", "Font color", gr.ColorPicker, {}),
|
|
|
|
"image_sep_browser": OptionInfo("<h2>Image Gallery</h2>", "", gr.HTML),
|
|
"browser_cache": OptionInfo(True, "Use image gallery cache"),
|
|
"browser_folders": OptionInfo("", "Additional image browser folders"),
|
|
"browser_gallery_autoupdate": OptionInfo(True, "Gallery auto-update on tab change", gr.Checkbox, { "visible": False}),
|
|
"browser_fixed_width": OptionInfo(False, "Use fixed width thumbnails", gr.Checkbox, { "visible": False}),
|
|
"viewer_show_metadata": OptionInfo(True, "Show metadata in image viewer"),
|
|
|
|
"save_sep_options": OptionInfo("<h2>Intermediate Image Saving</h2>", "", gr.HTML),
|
|
"save_init_img": OptionInfo(False, "Save init images"),
|
|
"save_images_before_highres_fix": OptionInfo(False, "Save image before hires"),
|
|
"save_images_before_refiner": OptionInfo(False, "Save image before refiner"),
|
|
"save_images_before_detailer": OptionInfo(False, "Save image before detailer"),
|
|
"save_images_before_color_correction": OptionInfo(False, "Save image before color correction"),
|
|
"gradio_skip_video": OptionInfo(False, "Do not display video output in UI"),
|
|
|
|
"image_sep_watermark": OptionInfo("<h2>Watermarking</h2>", "", gr.HTML),
|
|
"image_watermark": OptionInfo('', "Invisible watermark string"),
|
|
"image_watermark_position": OptionInfo('none', 'Image watermark position', gr.Dropdown, {"choices": ["none", "top/left", "top/center", "top/right", "bottom/left", "bottom/center", "bottom/right", "center", "random"]}),
|
|
"image_watermark_image": OptionInfo('', "Image watermark file"),
|
|
}))
|
|
|
|
# --- Image Paths ---
|
|
options_templates.update(options_section(('saving-paths', "Image Paths"), {
|
|
"saving_sep_images": OptionInfo("<h2>Save Options</h2>", "", gr.HTML),
|
|
"save_images_add_number": OptionInfo(True, "Numbered filenames", component_args=hide_dirs),
|
|
"use_original_name_batch": OptionInfo(True, "Batch uses original name"),
|
|
"save_to_dirs": OptionInfo(False, "Save images to a subdirectory"),
|
|
"directories_filename_pattern": OptionInfo("[date]", "Directory name pattern", component_args=hide_dirs),
|
|
"samples_filename_pattern": OptionInfo("[seq]-[date]-[model_name]", "Images filename pattern", component_args=hide_dirs),
|
|
"directories_max_prompt_words": OptionInfo(8, "Max words", gr.Slider, {"minimum": 1, "maximum": 99, "step": 1, **hide_dirs}),
|
|
|
|
"outdir_sep_dirs": OptionInfo("<h2>Folders</h2>", "", gr.HTML),
|
|
"outdir_samples": OptionInfo("", "Base images folder", component_args=hide_dirs, folder=True),
|
|
"outdir_txt2img_samples": OptionInfo("outputs/text", 'Folder for text generate', component_args=hide_dirs, folder=True),
|
|
"outdir_img2img_samples": OptionInfo("outputs/image", 'Folder for image generate', component_args=hide_dirs, folder=True),
|
|
"outdir_control_samples": OptionInfo("outputs/control", 'Folder for control generate', component_args=hide_dirs, folder=True),
|
|
"outdir_extras_samples": OptionInfo("outputs/extras", 'Folder for processed images', component_args=hide_dirs, folder=True),
|
|
"outdir_save": OptionInfo("outputs/save", "Folder for manually saved images", component_args=hide_dirs, folder=True),
|
|
"outdir_video": OptionInfo("outputs/video", "Folder for videos", component_args=hide_dirs, folder=True),
|
|
"outdir_init_images": OptionInfo("outputs/inputs", "Folder for init images", component_args=hide_dirs, folder=True),
|
|
|
|
"outdir_sep_grids": OptionInfo("<h2>Grids</h2>", "", gr.HTML),
|
|
"outdir_grids": OptionInfo("", "Base grids folder", component_args=hide_dirs, folder=True),
|
|
"outdir_txt2img_grids": OptionInfo("outputs/grids", 'Folder for txt2img grids', component_args=hide_dirs, folder=True),
|
|
"outdir_img2img_grids": OptionInfo("outputs/grids", 'Folder for img2img grids', component_args=hide_dirs, folder=True),
|
|
"outdir_control_grids": OptionInfo("outputs/grids", 'Folder for control grids', component_args=hide_dirs, folder=True),
|
|
}))
|
|
|
|
# --- Image Metadata ---
|
|
options_templates.update(options_section(('image-metadata', "Image Metadata"), {
|
|
"image_metadata": OptionInfo(True, "Save metadata in image"),
|
|
"save_txt": OptionInfo(False, "Save metadata to text file"),
|
|
"save_log_fn": OptionInfo("", "Save metadata to JSON file", component_args=hide_dirs),
|
|
"disable_apply_params": OptionInfo('', "Restore from metadata: skip params", gr.Textbox),
|
|
"disable_apply_metadata": OptionInfo(['sd_model_checkpoint', 'sd_vae', 'sd_unet', 'sd_text_encoder'], "Restore from metadata: skip settings", gr.Dropdown, lambda: {"multiselect":True, "choices": list(options_templates.keys())}),
|
|
}))
|
|
|
|
# --- User Interface ---
|
|
options_templates.update(options_section(('ui', "User Interface"), {
|
|
"themes_sep_ui": OptionInfo("<h2>Theme options</h2>", "", gr.HTML),
|
|
"theme_type": OptionInfo("Modern", "Theme type", gr.Radio, {"choices": ["Modern", "Standard", "None"]}),
|
|
"theme_style": OptionInfo("Auto", "Theme mode", gr.Radio, {"choices": ["Auto", "Dark", "Light"]}),
|
|
"gradio_theme": OptionInfo("Default", "UI theme", gr.Dropdown, lambda: {"choices": theme.list_themes()}, refresh=theme.refresh_themes),
|
|
|
|
"quicksetting_sep_images": OptionInfo("<h2>Quicksettings</h2>", "", gr.HTML),
|
|
"quicksettings_list": OptionInfo(["sd_model_checkpoint"], "Quicksettings list", gr.Dropdown, lambda: {"multiselect":True, "choices": list(options_templates.keys())}),
|
|
|
|
"selections_sep_ui": OptionInfo("<h2>Selections</h2>", "", gr.HTML),
|
|
"show_samplers": OptionInfo([], "Show samplers in user interface", gr.Dropdown, lambda: {"multiselect": True, "choices": [x.name for x in list_samplers()]}, refresh=list_samplers),
|
|
"show_upscalers": OptionInfo([], "Show upscalers in user interface", gr.Dropdown, lambda: {"multiselect": True, "choices": list_upscalers()}, refresh=refresh_upscalers),
|
|
|
|
"server_sep_ui": OptionInfo("<h2>Startup & Server Options</h2>", "", gr.HTML),
|
|
"autolaunch": OptionInfo(False, "Autolaunch browser upon startup"),
|
|
"motd": OptionInfo(False, "Show MOTD"),
|
|
"subpath": OptionInfo("", "Mount URL subpath"),
|
|
"ui_request_timeout": OptionInfo(120000, "UI request timeout", gr.Slider, {"minimum": 1000, "maximum": 300000, "step": 10}),
|
|
|
|
"ui_tabs": OptionInfo("<h2>UI Tabs</h2>", "", gr.HTML),
|
|
"ui_disabled": OptionInfo([], "Disabled UI tabs", gr.Dropdown, { 'visible': False }),
|
|
|
|
"cards_sep_ui": OptionInfo("<h2>Networks panel</h2>", "", gr.HTML),
|
|
"extra_networks_card_size": OptionInfo(130, "Network card size (px)", gr.Slider, {"minimum": 20, "maximum": 2000, "step": 1}),
|
|
"extra_networks_card_cover": OptionInfo("sidebar", "Network panel position", gr.Radio, {"choices": ["cover", "inline", "sidebar"]}),
|
|
"extra_networks_card_square": OptionInfo(True, "Disable variable aspect ratio"),
|
|
|
|
"other_sep_ui": OptionInfo("<h2>Other...</h2>", "", gr.HTML),
|
|
"ui_locale": OptionInfo("Auto", "UI locale", gr.Dropdown, lambda: {"choices": theme.list_locales()}),
|
|
"font_size": OptionInfo(14, "Font size", gr.Slider, {"minimum": 8, "maximum": 32, "step": 1}),
|
|
"gpu_monitor": OptionInfo(3000, "GPU monitor interval", gr.Slider, {"minimum": 100, "maximum": 60000, "step": 100}),
|
|
"aspect_ratios": OptionInfo("1:1, 4:3, 3:2, 16:9, 16:10, 21:9, 2:3, 3:4, 9:16, 10:16, 9:21", "Allowed aspect ratios"),
|
|
"ui_columns": OptionInfo(4, "Gallery view columns", gr.Slider, {"minimum": 1, "maximum": 8, "step": 1}),
|
|
|
|
'uiux_separator_appearance': OptionInfo("<h2>Appearance</h2>", "", gr.HTML),
|
|
"uiux_grid_image_size": OptionInfo(150, "Grid image size", gr.Slider, {"minimum": 64, "maximum": 1024, "step": 1}),
|
|
"uiux_hide_legacy": OptionInfo(True, "Hide legacy tabs"),
|
|
"uiux_persist_layout": OptionInfo(True, "Persist UI layout"),
|
|
"uiux_no_slider_layout": OptionInfo(False, "Hide input range sliders"),
|
|
"uiux_show_labels_aside": OptionInfo(False, "Show labels for aside tabs"),
|
|
"uiux_show_labels_main": OptionInfo(False, "Show labels for main tabs"),
|
|
"uiux_show_labels_tabs": OptionInfo(True, "Show labels for page tabs"),
|
|
"uiux_show_input_range_ticks": OptionInfo(True, "Show ticks for input range slider", gr.Checkbox, {"visible": False}),
|
|
"uiux_no_headers_params": OptionInfo(False, "Hide params headers", gr.Checkbox, {"visible": False}),
|
|
"uiux_show_outline_params": OptionInfo(True, "Show parameter outline", gr.Checkbox, {"visible": False}),
|
|
|
|
'uiux_separator_mobile': OptionInfo("<h2>Mobile</h2>", "", gr.HTML),
|
|
"uiux_default_layout": OptionInfo("Auto", "Layout", gr.Radio, {"choices": ["Auto","Desktop", "Mobile"]}),
|
|
"uiux_mobile_scale": OptionInfo(0.7, "Mobile scale", gr.Slider, {"minimum": 0.5, "maximum": 1, "step": 0.05}),
|
|
|
|
"images_sep_log": OptionInfo("<h2>Log Display</h2>", "", gr.HTML),
|
|
"logmonitor_show": OptionInfo(True, "Show log view"),
|
|
"logmonitor_refresh_period": OptionInfo(5000, "Log view update period", gr.Slider, {"minimum": 0, "maximum": 30000, "step": 25}),
|
|
|
|
"images_sep_ui": OptionInfo("<h2>Outputs & Images</h2>", "", gr.HTML),
|
|
"return_grid": OptionInfo(True, "Show grid in results"),
|
|
"send_seed": OptionInfo(True, "Send seed when sending prompt or image to other interface", gr.Checkbox, {"visible": False}),
|
|
"send_size": OptionInfo(False, "Send size when sending prompt or image to another interface", gr.Checkbox, {"visible": False}),
|
|
}))
|
|
|
|
# --- Live Previews ---
|
|
options_templates.update(options_section(('live-preview', "Live Previews"), {
|
|
"show_progress_every_n_steps": OptionInfo(1, "Live preview display period", gr.Slider, {"minimum": 0, "maximum": 20, "step": 1, "visible": False}),
|
|
"show_progress_type": OptionInfo("Tiny", "Live preview method", gr.Dropdown, {"choices": ["None", "Micro", "Tiny", "Full"]}),
|
|
"live_preview_refresh_period": OptionInfo(500, "Progress update period", gr.Slider, {"minimum": 0, "maximum": 5000, "step": 25}),
|
|
"live_preview_force": OptionInfo(False, "Force live previews on each step"),
|
|
"live_preview_require_focus": OptionInfo(True, "Pause live previews when tab is not focused"),
|
|
"live_preview_downscale": OptionInfo(True, "Downscale high resolution live previews"),
|
|
"taesd_layers": OptionInfo(3, "Tiny: decode layers", gr.Slider, {"minimum": 1, "maximum": 3, "step": 1}),
|
|
"taesd_frames": OptionInfo(4, "Tiny: video frames", gr.Slider, {"minimum": -1, "maximum": 32, "step": 1, "visible": False}),
|
|
|
|
"notification_audio_enable": OptionInfo(False, "Play a notification upon completion"),
|
|
"notification_audio_path": OptionInfo("ui/assets/notification.mp3","Path to notification sound", component_args=hide_dirs, folder=True),
|
|
}))
|
|
|
|
# --- Postprocessing ---
|
|
options_templates.update(options_section(('postprocessing', "Postprocessing"), {
|
|
"postprocessing_sep": OptionInfo("<h2>Postprocessing Operations</h2>", "", gr.HTML),
|
|
'postprocessing_enable_in_main_ui': OptionInfo([], "Additional postprocessing operations", gr.Dropdown, lambda: {"multiselect":True, "choices": [x.name for x in shared_items.postprocessing_scripts()]}),
|
|
'postprocessing_operation_order': OptionInfo([], "Postprocessing operation order", gr.Dropdown, lambda: {"multiselect":True, "choices": [x.name for x in shared_items.postprocessing_scripts()], "visible": False }),
|
|
|
|
"postprocessing_sep_img2img": OptionInfo("<h2>Inpaint</h2>", "", gr.HTML),
|
|
"img2img_color_correction": OptionInfo(False, "Apply color correction"),
|
|
"color_correction_method": OptionInfo("histogram", "Color correction method", gr.Radio, {"choices": ["histogram", "wavelet", "adain"]}),
|
|
"mask_apply_overlay": OptionInfo(True, "Apply mask as overlay"),
|
|
"img2img_background_color": OptionInfo("#ffffff", "Image transparent color fill", gr.ColorPicker, {}),
|
|
"inpainting_mask_weight": OptionInfo(1.0, "Inpainting conditioning mask strength", gr.Slider, {"minimum": 0.0, "maximum": 1.0, "step": 0.01}),
|
|
"initial_noise_multiplier": OptionInfo(1.0, "Noise multiplier for image processing", gr.Slider, {"minimum": 0.1, "maximum": 1.5, "step": 0.01, "visible": False}),
|
|
|
|
"postprocessing_sep_detailer": OptionInfo("<h2>Detailer</h2>", "", gr.HTML),
|
|
"detailer_unload": OptionInfo(False, "Move detailer model to CPU when complete"),
|
|
"detailer_augment": OptionInfo(False, "Detailer use model augment"),
|
|
|
|
"postprocessing_sep_upscalers": OptionInfo("<h2>Upscaling</h2>", "", gr.HTML),
|
|
"upscaler_unload": OptionInfo(False, "Unload upscaler after processing"),
|
|
"upscaler_latent_steps": OptionInfo(20, "Upscaler latent steps", gr.Slider, {"minimum": 4, "maximum": 100, "step": 1}),
|
|
"upscaler_tile_size": OptionInfo(192, "Upscaler tile size", gr.Slider, {"minimum": 0, "maximum": 512, "step": 16}),
|
|
"upscaler_tile_overlap": OptionInfo(8, "Upscaler tile overlap", gr.Slider, {"minimum": 0, "maximum": 64, "step": 1}),
|
|
|
|
"postprocessing_sep_resize": OptionInfo("<h2>Resize</h2>", "", gr.HTML),
|
|
"resize_quality": OptionInfo("PIL Lanczos", "Image resize algorithm", gr.Dropdown, {"choices": ["PIL Lanczos", "Sharpfin MKS2021", "Sharpfin Lanczos3", "Sharpfin Mitchell", "Sharpfin Catmull-Rom"]}),
|
|
"resize_linearize_srgb": OptionInfo(True, "Apply sRGB linearization"),
|
|
}))
|
|
|
|
# --- Huggingface ---
|
|
options_templates.update(options_section(('huggingface', "Huggingface"), {
|
|
"huggingface_sep": OptionInfo("<h2>Huggingface</h2>", "", gr.HTML),
|
|
"diffuser_cache_config": OptionInfo(True, "Use cached model config when available"),
|
|
"huggingface_token": OptionInfo('', 'HuggingFace token', gr.Textbox, {"lines": 2}, secret=True, env_var='HF_TOKEN'),
|
|
"hf_transfer_mode": OptionInfo("XET", "HuggingFace download method", gr.Dropdown, {"choices": ['HTTP', 'XET', 'XET HighPerformance', 'XET Sequential']}),
|
|
"huggingface_mirror": OptionInfo('', 'HuggingFace mirror', gr.Textbox),
|
|
"offline_mode": OptionInfo(False, 'Force offline mode', gr.Checkbox),
|
|
|
|
"diffusers_model_load_variant": OptionInfo("default", "Preferred Model variant", gr.Radio, {"choices": ['default', 'fp32', 'fp16']}),
|
|
"diffusers_vae_load_variant": OptionInfo("default", "Preferred VAE variant", gr.Radio, {"choices": ['default', 'fp32', 'fp16']}),
|
|
"custom_diffusers_pipeline": OptionInfo('', 'Load custom Diffusers pipeline'),
|
|
"civitai_token": OptionInfo('', 'CivitAI token', gr.Textbox, {"lines": 2, "visible": False}, secret=True, env_var='CIVITAI_TOKEN'),
|
|
"civitai_save_subfolder_enabled": OptionInfo(False, 'CivitAI save to subfolders', gr.Checkbox, {"visible": False}),
|
|
"civitai_save_subfolder": OptionInfo('{{BASEMODEL}}', 'CivitAI subfolder template', gr.Textbox, {"visible": False}),
|
|
"civitai_discard_hash_mismatch": OptionInfo(True, 'CivitAI discard downloads with hash mismatch', gr.Checkbox, {"visible": False}),
|
|
"civitai_save_precision": OptionInfo(True, 'CivitAI add precision to file names', gr.Checkbox),
|
|
}))
|
|
|
|
# --- Extra Networks ---
|
|
from modules import shared
|
|
options_templates.update(options_section(('extra_networks', "Networks"), {
|
|
"extra_networks_sep1": OptionInfo("<h2>Networks UI</h2>", "", gr.HTML),
|
|
"extra_networks_show": OptionInfo(True, "UI show on startup"),
|
|
"extra_networks": OptionInfo(["All"], "Available networks", gr.Dropdown, lambda: {"multiselect":True, "choices": ['All'] + [en.title for en in shared.extra_networks]}),
|
|
"extra_networks_sort": OptionInfo("Default", "Sort order", gr.Dropdown, {"choices": ['Default', 'Name [A-Z]', 'Name [Z-A]', 'Date [Newest]', 'Date [Oldest]', 'Size [Largest]', 'Size [Smallest]']}),
|
|
"extra_networks_view": OptionInfo("gallery", "UI view", gr.Radio, {"choices": ["gallery", "list"]}),
|
|
"extra_networks_sidebar_width": OptionInfo(35, "UI sidebar width (%)", gr.Slider, {"minimum": 10, "maximum": 80, "step": 1}),
|
|
"extra_networks_height": OptionInfo(0, "UI height (%)", gr.Slider, {"minimum": 0, "maximum": 100, "step": 1}), # set in ui_javascript
|
|
"extra_networks_fetch": OptionInfo(True, "UI fetch network info on mouse-over"),
|
|
"extra_network_skip_indexing": OptionInfo(False, "Build info on first access", gr.Checkbox),
|
|
|
|
"extra_networks_scan_sep": OptionInfo("<h2>Networks Scan</h2>", "", gr.HTML),
|
|
"extra_networks_scan_skip": OptionInfo("", "Skip CivitAI scan for regex pattern(s)", gr.Textbox),
|
|
|
|
"extra_networks_model_sep": OptionInfo("<h2>Rerefence models</h2>", "", gr.HTML),
|
|
"extra_network_reference_enable": OptionInfo(True, "Enable use of reference models", gr.Checkbox),
|
|
"extra_network_reference_values": OptionInfo(False, "Use reference values when available", gr.Checkbox),
|
|
|
|
"extra_networks_styles_sep": OptionInfo("<h2>Styles</h2>", "", gr.HTML),
|
|
"extra_networks_styles": OptionInfo(True, "Show reference styles"),
|
|
"extra_networks_apply_unparsed": OptionInfo(True, "Restore unparsed prompt"),
|
|
|
|
"extra_networks_embed_sep": OptionInfo("<h2>Embeddings</h2>", "", gr.HTML),
|
|
"diffusers_enable_embed": OptionInfo(True, "Enable embeddings support", gr.Checkbox),
|
|
"diffusers_convert_embed": OptionInfo(False, "Auto-convert SD15 embeddings to SDXL", gr.Checkbox),
|
|
|
|
"extra_networks_wildcard_sep": OptionInfo("<h2>Wildcards</h2>", "", gr.HTML),
|
|
"wildcards_enabled": OptionInfo(True, "Enable file wildcards support"),
|
|
}))
|
|
|
|
# --- LoRA ---
|
|
options_templates.update(options_section(('lora', "LoRA"), {
|
|
"lora_load_sep": OptionInfo("<h2>Load options</h2>", "", gr.HTML),
|
|
"lora_force_reload": OptionInfo(False, "LoRA force reload always"),
|
|
"lora_force_diffusers": OptionInfo(False if not cmd_opts.use_openvino else True, "LoRA load using Diffusers method"),
|
|
"lora_in_memory_limit": OptionInfo(1, "LoRA memory cache", gr.Slider, {"minimum": 0, "maximum": 32, "step": 1}),
|
|
|
|
"lora_prompt_sep": OptionInfo("<h2>Prompt helpers</h2>", "", gr.HTML),
|
|
"extra_networks_default_multiplier": OptionInfo(1.0, "Default strength", gr.Slider, {"minimum": 0.0, "maximum": 2.0, "step": 0.01}),
|
|
"lora_apply_tags": OptionInfo(0, "LoRA auto-apply tags", gr.Slider, {"minimum": -1, "maximum": 32, "step": 1}),
|
|
|
|
"lora_apply_sep": OptionInfo("<h2>Apply method</h2>", "", gr.HTML),
|
|
"lora_fuse_native": OptionInfo(True, "LoRA native fuse with model"),
|
|
"lora_fuse_diffusers": OptionInfo(False, "LoRA diffusers fuse with model"),
|
|
|
|
"lora_quant_sep": OptionInfo("<h2>Quantization options</h2>", "", gr.HTML),
|
|
"lora_sdnq_apply": OptionInfo("exact", "LoRA quantized apply method", gr.Radio, {"choices": ["exact", "requantize"]}),
|
|
"lora_sdnq_host_rank": OptionInfo(256, "LoRA quantized host rank", gr.Slider, {"minimum": 0, "maximum": 1024, "step": 32}),
|
|
"lora_sdnq_host_calib": OptionInfo(True, "LoRA quantized host calibration"),
|
|
"lora_sdnq_host_cache": OptionInfo(10, "LoRA quantized host cache", gr.Slider, {"minimum": 0, "maximum": 100, "step": 1}),
|
|
|
|
"lora_stack_sep": OptionInfo("<h2>Stacking options</h2>", "", gr.HTML),
|
|
"lora_stack_mode": OptionInfo("sum", "LoRA stack mode", gr.Dropdown, {"choices": ["sum", "ties", "dare_ties", "dare_linear", "magnitude_prune", "klora", "estlora"]}),
|
|
"lora_stack_density": OptionInfo(0.5, "LoRA stack density", gr.Slider, {"minimum": 0.05, "maximum": 1.0, "step": 0.05}),
|
|
"lora_stack_alpha": OptionInfo(0.0, "LoRA stack ramp", gr.Slider, {"minimum": 0.0, "maximum": 3.0, "step": 0.1}),
|
|
"lora_stack_discrepancy": OptionInfo(0.5, "LoRA stack discrepancy", gr.Slider, {"minimum": 0.0, "maximum": 1.0, "step": 0.05}),
|
|
|
|
"lora_meta_sep": OptionInfo("<h2>Metadata</h2>", "", gr.HTML),
|
|
"lora_add_hashes_to_infotext": OptionInfo(False, "LoRA add hash info to metadata"),
|
|
}))
|
|
|
|
# --- Extensions ---
|
|
options_templates.update(options_section(('extensions', "Extensions"), {
|
|
"disable_all_extensions": OptionInfo("none", "Disable all extensions", gr.Radio, {"choices": ["none", "user", "all"]}),
|
|
}))
|
|
|
|
# --- Hidden Options ---
|
|
options_templates.update(
|
|
options_section(
|
|
("hidden_options", "Hidden options"),
|
|
{
|
|
# internal options
|
|
"diffusers_version": OptionInfo("", "Diffusers version", gr.Textbox, {"visible": False}),
|
|
"transformers_version": OptionInfo("", "Transformers version", gr.Textbox, {"visible": False}),
|
|
"disabled_extensions": OptionInfo([], "Disable these extensions", gr.Textbox, {"visible": False}),
|
|
"sd_checkpoint_hash": OptionInfo("", "SHA256 hash of the current checkpoint", gr.Textbox, {"visible": False}),
|
|
"tooltips": OptionInfo("UI Tooltips", "UI tooltips", gr.Radio, {"choices": ["None", "Browser default", "UI tooltips"], "visible": False}),
|
|
|
|
# Autocomplete settings (controlled via Tag Autocomplete script UI)
|
|
"autocomplete_active": OptionInfo(False, "Enable Autocomplete", gr.Checkbox, {"visible": False}),
|
|
"autocomplete_enabled": OptionInfo([], "Enabled tag autocomplete files", gr.Dropdown, {"multiselect": True, "choices": [], "visible": False}),
|
|
"autocomplete_min_chars": OptionInfo(3, "Min autocomplete chars", gr.Slider, {"minimum": 2, "maximum": 6, "step": 1, "visible": False}),
|
|
"autocomplete_keep_underscores": OptionInfo(False, "Keep underscores in autocomplete", gr.Checkbox, {"visible": False}),
|
|
"autocomplete_append_comma": OptionInfo(True, "Append comma after autocomplete", gr.Checkbox, {"visible": False}),
|
|
|
|
# Caption settings (controlled via Caption Tab UI)
|
|
"caption_default_type": OptionInfo("VLM", "Default caption type", gr.Radio, {"choices": ["VLM", "OpenCLiP", "Tagger"], "visible": False}),
|
|
"tagger_show_scores": OptionInfo(False, "Tagger: show confidence scores in results", gr.Checkbox, {"visible": False}),
|
|
"caption_openclip_model": OptionInfo("ViT-L-14/openai", "OpenCLiP: default model", gr.Dropdown, lambda: {"choices": modules.caption.openclip.get_clip_models(), "visible": False}, refresh=modules.caption.openclip.refresh_clip_models),
|
|
"caption_openclip_mode": OptionInfo(modules.caption.openclip.caption_types[0], "OpenCLiP: default mode", gr.Dropdown, {"choices": modules.caption.openclip.caption_types, "visible": False}),
|
|
"caption_openclip_blip_model": OptionInfo(list(modules.caption.openclip.caption_models)[0], "OpenCLiP: default captioner", gr.Dropdown, {"choices": list(modules.caption.openclip.caption_models), "visible": False}),
|
|
"caption_openclip_num_beams": OptionInfo(1, "OpenCLiP: num beams", gr.Slider, {"minimum": 1, "maximum": 16, "step": 1, "visible": False}),
|
|
"caption_openclip_max_length": OptionInfo(74, "OpenCLiP: max length", gr.Slider, {"minimum": 1, "maximum": 512, "step": 1, "visible": False}),
|
|
"caption_openclip_min_flavors": OptionInfo(2, "OpenCLiP: min flavors", gr.Slider, {"minimum": 0, "maximum": 32, "step": 1, "visible": False}),
|
|
"caption_openclip_max_flavors": OptionInfo(16, "OpenCLiP: max flavors", gr.Slider, {"minimum": 0, "maximum": 32, "step": 1, "visible": False}),
|
|
"caption_openclip_flavor_count": OptionInfo(1024, "OpenCLiP: intermediate flavors", gr.Slider, {"minimum": 256, "maximum": 4096, "step": 64, "visible": False}),
|
|
"caption_openclip_chunk_size": OptionInfo(1024, "OpenCLiP: chunk size", gr.Slider, {"minimum": 256, "maximum": 4096, "step": 64, "visible": False}),
|
|
"caption_vlm_model": OptionInfo(modules.caption.vqa.vlm_default, "VLM: default model", gr.Dropdown, {"choices": list(modules.caption.vqa.vlm_models), "visible": False}),
|
|
"caption_vlm_prompt": OptionInfo(modules.caption.vqa.vlm_prompts[2], "VLM: default prompt", DropdownEditable, {"choices": modules.caption.vqa.vlm_prompts, "visible": False}),
|
|
"caption_vlm_system": OptionInfo(modules.caption.vqa.vlm_system, "VLM: system prompt", gr.Textbox, {"visible": False}),
|
|
"caption_vlm_num_beams": OptionInfo(1, "VLM: num beams", gr.Slider, {"minimum": 1, "maximum": 16, "step": 1, "visible": False}),
|
|
"caption_vlm_max_length": OptionInfo(512, "VLM: max length", gr.Slider, {"minimum": 1, "maximum": 4096, "step": 1, "visible": False}),
|
|
"caption_vlm_do_sample": OptionInfo(True, "VLM: use sample method", gr.Checkbox, {"visible": False}),
|
|
"caption_vlm_temperature": OptionInfo(0.8, "VLM: temperature", gr.Slider, {"minimum": 0, "maximum": 1.0, "step": 0.01, "visible": False}),
|
|
"caption_vlm_top_k": OptionInfo(0, "VLM: top-k", gr.Slider, {"minimum": 0, "maximum": 99, "step": 1, "visible": False}),
|
|
"caption_vlm_top_p": OptionInfo(0, "VLM: top-p", gr.Slider, {"minimum": 0, "maximum": 1.0, "step": 0.01, "visible": False}),
|
|
"caption_vlm_keep_prefill": OptionInfo(False, "VLM: keep prefill text in output", gr.Checkbox, {"visible": False}),
|
|
"caption_vlm_keep_thinking": OptionInfo(False, "VLM: keep reasoning trace in output", gr.Checkbox, {"visible": False}),
|
|
"caption_vlm_thinking_mode": OptionInfo(False, "VLM: enable thinking/reasoning mode", gr.Checkbox, {"visible": False}),
|
|
"caption_vlm_custom_args": OptionInfo("", "VLM: custom arguments", gr.Textbox, {"visible": False}),
|
|
"tagger_threshold": OptionInfo(0.50, "Tagger: general tag threshold", gr.Slider, {"minimum": 0, "maximum": 1, "step": 0.01, "visible": False}),
|
|
"tagger_include_rating": OptionInfo(False, "Tagger: include rating tags", gr.Checkbox, {"visible": False}),
|
|
"tagger_max_tags": OptionInfo(74, "Tagger: max tags", gr.Slider, {"minimum": 1, "maximum": 512, "step": 1, "visible": False}),
|
|
"tagger_sort_alpha": OptionInfo(False, "Tagger: sort alphabetically", gr.Checkbox, {"visible": False}),
|
|
"tagger_use_spaces": OptionInfo(False, "Tagger: use spaces for tags", gr.Checkbox, {"visible": False}),
|
|
"tagger_escape_brackets": OptionInfo(True, "Tagger: escape brackets", gr.Checkbox, {"visible": False}),
|
|
"tagger_exclude_tags": OptionInfo("", "Tagger: exclude tags", gr.Textbox, {"visible": False}),
|
|
"waifudiffusion_model": OptionInfo("wd-eva02-large-tagger-v3", "WaifuDiffusion: default model", gr.Dropdown, {"choices": [], "visible": False}),
|
|
"waifudiffusion_character_threshold": OptionInfo(0.85, "WaifuDiffusion: character tag threshold", gr.Slider, {"minimum": 0, "maximum": 1, "step": 0.01, "visible": False}),
|
|
# control settings are handled separately
|
|
"control_hires": OptionInfo(False, "Hires use Control", gr.Checkbox, {"visible": False}),
|
|
"control_aspect_ratio": OptionInfo(False, "Aspect ratio resize", gr.Checkbox, {"visible": False}),
|
|
"control_max_units": OptionInfo(4, "Maximum number of units", gr.Slider, {"minimum": 1, "maximum": 10, "step": 1, "visible": False}),
|
|
"control_tiles": OptionInfo("1x1, 1x2, 1x3, 1x4, 2x1, 2x1, 2x2, 2x3, 2x4, 3x1, 3x2, 3x3, 3x4, 4x1, 4x2, 4x3, 4x4", "Tiling options", gr.Textbox, {"visible": False}),
|
|
"control_move_processor": OptionInfo(False, "Processor move to CPU when complete", gr.Checkbox, {"visible": False}),
|
|
"control_unload_processor": OptionInfo(False, "Processor unload after use", gr.Checkbox, {"visible": False}),
|
|
# sampler settings are handled separately
|
|
"eta_noise_seed_delta": OptionInfo(0, "Noise seed delta (eta)", gr.Number, {"precision": 0, "visible": False}),
|
|
"scheduler_eta": OptionInfo(1.0, "Noise multiplier (eta)", gr.Slider, {"minimum": 0.0, "maximum": 1.0, "step": 0.01, "visible": False}),
|
|
"schedulers_solver_order": OptionInfo(0, "Solver order (where", gr.Slider, {"minimum": 0, "maximum": 5, "step": 1, "visible": False}),
|
|
"schedulers_use_loworder": OptionInfo(True, "Use simplified solvers in final steps", gr.Checkbox, {"visible": False}),
|
|
"schedulers_prediction_type": OptionInfo("default", "Override model prediction type", gr.Radio, {"choices": ["default", "epsilon", "sample", "v_prediction", "flow_prediction"], "visible": False}),
|
|
"schedulers_sigma": OptionInfo("default", "Sigma algorithm", gr.Radio, {"choices": ["default", "karras", "betas", "exponential", "lambdas", "flowmatch"], "visible": False}),
|
|
"schedulers_beta_schedule": OptionInfo("default", "Beta schedule", gr.Dropdown, {"choices": ["default", "linear", "scaled_linear", "squaredcos_cap_v2", "sigmoid"], "visible": False}),
|
|
"schedulers_use_thresholding": OptionInfo(False, "Use dynamic thresholding", gr.Checkbox, {"visible": False}),
|
|
"schedulers_timestep_spacing": OptionInfo("default", "Timestep spacing", gr.Dropdown, {"choices": ["default", "linspace", "leading", "trailing"], "visible": False}),
|
|
"schedulers_timesteps": OptionInfo("", "Timesteps", gr.Textbox, {"visible": False}),
|
|
"schedulers_rescale_betas": OptionInfo(False, "Rescale betas with zero terminal SNR", gr.Checkbox, {"visible": False}),
|
|
"schedulers_beta_start": OptionInfo(0, "Beta start", gr.Slider, {"minimum": 0, "maximum": 1, "step": 0.00001}),
|
|
"schedulers_beta_end": OptionInfo(0, "Beta end", gr.Slider, {"minimum": 0, "maximum": 1, "step": 0.00001}),
|
|
"schedulers_timesteps_range": OptionInfo(1000, "Timesteps range", gr.Slider, {"minimum": 250, "maximum": 4000, "step": 1}),
|
|
"schedulers_shift": OptionInfo(3, "Sampler shift", gr.Slider, {"minimum": 0.1, "maximum": 10, "step": 0.1, "visible": False}),
|
|
"schedulers_fallback": OptionInfo(True, "Sampler fallback on invalid", gr.Checkbox, {"visible": False}),
|
|
"schedulers_dynamic_shift": OptionInfo(False, "Sampler dynamic shift", gr.Checkbox, {"visible": False}),
|
|
"schedulers_base_image_seq_len": OptionInfo(0, "Sampler base seq", gr.Slider, {"minimum": 0, "maximum": 1024, "step": 16, "visible": False}),
|
|
"schedulers_max_image_seq_len": OptionInfo(0, "Sampler max seq", gr.Slider, {"minimum": 0, "maximum": 16384, "step": 16, "visible": False}),
|
|
"schedulers_sigma_adjust": OptionInfo(1.0, "Sigma adjust", gr.Slider, {"minimum": 0.5, "maximum": 1.5, "step": 0.01, "visible": False}),
|
|
"schedulers_sigma_adjust_min": OptionInfo(0.2, "Sigma adjust start", gr.Slider, {"minimum": 0.0, "maximum": 1.0, "step": 0.01, "visible": False}),
|
|
"schedulers_sigma_adjust_max": OptionInfo(0.8, "Sigma adjust end", gr.Slider, {"minimum": 0.0, "maximum": 1.0, "step": 0.01, "visible": False}),
|
|
"schedulers_base_shift": OptionInfo(0.5, "Sampler base shift", gr.Slider, {"minimum": 0.0, "maximum": 1.0, "step": 0.01, "visible": False}),
|
|
"schedulers_max_shift": OptionInfo(1.15, "Sampler max shift", gr.Slider, {"minimum": 0.0, "maximum": 4.0, "step": 0.01, "visible": False}),
|
|
"uni_pc_variant": OptionInfo("bh2", "UniPC variant", gr.Radio, {"choices": ["bh1", "bh2", "vary_coeff"], "visible": False}),
|
|
"uni_pc_skip_type": OptionInfo("time_uniform", "UniPC skip type", gr.Radio, {"choices": ["time_uniform", "time_quadratic", "logSNR"], "visible": False}),
|
|
# detailer settings are handled separately
|
|
"detailer_classes": OptionInfo("", "Detailer classes", gr.Textbox, {"visible": False}),
|
|
"detailer_conf": OptionInfo(0.6, "Min confidence", gr.Slider, {"minimum": 0.0, "maximum": 1.0, "step": 0.05, "visible": False}),
|
|
"detailer_max": OptionInfo(2, "Max detected", gr.Slider, {"minimum": 1, "maximum": 10, "step": 1, "visible": False}),
|
|
"detailer_iou": OptionInfo(0.5, "Max overlap", gr.Slider, {"minimum": 0, "maximum": 1.0, "step": 0.05, "visible": False}),
|
|
"detailer_sigma_adjust": OptionInfo(1.0, "Detailer sigma adjust", gr.Slider, {"minimum": 0, "maximum": 1.0, "step": 0.05, "visible": False}),
|
|
"detailer_sigma_adjust_max": OptionInfo(1.0, "Detailer sigma end", gr.Slider, {"minimum": 0, "maximum": 1.0, "step": 0.05, "visible": False}),
|
|
"detailer_min_size": OptionInfo(0.0, "Min object size", gr.Slider, {"minimum": 0.0, "maximum": 1.0, "step": 0.05, "visible": False}),
|
|
"detailer_max_size": OptionInfo(1.0, "Max object size", gr.Slider, {"minimum": 0.0, "maximum": 1.0, "step": 0.05, "visible": False}),
|
|
"detailer_padding": OptionInfo(20, "Item padding", gr.Slider, {"minimum": 0, "maximum": 100, "step": 1, "visible": False}),
|
|
"detailer_blur": OptionInfo(10, "Item edge blur", gr.Slider, {"minimum": 0, "maximum": 100, "step": 1, "visible": False}),
|
|
"detailer_models": OptionInfo(["face-yolo8n"], "Detailer models", gr.Dropdown, lambda: {"multiselect": True, "choices": list(shared.detailer.list) if shared.detailer else [], "visible": False}),
|
|
"detailer_args": OptionInfo("", "Detailer args", gr.Textbox, {"visible": False}),
|
|
"detailer_merge": OptionInfo(False, "Merge multiple results from each detailer model", gr.Checkbox, {"visible": False}),
|
|
"detailer_sort": OptionInfo(False, "Sort detailer output by location", gr.Checkbox, {"visible": False}),
|
|
"detailer_save": OptionInfo(False, "Include detection results", gr.Checkbox, {"visible": False}),
|
|
"detailer_segmentation": OptionInfo(False, "Use segmentation", gr.Checkbox, {"visible": False}),
|
|
},
|
|
)
|
|
)
|
|
|
|
return options_templates
|