Skip to content

image

Image-generation-specific model constants, enums, and descriptors.

IMAGE_GENERATION_BASELINE_NATIVE_RESOLUTION_LOOKUP module-attribute

IMAGE_GENERATION_BASELINE_NATIVE_RESOLUTION_LOOKUP: dict[
    KNOWN_IMAGE_GENERATION_BASELINE | str, int
] = {}

The single-side preferred resolution for each known stable diffusion baseline.

_ALTERNATIVE_NAME_TO_BASELINE module-attribute

_ALTERNATIVE_NAME_TO_BASELINE: dict[
    str, KNOWN_IMAGE_GENERATION_BASELINE | str
] = {}

_IMAGE_BASELINE_REGISTRY module-attribute

_IMAGE_BASELINE_REGISTRY = DescriptorRegistry[
    KNOWN_IMAGE_GENERATION_BASELINE | str,
    BaselineDescriptor,
](_rebuild_baseline_derived_data)

alternative_sdxl_baseline_names module-attribute

alternative_sdxl_baseline_names: list[str] = list(
    alternative_names
)

_unregistered_baselines module-attribute

_unregistered_baselines = {
    b
    for b in KNOWN_IMAGE_GENERATION_BASELINE
    if not contains(b)
}

_CONTROLNET_STYLE_REGISTRY module-attribute

_CONTROLNET_STYLE_REGISTRY = EnumRegistry(
    (value) for item in CONTROLNET_STYLE
)

KNOWN_IMAGE_GENERATION_BASELINE

Bases: StrEnum

An enum of all the image generation baselines.

Source code in src/horde_model_reference/model_consts/image.py
class KNOWN_IMAGE_GENERATION_BASELINE(StrEnum):
    """An enum of all the image generation baselines."""

    infer = auto()
    """The baseline is not known and should be inferred from the model name."""

    stable_diffusion_1 = auto()
    stable_diffusion_2_768 = auto()
    stable_diffusion_2_512 = auto()
    stable_diffusion_xl = auto()
    stable_cascade = auto()
    flux_1 = auto()  # TODO: Extract flux and create "IMAGE_GENERATION_BASELINE_CATEGORY" due to name inconsistency
    flux_schnell = auto()  # FIXME
    flux_dev = auto()  # FIXME
    qwen_image = auto()
    z_image_turbo = auto()

infer class-attribute instance-attribute

infer = auto()

The baseline is not known and should be inferred from the model name.

stable_diffusion_1 class-attribute instance-attribute

stable_diffusion_1 = auto()

stable_diffusion_2_768 class-attribute instance-attribute

stable_diffusion_2_768 = auto()

stable_diffusion_2_512 class-attribute instance-attribute

stable_diffusion_2_512 = auto()

stable_diffusion_xl class-attribute instance-attribute

stable_diffusion_xl = auto()

stable_cascade class-attribute instance-attribute

stable_cascade = auto()

flux_1 class-attribute instance-attribute

flux_1 = auto()

flux_schnell class-attribute instance-attribute

flux_schnell = auto()

flux_dev class-attribute instance-attribute

flux_dev = auto()

qwen_image class-attribute instance-attribute

qwen_image = auto()

z_image_turbo class-attribute instance-attribute

z_image_turbo = auto()

BaselineDescriptor dataclass

Describes a known image-generation baseline in a single place.

Attributes:

  • native_resolution (int | None) –

    Preferred single-side resolution, or None for baselines like infer that have no fixed resolution.

  • alternative_names (tuple[str, ...]) –

    Alternative human/API names that map to this baseline.

Source code in src/horde_model_reference/model_consts/image.py
@dataclass(frozen=True)
class BaselineDescriptor:
    """Describes a known image-generation baseline in a single place.

    Attributes:
        native_resolution: Preferred single-side resolution, or ``None`` for baselines
            like ``infer`` that have no fixed resolution.
        alternative_names: Alternative human/API names that map to this baseline.

    """

    native_resolution: int | None
    alternative_names: tuple[str, ...] = field(default_factory=tuple)

native_resolution instance-attribute

native_resolution: int | None

alternative_names class-attribute instance-attribute

alternative_names: tuple[str, ...] = field(
    default_factory=tuple
)

__init__

__init__(
    native_resolution: int | None,
    alternative_names: tuple[str, ...] = tuple(),
) -> None

CONTROLNET_STYLE

Bases: StrEnum

