Skip to content

model_reference_records

The model database pydantic models and associate enums/lookups.

MODEL_RECORD_TYPE_LOOKUP module-attribute

MODEL_RECORD_TYPE_LOOKUP: dict[
    MODEL_REFERENCE_CATEGORY | str, type[GenericModelRecord]
] = {}

_ERROR_POLICY module-attribute

_ERROR_POLICY = FieldPolicy(severity='error')

_WARNING_POLICY module-attribute

_WARNING_POLICY = FieldPolicy(severity='warning')

__all__ module-attribute

__all__ = [
    "MODEL_RECORD_TYPE_LOOKUP",
    "AudioGenerationModelRecord",
    "BlipModelRecord",
    "ClipModelRecord",
    "CodeformerModelRecord",
    "ControlNetModelRecord",
    "DownloadRecord",
    "EsrganModelRecord",
    "FineTuneSeriesInfo",
    "GenericModelRecord",
    "GenericModelRecordConfig",
    "GenericModelRecordMetadata",
    "GfpganModelRecord",
    "ImageGenerationModelRecord",
    "MiscellaneousModelRecord",
    "SafetyCheckerModelRecord",
    "TextGenerationModelRecord",
    "VideoGenerationModelRecord",
    "get_record_type_for_category",
    "register_record_type",
]

DownloadRecord

Bases: BaseModel

A record of a file to download for a model. Typically a ckpt file.

Source code in src/horde_model_reference/model_reference_records.py
class DownloadRecord(BaseModel):  # TODO Rename? (record to subrecord?)
    """A record of a file to download for a model. Typically a ckpt file."""

    model_config = get_default_config()

    file_name: str
    """The horde specific filename. This is not necessarily the same as the file's name on the model host."""
    file_url: str
    """The fully qualified URL to download the file from."""
    sha256sum: str = "FIXME"
    """The sha256sum of the file."""
    file_purpose: str | None = None
    """"""
    known_slow_download: bool | None = None
    """Whether the download is known to be slow or not."""

model_config class-attribute instance-attribute

model_config = get_default_config()

file_name instance-attribute

file_name: str

The horde specific filename. This is not necessarily the same as the file's name on the model host.

file_url instance-attribute

file_url: str

The fully qualified URL to download the file from.

sha256sum class-attribute instance-attribute

sha256sum: str = 'FIXME'

The sha256sum of the file.

file_purpose class-attribute instance-attribute

file_purpose: str | None = None

known_slow_download class-attribute instance-attribute

known_slow_download: bool | None = None

Whether the download is known to be slow or not.

GenericModelRecordConfig

Bases: BaseModel

Configuration for a generic model record.

Source code in src/horde_model_reference/model_reference_records.py
class GenericModelRecordConfig(BaseModel):
    """Configuration for a generic model record."""

    model_config = get_default_config()

    download: list[DownloadRecord] = Field(
        default_factory=list,
    )
    """A list of files to download for the model."""

model_config class-attribute instance-attribute

model_config = get_default_config()

download class-attribute instance-attribute

download: list[DownloadRecord] = Field(default_factory=list)

A list of files to download for the model.

GenericModelRecordMetadata

Bases: BaseModel

Metadata for a generic model record.

Source code in src/horde_model_reference/model_reference_records.py
class GenericModelRecordMetadata(BaseModel):
    """Metadata for a generic model record."""

    model_config = get_default_config()

    schema_version: str = SCHEMA_VERSION
    """The version of the schema used to create this record."""

    created_at: int | None = None
    """The Unix time of when the record was created."""
    updated_at: int | None = None
    """The Unix time of when the record was last updated."""

    created_by: str | None = None
    """The name or identifier of the person or system which created the record."""
    updated_by: str | None = None
    """The name or identifier of the person or system which last updated the record."""

model_config class-attribute instance-attribute

model_config = get_default_config()

schema_version class-attribute instance-attribute

schema_version: str = SCHEMA_VERSION

The version of the schema used to create this record.

created_at class-attribute instance-attribute

created_at: int | None = None

The Unix time of when the record was created.

updated_at class-attribute instance-attribute

updated_at: int | None = None

The Unix time of when the record was last updated.

created_by class-attribute instance-attribute

created_by: str | None = None

The name or identifier of the person or system which created the record.

updated_by class-attribute instance-attribute

updated_by: str | None = None

The name or identifier of the person or system which last updated the record.

FineTuneSeriesInfo

Bases: BaseModel

Information about a fine-tuning series.

Source code in src/horde_model_reference/model_reference_records.py
class FineTuneSeriesInfo(BaseModel):
    """Information about a fine-tuning series."""

    model_config = get_default_config()

    name: str
    """The name of the fine-tuning series."""
    version: str | None = None
    """The version of the fine-tuning series."""

    author: str | None = None
    """The author of the fine-tuning series."""

    description: str | None = None
    """A short description of the fine-tuning series."""
    homepage: str | None = None
    """A link to the homepage of the fine-tuning series."""

model_config class-attribute instance-attribute

model_config = get_default_config()

name instance-attribute

name: str

The name of the fine-tuning series.

version class-attribute instance-attribute

version: str | None = None

The version of the fine-tuning series.

author class-attribute instance-attribute

author: str | None = None

The author of the fine-tuning series.

description class-attribute instance-attribute

description: str | None = None

A short description of the fine-tuning series.

homepage class-attribute instance-attribute

homepage: str | None = None

A link to the homepage of the fine-tuning series.

GenericModelRecord

Bases: BaseModel

A generic model reference record.

