Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.
TypeScript ai-artartificial-intelligencegenerative-artimage-generationimg2imginpaintinglatent-diffusionlinuxmacosoutpaintingstable-diffusiontxt2imgwindows
feat(architectures): give the SDXL refiner a canvas, and require default settings at boot
Alexander Eichhorn1c678365768b
diff --git a/invokeai/backend/architectures/defs/sdxl_refiner.py b/invokeai/backend/architectures/defs/sdxl_refiner.pyindex 2ef26f22bd..f30c1a3d14 100644--- a/invokeai/backend/architectures/defs/sdxl_refiner.py+++ b/invokeai/backend/architectures/defs/sdxl_refiner.py@@ -1,8 +1,10 @@"""What the sdxl-refiner architecture declares."""from invokeai.backend.architectures.facets.conditioning import ConditioningFacet+from invokeai.backend.architectures.facets.default_settings import DefaultSettingsFacetfrom invokeai.backend.architectures.facets.latent_space import SDXL_4, LatentSpaceFacetfrom invokeai.backend.architectures.registry import register+from invokeai.backend.model_manager.configs.default_settings import MainModelDefaultSettingsfrom invokeai.backend.model_manager.taxonomy import BaseModelTypefrom invokeai.backend.stable_diffusion.diffusion.conditioning_data import SDXLConditioningInfo@@ -11,4 +13,8 @@ register(BaseModelType.StableDiffusionXLRefiner,LatentSpaceFacet(SDXL_4),ConditioningFacet(SDXLConditioningInfo),+ # Same canvas as SDXL, which it refines. Steps and CFG are deliberately absent: the refiner+ # is a second pass over an SDXL latent and the UI drives it with its own parameters, so+ # there is nothing here for them to prefill.+ DefaultSettingsFacet({None: MainModelDefaultSettings(width=1024, height=1024)}),)diff --git a/invokeai/backend/architectures/facets/default_settings.py b/invokeai/backend/architectures/facets/default_settings.pyindex eefbfeab14..f4c4354ae6 100644--- a/invokeai/backend/architectures/facets/default_settings.py+++ b/invokeai/backend/architectures/facets/default_settings.py@@ -5,16 +5,20 @@ Krea-2 Turbo wants CFG disabled. They are read once, when a model is identified,config, and used by the UI to prefill the generation sliders.They were a `match base:` block of twelve cases in `configs/main.py`, four of which sub-dispatched on-variant, ending in `case _: return None`. That fallback is why this facet is *not* `REQUIRED`: four-architectures deliberately have no defaults, with a standing `TODO(psyche)` asking whether they-should. Forgetting a new architecture here therefore fails softly — no crash, just sliders the user-has to set themselves — which is milder than the other facets and worth being honest about.+variant, ending in `case _: return None`. Four architectures fell into that fallback and had no+defaults at all, under a standing `TODO(psyche)` asking whether they should; all four have since+been given the values their model cards recommend, which answers it.++With no architecture left without defaults, this is `REQUIRED`. The failure it guards is milder than+the other facets' — a forgotten declaration would leave the sliders wherever the last model put them+rather than crash — but that is a reason to catch it at boot, not a reason to tolerate it: nothing+about a missing prefill is visible enough to be noticed any other way."""from collections.abc import Mappingfrom dataclasses import dataclass, fieldfrom pathlib import Path-from typing import Any+from typing import Any, ClassVarfrom invokeai.backend.architectures.facet import Facetfrom invokeai.backend.architectures.registry import get@@ -26,6 +30,8 @@ from invokeai.backend.model_manager.taxonomy import AnyVariant, BaseModelTypeclass DefaultSettingsFacet(Facet):"""What the sliders should say when a model of this architecture is selected."""+ REQUIRED: ClassVar[bool] = True+by_variant: Mapping[Any, MainModelDefaultSettings]"""Keyed by variant, with `None` as the fallback for every variant not named.diff --git a/tests/backend/architectures/test_default_settings.py b/tests/backend/architectures/test_default_settings.pyindex 3e1f6d279a..bb3bd3fdc0 100644--- a/tests/backend/architectures/test_default_settings.py+++ b/tests/backend/architectures/test_default_settings.py@@ -17,29 +17,28 @@ from invokeai.backend.model_manager.taxonomy import (ZImageVariantType,)-# SD 3.5, CogView 4 and FLUX.1 reached the old `case _:` fallback and had no defaults at all; they-# now declare what their model cards recommend. The refiner is the one left: it is not run on its-# own, so there is nothing for it to prefill.-WITHOUT_DEFAULTS = {BaseModelType.StableDiffusionXLRefiner}+def test_the_facet_is_required() -> None:+ """Every architecture declares defaults, so `validate()` enforces it at boot.-def test_the_facet_is_optional() -> None:- """Unlike latent space and conditioning, a missing declaration here is a legitimate state.-- So `validate()` cannot enforce it, and forgetting a new architecture fails softly: no crash,- just sliders the user sets themselves.+ It was optional while four architectures legitimately had none. They now declare what their+ model cards recommend, and the SDXL refiner — the last holdout — declares SDXL's canvas. A+ missing prefill is quiet rather than loud, which is exactly why it needs a boot check."""- assert DefaultSettingsFacet.REQUIRED is False+ assert DefaultSettingsFacet.REQUIRED is True-def test_exactly_the_expected_architectures_declare_nothing() -> None:- undeclared = {b for b in generative_bases() if get(b, DefaultSettingsFacet) is None}- assert undeclared == WITHOUT_DEFAULTS+def test_every_architecture_declares_defaults() -> None:+ undeclared = sorted(b.value for b in generative_bases() if get(b, DefaultSettingsFacet) is None)+ assert undeclared == []-def test_an_architecture_without_defaults_resolves_to_none() -> None:- for base in WITHOUT_DEFAULTS:- assert resolve_default_settings(base) is None, base.value+def test_the_refiner_declares_a_canvas_but_no_sampler_settings() -> None:+ """It is a second pass over an SDXL latent, driven by the UI's own refiner parameters."""+ settings = resolve_default_settings(BaseModelType.StableDiffusionXLRefiner)+ assert settings is not None+ assert (settings.width, settings.height) == (1024, 1024)+ assert (settings.steps, settings.cfg_scale) == (None, None)@pytest.mark.parametrize(