An enum of all the ControlNet 'styles' - the process that defines the model's behavior.

Examples include canny, depth, and openpose.

Source code in src/horde_model_reference/model_consts/image.py
class CONTROLNET_STYLE(StrEnum):
    """An enum of all the ControlNet 'styles' - the process that defines the model's behavior.

    Examples include canny, depth, and openpose.
    """

    control_seg = auto()
    control_scribble = auto()
    control_fakescribbles = auto()
    control_openpose = auto()
    control_normal = auto()
    control_mlsd = auto()
    control_hough = auto()
    control_hed = auto()
    control_canny = auto()
    control_depth = auto()
    control_qr = auto()
    control_qr_xl = auto()

control_seg class-attribute instance-attribute

control_seg = auto()

control_scribble class-attribute instance-attribute

control_scribble = auto()

control_fakescribbles class-attribute instance-attribute

control_fakescribbles = auto()

control_openpose class-attribute instance-attribute

control_openpose = auto()

control_normal class-attribute instance-attribute

control_normal = auto()

control_mlsd class-attribute instance-attribute

control_mlsd = auto()

control_hough class-attribute instance-attribute

control_hough = auto()

control_hed class-attribute instance-attribute

control_hed = auto()

control_canny class-attribute instance-attribute

control_canny = auto()

control_depth class-attribute instance-attribute

control_depth = auto()

control_qr class-attribute instance-attribute

control_qr = auto()

control_qr_xl class-attribute instance-attribute

control_qr_xl = auto()

_rebuild_baseline_derived_data

_rebuild_baseline_derived_data(
    data: dict[
        KNOWN_IMAGE_GENERATION_BASELINE | str,
        BaselineDescriptor,
    ],
) -> None

Rebuild derived baseline lookups from the registry.

Source code in src/horde_model_reference/model_consts/image.py
def _rebuild_baseline_derived_data(
    data: dict[KNOWN_IMAGE_GENERATION_BASELINE | str, BaselineDescriptor],
) -> None:
    """Rebuild derived baseline lookups from the registry."""
    IMAGE_GENERATION_BASELINE_NATIVE_RESOLUTION_LOOKUP.clear()
    IMAGE_GENERATION_BASELINE_NATIVE_RESOLUTION_LOOKUP.update(
        {b: d.native_resolution for b, d in data.items() if d.native_resolution is not None}
    )

    _ALTERNATIVE_NAME_TO_BASELINE.clear()
    for bl, desc in data.items():
        for alt in desc.alternative_names:
            _ALTERNATIVE_NAME_TO_BASELINE[alt] = bl

register_image_baseline

register_image_baseline(
    name: KNOWN_IMAGE_GENERATION_BASELINE | str,
    descriptor: BaselineDescriptor,
) -> None

Register a new image-generation baseline.

Source code in src/horde_model_reference/model_consts/image.py
def register_image_baseline(name: KNOWN_IMAGE_GENERATION_BASELINE | str, descriptor: BaselineDescriptor) -> None:
    """Register a new image-generation baseline."""
    _IMAGE_BASELINE_REGISTRY.register(name, descriptor)

_matching_image_baseline_exists

_matching_image_baseline_exists(
    baseline: str,
    known_image_generation_baseline: KNOWN_IMAGE_GENERATION_BASELINE
    | str,
) -> bool

Return True if baseline is a recognized alternative name for known_image_generation_baseline.

Parameters:

Returns:

  • bool

    True if the baseline name matches the given known baseline, False otherwise.

Source code in src/horde_model_reference/model_consts/image.py
def _matching_image_baseline_exists(
    baseline: str,
    known_image_generation_baseline: KNOWN_IMAGE_GENERATION_BASELINE | str,
) -> bool:
    """Return True if *baseline* is a recognized alternative name for *known_image_generation_baseline*.

    Args:
        baseline: The baseline name to look up.
        known_image_generation_baseline: The known image generation baseline to check against.

    Returns:
        True if the baseline name matches the given known baseline, False otherwise.

    """
    desc = _IMAGE_BASELINE_REGISTRY.get(known_image_generation_baseline)
    if desc is not None and desc.alternative_names:
        return baseline in desc.alternative_names
    return baseline == str(known_image_generation_baseline)

is_known_image_baseline

is_known_image_baseline(baseline: str) -> bool

Return True if baseline is a known baseline or alternative name.

Parameters:

  • baseline (str) –

    The baseline name to check.