Source code in src/horde_model_reference/model_reference_records.py
class GenericModelRecord(BaseModel):
    """A generic model reference record."""

    model_config = get_default_config()

    record_type: str | MODEL_REFERENCE_CATEGORY
    """Discriminator field for polymorphic deserialization. Identifies the specific record type."""

    name: str
    """The name of the model."""
    description: str | None = None
    """A short description of the model."""
    version: str | None = None
    """The version of the  model (not the version of SD it is based on, see `baseline` for that info)."""

    finetune_series: FineTuneSeriesInfo | None = None
    """Information about the fine-tuning of the model. For image, some examples are 'Pony', 'Illustrious", etc."""

    metadata: GenericModelRecordMetadata = Field(
        default_factory=GenericModelRecordMetadata,
    )
    """Metadata about the record itself, such as creation and update times."""

    config: GenericModelRecordConfig = Field(
        default_factory=GenericModelRecordConfig,
    )
    """A dictionary of any configuration files and information on where to download the model file(s)."""

    model_classification: ModelClassification
    """The classification of the model."""

    @property
    def primary_download_url(self) -> str | None:
        """Return the URL of the first download entry, or None if there are no downloads."""
        if self.config and self.config.download:
            return self.config.download[0].file_url
        return None

    @property
    def all_download_urls(self) -> list[str]:
        """Return all download URLs for this model."""
        if self.config and self.config.download:
            return [d.file_url for d in self.config.download]
        return []

    @property
    def download_count(self) -> int:
        """Return the number of download entries for this model."""
        if self.config and self.config.download:
            return len(self.config.download)
        return 0

model_config class-attribute instance-attribute

model_config = get_default_config()

record_type instance-attribute

record_type: str | MODEL_REFERENCE_CATEGORY

Discriminator field for polymorphic deserialization. Identifies the specific record type.

name instance-attribute

name: str

The name of the model.

description class-attribute instance-attribute

description: str | None = None

A short description of the model.

version class-attribute instance-attribute

version: str | None = None

The version of the model (not the version of SD it is based on, see baseline for that info).

finetune_series class-attribute instance-attribute

finetune_series: FineTuneSeriesInfo | None = None

Information about the fine-tuning of the model. For image, some examples are 'Pony', 'Illustrious", etc.

metadata class-attribute instance-attribute

metadata: GenericModelRecordMetadata = Field(
    default_factory=GenericModelRecordMetadata
)

Metadata about the record itself, such as creation and update times.

config class-attribute instance-attribute

config: GenericModelRecordConfig = Field(
    default_factory=GenericModelRecordConfig
)

A dictionary of any configuration files and information on where to download the model file(s).

model_classification instance-attribute

model_classification: ModelClassification

The classification of the model.

primary_download_url property

primary_download_url: str | None

Return the URL of the first download entry, or None if there are no downloads.

all_download_urls property

all_download_urls: list[str]

Return all download URLs for this model.

download_count property

download_count: int

Return the number of download entries for this model.

ImageGenerationModelRecord

Bases: GenericModelRecord

A model entry in the model reference.

Source code in src/horde_model_reference/model_reference_records.py
@register_record_type(MODEL_REFERENCE_CATEGORY.image_generation)
class ImageGenerationModelRecord(GenericModelRecord):
    """A model entry in the model reference."""

    record_type: MODEL_REFERENCE_CATEGORY = MODEL_REFERENCE_CATEGORY.image_generation
    """Discriminator field identifying this as an image generation model record."""

    model_classification: ModelClassification = Field(
        default_factory=lambda: _classification_for(MODEL_REFERENCE_CATEGORY.image_generation),
    )
    """The domain (e.g., image, text) and purpose (e.g., generation, classification) of the model."""

    inpainting: bool | None = False
    """If this is an inpainting model or not."""
    baseline: KNOWN_IMAGE_GENERATION_BASELINE | str
    """The model on which this model is based."""
    optimization: str | None = None
    """The optimization type of the model."""
    tags: list[NormalizedTag] | None = None
    """Any tags associated with the model which may be useful for searching."""
    showcases: list[str] | None = None
    """Links to any showcases of the model which illustrate its style."""
    min_bridge_version: int | None = None
    """The minimum version of AI-Horde-Worker required to use this model."""
    trigger: list[str] | None = None
    """A list of trigger words or phrases which can be used to activate the model."""
    homepage: str | None = None
    """A link to the model's homepage."""
    nsfw: bool
    """Whether the model is NSFW or not."""

    style: NormalizedModelStyle | MODEL_STYLE | None = None
    """The style of the model."""

    requirements: dict[str, int | float | str | list[int] | list[float] | list[str] | bool] | None = None

    size_on_disk_bytes: int | None = None

    @model_validator(mode="after")
    def validator_set_arrays_to_empty_if_none(self) -> ImageGenerationModelRecord:
        """Set any `None` values to empty lists."""
        if self.tags is None:
            self.tags = []
        if self.showcases is None:
            self.showcases = []
        if self.trigger is None:
            self.trigger = []
        return self

    @model_validator(mode="after")
    def validator_is_baseline_and_style_known(self) -> ImageGenerationModelRecord:
        """Check if the baseline is known."""
        if not is_known_image_baseline(str(self.baseline)):
            _apply_policy(
                category=self.record_type,
                field_name="baseline",
                value=str(self.baseline),
                fallback_policy=_ERROR_POLICY,
                model_name=self.name,
            )

        if self.style is not None and not is_known_model_style(str(self.style)):
            _apply_policy(
                category=self.record_type,
                field_name="style",
                value=str(self.style),
                fallback_policy=_ERROR_POLICY,
                model_name=self.name,
            )

        return self

record_type class-attribute instance-attribute

record_type: MODEL_REFERENCE_CATEGORY = image_generation

Discriminator field identifying this as an image generation model record.

model_classification class-attribute instance-attribute

model_classification: ModelClassification = Field(
    default_factory=lambda: _classification_for(
        image_generation
    )
)

The domain (e.g., image, text) and purpose (e.g., generation, classification) of the model.

inpainting class-attribute instance-attribute

inpainting: bool | None = False

If this is an inpainting model or not.

