Hermes Bot commited on
Commit Β·
704a7f8
1
Parent(s): 2ce9191
Simplify base parameter UI to avoid Row errors
Browse files- ui/shared/ui_components.py +670 -671
ui/shared/ui_components.py
CHANGED
|
@@ -1,672 +1,671 @@
|
|
| 1 |
-
import gradio as gr
|
| 2 |
-
from comfy_integration.nodes import SAMPLER_CHOICES, SCHEDULER_CHOICES
|
| 3 |
-
from core.settings import (
|
| 4 |
-
MAX_LORAS, LORA_SOURCE_CHOICES, MAX_EMBEDDINGS, MAX_CONDITIONINGS,
|
| 5 |
-
MAX_CONTROLNETS, MAX_IPADAPTERS, RESOLUTION_MAP, ARCHITECTURES_CONFIG,
|
| 6 |
-
MODEL_MAP_CHECKPOINT, MODEL_TYPE_MAP, FEATURES_CONFIG, ARCH_CATEGORIES_MAP,
|
| 7 |
-
VAE_DIR, MODEL_DEFAULTS_CONFIG
|
| 8 |
-
)
|
| 9 |
-
import yaml
|
| 10 |
-
import os
|
| 11 |
-
from functools import lru_cache
|
| 12 |
-
from utils.app_utils import save_uploaded_file_with_hash
|
| 13 |
-
|
| 14 |
-
default_model_name = list(MODEL_MAP_CHECKPOINT.keys())[0] if MODEL_MAP_CHECKPOINT else None
|
| 15 |
-
default_m_type = MODEL_TYPE_MAP.get(default_model_name, "SDXL") if default_model_name else "SDXL"
|
| 16 |
-
default_architectures_dict = ARCHITECTURES_CONFIG.get('architectures', {})
|
| 17 |
-
default_arch_model_type = default_architectures_dict.get(default_m_type, {}).get("model_type", default_m_type.lower().replace(" ", "").replace(".", ""))
|
| 18 |
-
default_arch_features = FEATURES_CONFIG.get(default_arch_model_type, FEATURES_CONFIG.get('default', {}))
|
| 19 |
-
default_enabled_chains = default_arch_features.get('enabled_chains', [])
|
| 20 |
-
|
| 21 |
-
default_vals = MODEL_DEFAULTS_CONFIG.get('Default', {})
|
| 22 |
-
DEFAULT_STEPS = default_vals.get('steps', 20)
|
| 23 |
-
DEFAULT_CFG = default_vals.get('cfg', 5.0)
|
| 24 |
-
DEFAULT_SAMPLER = default_vals.get('sampler_name', 'euler')
|
| 25 |
-
DEFAULT_SCHEDULER = default_vals.get('scheduler', 'simple')
|
| 26 |
-
DEFAULT_POS_PROMPT = default_vals.get('positive_prompt', '')
|
| 27 |
-
DEFAULT_NEG_PROMPT = default_vals.get('negative_prompt', '')
|
| 28 |
-
|
| 29 |
-
@lru_cache(maxsize=1)
|
| 30 |
-
def get_ipadapter_config_from_yaml():
|
| 31 |
-
try:
|
| 32 |
-
_PROJECT_ROOT = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
| 33 |
-
_IPADAPTER_LIST_PATH = os.path.join(_PROJECT_ROOT, 'yaml', 'ipadapter.yaml')
|
| 34 |
-
with open(_IPADAPTER_LIST_PATH, 'r', encoding='utf-8') as f:
|
| 35 |
-
config = yaml.safe_load(f)
|
| 36 |
-
return config
|
| 37 |
-
except Exception as e:
|
| 38 |
-
print(f"Warning: Could not load ipadapter.yaml for UI components: {e}")
|
| 39 |
-
return {}
|
| 40 |
-
|
| 41 |
-
def get_ipadapter_presets(arch="SDXL"):
|
| 42 |
-
config = get_ipadapter_config_from_yaml()
|
| 43 |
-
presets = []
|
| 44 |
-
if config:
|
| 45 |
-
std_presets = config.get("IPAdapter_presets", {}).get(arch, [])
|
| 46 |
-
face_presets = config.get("IPAdapter_FaceID_presets", {}).get(arch, [])
|
| 47 |
-
if std_presets:
|
| 48 |
-
presets.extend(std_presets)
|
| 49 |
-
if face_presets:
|
| 50 |
-
presets.extend(face_presets)
|
| 51 |
-
return presets if presets else ["STANDARD (medium strength)"]
|
| 52 |
-
|
| 53 |
-
def create_model_architecture_filter_ui(prefix):
|
| 54 |
-
components = {}
|
| 55 |
-
ordered_architectures = ARCHITECTURES_CONFIG.get("architecture_order", [])
|
| 56 |
-
choices = ["ALL"] + ordered_architectures
|
| 57 |
-
|
| 58 |
-
components[f'model_arch_{prefix}'] = gr.Radio(
|
| 59 |
-
label="Model Architecture",
|
| 60 |
-
choices=choices,
|
| 61 |
-
value="ALL",
|
| 62 |
-
interactive=True,
|
| 63 |
-
visible=True
|
| 64 |
-
)
|
| 65 |
-
return components
|
| 66 |
-
|
| 67 |
-
def create_category_filter_ui(prefix):
|
| 68 |
-
valid_cats = list(set(cat for cats in ARCH_CATEGORIES_MAP.values() for cat in cats))
|
| 69 |
-
cat_choices = ["ALL"] + sorted(valid_cats)
|
| 70 |
-
|
| 71 |
-
components = {}
|
| 72 |
-
components[f'model_cat_{prefix}'] = gr.Dropdown(
|
| 73 |
-
label="Filter Models",
|
| 74 |
-
choices=cat_choices,
|
| 75 |
-
value="ALL",
|
| 76 |
-
interactive=True,
|
| 77 |
-
scale=1,
|
| 78 |
-
allow_custom_value=True
|
| 79 |
-
)
|
| 80 |
-
return components
|
| 81 |
-
|
| 82 |
-
def create_base_parameter_ui(prefix, defaults=None):
|
| 83 |
-
if defaults is None:
|
| 84 |
-
defaults = {}
|
| 85 |
-
|
| 86 |
-
components = {}
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
components[f'
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
components[f'
|
| 152 |
-
components[f'
|
| 153 |
-
components[f'
|
| 154 |
-
components[f'
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
key('
|
| 174 |
-
key('
|
| 175 |
-
key('
|
| 176 |
-
key('
|
| 177 |
-
key('
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
components[key('
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
key('
|
| 217 |
-
key('
|
| 218 |
-
key('
|
| 219 |
-
key('
|
| 220 |
-
key('
|
| 221 |
-
key('
|
| 222 |
-
key('
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
|
| 226 |
-
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
|
| 234 |
-
|
| 235 |
-
|
| 236 |
-
|
| 237 |
-
|
| 238 |
-
|
| 239 |
-
|
| 240 |
-
|
| 241 |
-
components[key('
|
| 242 |
-
|
| 243 |
-
|
| 244 |
-
|
| 245 |
-
|
| 246 |
-
|
| 247 |
-
|
| 248 |
-
|
| 249 |
-
|
| 250 |
-
|
| 251 |
-
|
| 252 |
-
|
| 253 |
-
|
| 254 |
-
|
| 255 |
-
|
| 256 |
-
|
| 257 |
-
|
| 258 |
-
|
| 259 |
-
|
| 260 |
-
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
key('
|
| 264 |
-
key('
|
| 265 |
-
key('
|
| 266 |
-
key('
|
| 267 |
-
key('
|
| 268 |
-
|
| 269 |
-
|
| 270 |
-
|
| 271 |
-
|
| 272 |
-
|
| 273 |
-
|
| 274 |
-
|
| 275 |
-
|
| 276 |
-
|
| 277 |
-
|
| 278 |
-
|
| 279 |
-
|
| 280 |
-
|
| 281 |
-
|
| 282 |
-
|
| 283 |
-
components[key('
|
| 284 |
-
|
| 285 |
-
|
| 286 |
-
|
| 287 |
-
|
| 288 |
-
|
| 289 |
-
|
| 290 |
-
|
| 291 |
-
|
| 292 |
-
|
| 293 |
-
|
| 294 |
-
|
| 295 |
-
|
| 296 |
-
|
| 297 |
-
|
| 298 |
-
|
| 299 |
-
|
| 300 |
-
|
| 301 |
-
|
| 302 |
-
|
| 303 |
-
|
| 304 |
-
|
| 305 |
-
|
| 306 |
-
|
| 307 |
-
|
| 308 |
-
|
| 309 |
-
|
| 310 |
-
|
| 311 |
-
|
| 312 |
-
|
| 313 |
-
|
| 314 |
-
)
|
| 315 |
-
|
| 316 |
-
|
| 317 |
-
|
| 318 |
-
|
| 319 |
-
|
| 320 |
-
|
| 321 |
-
|
| 322 |
-
|
| 323 |
-
|
| 324 |
-
|
| 325 |
-
|
| 326 |
-
|
| 327 |
-
|
| 328 |
-
)
|
| 329 |
-
components[key('
|
| 330 |
-
|
| 331 |
-
|
| 332 |
-
|
| 333 |
-
|
| 334 |
-
|
| 335 |
-
|
| 336 |
-
key('
|
| 337 |
-
key('
|
| 338 |
-
key('
|
| 339 |
-
|
| 340 |
-
|
| 341 |
-
|
| 342 |
-
|
| 343 |
-
|
| 344 |
-
|
| 345 |
-
|
| 346 |
-
|
| 347 |
-
|
| 348 |
-
|
| 349 |
-
|
| 350 |
-
|
| 351 |
-
|
| 352 |
-
components[key('
|
| 353 |
-
|
| 354 |
-
|
| 355 |
-
|
| 356 |
-
all_ipa_components_flat =
|
| 357 |
-
|
| 358 |
-
components[key('
|
| 359 |
-
components[key('
|
| 360 |
-
components[key('
|
| 361 |
-
components[key('
|
| 362 |
-
|
| 363 |
-
]
|
| 364 |
-
|
| 365 |
-
|
| 366 |
-
|
| 367 |
-
|
| 368 |
-
|
| 369 |
-
|
| 370 |
-
|
| 371 |
-
|
| 372 |
-
|
| 373 |
-
|
| 374 |
-
|
| 375 |
-
|
| 376 |
-
|
| 377 |
-
|
| 378 |
-
key('
|
| 379 |
-
key('
|
| 380 |
-
key('
|
| 381 |
-
key('
|
| 382 |
-
|
| 383 |
-
|
| 384 |
-
|
| 385 |
-
|
| 386 |
-
|
| 387 |
-
|
| 388 |
-
|
| 389 |
-
|
| 390 |
-
|
| 391 |
-
|
| 392 |
-
|
| 393 |
-
|
| 394 |
-
|
| 395 |
-
|
| 396 |
-
|
| 397 |
-
components[key('
|
| 398 |
-
|
| 399 |
-
|
| 400 |
-
|
| 401 |
-
|
| 402 |
-
|
| 403 |
-
|
| 404 |
-
|
| 405 |
-
|
| 406 |
-
|
| 407 |
-
|
| 408 |
-
|
| 409 |
-
|
| 410 |
-
|
| 411 |
-
|
| 412 |
-
|
| 413 |
-
|
| 414 |
-
|
| 415 |
-
|
| 416 |
-
key('
|
| 417 |
-
key('
|
| 418 |
-
key('
|
| 419 |
-
key('
|
| 420 |
-
|
| 421 |
-
|
| 422 |
-
|
| 423 |
-
|
| 424 |
-
|
| 425 |
-
|
| 426 |
-
|
| 427 |
-
|
| 428 |
-
|
| 429 |
-
|
| 430 |
-
|
| 431 |
-
|
| 432 |
-
|
| 433 |
-
|
| 434 |
-
|
| 435 |
-
components[key('
|
| 436 |
-
|
| 437 |
-
|
| 438 |
-
|
| 439 |
-
|
| 440 |
-
|
| 441 |
-
|
| 442 |
-
|
| 443 |
-
|
| 444 |
-
|
| 445 |
-
|
| 446 |
-
|
| 447 |
-
|
| 448 |
-
|
| 449 |
-
|
| 450 |
-
|
| 451 |
-
|
| 452 |
-
|
| 453 |
-
key('
|
| 454 |
-
key('
|
| 455 |
-
|
| 456 |
-
|
| 457 |
-
|
| 458 |
-
|
| 459 |
-
|
| 460 |
-
|
| 461 |
-
|
| 462 |
-
|
| 463 |
-
|
| 464 |
-
|
| 465 |
-
|
| 466 |
-
|
| 467 |
-
components[key('
|
| 468 |
-
|
| 469 |
-
|
| 470 |
-
|
| 471 |
-
all_style_components_flat =
|
| 472 |
-
|
| 473 |
-
|
| 474 |
-
|
| 475 |
-
|
| 476 |
-
|
| 477 |
-
|
| 478 |
-
|
| 479 |
-
|
| 480 |
-
|
| 481 |
-
|
| 482 |
-
|
| 483 |
-
|
| 484 |
-
|
| 485 |
-
|
| 486 |
-
key('
|
| 487 |
-
key('
|
| 488 |
-
key('
|
| 489 |
-
key('
|
| 490 |
-
|
| 491 |
-
|
| 492 |
-
|
| 493 |
-
|
| 494 |
-
|
| 495 |
-
|
| 496 |
-
|
| 497 |
-
|
| 498 |
-
|
| 499 |
-
|
| 500 |
-
|
| 501 |
-
|
| 502 |
-
|
| 503 |
-
components[key('
|
| 504 |
-
|
| 505 |
-
|
| 506 |
-
|
| 507 |
-
|
| 508 |
-
|
| 509 |
-
|
| 510 |
-
|
| 511 |
-
|
| 512 |
-
|
| 513 |
-
|
| 514 |
-
|
| 515 |
-
|
| 516 |
-
|
| 517 |
-
|
| 518 |
-
|
| 519 |
-
|
| 520 |
-
|
| 521 |
-
|
| 522 |
-
|
| 523 |
-
|
| 524 |
-
key('
|
| 525 |
-
key('
|
| 526 |
-
key('
|
| 527 |
-
key('
|
| 528 |
-
key('
|
| 529 |
-
key('
|
| 530 |
-
|
| 531 |
-
|
| 532 |
-
|
| 533 |
-
|
| 534 |
-
|
| 535 |
-
|
| 536 |
-
|
| 537 |
-
|
| 538 |
-
|
| 539 |
-
|
| 540 |
-
|
| 541 |
-
|
| 542 |
-
|
| 543 |
-
|
| 544 |
-
|
| 545 |
-
components[key('
|
| 546 |
-
|
| 547 |
-
|
| 548 |
-
|
| 549 |
-
|
| 550 |
-
|
| 551 |
-
|
| 552 |
-
|
| 553 |
-
|
| 554 |
-
|
| 555 |
-
|
| 556 |
-
|
| 557 |
-
|
| 558 |
-
hashed_filename
|
| 559 |
-
|
| 560 |
-
|
| 561 |
-
|
| 562 |
-
|
| 563 |
-
|
| 564 |
-
|
| 565 |
-
|
| 566 |
-
|
| 567 |
-
|
| 568 |
-
gr.
|
| 569 |
-
|
| 570 |
-
|
| 571 |
-
|
| 572 |
-
|
| 573 |
-
|
| 574 |
-
|
| 575 |
-
|
| 576 |
-
)
|
| 577 |
-
|
| 578 |
-
|
| 579 |
-
|
| 580 |
-
|
| 581 |
-
|
| 582 |
-
|
| 583 |
-
|
| 584 |
-
"
|
| 585 |
-
|
| 586 |
-
|
| 587 |
-
)
|
| 588 |
-
components[key('
|
| 589 |
-
|
| 590 |
-
|
| 591 |
-
|
| 592 |
-
|
| 593 |
-
|
| 594 |
-
|
| 595 |
-
|
| 596 |
-
|
| 597 |
-
|
| 598 |
-
|
| 599 |
-
|
| 600 |
-
|
| 601 |
-
|
| 602 |
-
|
| 603 |
-
|
| 604 |
-
|
| 605 |
-
|
| 606 |
-
|
| 607 |
-
|
| 608 |
-
|
| 609 |
-
|
| 610 |
-
|
| 611 |
-
|
| 612 |
-
|
| 613 |
-
|
| 614 |
-
|
| 615 |
-
|
| 616 |
-
components[key('
|
| 617 |
-
|
| 618 |
-
|
| 619 |
-
|
| 620 |
-
components[key('
|
| 621 |
-
|
| 622 |
-
|
| 623 |
-
|
| 624 |
-
|
| 625 |
-
|
| 626 |
-
|
| 627 |
-
|
| 628 |
-
|
| 629 |
-
|
| 630 |
-
|
| 631 |
-
|
| 632 |
-
|
| 633 |
-
|
| 634 |
-
|
| 635 |
-
|
| 636 |
-
|
| 637 |
-
|
| 638 |
-
|
| 639 |
-
|
| 640 |
-
|
| 641 |
-
|
| 642 |
-
|
| 643 |
-
|
| 644 |
-
|
| 645 |
-
components[key('
|
| 646 |
-
|
| 647 |
-
|
| 648 |
-
|
| 649 |
-
components[key('
|
| 650 |
-
|
| 651 |
-
|
| 652 |
-
|
| 653 |
-
|
| 654 |
-
|
| 655 |
-
|
| 656 |
-
|
| 657 |
-
|
| 658 |
-
|
| 659 |
-
|
| 660 |
-
|
| 661 |
-
|
| 662 |
-
|
| 663 |
-
gr.
|
| 664 |
-
|
| 665 |
-
|
| 666 |
-
|
| 667 |
-
|
| 668 |
-
|
| 669 |
-
|
| 670 |
-
|
| 671 |
-
|
| 672 |
return components
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from comfy_integration.nodes import SAMPLER_CHOICES, SCHEDULER_CHOICES
|
| 3 |
+
from core.settings import (
|
| 4 |
+
MAX_LORAS, LORA_SOURCE_CHOICES, MAX_EMBEDDINGS, MAX_CONDITIONINGS,
|
| 5 |
+
MAX_CONTROLNETS, MAX_IPADAPTERS, RESOLUTION_MAP, ARCHITECTURES_CONFIG,
|
| 6 |
+
MODEL_MAP_CHECKPOINT, MODEL_TYPE_MAP, FEATURES_CONFIG, ARCH_CATEGORIES_MAP,
|
| 7 |
+
VAE_DIR, MODEL_DEFAULTS_CONFIG
|
| 8 |
+
)
|
| 9 |
+
import yaml
|
| 10 |
+
import os
|
| 11 |
+
from functools import lru_cache
|
| 12 |
+
from utils.app_utils import save_uploaded_file_with_hash
|
| 13 |
+
|
| 14 |
+
default_model_name = list(MODEL_MAP_CHECKPOINT.keys())[0] if MODEL_MAP_CHECKPOINT else None
|
| 15 |
+
default_m_type = MODEL_TYPE_MAP.get(default_model_name, "SDXL") if default_model_name else "SDXL"
|
| 16 |
+
default_architectures_dict = ARCHITECTURES_CONFIG.get('architectures', {})
|
| 17 |
+
default_arch_model_type = default_architectures_dict.get(default_m_type, {}).get("model_type", default_m_type.lower().replace(" ", "").replace(".", ""))
|
| 18 |
+
default_arch_features = FEATURES_CONFIG.get(default_arch_model_type, FEATURES_CONFIG.get('default', {}))
|
| 19 |
+
default_enabled_chains = default_arch_features.get('enabled_chains', [])
|
| 20 |
+
|
| 21 |
+
default_vals = MODEL_DEFAULTS_CONFIG.get('Default', {})
|
| 22 |
+
DEFAULT_STEPS = default_vals.get('steps', 20)
|
| 23 |
+
DEFAULT_CFG = default_vals.get('cfg', 5.0)
|
| 24 |
+
DEFAULT_SAMPLER = default_vals.get('sampler_name', 'euler')
|
| 25 |
+
DEFAULT_SCHEDULER = default_vals.get('scheduler', 'simple')
|
| 26 |
+
DEFAULT_POS_PROMPT = default_vals.get('positive_prompt', '')
|
| 27 |
+
DEFAULT_NEG_PROMPT = default_vals.get('negative_prompt', '')
|
| 28 |
+
|
| 29 |
+
@lru_cache(maxsize=1)
|
| 30 |
+
def get_ipadapter_config_from_yaml():
|
| 31 |
+
try:
|
| 32 |
+
_PROJECT_ROOT = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
| 33 |
+
_IPADAPTER_LIST_PATH = os.path.join(_PROJECT_ROOT, 'yaml', 'ipadapter.yaml')
|
| 34 |
+
with open(_IPADAPTER_LIST_PATH, 'r', encoding='utf-8') as f:
|
| 35 |
+
config = yaml.safe_load(f)
|
| 36 |
+
return config
|
| 37 |
+
except Exception as e:
|
| 38 |
+
print(f"Warning: Could not load ipadapter.yaml for UI components: {e}")
|
| 39 |
+
return {}
|
| 40 |
+
|
| 41 |
+
def get_ipadapter_presets(arch="SDXL"):
|
| 42 |
+
config = get_ipadapter_config_from_yaml()
|
| 43 |
+
presets = []
|
| 44 |
+
if config:
|
| 45 |
+
std_presets = config.get("IPAdapter_presets", {}).get(arch, [])
|
| 46 |
+
face_presets = config.get("IPAdapter_FaceID_presets", {}).get(arch, [])
|
| 47 |
+
if std_presets:
|
| 48 |
+
presets.extend(std_presets)
|
| 49 |
+
if face_presets:
|
| 50 |
+
presets.extend(face_presets)
|
| 51 |
+
return presets if presets else ["STANDARD (medium strength)"]
|
| 52 |
+
|
| 53 |
+
def create_model_architecture_filter_ui(prefix):
|
| 54 |
+
components = {}
|
| 55 |
+
ordered_architectures = ARCHITECTURES_CONFIG.get("architecture_order", [])
|
| 56 |
+
choices = ["ALL"] + ordered_architectures
|
| 57 |
+
|
| 58 |
+
components[f'model_arch_{prefix}'] = gr.Radio(
|
| 59 |
+
label="Model Architecture",
|
| 60 |
+
choices=choices,
|
| 61 |
+
value="ALL",
|
| 62 |
+
interactive=True,
|
| 63 |
+
visible=True
|
| 64 |
+
)
|
| 65 |
+
return components
|
| 66 |
+
|
| 67 |
+
def create_category_filter_ui(prefix):
|
| 68 |
+
valid_cats = list(set(cat for cats in ARCH_CATEGORIES_MAP.values() for cat in cats))
|
| 69 |
+
cat_choices = ["ALL"] + sorted(valid_cats)
|
| 70 |
+
|
| 71 |
+
components = {}
|
| 72 |
+
components[f'model_cat_{prefix}'] = gr.Dropdown(
|
| 73 |
+
label="Filter Models",
|
| 74 |
+
choices=cat_choices,
|
| 75 |
+
value="ALL",
|
| 76 |
+
interactive=True,
|
| 77 |
+
scale=1,
|
| 78 |
+
allow_custom_value=True
|
| 79 |
+
)
|
| 80 |
+
return components
|
| 81 |
+
|
| 82 |
+
def create_base_parameter_ui(prefix, defaults=None):
|
| 83 |
+
if defaults is None:
|
| 84 |
+
defaults = {}
|
| 85 |
+
|
| 86 |
+
components = {}
|
| 87 |
+
# Aspect Ratio
|
| 88 |
+
components[f'aspect_ratio_{prefix}'] = gr.Dropdown(
|
| 89 |
+
label="Aspect Ratio",
|
| 90 |
+
choices=list(RESOLUTION_MAP.get('sdxl', {}).keys()),
|
| 91 |
+
value="1:1 (Square)",
|
| 92 |
+
interactive=True,
|
| 93 |
+
allow_custom_value=True
|
| 94 |
+
)
|
| 95 |
+
# Width & Height
|
| 96 |
+
components[f'width_{prefix}'] = gr.Number(label="Width", value=defaults.get('w', 1024), interactive=True)
|
| 97 |
+
components[f'height_{prefix}'] = gr.Number(label="Height", value=defaults.get('h', 1024), interactive=True)
|
| 98 |
+
# Sampler & Scheduler
|
| 99 |
+
components[f'sampler_{prefix}'] = gr.Dropdown(
|
| 100 |
+
label="Sampler",
|
| 101 |
+
choices=SAMPLER_CHOICES,
|
| 102 |
+
value=DEFAULT_SAMPLER if DEFAULT_SAMPLER in SAMPLER_CHOICES else (SAMPLER_CHOICES[0] if SAMPLER_CHOICES else 'euler')
|
| 103 |
+
)
|
| 104 |
+
components[f'scheduler_{prefix}'] = gr.Dropdown(
|
| 105 |
+
label="Scheduler",
|
| 106 |
+
choices=SCHEDULER_CHOICES,
|
| 107 |
+
value=DEFAULT_SCHEDULER if DEFAULT_SCHEDULER in SCHEDULER_CHOICES else (SCHEDULER_CHOICES[0] if SCHEDULER_CHOICES else 'simple')
|
| 108 |
+
)
|
| 109 |
+
# Steps & CFG
|
| 110 |
+
components[f'steps_{prefix}'] = gr.Slider(label="Steps", minimum=1, maximum=100, step=1, value=DEFAULT_STEPS)
|
| 111 |
+
components[f'cfg_{prefix}'] = gr.Slider(label="CFG Scale", minimum=1.0, maximum=20.0, step=0.1, value=DEFAULT_CFG)
|
| 112 |
+
# Seed & Batch Size
|
| 113 |
+
components[f'seed_{prefix}'] = gr.Number(label="Seed (-1 for random)", value=-1, precision=0)
|
| 114 |
+
components[f'batch_size_{prefix}'] = gr.Slider(label="Batch Size", minimum=1, maximum=16, step=1, value=1)
|
| 115 |
+
# Clip Skip & Guidance (FLUX) & ZeroGPU Duration
|
| 116 |
+
components[f'clip_skip_{prefix}'] = gr.Slider(label="Clip Skip", minimum=1, maximum=2, step=1, value=1, visible=False, interactive=True)
|
| 117 |
+
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)
|
| 118 |
+
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.")
|
| 119 |
+
|
| 120 |
+
return components
|
| 121 |
+
|
| 122 |
+
|
| 123 |
+
def create_lora_settings_ui(prefix: str):
|
| 124 |
+
components = {}
|
| 125 |
+
|
| 126 |
+
lora_rows, lora_sources, lora_ids, lora_scales, lora_uploads = [], [], [], [], []
|
| 127 |
+
|
| 128 |
+
with gr.Accordion("LoRA Settings", open=False, visible=('lora' in default_enabled_chains)) as lora_accordion:
|
| 129 |
+
components[f'lora_accordion_{prefix}'] = lora_accordion
|
| 130 |
+
gr.Markdown("π‘ **Tip:** When downloading from Civitai, please use the **Version ID**, not the Model ID. You can find the Version ID in the URL (e.g., `civitai.com/models/123?modelVersionId=456`) or under the model's download button. When downloading from Hugging Face, please use the format: `repo_id/filename.extension` or `repo_id/folder_path/filename.extension` (e.g., `lightx2v/Qwen-Image-Lightning/Qwen-Image-Lightning-4steps-V2.0-bf16.safetensors`).")
|
| 131 |
+
components[f'lora_count_state_{prefix}'] = gr.State(1)
|
| 132 |
+
|
| 133 |
+
for i in range(MAX_LORAS):
|
| 134 |
+
with gr.Row(visible=i==0) as row:
|
| 135 |
+
source = gr.Dropdown(label=f"LoRA Source {i+1}", choices=LORA_SOURCE_CHOICES, value=LORA_SOURCE_CHOICES[0], scale=1)
|
| 136 |
+
lora_id = gr.Textbox(label="Civitai Version ID / HF file / Upload File", scale=2, type="text")
|
| 137 |
+
scale = gr.Slider(label=f"Scale", minimum=0.0, maximum=2.0, step=0.05, value=1.0, scale=1)
|
| 138 |
+
upload = gr.UploadButton(label="Upload", file_types=[".safetensors"], scale=1)
|
| 139 |
+
|
| 140 |
+
lora_rows.append(row)
|
| 141 |
+
lora_sources.append(source)
|
| 142 |
+
lora_ids.append(lora_id)
|
| 143 |
+
lora_scales.append(scale)
|
| 144 |
+
lora_uploads.append(upload)
|
| 145 |
+
|
| 146 |
+
with gr.Row():
|
| 147 |
+
components[f'add_lora_button_{prefix}'] = gr.Button("Add LoRA", variant="secondary")
|
| 148 |
+
components[f'delete_lora_button_{prefix}'] = gr.Button("Remove LoRA", variant="secondary", visible=False)
|
| 149 |
+
|
| 150 |
+
components[f'lora_rows_{prefix}'] = lora_rows
|
| 151 |
+
components[f'lora_sources_{prefix}'] = lora_sources
|
| 152 |
+
components[f'lora_ids_{prefix}'] = lora_ids
|
| 153 |
+
components[f'lora_scales_{prefix}'] = lora_scales
|
| 154 |
+
components[f'lora_uploads_{prefix}'] = lora_uploads
|
| 155 |
+
|
| 156 |
+
all_lora_components_flat = []
|
| 157 |
+
for i in range(MAX_LORAS):
|
| 158 |
+
all_lora_components_flat.extend([lora_sources[i], lora_ids[i], lora_scales[i], lora_uploads[i]])
|
| 159 |
+
components[f'all_lora_components_flat_{prefix}'] = all_lora_components_flat
|
| 160 |
+
|
| 161 |
+
return components
|
| 162 |
+
|
| 163 |
+
def create_controlnet_ui(prefix: str, max_units=MAX_CONTROLNETS):
|
| 164 |
+
components = {}
|
| 165 |
+
key = lambda name: f"{name}_{prefix}"
|
| 166 |
+
|
| 167 |
+
with gr.Accordion("ControlNet Settings", open=False, visible=('controlnet' in default_enabled_chains)) as accordion:
|
| 168 |
+
components[key('controlnet_accordion')] = accordion
|
| 169 |
+
|
| 170 |
+
cn_rows, images, series, types, strengths, filepaths = [], [], [], [], [], []
|
| 171 |
+
components.update({
|
| 172 |
+
key('controlnet_rows'): cn_rows,
|
| 173 |
+
key('controlnet_images'): images,
|
| 174 |
+
key('controlnet_series'): series,
|
| 175 |
+
key('controlnet_types'): types,
|
| 176 |
+
key('controlnet_strengths'): strengths,
|
| 177 |
+
key('controlnet_filepaths'): filepaths
|
| 178 |
+
})
|
| 179 |
+
|
| 180 |
+
for i in range(max_units):
|
| 181 |
+
with gr.Row(visible=(i < 1)) as row:
|
| 182 |
+
with gr.Column(scale=1):
|
| 183 |
+
images.append(gr.Image(label=f"Control Image {i+1}", type="pil", sources=["upload"], height=256))
|
| 184 |
+
with gr.Column(scale=2):
|
| 185 |
+
types.append(gr.Dropdown(label="Type", choices=[], interactive=True, allow_custom_value=True))
|
| 186 |
+
series.append(gr.Dropdown(label="Series", choices=[], interactive=True, allow_custom_value=True))
|
| 187 |
+
strengths.append(gr.Slider(label="Strength", minimum=0.0, maximum=2.0, step=0.05, value=1.0, interactive=True))
|
| 188 |
+
filepaths.append(gr.State(None))
|
| 189 |
+
cn_rows.append(row)
|
| 190 |
+
|
| 191 |
+
with gr.Row():
|
| 192 |
+
components[key('add_controlnet_button')] = gr.Button("β Add ControlNet")
|
| 193 |
+
components[key('delete_controlnet_button')] = gr.Button("β Delete ControlNet", visible=False)
|
| 194 |
+
components[key('controlnet_count_state')] = gr.State(1)
|
| 195 |
+
|
| 196 |
+
all_cn_components_flat = []
|
| 197 |
+
for i in range(max_units):
|
| 198 |
+
all_cn_components_flat.extend([
|
| 199 |
+
images[i], types[i], series[i], strengths[i], filepaths[i]
|
| 200 |
+
])
|
| 201 |
+
components[key('all_controlnet_components_flat')] = all_cn_components_flat
|
| 202 |
+
|
| 203 |
+
return components
|
| 204 |
+
|
| 205 |
+
def create_anima_controlnet_lllite_ui(prefix: str, max_units=MAX_CONTROLNETS):
|
| 206 |
+
components = {}
|
| 207 |
+
key = lambda name: f"{name}_{prefix}"
|
| 208 |
+
|
| 209 |
+
with gr.Accordion("Anima ControlNet Lllite Settings", open=False, visible=('anima_controlnet_lllite' in default_enabled_chains)) as accordion:
|
| 210 |
+
components[key('anima_controlnet_lllite_accordion')] = accordion
|
| 211 |
+
gr.Markdown("π‘ **Tip:** Processed using the [kohya-ss/ComfyUI-Anima-LLLite](https://github.com/kohya-ss/ComfyUI-Anima-LLLite) node.")
|
| 212 |
+
|
| 213 |
+
cn_rows, images, series, types, strengths, filepaths, start_percents, end_percents = [], [], [], [], [], [], [], []
|
| 214 |
+
components.update({
|
| 215 |
+
key('anima_controlnet_lllite_rows'): cn_rows,
|
| 216 |
+
key('anima_controlnet_lllite_images'): images,
|
| 217 |
+
key('anima_controlnet_lllite_series'): series,
|
| 218 |
+
key('anima_controlnet_lllite_types'): types,
|
| 219 |
+
key('anima_controlnet_lllite_strengths'): strengths,
|
| 220 |
+
key('anima_controlnet_lllite_filepaths'): filepaths,
|
| 221 |
+
key('anima_controlnet_lllite_start_percents'): start_percents,
|
| 222 |
+
key('anima_controlnet_lllite_end_percents'): end_percents
|
| 223 |
+
})
|
| 224 |
+
|
| 225 |
+
for i in range(max_units):
|
| 226 |
+
with gr.Row(visible=(i < 1)) as row:
|
| 227 |
+
with gr.Column(scale=1):
|
| 228 |
+
images.append(gr.Image(label=f"Control Image {i+1}", type="pil", sources=["upload"], height=256))
|
| 229 |
+
with gr.Column(scale=2):
|
| 230 |
+
types.append(gr.Dropdown(label="Type", choices=[], interactive=True, allow_custom_value=True))
|
| 231 |
+
series.append(gr.Dropdown(label="Series", choices=[], interactive=True, allow_custom_value=True))
|
| 232 |
+
strengths.append(gr.Slider(label="Strength", minimum=0.0, maximum=2.0, step=0.05, value=1.0, interactive=True))
|
| 233 |
+
with gr.Row(visible=False):
|
| 234 |
+
start_percents.append(gr.State(0.0))
|
| 235 |
+
end_percents.append(gr.State(1.0))
|
| 236 |
+
filepaths.append(gr.State(None))
|
| 237 |
+
cn_rows.append(row)
|
| 238 |
+
|
| 239 |
+
with gr.Row():
|
| 240 |
+
components[key('add_anima_controlnet_lllite_button')] = gr.Button("β Add Lllite")
|
| 241 |
+
components[key('delete_anima_controlnet_lllite_button')] = gr.Button("β Delete Lllite", visible=False)
|
| 242 |
+
components[key('anima_controlnet_lllite_count_state')] = gr.State(1)
|
| 243 |
+
|
| 244 |
+
all_cn_components_flat = []
|
| 245 |
+
for i in range(max_units):
|
| 246 |
+
all_cn_components_flat.extend([
|
| 247 |
+
images[i], types[i], series[i], strengths[i], filepaths[i], start_percents[i], end_percents[i]
|
| 248 |
+
])
|
| 249 |
+
components[key('all_anima_controlnet_lllite_components_flat')] = all_cn_components_flat
|
| 250 |
+
|
| 251 |
+
return components
|
| 252 |
+
|
| 253 |
+
def create_diffsynth_controlnet_ui(prefix: str, max_units=MAX_CONTROLNETS):
|
| 254 |
+
components = {}
|
| 255 |
+
key = lambda name: f"{name}_{prefix}"
|
| 256 |
+
|
| 257 |
+
with gr.Accordion("DiffSynth ControlNet Settings", open=False, visible=('controlnet_model_patch' in default_enabled_chains)) as accordion:
|
| 258 |
+
components[key('diffsynth_controlnet_accordion')] = accordion
|
| 259 |
+
|
| 260 |
+
cn_rows, images, series, types, strengths, filepaths = [], [], [], [], [], []
|
| 261 |
+
components.update({
|
| 262 |
+
key('diffsynth_controlnet_rows'): cn_rows,
|
| 263 |
+
key('diffsynth_controlnet_images'): images,
|
| 264 |
+
key('diffsynth_controlnet_series'): series,
|
| 265 |
+
key('diffsynth_controlnet_types'): types,
|
| 266 |
+
key('diffsynth_controlnet_strengths'): strengths,
|
| 267 |
+
key('diffsynth_controlnet_filepaths'): filepaths
|
| 268 |
+
})
|
| 269 |
+
|
| 270 |
+
for i in range(max_units):
|
| 271 |
+
with gr.Row(visible=(i < 1)) as row:
|
| 272 |
+
with gr.Column(scale=1):
|
| 273 |
+
images.append(gr.Image(label=f"Control Image {i+1}", type="pil", sources=["upload"], height=256))
|
| 274 |
+
with gr.Column(scale=2):
|
| 275 |
+
types.append(gr.Dropdown(label="Type", choices=[], interactive=True, allow_custom_value=True))
|
| 276 |
+
series.append(gr.Dropdown(label="Series", choices=[], interactive=True, allow_custom_value=True))
|
| 277 |
+
strengths.append(gr.Slider(label="Strength", minimum=0.0, maximum=2.0, step=0.05, value=1.0, interactive=True))
|
| 278 |
+
filepaths.append(gr.State(None))
|
| 279 |
+
cn_rows.append(row)
|
| 280 |
+
|
| 281 |
+
with gr.Row():
|
| 282 |
+
components[key('add_diffsynth_controlnet_button')] = gr.Button("β Add DiffSynth ControlNet")
|
| 283 |
+
components[key('delete_diffsynth_controlnet_button')] = gr.Button("β Delete DiffSynth ControlNet", visible=False)
|
| 284 |
+
components[key('diffsynth_controlnet_count_state')] = gr.State(1)
|
| 285 |
+
|
| 286 |
+
all_cn_components_flat = []
|
| 287 |
+
for i in range(max_units):
|
| 288 |
+
all_cn_components_flat.extend([
|
| 289 |
+
images[i], types[i], series[i], strengths[i], filepaths[i]
|
| 290 |
+
])
|
| 291 |
+
components[key('all_diffsynth_controlnet_components_flat')] = all_cn_components_flat
|
| 292 |
+
|
| 293 |
+
return components
|
| 294 |
+
|
| 295 |
+
def create_ipadapter_ui(prefix: str, max_units=MAX_IPADAPTERS):
|
| 296 |
+
components = {}
|
| 297 |
+
key = lambda name: f"{name}_{prefix}"
|
| 298 |
+
|
| 299 |
+
sdxl_presets = get_ipadapter_presets("SDXL")
|
| 300 |
+
default_preset = sdxl_presets[0] if sdxl_presets else None
|
| 301 |
+
|
| 302 |
+
with gr.Accordion("IPAdapter Settings", open=False, visible=('ipadapter' in default_enabled_chains)) as accordion:
|
| 303 |
+
components[key('ipadapter_accordion')] = accordion
|
| 304 |
+
gr.Markdown("π‘ **Tip:** Processed using the [cubiq/ComfyUI_IPAdapter_plus](https://github.com/cubiq/ComfyUI_IPAdapter_plus) node.")
|
| 305 |
+
|
| 306 |
+
with gr.Row():
|
| 307 |
+
components[key('ipadapter_final_preset')] = gr.Dropdown(
|
| 308 |
+
label="Preset (for all images)",
|
| 309 |
+
choices=sdxl_presets,
|
| 310 |
+
value=default_preset,
|
| 311 |
+
interactive=True,
|
| 312 |
+
allow_custom_value=True
|
| 313 |
+
)
|
| 314 |
+
components[key('ipadapter_embeds_scaling')] = gr.Dropdown(
|
| 315 |
+
label="Embeds Scaling",
|
| 316 |
+
choices=['V only', 'K+V', 'K+V w/ C penalty', 'K+mean(V) w/ C penalty'],
|
| 317 |
+
value='V only',
|
| 318 |
+
interactive=True
|
| 319 |
+
)
|
| 320 |
+
|
| 321 |
+
with gr.Row():
|
| 322 |
+
components[key('ipadapter_combine_method')] = gr.Dropdown(
|
| 323 |
+
label="Combine Method",
|
| 324 |
+
choices=["concat", "add", "subtract", "average", "norm average", "max", "min"],
|
| 325 |
+
value="concat",
|
| 326 |
+
interactive=True
|
| 327 |
+
)
|
| 328 |
+
components[key('ipadapter_final_weight')] = gr.Slider(label="Final Weight", minimum=0.0, maximum=2.0, step=0.05, value=1.0, interactive=True)
|
| 329 |
+
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)
|
| 330 |
+
|
| 331 |
+
gr.Markdown("---")
|
| 332 |
+
|
| 333 |
+
ipa_rows, images, weights, lora_strengths = [], [], [], []
|
| 334 |
+
components.update({
|
| 335 |
+
key('ipadapter_rows'): ipa_rows,
|
| 336 |
+
key('ipadapter_images'): images,
|
| 337 |
+
key('ipadapter_weights'): weights,
|
| 338 |
+
key('ipadapter_lora_strengths'): lora_strengths
|
| 339 |
+
})
|
| 340 |
+
|
| 341 |
+
for i in range(max_units):
|
| 342 |
+
with gr.Row(visible=(i < 1)) as row:
|
| 343 |
+
with gr.Column(scale=1):
|
| 344 |
+
images.append(gr.Image(label=f"IPAdapter Image {i+1}", type="pil", sources=["upload"], height=256))
|
| 345 |
+
with gr.Column(scale=2):
|
| 346 |
+
weights.append(gr.Slider(label="Weight", minimum=0.0, maximum=2.0, step=0.05, value=1.0, interactive=True))
|
| 347 |
+
lora_strengths.append(gr.Slider(label="LoRA Strength", minimum=0.0, maximum=2.0, step=0.05, value=0.6, interactive=True, visible=False))
|
| 348 |
+
ipa_rows.append(row)
|
| 349 |
+
|
| 350 |
+
with gr.Row():
|
| 351 |
+
components[key('add_ipadapter_button')] = gr.Button("β Add IPAdapter")
|
| 352 |
+
components[key('delete_ipadapter_button')] = gr.Button("β Delete IPAdapter", visible=False)
|
| 353 |
+
components[key('ipadapter_count_state')] = gr.State(1)
|
| 354 |
+
|
| 355 |
+
all_ipa_components_flat = images + weights + lora_strengths
|
| 356 |
+
all_ipa_components_flat += [
|
| 357 |
+
components[key('ipadapter_final_preset')],
|
| 358 |
+
components[key('ipadapter_final_weight')],
|
| 359 |
+
components[key('ipadapter_final_lora_strength')],
|
| 360 |
+
components[key('ipadapter_embeds_scaling')],
|
| 361 |
+
components[key('ipadapter_combine_method')],
|
| 362 |
+
]
|
| 363 |
+
components[key('all_ipadapter_components_flat')] = all_ipa_components_flat
|
| 364 |
+
|
| 365 |
+
return components
|
| 366 |
+
|
| 367 |
+
def create_flux1_ipadapter_ui(prefix: str, max_units=MAX_IPADAPTERS):
|
| 368 |
+
components = {}
|
| 369 |
+
key = lambda name: f"{name}_{prefix}"
|
| 370 |
+
|
| 371 |
+
with gr.Accordion("IPAdapter Settings (FLUX.1)", open=False, visible=('flux1_ipadapter' in default_enabled_chains)) as accordion:
|
| 372 |
+
components[key('flux1_ipadapter_accordion')] = accordion
|
| 373 |
+
gr.Markdown("π‘ **Tip:** Processed using the [Shakker-Labs/ComfyUI-IPAdapter-Flux](https://github.com/Shakker-Labs/ComfyUI-IPAdapter-Flux) node.")
|
| 374 |
+
|
| 375 |
+
ipa_rows, images, weights, start_percents, end_percents = [], [], [], [], []
|
| 376 |
+
components.update({
|
| 377 |
+
key('flux1_ipadapter_rows'): ipa_rows,
|
| 378 |
+
key('flux1_ipadapter_images'): images,
|
| 379 |
+
key('flux1_ipadapter_weights'): weights,
|
| 380 |
+
key('flux1_ipadapter_start_percents'): start_percents,
|
| 381 |
+
key('flux1_ipadapter_end_percents'): end_percents,
|
| 382 |
+
})
|
| 383 |
+
|
| 384 |
+
for i in range(max_units):
|
| 385 |
+
with gr.Row(visible=(i < 1)) as row:
|
| 386 |
+
with gr.Column(scale=1):
|
| 387 |
+
images.append(gr.Image(label=f"IPAdapter Image {i+1}", type="pil", sources=["upload"], height=256))
|
| 388 |
+
with gr.Column(scale=2):
|
| 389 |
+
weights.append(gr.Slider(label="Weight", minimum=0.0, maximum=2.0, step=0.05, value=0.6, interactive=True))
|
| 390 |
+
with gr.Row():
|
| 391 |
+
start_percents.append(gr.Slider(label="Start At", minimum=0.0, maximum=1.0, step=0.01, value=0.0, interactive=True))
|
| 392 |
+
end_percents.append(gr.Slider(label="End At", minimum=0.0, maximum=1.0, step=0.01, value=0.6, interactive=True))
|
| 393 |
+
ipa_rows.append(row)
|
| 394 |
+
|
| 395 |
+
with gr.Row():
|
| 396 |
+
components[key('add_flux1_ipadapter_button')] = gr.Button("β Add IPAdapter (FLUX)")
|
| 397 |
+
components[key('delete_flux1_ipadapter_button')] = gr.Button("β Delete IPAdapter (FLUX)", visible=False)
|
| 398 |
+
components[key('flux1_ipadapter_count_state')] = gr.State(1)
|
| 399 |
+
|
| 400 |
+
all_flux1_ipa_components_flat = images + weights + start_percents + end_percents
|
| 401 |
+
components[key('all_flux1_ipadapter_components_flat')] = all_flux1_ipa_components_flat
|
| 402 |
+
|
| 403 |
+
return components
|
| 404 |
+
|
| 405 |
+
def create_sd3_ipadapter_ui(prefix: str, max_units=MAX_IPADAPTERS):
|
| 406 |
+
components = {}
|
| 407 |
+
key = lambda name: f"{name}_{prefix}"
|
| 408 |
+
|
| 409 |
+
with gr.Accordion("IPAdapter Settings (SD3)", open=False, visible=('sd3_ipadapter' in default_enabled_chains)) as accordion:
|
| 410 |
+
components[key('sd3_ipadapter_accordion')] = accordion
|
| 411 |
+
gr.Markdown("π‘ **Tip:** Processed using the [Slickytail/ComfyUI-InstantX-IPAdapter-SD3](https://github.com/Slickytail/ComfyUI-InstantX-IPAdapter-SD3) node.")
|
| 412 |
+
|
| 413 |
+
ipa_rows, images, weights, start_percents, end_percents = [], [], [], [], []
|
| 414 |
+
components.update({
|
| 415 |
+
key('sd3_ipadapter_rows'): ipa_rows,
|
| 416 |
+
key('sd3_ipadapter_images'): images,
|
| 417 |
+
key('sd3_ipadapter_weights'): weights,
|
| 418 |
+
key('sd3_ipadapter_start_percents'): start_percents,
|
| 419 |
+
key('sd3_ipadapter_end_percents'): end_percents,
|
| 420 |
+
})
|
| 421 |
+
|
| 422 |
+
for i in range(max_units):
|
| 423 |
+
with gr.Row(visible=(i < 1)) as row:
|
| 424 |
+
with gr.Column(scale=1):
|
| 425 |
+
images.append(gr.Image(label=f"IPAdapter Image {i+1}", type="pil", sources=["upload"], height=256))
|
| 426 |
+
with gr.Column(scale=2):
|
| 427 |
+
weights.append(gr.Slider(label="Weight", minimum=0.0, maximum=2.0, step=0.05, value=0.5, interactive=True))
|
| 428 |
+
with gr.Row():
|
| 429 |
+
start_percents.append(gr.Slider(label="Start At", minimum=0.0, maximum=1.0, step=0.01, value=0.0, interactive=True))
|
| 430 |
+
end_percents.append(gr.Slider(label="End At", minimum=0.0, maximum=1.0, step=0.01, value=1.0, interactive=True))
|
| 431 |
+
ipa_rows.append(row)
|
| 432 |
+
|
| 433 |
+
with gr.Row():
|
| 434 |
+
components[key('add_sd3_ipadapter_button')] = gr.Button("β Add IPAdapter (SD3)")
|
| 435 |
+
components[key('delete_sd3_ipadapter_button')] = gr.Button("β Delete IPAdapter (SD3)", visible=False)
|
| 436 |
+
components[key('sd3_ipadapter_count_state')] = gr.State(1)
|
| 437 |
+
|
| 438 |
+
all_sd3_ipa_components_flat = images + weights + start_percents + end_percents
|
| 439 |
+
components[key('all_sd3_ipadapter_components_flat')] = all_sd3_ipa_components_flat
|
| 440 |
+
|
| 441 |
+
return components
|
| 442 |
+
|
| 443 |
+
def create_style_ui(prefix: str):
|
| 444 |
+
components = {}
|
| 445 |
+
key = lambda name: f"{name}_{prefix}"
|
| 446 |
+
|
| 447 |
+
with gr.Accordion("Style Settings (FLUX.1)", open=False, visible=('style' in default_enabled_chains)) as accordion:
|
| 448 |
+
components[key('style_accordion')] = accordion
|
| 449 |
+
|
| 450 |
+
style_rows, images, strengths = [], [], []
|
| 451 |
+
components.update({
|
| 452 |
+
key('style_rows'): style_rows,
|
| 453 |
+
key('style_images'): images,
|
| 454 |
+
key('style_strengths'): strengths
|
| 455 |
+
})
|
| 456 |
+
|
| 457 |
+
for i in range(5):
|
| 458 |
+
with gr.Row(visible=(i < 1)) as row:
|
| 459 |
+
with gr.Column(scale=1):
|
| 460 |
+
images.append(gr.Image(label=f"Style Image {i+1}", type="pil", sources=["upload"], height=256))
|
| 461 |
+
with gr.Column(scale=2):
|
| 462 |
+
strengths.append(gr.Slider(label="Strength", minimum=0.0, maximum=2.0, step=0.05, value=1.0, interactive=True))
|
| 463 |
+
style_rows.append(row)
|
| 464 |
+
|
| 465 |
+
with gr.Row():
|
| 466 |
+
components[key('add_style_button')] = gr.Button("β Add Style (FLUX)")
|
| 467 |
+
components[key('delete_style_button')] = gr.Button("β Delete Style (FLUX)", visible=False)
|
| 468 |
+
components[key('style_count_state')] = gr.State(1)
|
| 469 |
+
|
| 470 |
+
all_style_components_flat = images + strengths
|
| 471 |
+
components[key('all_style_components_flat')] = all_style_components_flat
|
| 472 |
+
|
| 473 |
+
return components
|
| 474 |
+
|
| 475 |
+
def create_embedding_ui(prefix: str):
|
| 476 |
+
components = {}
|
| 477 |
+
key = lambda name: f"{name}_{prefix}"
|
| 478 |
+
|
| 479 |
+
with gr.Accordion("Embedding Settings", open=False, visible=('embedding' in default_enabled_chains)) as accordion:
|
| 480 |
+
components[key('embedding_accordion')] = accordion
|
| 481 |
+
gr.Markdown("π‘ **Tip:** When downloading from Civitai, please use the **Version ID**, not the Model ID. You can find the Version ID in the URL (e.g., `civitai.com/models/123?modelVersionId=456`) or under the model's download button. For example, entering the Version ID 456 will automatically save the file as \"civitai_456.safetensors\", and you will need to manually enter `embedding:civitai_456` in either your prompt or negative prompt to activate it.When downloading from Hugging Face, please use the format: repo_id/filename.extension or repo_id/folder_path/filename.extension (e.g., ilikebigturtles/lazypos/lazypos.safetensors or ilikebigturtles/lazyneg/lazyneg.safetensors). For Hugging Face files, you will need to enter embedding:filename (e.g., entering embedding:lazypos in your positive prompt, or embedding:lazyneg in your negative prompt) to activate it.")
|
| 482 |
+
|
| 483 |
+
embedding_rows, sources, ids, files, upload_buttons = [], [], [], [], []
|
| 484 |
+
components.update({
|
| 485 |
+
key('embedding_rows'): embedding_rows,
|
| 486 |
+
key('embeddings_sources'): sources,
|
| 487 |
+
key('embeddings_ids'): ids,
|
| 488 |
+
key('embeddings_files'): files,
|
| 489 |
+
key('embeddings_uploads'): upload_buttons
|
| 490 |
+
})
|
| 491 |
+
|
| 492 |
+
for i in range(MAX_EMBEDDINGS):
|
| 493 |
+
with gr.Row(visible=(i < 1)) as row:
|
| 494 |
+
sources.append(gr.Dropdown(label=f"Embedding Source {i+1}", choices=LORA_SOURCE_CHOICES, value="Civitai", scale=1, interactive=True))
|
| 495 |
+
ids.append(gr.Textbox(label="Civitai Version ID / HF file / Upload File", scale=3, interactive=True, type="text"))
|
| 496 |
+
upload_btn = gr.UploadButton("Upload", file_types=[".safetensors"], scale=1)
|
| 497 |
+
files.append(gr.State(None))
|
| 498 |
+
upload_buttons.append(upload_btn)
|
| 499 |
+
embedding_rows.append(row)
|
| 500 |
+
|
| 501 |
+
with gr.Row():
|
| 502 |
+
components[key('add_embedding_button')] = gr.Button("β Add Embedding")
|
| 503 |
+
components[key('delete_embedding_button')] = gr.Button("β Delete Embedding", visible=False)
|
| 504 |
+
components[key('embedding_count_state')] = gr.State(1)
|
| 505 |
+
|
| 506 |
+
all_embedding_components_flat = []
|
| 507 |
+
for i in range(MAX_EMBEDDINGS):
|
| 508 |
+
all_embedding_components_flat.extend([sources[i], ids[i], files[i]])
|
| 509 |
+
components[key('all_embedding_components_flat')] = all_embedding_components_flat
|
| 510 |
+
|
| 511 |
+
return components
|
| 512 |
+
|
| 513 |
+
def create_conditioning_ui(prefix: str):
|
| 514 |
+
components = {}
|
| 515 |
+
key = lambda name: f"{name}_{prefix}"
|
| 516 |
+
|
| 517 |
+
with gr.Accordion("Conditioning Settings", open=False, visible=('conditioning' in default_enabled_chains)) as accordion:
|
| 518 |
+
components[key('conditioning_accordion')] = accordion
|
| 519 |
+
gr.Markdown("π‘ **Tip:** Define rectangular areas and assign specific prompts to them. Coordinates (X, Y) start from the top-left corner.")
|
| 520 |
+
|
| 521 |
+
cond_rows, prompts, widths, heights, xs, ys, strengths = [], [], [], [], [], [], []
|
| 522 |
+
components.update({
|
| 523 |
+
key('conditioning_rows'): cond_rows,
|
| 524 |
+
key('conditioning_prompts'): prompts,
|
| 525 |
+
key('conditioning_widths'): widths,
|
| 526 |
+
key('conditioning_heights'): heights,
|
| 527 |
+
key('conditioning_xs'): xs,
|
| 528 |
+
key('conditioning_ys'): ys,
|
| 529 |
+
key('conditioning_strengths'): strengths
|
| 530 |
+
})
|
| 531 |
+
|
| 532 |
+
for i in range(MAX_CONDITIONINGS):
|
| 533 |
+
with gr.Column(visible=(i < 1)) as row_wrapper:
|
| 534 |
+
prompts.append(gr.Textbox(label=f"Area Prompt {i+1}", lines=2, interactive=True))
|
| 535 |
+
with gr.Row():
|
| 536 |
+
xs.append(gr.Number(label="X", value=0, interactive=True, step=8, scale=1))
|
| 537 |
+
ys.append(gr.Number(label="Y", value=0, interactive=True, step=8, scale=1))
|
| 538 |
+
widths.append(gr.Number(label="Width", value=512, interactive=True, step=8, scale=1))
|
| 539 |
+
heights.append(gr.Number(label="Height", value=512, interactive=True, step=8, scale=1))
|
| 540 |
+
strengths.append(gr.Slider(label="Strength", minimum=0.1, maximum=2.0, step=0.05, value=1.0, interactive=True, scale=2))
|
| 541 |
+
cond_rows.append(row_wrapper)
|
| 542 |
+
|
| 543 |
+
with gr.Row():
|
| 544 |
+
components[key('add_conditioning_button')] = gr.Button("β Add Area")
|
| 545 |
+
components[key('delete_conditioning_button')] = gr.Button("β Delete Area", visible=False)
|
| 546 |
+
components[key('conditioning_count_state')] = gr.State(1)
|
| 547 |
+
|
| 548 |
+
all_cond_components_flat = prompts + widths + heights + xs + ys + strengths
|
| 549 |
+
components[key('all_conditioning_components_flat')] = all_cond_components_flat
|
| 550 |
+
|
| 551 |
+
return components
|
| 552 |
+
|
| 553 |
+
def on_vae_upload(file_obj):
|
| 554 |
+
if not file_obj:
|
| 555 |
+
return gr.update(), gr.update(), None
|
| 556 |
+
|
| 557 |
+
hashed_filename = save_uploaded_file_with_hash(file_obj, VAE_DIR)
|
| 558 |
+
return hashed_filename, "File", file_obj
|
| 559 |
+
|
| 560 |
+
def create_vae_override_ui(prefix: str):
|
| 561 |
+
components = {}
|
| 562 |
+
key = lambda name: f"{name}_{prefix}"
|
| 563 |
+
source_choices = ["None"] + LORA_SOURCE_CHOICES
|
| 564 |
+
|
| 565 |
+
with gr.Accordion("VAE Settings (Override)", open=False, visible=('vae' in default_enabled_chains)) as vae_accordion:
|
| 566 |
+
components[key('vae_accordion')] = vae_accordion
|
| 567 |
+
gr.Markdown("π‘ **Tip:** When downloading from Civitai, please use the **Version ID**, not the Model ID. You can find the Version ID in the URL (e.g., `civitai.com/models/123?modelVersionId=456`) or under the model's download button. When downloading from Hugging Face, please use the format: `repo_id/filename.extension` or `repo_id/folder_path/filename.extension` (e.g., `madebyollin/sdxl-vae-fp16-fix/sdxl_vae.safetensors`).")
|
| 568 |
+
with gr.Row():
|
| 569 |
+
components[key('vae_source')] = gr.Dropdown(
|
| 570 |
+
label="VAE Source",
|
| 571 |
+
choices=source_choices,
|
| 572 |
+
value="None",
|
| 573 |
+
scale=1,
|
| 574 |
+
interactive=True
|
| 575 |
+
)
|
| 576 |
+
components[key('vae_id')] = gr.Textbox(
|
| 577 |
+
label="Civitai Version ID / HF file / Upload File",
|
| 578 |
+
scale=3,
|
| 579 |
+
interactive=True,
|
| 580 |
+
type="text"
|
| 581 |
+
)
|
| 582 |
+
upload_btn = gr.UploadButton(
|
| 583 |
+
"Upload",
|
| 584 |
+
file_types=[".safetensors"],
|
| 585 |
+
scale=1
|
| 586 |
+
)
|
| 587 |
+
components[key('vae_upload_button')] = upload_btn
|
| 588 |
+
components[key('vae_file')] = gr.State(None)
|
| 589 |
+
|
| 590 |
+
upload_btn.upload(
|
| 591 |
+
fn=on_vae_upload,
|
| 592 |
+
inputs=[upload_btn],
|
| 593 |
+
outputs=[components[key('vae_id')], components[key('vae_source')], components[key('vae_file')]]
|
| 594 |
+
)
|
| 595 |
+
|
| 596 |
+
return components
|
| 597 |
+
|
| 598 |
+
def create_reference_latent_ui(prefix: str, max_units=10):
|
| 599 |
+
components = {}
|
| 600 |
+
key = lambda name: f"{name}_{prefix}"
|
| 601 |
+
|
| 602 |
+
with gr.Accordion("Reference Edit Settings", open=False, visible=('reference_latent' in default_enabled_chains)) as ref_accordion:
|
| 603 |
+
components[key('reference_latent_accordion')] = ref_accordion
|
| 604 |
+
gr.Markdown("π‘ **Tip:** For multimodal models, this feature enables powerful editing and combining capabilities. In txt2img mode, adding a single reference image performs an **Image Edit**, while adding multiple images performs an **Image Combine**.")
|
| 605 |
+
|
| 606 |
+
ref_image_groups = []
|
| 607 |
+
ref_image_inputs = []
|
| 608 |
+
with gr.Row():
|
| 609 |
+
for i in range(max_units):
|
| 610 |
+
with gr.Column(visible=(i < 1), min_width=160) as img_col:
|
| 611 |
+
img_comp = gr.Image(type="pil", label=f"Ref. {i+1}", sources=["upload"], height=150)
|
| 612 |
+
ref_image_groups.append(img_col)
|
| 613 |
+
ref_image_inputs.append(img_comp)
|
| 614 |
+
|
| 615 |
+
components[key('reference_latent_rows')] = ref_image_groups
|
| 616 |
+
components[key('reference_latent_images')] = ref_image_inputs
|
| 617 |
+
|
| 618 |
+
with gr.Row():
|
| 619 |
+
components[key('add_reference_latent_button')] = gr.Button("β Add Reference Image")
|
| 620 |
+
components[key('delete_reference_latent_button')] = gr.Button("β Delete Reference Image", visible=False)
|
| 621 |
+
components[key('reference_latent_count_state')] = gr.State(1)
|
| 622 |
+
|
| 623 |
+
components[key('all_reference_latent_components_flat')] = ref_image_inputs
|
| 624 |
+
|
| 625 |
+
return components
|
| 626 |
+
|
| 627 |
+
def create_hidream_o1_reference_ui(prefix: str, max_units=10):
|
| 628 |
+
components = {}
|
| 629 |
+
key = lambda name: f"{name}_{prefix}"
|
| 630 |
+
|
| 631 |
+
with gr.Accordion("HiDream-O1 Reference Edit Settings", open=False, visible=('hidream_o1_reference' in default_enabled_chains)) as ref_accordion:
|
| 632 |
+
components[key('hidream_o1_reference_accordion')] = ref_accordion
|
| 633 |
+
gr.Markdown("π‘ **Tip:** Please use **HiDream-O1-Image-Dev** (HiDream-O1-Image will time out), and set the resolution to **4.0MP** (e.g., 2048x2048). In txt2img mode, adding a single reference image performs an **Image Edit**, while adding multiple images performs an **Image Combine**.")
|
| 634 |
+
|
| 635 |
+
ref_image_groups = []
|
| 636 |
+
ref_image_inputs = []
|
| 637 |
+
with gr.Row():
|
| 638 |
+
for i in range(max_units):
|
| 639 |
+
with gr.Column(visible=(i < 1), min_width=160) as img_col:
|
| 640 |
+
img_comp = gr.Image(type="pil", label=f"Ref. {i+1}", sources=["upload"], height=150)
|
| 641 |
+
ref_image_groups.append(img_col)
|
| 642 |
+
ref_image_inputs.append(img_comp)
|
| 643 |
+
|
| 644 |
+
components[key('hidream_o1_reference_rows')] = ref_image_groups
|
| 645 |
+
components[key('hidream_o1_reference_images')] = ref_image_inputs
|
| 646 |
+
|
| 647 |
+
with gr.Row():
|
| 648 |
+
components[key('add_hidream_o1_reference_button')] = gr.Button("β Add Reference Image")
|
| 649 |
+
components[key('delete_hidream_o1_reference_button')] = gr.Button("β Delete Reference Image", visible=False)
|
| 650 |
+
components[key('hidream_o1_reference_count_state')] = gr.State(1)
|
| 651 |
+
|
| 652 |
+
components[key('all_hidream_o1_reference_components_flat')] = ref_image_inputs
|
| 653 |
+
|
| 654 |
+
return components
|
| 655 |
+
|
| 656 |
+
def create_pid_ui(prefix: str):
|
| 657 |
+
components = {}
|
| 658 |
+
key = lambda name: f"{name}_{prefix}"
|
| 659 |
+
|
| 660 |
+
with gr.Accordion("PiD Settings", open=False, visible=('pid' in default_enabled_chains)) as pid_accordion:
|
| 661 |
+
components[key('pid_accordion')] = pid_accordion
|
| 662 |
+
gr.Markdown("π‘ **Tip:** Use PiD (Pixel Diffusion Decoder) instead of the VAE Decoder for 4x decoding.")
|
| 663 |
+
with gr.Row():
|
| 664 |
+
components[key('pid_settings')] = gr.Dropdown(
|
| 665 |
+
label="PiD Mode",
|
| 666 |
+
choices=["OFF", "ON"],
|
| 667 |
+
value="OFF",
|
| 668 |
+
interactive=True
|
| 669 |
+
)
|
| 670 |
+
|
|
|
|
| 671 |
return components
|