Returns:

  • bool

    True if the baseline is known, False otherwise.

Source code in src/horde_model_reference/model_consts/image.py
def is_known_image_baseline(baseline: str) -> bool:
    """Return True if *baseline* is a known baseline or alternative name.

    Args:
        baseline: The baseline name to check.

    Returns:
        True if the baseline is known, False otherwise.

    """
    return _IMAGE_BASELINE_REGISTRY.contains(baseline) or baseline in _ALTERNATIVE_NAME_TO_BASELINE

get_baseline_descriptor

get_baseline_descriptor(
    baseline: KNOWN_IMAGE_GENERATION_BASELINE | str,
) -> BaselineDescriptor

Return the BaselineDescriptor for baseline.

Parameters:

Raises:

  • KeyError

    If the baseline is not registered.

Source code in src/horde_model_reference/model_consts/image.py
def get_baseline_descriptor(baseline: KNOWN_IMAGE_GENERATION_BASELINE | str) -> BaselineDescriptor:
    """Return the ``BaselineDescriptor`` for *baseline*.

    Args:
        baseline: The known image generation baseline (enum member or plain string).

    Raises:
        KeyError: If the baseline is not registered.

    """
    return _IMAGE_BASELINE_REGISTRY.get(baseline)

get_all_registered_baselines

get_all_registered_baselines() -> dict[
    KNOWN_IMAGE_GENERATION_BASELINE | str,
    BaselineDescriptor,
]

Return a shallow copy of the baseline registry.

This includes both built-in KNOWN_IMAGE_GENERATION_BASELINE members and any externally registered baselines.

Source code in src/horde_model_reference/model_consts/image.py
def get_all_registered_baselines() -> dict[KNOWN_IMAGE_GENERATION_BASELINE | str, BaselineDescriptor]:
    """Return a shallow copy of the baseline registry.

    This includes both built-in ``KNOWN_IMAGE_GENERATION_BASELINE`` members and
    any externally registered baselines.
    """
    return _IMAGE_BASELINE_REGISTRY.all()

get_baseline_native_resolution

get_baseline_native_resolution(
    baseline: KNOWN_IMAGE_GENERATION_BASELINE | str,
) -> int

Get the native resolution of a stable diffusion baseline.

Parameters:

Returns:

  • int

    The native resolution of the baseline.

Source code in src/horde_model_reference/model_consts/image.py
def get_baseline_native_resolution(baseline: KNOWN_IMAGE_GENERATION_BASELINE | str) -> int:
    """Get the native resolution of a stable diffusion baseline.

    Args:
        baseline: The stable diffusion baseline (enum member or plain string).

    Returns:
        The native resolution of the baseline.

    """
    return IMAGE_GENERATION_BASELINE_NATIVE_RESOLUTION_LOOKUP[baseline]

get_baselines_by_resolution

get_baselines_by_resolution(
    resolution: int,
) -> list[KNOWN_IMAGE_GENERATION_BASELINE | str]

Get all baselines that have the given native resolution.

Parameters:

  • resolution (int) –

    The native resolution to look for.

Returns:

Source code in src/horde_model_reference/model_consts/image.py
def get_baselines_by_resolution(resolution: int) -> list[KNOWN_IMAGE_GENERATION_BASELINE | str]:
    """Get all baselines that have the given native resolution.

    Args:
        resolution: The native resolution to look for.

    Returns:
        A list of baselines that have the given native resolution.

    """
    return [
        baseline
        for baseline, native_resolution in IMAGE_GENERATION_BASELINE_NATIVE_RESOLUTION_LOOKUP.items()
        if native_resolution == resolution
    ]

register_controlnet_style

register_controlnet_style(
    style: CONTROLNET_STYLE | str,
) -> None

Register a new ControlNet style.

Source code in src/horde_model_reference/model_consts/image.py
def register_controlnet_style(style: CONTROLNET_STYLE | str) -> None:
    """Register a new ControlNet style."""
    _CONTROLNET_STYLE_REGISTRY.register(style)

is_known_controlnet_style

is_known_controlnet_style(
    style: CONTROLNET_STYLE | str,
) -> bool

Check if a ControlNet style is known.

Source code in src/horde_model_reference/model_consts/image.py
def is_known_controlnet_style(style: CONTROLNET_STYLE | str) -> bool:
    """Check if a ControlNet style is known."""
    return _CONTROLNET_STYLE_REGISTRY.is_known(style)