baseline instance-attribute

baseline: KNOWN_IMAGE_GENERATION_BASELINE | str

The model on which this model is based.

optimization class-attribute instance-attribute

optimization: str | None = None

The optimization type of the model.

tags class-attribute instance-attribute

tags: list[NormalizedTag] | None = None

Any tags associated with the model which may be useful for searching.

showcases class-attribute instance-attribute

showcases: list[str] | None = None

Links to any showcases of the model which illustrate its style.

min_bridge_version class-attribute instance-attribute

min_bridge_version: int | None = None

The minimum version of AI-Horde-Worker required to use this model.

trigger class-attribute instance-attribute

trigger: list[str] | None = None

A list of trigger words or phrases which can be used to activate the model.

homepage class-attribute instance-attribute

homepage: str | None = None

A link to the model's homepage.

nsfw instance-attribute

nsfw: bool

Whether the model is NSFW or not.

style class-attribute instance-attribute

style: NormalizedModelStyle | MODEL_STYLE | None = None

The style of the model.

requirements class-attribute instance-attribute

requirements: (
    dict[
        str,
        int
        | float
        | str
        | list[int]
        | list[float]
        | list[str]
        | bool,
    ]
    | None
) = None

size_on_disk_bytes class-attribute instance-attribute

size_on_disk_bytes: int | None = None

model_config class-attribute instance-attribute

model_config = get_default_config()

name instance-attribute

name: str

The name of the model.

description class-attribute instance-attribute

description: str | None = None

A short description of the model.

version class-attribute instance-attribute

version: str | None = None

The version of the model (not the version of SD it is based on, see baseline for that info).

finetune_series class-attribute instance-attribute

finetune_series: FineTuneSeriesInfo | None = None

Information about the fine-tuning of the model. For image, some examples are 'Pony', 'Illustrious", etc.

metadata class-attribute instance-attribute

metadata: GenericModelRecordMetadata = Field(
    default_factory=GenericModelRecordMetadata
)

Metadata about the record itself, such as creation and update times.

config class-attribute instance-attribute

config: GenericModelRecordConfig = Field(
    default_factory=GenericModelRecordConfig
)

A dictionary of any configuration files and information on where to download the model file(s).

primary_download_url property

primary_download_url: str | None

Return the URL of the first download entry, or None if there are no downloads.

all_download_urls property

all_download_urls: list[str]

Return all download URLs for this model.

download_count property

download_count: int

Return the number of download entries for this model.

validator_set_arrays_to_empty_if_none

validator_set_arrays_to_empty_if_none() -> (
    ImageGenerationModelRecord
)

Set any None values to empty lists.

Source code in src/horde_model_reference/model_reference_records.py
@model_validator(mode="after")
def validator_set_arrays_to_empty_if_none(self) -> ImageGenerationModelRecord:
    """Set any `None` values to empty lists."""
    if self.tags is None:
        self.tags = []
    if self.showcases is None:
        self.showcases = []
    if self.trigger is None:
        self.trigger = []
    return self

validator_is_baseline_and_style_known

validator_is_baseline_and_style_known() -> (
    ImageGenerationModelRecord
)

Check if the baseline is known.

Source code in src/horde_model_reference/model_reference_records.py
@model_validator(mode="after")
def validator_is_baseline_and_style_known(self) -> ImageGenerationModelRecord:
    """Check if the baseline is known."""
    if not is_known_image_baseline(str(self.baseline)):
        _apply_policy(
            category=self.record_type,
            field_name="baseline",
            value=str(self.baseline),
            fallback_policy=_ERROR_POLICY,
            model_name=self.name,
        )

    if self.style is not None and not is_known_model_style(str(self.style)):
        _apply_policy(
            category=self.record_type,
            field_name="style",
            value=str(self.style),
            fallback_policy=_ERROR_POLICY,
            model_name=self.name,
        )

    return self

ControlNetModelRecord

Bases: GenericModelRecord

A ControlNet model entry in the model reference.

Source code in src/horde_model_reference/model_reference_records.py
@register_record_type(MODEL_REFERENCE_CATEGORY.controlnet)
class ControlNetModelRecord(GenericModelRecord):
    """A ControlNet model entry in the model reference."""

    record_type: MODEL_REFERENCE_CATEGORY = MODEL_REFERENCE_CATEGORY.controlnet
    """Discriminator field identifying this as a ControlNet model record."""

    model_classification: ModelClassification = Field(
        default_factory=lambda: _classification_for(MODEL_REFERENCE_CATEGORY.controlnet),
    )

    controlnet_style: CONTROLNET_STYLE | str | None = None
    """The 'style' (purpose) of the controlnet. See `CONTROLNET_STYLE` for all possible values and more info."""

    @model_validator(mode="after")
    def validator_is_style_known(self) -> ControlNetModelRecord:
        """Check if the style is known."""
        if self.controlnet_style is not None and not is_known_controlnet_style(str(self.controlnet_style)):
            _apply_policy(
                category=self.record_type,
                field_name="controlnet_style",
                value=str(self.controlnet_style),
                fallback_policy=_WARNING_POLICY,
                model_name=self.name,
            )

        return self

record_type class-attribute instance-attribute

record_type: MODEL_REFERENCE_CATEGORY = controlnet

Discriminator field identifying this as a ControlNet model record.

model_classification class-attribute instance-attribute

model_classification: ModelClassification = Field(
    default_factory=lambda: _classification_for(controlnet)
)

controlnet_style class-attribute instance-attribute

controlnet_style: CONTROLNET_STYLE | str | None = None

The 'style' (purpose) of the controlnet. See CONTROLNET_STYLE for all possible values and more info.

model_config class-attribute instance-attribute

model_config = get_default_config()

name instance-attribute

name: str

The name of the model.

description class-attribute instance-attribute

description: str | None = None

A short description of the model.

version class-attribute instance-attribute

version: str | None = None

The version of the model (not the version of SD it is based on, see baseline for that info).

finetune_series class-attribute instance-attribute

finetune_series: FineTuneSeriesInfo | None = None

Information about the fine-tuning of the model. For image, some examples are 'Pony', 'Illustrious", etc.

metadata class-attribute instance-attribute

metadata: GenericModelRecordMetadata = Field(
    default_factory=GenericModelRecordMetadata
)

Metadata about the record itself, such as creation and update times.

config class-attribute instance-attribute

config: GenericModelRecordConfig = Field(
    default_factory=GenericModelRecordConfig
)

A dictionary of any configuration files and information on where to download the model file(s).

primary_download_url property

primary_download_url: str | None

Return the URL of the first download entry, or None if there are no downloads.

all_download_urls property

all_download_urls: list[str]

Return all download URLs for this model.

download_count property

download_count: int

Return the number of download entries for this model.

validator_is_style_known

validator_is_style_known() -> ControlNetModelRecord

Check if the style is known.

Source code in src/horde_model_reference/model_reference_records.py
@model_validator(mode="after")
def validator_is_style_known(self) -> ControlNetModelRecord:
    """Check if the style is known."""
    if self.controlnet_style is not None and not is_known_controlnet_style(str(self.controlnet_style)):
        _apply_policy(
            category=self.record_type,
            field_name="controlnet_style",
            value=str(self.controlnet_style),
            fallback_policy=_WARNING_POLICY,
            model_name=self.name,
        )

    return self

TextGenerationModelRecord

Bases: GenericModelRecord

A text generation model entry in the model reference.

Source code in src/horde_model_reference/model_reference_records.py
@register_record_type(MODEL_REFERENCE_CATEGORY.text_generation)
class TextGenerationModelRecord(GenericModelRecord):
    """A text generation model entry in the model reference."""

    record_type: MODEL_REFERENCE_CATEGORY = MODEL_REFERENCE_CATEGORY.text_generation
    """Discriminator field identifying this as a text generation model record."""

    model_classification: ModelClassification = Field(
        default_factory=lambda: _classification_for(MODEL_REFERENCE_CATEGORY.text_generation),
    )

    baseline: str | None = None
    parameters_count: int = Field(alias="parameters")
    nsfw: bool = False
    style: str | None = None
    display_name: str | None = None
    url: str | None = None
    tags: list[NormalizedTag] | None = None
    instruct_format: str | None = None
    """The instruction template format used by this model (e.g., ChatML, Mistral, Alpaca)."""
    settings: dict[str, int | float | str | list[int] | list[float] | list[str] | bool] | None = None
    text_model_group: str | None = None
    """The base model group name for grouping model variants together."""

record_type class-attribute instance-attribute

record_type: MODEL_REFERENCE_CATEGORY = text_generation

Discriminator field identifying this as a text generation model record.

model_classification class-attribute instance-attribute

model_classification: ModelClassification = Field(
    default_factory=lambda: _classification_for(
        text_generation
    )
)

baseline class-attribute instance-attribute

baseline: str | None = None

parameters_count class-attribute instance-attribute

parameters_count: int = Field(alias='parameters')

nsfw class-attribute instance-attribute

nsfw: bool = False

style class-attribute instance-attribute

style: str | None = None

display_name class-attribute instance-attribute

display_name: str | None = None

url class-attribute instance-attribute

url: str | None = None

tags class-attribute instance-attribute

tags: list[NormalizedTag] | None = None

instruct_format class-attribute instance-attribute

instruct_format: str | None = None

The instruction template format used by this model (e.g., ChatML, Mistral, Alpaca).

settings class-attribute instance-attribute

settings: (
    dict[
        str,
        int
        | float
        | str
        | list[int]
        | list[float]
        | list[str]
        | bool,
    ]
    | None
) = None

text_model_group class-attribute instance-attribute

text_model_group: str | None = None

The base model group name for grouping model variants together.

model_config class-attribute instance-attribute

model_config = get_default_config()

name instance-attribute

name: str

The name of the model.

description class-attribute instance-attribute

description: str | None = None

A short description of the model.

version class-attribute instance-attribute

version: str | None = None

The version of the model (not the version of SD it is based on, see baseline for that info).

finetune_series class-attribute instance-attribute

finetune_series: FineTuneSeriesInfo | None = None

Information about the fine-tuning of the model. For image, some examples are 'Pony', 'Illustrious", etc.

metadata class-attribute instance-attribute

metadata: GenericModelRecordMetadata = Field(
    default_factory=GenericModelRecordMetadata
)

Metadata about the record itself, such as creation and update times.

config class-attribute instance-attribute

config: GenericModelRecordConfig = Field(
    default_factory=GenericModelRecordConfig
)

A dictionary of any configuration files and information on where to download the model file(s).

primary_download_url property

primary_download_url: str | None

Return the URL of the first download entry, or None if there are no downloads.

all_download_urls property

all_download_urls: list[str]

Return all download URLs for this model.

download_count property

download_count: int

Return the number of download entries for this model.

BlipModelRecord

Bases: GenericModelRecord

A BLIP model entry in the model reference.

Source code in src/horde_model_reference/model_reference_records.py
@register_record_type(MODEL_REFERENCE_CATEGORY.blip)
class BlipModelRecord(GenericModelRecord):
    """A BLIP model entry in the model reference."""

    record_type: MODEL_REFERENCE_CATEGORY = MODEL_REFERENCE_CATEGORY.blip
    """Discriminator field identifying this as a BLIP model record."""

    model_classification: ModelClassification = Field(
        default_factory=lambda: _classification_for(MODEL_REFERENCE_CATEGORY.blip),
    )

record_type class-attribute instance-attribute

record_type: MODEL_REFERENCE_CATEGORY = blip

Discriminator field identifying this as a BLIP model record.

model_classification class-attribute instance-attribute

model_classification: ModelClassification = Field(
    default_factory=lambda: _classification_for(blip)
)

model_config class-attribute instance-attribute

model_config = get_default_config()

name instance-attribute

name: str

The name of the model.

description class-attribute instance-attribute

description: str | None = None

A short description of the model.

version class-attribute instance-attribute

version: str | None = None

The version of the model (not the version of SD it is based on, see baseline for that info).

finetune_series class-attribute instance-attribute

finetune_series: FineTuneSeriesInfo | None = None

Information about the fine-tuning of the model. For image, some examples are 'Pony', 'Illustrious", etc.

metadata class-attribute instance-attribute

metadata: GenericModelRecordMetadata = Field(
    default_factory=GenericModelRecordMetadata
)

Metadata about the record itself, such as creation and update times.

config class-attribute instance-attribute

config: GenericModelRecordConfig = Field(
    default_factory=GenericModelRecordConfig
)

A dictionary of any configuration files and information on where to download the model file(s).

primary_download_url property

primary_download_url: str | None

Return the URL of the first download entry, or None if there are no downloads.

all_download_urls property

all_download_urls: list[str]

Return all download URLs for this model.

download_count property

download_count: int

Return the number of download entries for this model.

ClipModelRecord

Bases: GenericModelRecord

A CLIP model entry in the model reference.

Source code in src/horde_model_reference/model_reference_records.py
@register_record_type(MODEL_REFERENCE_CATEGORY.clip)
class ClipModelRecord(GenericModelRecord):
    """A CLIP model entry in the model reference."""

    record_type: MODEL_REFERENCE_CATEGORY = MODEL_REFERENCE_CATEGORY.clip
    """Discriminator field identifying this as a CLIP model record."""

    model_classification: ModelClassification = Field(
        default_factory=lambda: _classification_for(MODEL_REFERENCE_CATEGORY.clip),
    )

    pretrained_name: str | None = None
    """The pretrained model name, if applicable."""

record_type class-attribute instance-attribute

record_type: MODEL_REFERENCE_CATEGORY = clip

Discriminator field identifying this as a CLIP model record.

model_classification class-attribute instance-attribute

model_classification: ModelClassification = Field(
    default_factory=lambda: _classification_for(clip)
)

pretrained_name class-attribute instance-attribute

pretrained_name: str | None = None

The pretrained model name, if applicable.

model_config class-attribute instance-attribute

model_config = get_default_config()

name instance-attribute

name: str

The name of the model.

description class-attribute instance-attribute

description: str | None = None

A short description of the model.

version class-attribute instance-attribute

version: str | None = None

The version of the model (not the version of SD it is based on, see baseline for that info).

finetune_series class-attribute instance-attribute

finetune_series: FineTuneSeriesInfo | None = None

Information about the fine-tuning of the model. For image, some examples are 'Pony', 'Illustrious", etc.

metadata class-attribute instance-attribute

metadata: GenericModelRecordMetadata = Field(
    default_factory=GenericModelRecordMetadata
)

Metadata about the record itself, such as creation and update times.

config class-attribute instance-attribute

config: GenericModelRecordConfig = Field(
    default_factory=GenericModelRecordConfig
)

A dictionary of any configuration files and information on where to download the model file(s).

primary_download_url property

primary_download_url: str | None

Return the URL of the first download entry, or None if there are no downloads.

all_download_urls property

all_download_urls: list[str]

Return all download URLs for this model.

download_count property

download_count: int

Return the number of download entries for this model.

CodeformerModelRecord

Bases: GenericModelRecord

A Codeformer model entry in the model reference.

Source code in src/horde_model_reference/model_reference_records.py
@register_record_type(MODEL_REFERENCE_CATEGORY.codeformer)
class CodeformerModelRecord(GenericModelRecord):
    """A Codeformer model entry in the model reference."""

    record_type: MODEL_REFERENCE_CATEGORY = MODEL_REFERENCE_CATEGORY.codeformer
    """Discriminator field identifying this as a Codeformer model record."""

    model_classification: ModelClassification = Field(
        default_factory=lambda: _classification_for(MODEL_REFERENCE_CATEGORY.codeformer),
    )

record_type class-attribute instance-attribute

record_type: MODEL_REFERENCE_CATEGORY = codeformer

Discriminator field identifying this as a Codeformer model record.

model_classification class-attribute instance-attribute

model_classification: ModelClassification = Field(
    default_factory=lambda: _classification_for(codeformer)
)

model_config class-attribute instance-attribute

model_config = get_default_config()

name instance-attribute

name: str

The name of the model.

description class-attribute instance-attribute

description: str | None = None

A short description of the model.

version class-attribute instance-attribute

version: str | None = None

The version of the model (not the version of SD it is based on, see baseline for that info).

finetune_series class-attribute instance-attribute

finetune_series: FineTuneSeriesInfo | None = None

Information about the fine-tuning of the model. For image, some examples are 'Pony', 'Illustrious", etc.

metadata class-attribute instance-attribute

metadata: GenericModelRecordMetadata = Field(
    default_factory=GenericModelRecordMetadata
)

Metadata about the record itself, such as creation and update times.

config class-attribute instance-attribute

config: GenericModelRecordConfig = Field(
    default_factory=GenericModelRecordConfig
)

A dictionary of any configuration files and information on where to download the model file(s).

primary_download_url property

primary_download_url: str | None

Return the URL of the first download entry, or None if there are no downloads.

all_download_urls property

all_download_urls: list[str]

Return all download URLs for this model.

download_count property

download_count: int

Return the number of download entries for this model.

EsrganModelRecord

Bases: GenericModelRecord

An ESRGAN model entry in the model reference.

Source code in src/horde_model_reference/model_reference_records.py
@register_record_type(MODEL_REFERENCE_CATEGORY.esrgan)
class EsrganModelRecord(GenericModelRecord):
    """An ESRGAN model entry in the model reference."""

    record_type: MODEL_REFERENCE_CATEGORY = MODEL_REFERENCE_CATEGORY.esrgan
    """Discriminator field identifying this as an ESRGAN model record."""

    model_classification: ModelClassification = Field(
        default_factory=lambda: _classification_for(MODEL_REFERENCE_CATEGORY.esrgan),
    )

record_type class-attribute instance-attribute

record_type: MODEL_REFERENCE_CATEGORY = esrgan

Discriminator field identifying this as an ESRGAN model record.

model_classification class-attribute instance-attribute

model_classification: ModelClassification = Field(
    default_factory=lambda: _classification_for(esrgan)
)

model_config class-attribute instance-attribute

model_config = get_default_config()

name instance-attribute

name: str

The name of the model.

description class-attribute instance-attribute

description: str | None = None

A short description of the model.

version class-attribute instance-attribute

version: str | None = None

The version of the model (not the version of SD it is based on, see baseline for that info).

finetune_series class-attribute instance-attribute

finetune_series: FineTuneSeriesInfo | None = None

Information about the fine-tuning of the model. For image, some examples are 'Pony', 'Illustrious", etc.

metadata class-attribute instance-attribute

metadata: GenericModelRecordMetadata = Field(
    default_factory=GenericModelRecordMetadata
)

Metadata about the record itself, such as creation and update times.

config class-attribute instance-attribute

config: GenericModelRecordConfig = Field(
    default_factory=GenericModelRecordConfig
)

A dictionary of any configuration files and information on where to download the model file(s).

primary_download_url property

primary_download_url: str | None

Return the URL of the first download entry, or None if there are no downloads.

all_download_urls property

all_download_urls: list[str]

Return all download URLs for this model.

download_count property

download_count: int

Return the number of download entries for this model.

GfpganModelRecord

Bases: GenericModelRecord

A GFPGAN model entry in the model reference.

Source code in src/horde_model_reference/model_reference_records.py
@register_record_type(MODEL_REFERENCE_CATEGORY.gfpgan)
class GfpganModelRecord(GenericModelRecord):
    """A GFPGAN model entry in the model reference."""

    record_type: MODEL_REFERENCE_CATEGORY = MODEL_REFERENCE_CATEGORY.gfpgan
    """Discriminator field identifying this as a GFPGAN model record."""

    model_classification: ModelClassification = Field(
        default_factory=lambda: _classification_for(MODEL_REFERENCE_CATEGORY.gfpgan),
    )

record_type class-attribute instance-attribute

record_type: MODEL_REFERENCE_CATEGORY = gfpgan

Discriminator field identifying this as a GFPGAN model record.

model_classification class-attribute instance-attribute

model_classification: ModelClassification = Field(
    default_factory=lambda: _classification_for(gfpgan)
)

model_config class-attribute instance-attribute

model_config = get_default_config()

name instance-attribute

name: str

The name of the model.

description class-attribute instance-attribute

description: str | None = None

A short description of the model.

version class-attribute instance-attribute

version: str | None = None

The version of the model (not the version of SD it is based on, see baseline for that info).

finetune_series class-attribute instance-attribute

finetune_series: FineTuneSeriesInfo | None = None

Information about the fine-tuning of the model. For image, some examples are 'Pony', 'Illustrious", etc.

metadata class-attribute instance-attribute

metadata: GenericModelRecordMetadata = Field(
    default_factory=GenericModelRecordMetadata
)

Metadata about the record itself, such as creation and update times.

config class-attribute instance-attribute

config: GenericModelRecordConfig = Field(
    default_factory=GenericModelRecordConfig
)

A dictionary of any configuration files and information on where to download the model file(s).

primary_download_url property

primary_download_url: str | None

Return the URL of the first download entry, or None if there are no downloads.

all_download_urls property

all_download_urls: list[str]

Return all download URLs for this model.

download_count property

download_count: int

Return the number of download entries for this model.

SafetyCheckerModelRecord

Bases: GenericModelRecord

A safety checker model entry in the model reference.

Source code in src/horde_model_reference/model_reference_records.py
@register_record_type(MODEL_REFERENCE_CATEGORY.safety_checker)
class SafetyCheckerModelRecord(GenericModelRecord):
    """A safety checker model entry in the model reference."""

    record_type: MODEL_REFERENCE_CATEGORY = MODEL_REFERENCE_CATEGORY.safety_checker
    """Discriminator field identifying this as a safety checker model record."""

    model_classification: ModelClassification = Field(
        default_factory=lambda: _classification_for(MODEL_REFERENCE_CATEGORY.safety_checker),
    )

record_type class-attribute instance-attribute

record_type: MODEL_REFERENCE_CATEGORY = safety_checker

Discriminator field identifying this as a safety checker model record.

model_classification class-attribute instance-attribute

model_classification: ModelClassification = Field(
    default_factory=lambda: _classification_for(
        safety_checker
    )
)

model_config class-attribute instance-attribute

model_config = get_default_config()

name instance-attribute

name: str

The name of the model.

description class-attribute instance-attribute

description: str | None = None

A short description of the model.

version class-attribute instance-attribute

version: str | None = None

The version of the model (not the version of SD it is based on, see baseline for that info).

finetune_series class-attribute instance-attribute

finetune_series: FineTuneSeriesInfo | None = None

Information about the fine-tuning of the model. For image, some examples are 'Pony', 'Illustrious", etc.

metadata class-attribute instance-attribute

metadata: GenericModelRecordMetadata = Field(
    default_factory=GenericModelRecordMetadata
)

Metadata about the record itself, such as creation and update times.

config class-attribute instance-attribute

config: GenericModelRecordConfig = Field(
    default_factory=GenericModelRecordConfig
)

A dictionary of any configuration files and information on where to download the model file(s).

primary_download_url property

primary_download_url: str | None

Return the URL of the first download entry, or None if there are no downloads.

all_download_urls property

all_download_urls: list[str]

Return all download URLs for this model.

download_count property

download_count: int

Return the number of download entries for this model.

VideoGenerationModelRecord

Bases: GenericModelRecord

A video generation model entry in the model reference.

Source code in src/horde_model_reference/model_reference_records.py
@register_record_type(MODEL_REFERENCE_CATEGORY.video_generation)
class VideoGenerationModelRecord(GenericModelRecord):
    """A video generation model entry in the model reference."""

    record_type: MODEL_REFERENCE_CATEGORY = MODEL_REFERENCE_CATEGORY.video_generation
    """Discriminator field identifying this as a video generation model record."""

    model_classification: ModelClassification = Field(
        default_factory=lambda: _classification_for(MODEL_REFERENCE_CATEGORY.video_generation),
    )

    baseline: str | None = None
    """The model on which this model is based."""
    nsfw: bool = False
    """Whether the model is NSFW or not."""
    tags: list[NormalizedTag] | None = None
    """Any tags associated with the model which may be useful for searching."""

record_type class-attribute instance-attribute

record_type: MODEL_REFERENCE_CATEGORY = video_generation

Discriminator field identifying this as a video generation model record.

model_classification class-attribute instance-attribute

model_classification: ModelClassification = Field(
    default_factory=lambda: _classification_for(
        video_generation
    )
)

baseline class-attribute instance-attribute

baseline: str | None = None

The model on which this model is based.

nsfw class-attribute instance-attribute

nsfw: bool = False

Whether the model is NSFW or not.

tags class-attribute instance-attribute

tags: list[NormalizedTag] | None = None

Any tags associated with the model which may be useful for searching.

model_config class-attribute instance-attribute

model_config = get_default_config()

name instance-attribute

name: str

The name of the model.

description class-attribute instance-attribute

description: str | None = None

A short description of the model.

version class-attribute instance-attribute

version: str | None = None

The version of the model (not the version of SD it is based on, see baseline for that info).

finetune_series class-attribute instance-attribute

finetune_series: FineTuneSeriesInfo | None = None

Information about the fine-tuning of the model. For image, some examples are 'Pony', 'Illustrious", etc.

metadata class-attribute instance-attribute

metadata: GenericModelRecordMetadata = Field(
    default_factory=GenericModelRecordMetadata
)

Metadata about the record itself, such as creation and update times.

config class-attribute instance-attribute

config: GenericModelRecordConfig = Field(
    default_factory=GenericModelRecordConfig
)

A dictionary of any configuration files and information on where to download the model file(s).

primary_download_url property

primary_download_url: str | None

Return the URL of the first download entry, or None if there are no downloads.

all_download_urls property

all_download_urls: list[str]

Return all download URLs for this model.

download_count property

download_count: int

Return the number of download entries for this model.

AudioGenerationModelRecord

Bases: GenericModelRecord

An audio generation model entry in the model reference.

Source code in src/horde_model_reference/model_reference_records.py
@register_record_type(MODEL_REFERENCE_CATEGORY.audio_generation)
class AudioGenerationModelRecord(GenericModelRecord):
    """An audio generation model entry in the model reference."""

    record_type: MODEL_REFERENCE_CATEGORY = MODEL_REFERENCE_CATEGORY.audio_generation
    """Discriminator field identifying this as an audio generation model record."""

    model_classification: ModelClassification = Field(
        default_factory=lambda: _classification_for(MODEL_REFERENCE_CATEGORY.audio_generation),
    )

    baseline: str | None = None
    """The model on which this model is based."""
    nsfw: bool = False
    """Whether the model is NSFW or not."""
    tags: list[NormalizedTag] | None = None
    """Any tags associated with the model which may be useful for searching."""

record_type class-attribute instance-attribute

record_type: MODEL_REFERENCE_CATEGORY = audio_generation

Discriminator field identifying this as an audio generation model record.

model_classification class-attribute instance-attribute

model_classification: ModelClassification = Field(
    default_factory=lambda: _classification_for(
        audio_generation
    )
)

baseline class-attribute instance-attribute

baseline: str | None = None

The model on which this model is based.

nsfw class-attribute instance-attribute

nsfw: bool = False

Whether the model is NSFW or not.

tags class-attribute instance-attribute

tags: list[NormalizedTag] | None = None

Any tags associated with the model which may be useful for searching.

model_config class-attribute instance-attribute

model_config = get_default_config()

name instance-attribute

name: str

The name of the model.

description class-attribute instance-attribute

description: str | None = None

A short description of the model.

version class-attribute instance-attribute

version: str | None = None

The version of the model (not the version of SD it is based on, see baseline for that info).

finetune_series class-attribute instance-attribute

finetune_series: FineTuneSeriesInfo | None = None

Information about the fine-tuning of the model. For image, some examples are 'Pony', 'Illustrious", etc.

metadata class-attribute instance-attribute

metadata: GenericModelRecordMetadata = Field(
    default_factory=GenericModelRecordMetadata
)

Metadata about the record itself, such as creation and update times.

config class-attribute instance-attribute

config: GenericModelRecordConfig = Field(
    default_factory=GenericModelRecordConfig
)

A dictionary of any configuration files and information on where to download the model file(s).

primary_download_url property

primary_download_url: str | None

Return the URL of the first download entry, or None if there are no downloads.

all_download_urls property

all_download_urls: list[str]

Return all download URLs for this model.

download_count property

download_count: int

Return the number of download entries for this model.

MiscellaneousModelRecord

Bases: GenericModelRecord

A miscellaneous model entry in the model reference.

Source code in src/horde_model_reference/model_reference_records.py
@register_record_type(MODEL_REFERENCE_CATEGORY.miscellaneous)
class MiscellaneousModelRecord(GenericModelRecord):
    """A miscellaneous model entry in the model reference."""

    record_type: MODEL_REFERENCE_CATEGORY = MODEL_REFERENCE_CATEGORY.miscellaneous
    """Discriminator field identifying this as a miscellaneous model record."""

    model_classification: ModelClassification = Field(
        default_factory=lambda: _classification_for(MODEL_REFERENCE_CATEGORY.miscellaneous),
    )

record_type class-attribute instance-attribute

record_type: MODEL_REFERENCE_CATEGORY = miscellaneous

Discriminator field identifying this as a miscellaneous model record.

model_classification class-attribute instance-attribute

model_classification: ModelClassification = Field(
    default_factory=lambda: _classification_for(
        miscellaneous
    )
)

model_config class-attribute instance-attribute

model_config = get_default_config()

name instance-attribute

name: str

The name of the model.

description class-attribute instance-attribute

description: str | None = None

A short description of the model.

version class-attribute instance-attribute

version: str | None = None

The version of the model (not the version of SD it is based on, see baseline for that info).

finetune_series class-attribute instance-attribute

finetune_series: FineTuneSeriesInfo | None = None

Information about the fine-tuning of the model. For image, some examples are 'Pony', 'Illustrious", etc.

metadata class-attribute instance-attribute

metadata: GenericModelRecordMetadata = Field(
    default_factory=GenericModelRecordMetadata
)

Metadata about the record itself, such as creation and update times.

config class-attribute instance-attribute

config: GenericModelRecordConfig = Field(
    default_factory=GenericModelRecordConfig
)

A dictionary of any configuration files and information on where to download the model file(s).

primary_download_url property

primary_download_url: str | None

Return the URL of the first download entry, or None if there are no downloads.

all_download_urls property

all_download_urls: list[str]

Return all download URLs for this model.

download_count property

download_count: int

Return the number of download entries for this model.

_classification_for

_classification_for(
    category: MODEL_REFERENCE_CATEGORY | str,
) -> ModelClassification

Build the default ModelClassification for category from the registry.

Source code in src/horde_model_reference/model_reference_records.py
def _classification_for(category: MODEL_REFERENCE_CATEGORY | str) -> ModelClassification:
    """Build the default ``ModelClassification`` for *category* from the registry."""
    desc = get_category_descriptor(category)
    return ModelClassification(domain=desc.domain, purpose=desc.purpose)

get_default_config

get_default_config() -> ConfigDict

Get the default config for model records based on whether AI Horde is being tested or not.

Source code in src/horde_model_reference/model_reference_records.py
def get_default_config() -> ConfigDict:
    """Get the default config for model records based on whether AI Horde is being tested or not."""
    if ai_horde_ci_settings.ai_horde_testing:
        return ConfigDict(extra="forbid", populate_by_name=True)
    return ConfigDict(extra="ignore", populate_by_name=True)

register_record_type

register_record_type(
    category: MODEL_REFERENCE_CATEGORY | str,
) -> Callable[
    [type[GenericModelRecord]], type[GenericModelRecord]
]

Register a model record type with its category.

Source code in src/horde_model_reference/model_reference_records.py
def register_record_type(
    category: MODEL_REFERENCE_CATEGORY | str,
) -> Callable[[type[GenericModelRecord]], type[GenericModelRecord]]:
    """Register a model record type with its category."""

    def decorator(cls: type[GenericModelRecord]) -> type[GenericModelRecord]:
        if category in MODEL_RECORD_TYPE_LOOKUP:
            logger.warning(
                f"Overriding existing record type for category {category}: "
                f"{MODEL_RECORD_TYPE_LOOKUP[category]} -> {cls}",
            )
        MODEL_RECORD_TYPE_LOOKUP[category] = cls
        return cls

    return decorator

_field_policy_for

_field_policy_for(
    category: MODEL_REFERENCE_CATEGORY | str,
    field_name: str,
    fallback: FieldPolicy,
) -> FieldPolicy
Source code in src/horde_model_reference/model_reference_records.py
def _field_policy_for(
    category: MODEL_REFERENCE_CATEGORY | str,
    field_name: str,
    fallback: FieldPolicy,
) -> FieldPolicy:
    policy = kind_policy_registry.get(category_key(category))
    if policy is None:
        return fallback
    return policy.field_policies.get(field_name, fallback)

_apply_policy

_apply_policy(
    *,
    category: MODEL_REFERENCE_CATEGORY | str,
    field_name: str,
    value: str,
    fallback_policy: FieldPolicy,
    model_name: str,
) -> None
Source code in src/horde_model_reference/model_reference_records.py
def _apply_policy(
    *,
    category: MODEL_REFERENCE_CATEGORY | str,
    field_name: str,
    value: str,
    fallback_policy: FieldPolicy,
    model_name: str,
) -> None:
    field_policy = _field_policy_for(category, field_name, fallback_policy)
    if field_policy.severity == "error":
        raise ValueError(f"Unknown {field_name}: {value}")

    logger.debug(f"Unknown {field_name} {value} for model {model_name}")

get_record_type_for_category

get_record_type_for_category(
    category: MODEL_REFERENCE_CATEGORY | str,
) -> type[GenericModelRecord]

Return the registered record type for category, falling back to GenericModelRecord.

Parameters:

Returns:

Source code in src/horde_model_reference/model_reference_records.py
def get_record_type_for_category(category: MODEL_REFERENCE_CATEGORY | str) -> type[GenericModelRecord]:
    """Return the registered record type for *category*, falling back to ``GenericModelRecord``.

    Args:
        category: The model reference category (enum member or plain string).

    Returns:
        The record type class registered for the category, or ``GenericModelRecord``
        if no specific type has been registered.

    """
    return MODEL_RECORD_TYPE_LOOKUP.get(category, GenericModelRecord)