Skip to content

v0_4 ¤

CLASS DESCRIPTION
AfterValidator
AttachmentsDescr
Author
BadgeDescr

A custom badge

BinarizeDescr

BinarizeDescr the tensor with a fixed BinarizeKwargs.threshold.

BinarizeKwargs

key word arguments for BinarizeDescr

CallableFromDepencency
CallableFromDepencencyNode
CallableFromFile
CallableFromFileNode
CiteEntry
ClipDescr

Clip tensor values to a range.

ClipKwargs

key word arguments for ClipDescr

DatasetDescr

A bioimage.io dataset resource description file (dataset RDF) describes a dataset relevant to bioimage

Datetime

Timestamp in ISO 8601 format

Dependencies
DependenciesNode
Doi

A digital object identifier, see https://www.doi.org/

FileDescr

A file description

GenericModelDescrBase

Base for all resource descriptions including of model descriptions

HttpUrl

A URL with the HTTP or HTTPS scheme.

Identifier
ImplicitOutputShape

Output tensor shape depending on an input tensor shape.

InputTensorDescr
KerasHdf5WeightsDescr
KwargsNode
LicenseId
LinkedDataset

Reference to a bioimage.io dataset.

LinkedModel

Reference to a bioimage.io model.

LinkedResource

Reference to a bioimage.io resource

LowerCaseIdentifier
Maintainer
ModelDescr

Specification of the fields used in a bioimage.io-compliant RDF that describes AI models with pretrained weights.

ModelId
Node
NodeWithExplicitlySetFields
OnnxWeightsDescr
OrcidId

An ORCID identifier, see https://orcid.org/

OutputTensorDescr
ParameterizedInputShape

A sequence of valid shapes given by shape_k = min + k * step for k in {0, 1, ...}.

ProcessingDescrBase

processing base class

ProcessingKwargs

base class for pre-/postprocessing key word arguments

PytorchStateDictWeightsDescr
RelativeFilePath

A path relative to the rdf.yaml file (also if the RDF source is a URL).

ResourceId
RestrictCharacters
RunMode
ScaleLinearDescr

Fixed linear scaling.

ScaleLinearKwargs

key word arguments for ScaleLinearDescr

ScaleMeanVarianceDescr

Scale the tensor s.t. its mean and variance match a reference tensor.

ScaleMeanVarianceKwargs

key word arguments for ScaleMeanVarianceDescr

ScaleRangeDescr

Scale with percentiles.

ScaleRangeKwargs

key word arguments for ScaleRangeDescr

Sha256

A SHA-256 hash value

SigmoidDescr

The logistic sigmoid funciton, a.k.a. expit function.

TensorDescrBase
TensorName
TensorflowJsWeightsDescr
TensorflowSavedModelBundleWeightsDescr
TorchscriptWeightsDescr
Uploader
ValidatedStringWithInnerNode

A validated string with further validation and serialization using a Node

Version

wraps a packaging.version.Version instance for validation in pydantic models

WeightsDescr
WeightsEntryDescrBase
WithSuffix
ZeroMeanUnitVarianceDescr

Subtract mean and divide by variance.

ZeroMeanUnitVarianceKwargs

key word arguments for ZeroMeanUnitVarianceDescr

FUNCTION DESCRIPTION
convert_from_older_format
issue_warning
load_array
package_weights
validate_unique_entries
warn

treat a type or its annotation metadata as a warning condition

ATTRIBUTE DESCRIPTION
AxesInCZYX

AxesStr

BioimageioYamlContent

CustomCallable

FileSource_

A file source that is included when packaging the resource.

KnownRunMode

NotEmpty

PostprocessingDescr

PostprocessingName

PreprocessingDescr

PreprocessingName

SHA256_HINT

VALID_COVER_IMAGE_EXTENSIONS

WeightsFormat

include_in_package

DEPRECATED serializer for source fields without corresponding sha256 field.

packaging_context_var

TYPE: ContextVar[Optional[PackagingContext]]

AxesInCZYX module-attribute ¤

AxesInCZYX = str

AxesStr module-attribute ¤

AxesStr = str

CustomCallable module-attribute ¤

CustomCallable = Union[
    CallableFromFile, CallableFromDepencency
]

KnownRunMode module-attribute ¤

KnownRunMode = Literal['deepimagej']

NotEmpty module-attribute ¤

NotEmpty = S

PostprocessingName module-attribute ¤

PostprocessingName = Literal[
    "binarize",
    "clip",
    "scale_linear",
    "sigmoid",
    "zero_mean_unit_variance",
    "scale_range",
    "scale_mean_variance",
]

PreprocessingName module-attribute ¤

PreprocessingName = Literal[
    "binarize",
    "clip",
    "scale_linear",
    "sigmoid",
    "zero_mean_unit_variance",
    "scale_range",
]

SHA256_HINT module-attribute ¤

SHA256_HINT = "You can drag and drop your file to this\n[online tool](http://emn178.github.io/online-tools/sha256_checksum.html) to generate a SHA256 in your browser.\nOr you can generate a SHA256 checksum with Python's `hashlib`,\n[here is a codesnippet](https://gist.github.com/FynnBe/e64460463df89439cff218bbf59c1100)."

VALID_COVER_IMAGE_EXTENSIONS module-attribute ¤

VALID_COVER_IMAGE_EXTENSIONS = (
    ".gif",
    ".jpeg",
    ".jpg",
    ".png",
    ".svg",
    ".tif",
    ".tiff",
)

WeightsFormat module-attribute ¤

WeightsFormat = Literal[
    "keras_hdf5",
    "onnx",
    "pytorch_state_dict",
    "tensorflow_js",
    "tensorflow_saved_model_bundle",
    "torchscript",
]

include_in_package module-attribute ¤

include_in_package = PrettyPlainSerializer(
    _package_serializer, when_used="unless-none"
)

DEPRECATED serializer for source fields without corresponding sha256 field.

packaging_context_var module-attribute ¤

packaging_context_var: ContextVar[
    Optional[PackagingContext]
] = ContextVar("packaging_context_var", default=None)

AfterValidator dataclass ¤

AfterValidator()

Bases: functional_validators.AfterValidator


              flowchart TD
              bioimageio.spec.model.v0_4.AfterValidator[AfterValidator]

              

              click bioimageio.spec.model.v0_4.AfterValidator href "" "bioimageio.spec.model.v0_4.AfterValidator"
            
METHOD DESCRIPTION
__str__

__str__ ¤

__str__()
Source code in src/bioimageio/spec/_internal/validator_annotations.py
15
16
def __str__(self):
    return f"AfterValidator({self.func.__name__})"

AttachmentsDescr pydantic-model ¤

Bases: Node

Show JSON schema:
{
  "$defs": {
    "RelativeFilePath": {
      "description": "A path relative to the `rdf.yaml` file (also if the RDF source is a URL).",
      "format": "path",
      "title": "RelativeFilePath",
      "type": "string"
    }
  },
  "additionalProperties": true,
  "properties": {
    "files": {
      "description": "File attachments",
      "items": {
        "anyOf": [
          {
            "description": "A URL with the HTTP or HTTPS scheme.",
            "format": "uri",
            "maxLength": 2083,
            "minLength": 1,
            "title": "HttpUrl",
            "type": "string"
          },
          {
            "$ref": "#/$defs/RelativeFilePath"
          },
          {
            "format": "file-path",
            "title": "FilePath",
            "type": "string"
          }
        ]
      },
      "title": "Files",
      "type": "array"
    }
  },
  "title": "generic.v0_2.AttachmentsDescr",
  "type": "object"
}

Config:

  • default: {None: Node.model_config, 'extra': 'allow'}

Fields:

files pydantic-field ¤

files: List[FileSource_]

File attachments

model_config class-attribute instance-attribute ¤

model_config = {None: Node.model_config, 'extra': 'allow'}

update pydantic model config to allow additional unknown keys

model_validate classmethod ¤

model_validate(
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[
        ValidationContext, Mapping[str, Any], None
    ] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self

Validate a pydantic model instance.

PARAMETER DESCRIPTION

obj ¤

The object to validate.

TYPE: Union[Any, Mapping[str, Any]]

strict ¤

Whether to raise an exception on invalid fields.

TYPE: Optional[bool] DEFAULT: None

from_attributes ¤

Whether to extract data from object attributes.

TYPE: Optional[bool] DEFAULT: None

context ¤

Additional context to pass to the validator.

TYPE: Union[ValidationContext, Mapping[str, Any], None] DEFAULT: None

RAISES DESCRIPTION
ValidationError

If the object failed validation.

RETURNS DESCRIPTION
Self

The validated description instance.

Source code in src/bioimageio/spec/_internal/node.py
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
@classmethod
def model_validate(
    cls,
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[ValidationContext, Mapping[str, Any], None] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self:
    """Validate a pydantic model instance.

    Args:
        obj: The object to validate.
        strict: Whether to raise an exception on invalid fields.
        from_attributes: Whether to extract data from object attributes.
        context: Additional context to pass to the validator.

    Raises:
        ValidationError: If the object failed validation.

    Returns:
        The validated description instance.
    """
    __tracebackhide__ = True

    if context is None:
        context = get_validation_context()
    elif isinstance(context, collections.abc.Mapping):
        context = ValidationContext(**context)

    assert not isinstance(obj, collections.abc.Mapping) or is_kwargs(obj), obj

    with context:
        # use validation context as context manager for equal behavior of __init__ and model_validate
        return super().model_validate(
            obj, strict=strict, from_attributes=from_attributes
        )

Author pydantic-model ¤

Bases: _Person

Show JSON schema:
{
  "additionalProperties": false,
  "properties": {
    "affiliation": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Affiliation",
      "title": "Affiliation"
    },
    "email": {
      "anyOf": [
        {
          "format": "email",
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Email",
      "title": "Email"
    },
    "orcid": {
      "anyOf": [
        {
          "description": "An ORCID identifier, see https://orcid.org/",
          "title": "OrcidId",
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "An [ORCID iD](https://support.orcid.org/hc/en-us/sections/360001495313-What-is-ORCID\n) in hyphenated groups of 4 digits, (and [valid](\nhttps://support.orcid.org/hc/en-us/articles/360006897674-Structure-of-the-ORCID-Identifier\n) as per ISO 7064 11,2.)",
      "examples": [
        "0000-0001-2345-6789"
      ],
      "title": "Orcid"
    },
    "name": {
      "title": "Name",
      "type": "string"
    },
    "github_user": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Github User"
    }
  },
  "required": [
    "name"
  ],
  "title": "generic.v0_2.Author",
  "type": "object"
}

Fields:

affiliation pydantic-field ¤

affiliation: Optional[str] = None

Affiliation

email pydantic-field ¤

email: Optional[EmailStr] = None

Email

github_user pydantic-field ¤

github_user: Optional[str] = None

name pydantic-field ¤

name: str

orcid pydantic-field ¤

orcid: Optional[OrcidId] = None

An ORCID iD in hyphenated groups of 4 digits, (and valid as per ISO 7064 11,2.)

model_validate classmethod ¤

model_validate(
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[
        ValidationContext, Mapping[str, Any], None
    ] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self

Validate a pydantic model instance.

PARAMETER DESCRIPTION

obj ¤

The object to validate.

TYPE: Union[Any, Mapping[str, Any]]

strict ¤

Whether to raise an exception on invalid fields.

TYPE: Optional[bool] DEFAULT: None

from_attributes ¤

Whether to extract data from object attributes.

TYPE: Optional[bool] DEFAULT: None

context ¤

Additional context to pass to the validator.

TYPE: Union[ValidationContext, Mapping[str, Any], None] DEFAULT: None

RAISES DESCRIPTION
ValidationError

If the object failed validation.

RETURNS DESCRIPTION
Self

The validated description instance.

Source code in src/bioimageio/spec/_internal/node.py
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
@classmethod
def model_validate(
    cls,
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[ValidationContext, Mapping[str, Any], None] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self:
    """Validate a pydantic model instance.

    Args:
        obj: The object to validate.
        strict: Whether to raise an exception on invalid fields.
        from_attributes: Whether to extract data from object attributes.
        context: Additional context to pass to the validator.

    Raises:
        ValidationError: If the object failed validation.

    Returns:
        The validated description instance.
    """
    __tracebackhide__ = True

    if context is None:
        context = get_validation_context()
    elif isinstance(context, collections.abc.Mapping):
        context = ValidationContext(**context)

    assert not isinstance(obj, collections.abc.Mapping) or is_kwargs(obj), obj

    with context:
        # use validation context as context manager for equal behavior of __init__ and model_validate
        return super().model_validate(
            obj, strict=strict, from_attributes=from_attributes
        )

BadgeDescr pydantic-model ¤

Bases: Node

A custom badge

Show JSON schema:
{
  "$defs": {
    "RelativeFilePath": {
      "description": "A path relative to the `rdf.yaml` file (also if the RDF source is a URL).",
      "format": "path",
      "title": "RelativeFilePath",
      "type": "string"
    }
  },
  "additionalProperties": false,
  "description": "A custom badge",
  "properties": {
    "label": {
      "description": "badge label to display on hover",
      "examples": [
        "Open in Colab"
      ],
      "title": "Label",
      "type": "string"
    },
    "icon": {
      "anyOf": [
        {
          "format": "file-path",
          "title": "FilePath",
          "type": "string"
        },
        {
          "$ref": "#/$defs/RelativeFilePath"
        },
        {
          "description": "A URL with the HTTP or HTTPS scheme.",
          "format": "uri",
          "maxLength": 2083,
          "minLength": 1,
          "title": "HttpUrl",
          "type": "string"
        },
        {
          "format": "uri",
          "maxLength": 2083,
          "minLength": 1,
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "badge icon (included in bioimage.io package if not a URL)",
      "examples": [
        "https://colab.research.google.com/assets/colab-badge.svg"
      ],
      "title": "Icon"
    },
    "url": {
      "description": "target URL",
      "examples": [
        "https://colab.research.google.com/github/HenriquesLab/ZeroCostDL4Mic/blob/master/Colab_notebooks/U-net_2D_ZeroCostDL4Mic.ipynb"
      ],
      "format": "uri",
      "maxLength": 2083,
      "minLength": 1,
      "title": "HttpUrl",
      "type": "string"
    }
  },
  "required": [
    "label",
    "url"
  ],
  "title": "generic.v0_2.BadgeDescr",
  "type": "object"
}

Fields:

icon pydantic-field ¤

icon: Optional[
    Union[
        Union[FilePath, RelativeFilePath],
        Union[HttpUrl, pydantic.HttpUrl],
    ]
] = None

badge icon (included in bioimage.io package if not a URL)

label pydantic-field ¤

label: str

badge label to display on hover

url pydantic-field ¤

url: HttpUrl

target URL

model_validate classmethod ¤

model_validate(
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[
        ValidationContext, Mapping[str, Any], None
    ] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self

Validate a pydantic model instance.

PARAMETER DESCRIPTION

obj ¤

The object to validate.

TYPE: Union[Any, Mapping[str, Any]]

strict ¤

Whether to raise an exception on invalid fields.

TYPE: Optional[bool] DEFAULT: None

from_attributes ¤

Whether to extract data from object attributes.

TYPE: Optional[bool] DEFAULT: None

context ¤

Additional context to pass to the validator.

TYPE: Union[ValidationContext, Mapping[str, Any], None] DEFAULT: None

RAISES DESCRIPTION
ValidationError

If the object failed validation.

RETURNS DESCRIPTION
Self

The validated description instance.

Source code in src/bioimageio/spec/_internal/node.py
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
@classmethod
def model_validate(
    cls,
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[ValidationContext, Mapping[str, Any], None] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self:
    """Validate a pydantic model instance.

    Args:
        obj: The object to validate.
        strict: Whether to raise an exception on invalid fields.
        from_attributes: Whether to extract data from object attributes.
        context: Additional context to pass to the validator.

    Raises:
        ValidationError: If the object failed validation.

    Returns:
        The validated description instance.
    """
    __tracebackhide__ = True

    if context is None:
        context = get_validation_context()
    elif isinstance(context, collections.abc.Mapping):
        context = ValidationContext(**context)

    assert not isinstance(obj, collections.abc.Mapping) or is_kwargs(obj), obj

    with context:
        # use validation context as context manager for equal behavior of __init__ and model_validate
        return super().model_validate(
            obj, strict=strict, from_attributes=from_attributes
        )

BinarizeDescr pydantic-model ¤

Bases: ProcessingDescrBase

BinarizeDescr the tensor with a fixed BinarizeKwargs.threshold. Values above the threshold will be set to one, values below the threshold to zero.

Show JSON schema:
{
  "$defs": {
    "BinarizeKwargs": {
      "additionalProperties": false,
      "description": "key word arguments for `BinarizeDescr`",
      "properties": {
        "threshold": {
          "description": "The fixed threshold",
          "title": "Threshold",
          "type": "number"
        }
      },
      "required": [
        "threshold"
      ],
      "title": "model.v0_4.BinarizeKwargs",
      "type": "object"
    }
  },
  "additionalProperties": false,
  "description": "BinarizeDescr the tensor with a fixed `BinarizeKwargs.threshold`.\nValues above the threshold will be set to one, values below the threshold to zero.",
  "properties": {
    "name": {
      "const": "binarize",
      "title": "Name",
      "type": "string"
    },
    "kwargs": {
      "$ref": "#/$defs/BinarizeKwargs"
    }
  },
  "required": [
    "name",
    "kwargs"
  ],
  "title": "model.v0_4.BinarizeDescr",
  "type": "object"
}

Fields:

implemented_name class-attribute ¤

implemented_name: Literal['binarize'] = 'binarize'

kwargs pydantic-field ¤

name pydantic-field ¤

name: Literal['binarize'] = 'binarize'

__pydantic_init_subclass__ classmethod ¤

__pydantic_init_subclass__(**kwargs: Any) -> None
Source code in src/bioimageio/spec/_internal/common_nodes.py
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
@classmethod
def __pydantic_init_subclass__(cls, **kwargs: Any) -> None:
    explict_fields: Dict[str, Any] = {}
    for attr in dir(cls):
        if attr.startswith("implemented_"):
            field_name = attr.replace("implemented_", "")
            if field_name not in cls.model_fields:
                continue

            assert (
                cls.model_fields[field_name].get_default() is PydanticUndefined
            ), field_name
            default = getattr(cls, attr)
            explict_fields[field_name] = default

    cls._fields_to_set_explicitly = MappingProxyType(explict_fields)
    return super().__pydantic_init_subclass__(**kwargs)

model_validate classmethod ¤

model_validate(
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[
        ValidationContext, Mapping[str, Any], None
    ] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self

Validate a pydantic model instance.

PARAMETER DESCRIPTION

obj ¤

The object to validate.

TYPE: Union[Any, Mapping[str, Any]]

strict ¤

Whether to raise an exception on invalid fields.

TYPE: Optional[bool] DEFAULT: None

from_attributes ¤

Whether to extract data from object attributes.

TYPE: Optional[bool] DEFAULT: None

context ¤

Additional context to pass to the validator.

TYPE: Union[ValidationContext, Mapping[str, Any], None] DEFAULT: None

RAISES DESCRIPTION
ValidationError

If the object failed validation.

RETURNS DESCRIPTION
Self

The validated description instance.

Source code in src/bioimageio/spec/_internal/node.py
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
@classmethod
def model_validate(
    cls,
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[ValidationContext, Mapping[str, Any], None] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self:
    """Validate a pydantic model instance.

    Args:
        obj: The object to validate.
        strict: Whether to raise an exception on invalid fields.
        from_attributes: Whether to extract data from object attributes.
        context: Additional context to pass to the validator.

    Raises:
        ValidationError: If the object failed validation.

    Returns:
        The validated description instance.
    """
    __tracebackhide__ = True

    if context is None:
        context = get_validation_context()
    elif isinstance(context, collections.abc.Mapping):
        context = ValidationContext(**context)

    assert not isinstance(obj, collections.abc.Mapping) or is_kwargs(obj), obj

    with context:
        # use validation context as context manager for equal behavior of __init__ and model_validate
        return super().model_validate(
            obj, strict=strict, from_attributes=from_attributes
        )

BinarizeKwargs pydantic-model ¤

Bases: ProcessingKwargs

key word arguments for BinarizeDescr

Show JSON schema:
{
  "additionalProperties": false,
  "description": "key word arguments for `BinarizeDescr`",
  "properties": {
    "threshold": {
      "description": "The fixed threshold",
      "title": "Threshold",
      "type": "number"
    }
  },
  "required": [
    "threshold"
  ],
  "title": "model.v0_4.BinarizeKwargs",
  "type": "object"
}

Fields:

threshold pydantic-field ¤

threshold: float

The fixed threshold

__contains__ ¤

__contains__(item: str) -> bool
Source code in src/bioimageio/spec/_internal/common_nodes.py
425
426
def __contains__(self, item: str) -> bool:
    return item in self.__class__.model_fields

__getitem__ ¤

__getitem__(item: str) -> Any
Source code in src/bioimageio/spec/_internal/common_nodes.py
419
420
421
422
423
def __getitem__(self, item: str) -> Any:
    if item in self.__class__.model_fields:
        return getattr(self, item)
    else:
        raise KeyError(item)

get ¤

get(item: str, default: Any = None) -> Any
Source code in src/bioimageio/spec/_internal/common_nodes.py
416
417
def get(self, item: str, default: Any = None) -> Any:
    return self[item] if item in self else default

model_validate classmethod ¤

model_validate(
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[
        ValidationContext, Mapping[str, Any], None
    ] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self

Validate a pydantic model instance.

PARAMETER DESCRIPTION

obj ¤

The object to validate.

TYPE: Union[Any, Mapping[str, Any]]

strict ¤

Whether to raise an exception on invalid fields.

TYPE: Optional[bool] DEFAULT: None

from_attributes ¤

Whether to extract data from object attributes.

TYPE: Optional[bool] DEFAULT: None

context ¤

Additional context to pass to the validator.

TYPE: Union[ValidationContext, Mapping[str, Any], None] DEFAULT: None

RAISES DESCRIPTION
ValidationError

If the object failed validation.

RETURNS DESCRIPTION
Self

The validated description instance.

Source code in src/bioimageio/spec/_internal/node.py
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
@classmethod
def model_validate(
    cls,
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[ValidationContext, Mapping[str, Any], None] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self:
    """Validate a pydantic model instance.

    Args:
        obj: The object to validate.
        strict: Whether to raise an exception on invalid fields.
        from_attributes: Whether to extract data from object attributes.
        context: Additional context to pass to the validator.

    Raises:
        ValidationError: If the object failed validation.

    Returns:
        The validated description instance.
    """
    __tracebackhide__ = True

    if context is None:
        context = get_validation_context()
    elif isinstance(context, collections.abc.Mapping):
        context = ValidationContext(**context)

    assert not isinstance(obj, collections.abc.Mapping) or is_kwargs(obj), obj

    with context:
        # use validation context as context manager for equal behavior of __init__ and model_validate
        return super().model_validate(
            obj, strict=strict, from_attributes=from_attributes
        )

CallableFromDepencency ¤

Bases: ValidatedStringWithInnerNode[CallableFromDepencencyNode]


              flowchart TD
              bioimageio.spec.model.v0_4.CallableFromDepencency[CallableFromDepencency]
              bioimageio.spec._internal.validated_string_with_inner_node.ValidatedStringWithInnerNode[ValidatedStringWithInnerNode]
              bioimageio.spec._internal.validated_string.ValidatedString[ValidatedString]

                              bioimageio.spec._internal.validated_string_with_inner_node.ValidatedStringWithInnerNode --> bioimageio.spec.model.v0_4.CallableFromDepencency
                                bioimageio.spec._internal.validated_string.ValidatedString --> bioimageio.spec._internal.validated_string_with_inner_node.ValidatedStringWithInnerNode
                



              click bioimageio.spec.model.v0_4.CallableFromDepencency href "" "bioimageio.spec.model.v0_4.CallableFromDepencency"
              click bioimageio.spec._internal.validated_string_with_inner_node.ValidatedStringWithInnerNode href "" "bioimageio.spec._internal.validated_string_with_inner_node.ValidatedStringWithInnerNode"
              click bioimageio.spec._internal.validated_string.ValidatedString href "" "bioimageio.spec._internal.validated_string.ValidatedString"
            
METHOD DESCRIPTION
__get_pydantic_core_schema__
__get_pydantic_json_schema__
__new__
ATTRIBUTE DESCRIPTION
callable_name

The callable Python identifier implemented in module module_name.

module_name

The Python module that implements callable_name.

root_model

TYPE: Type[RootModel[Any]]

callable_name property ¤

callable_name

The callable Python identifier implemented in module module_name.

module_name property ¤

module_name

The Python module that implements callable_name.

root_model class-attribute ¤

root_model: Type[RootModel[Any]] = RootModel[str]

__get_pydantic_core_schema__ classmethod ¤

__get_pydantic_core_schema__(
    source_type: Any, handler: GetCoreSchemaHandler
) -> CoreSchema
Source code in src/bioimageio/spec/_internal/validated_string.py
29
30
31
32
33
@classmethod
def __get_pydantic_core_schema__(
    cls, source_type: Any, handler: GetCoreSchemaHandler
) -> CoreSchema:
    return no_info_after_validator_function(cls, handler(str))

__get_pydantic_json_schema__ classmethod ¤

__get_pydantic_json_schema__(
    core_schema: CoreSchema, handler: GetJsonSchemaHandler
) -> JsonSchemaValue
Source code in src/bioimageio/spec/_internal/validated_string.py
35
36
37
38
39
40
41
42
43
44
@classmethod
def __get_pydantic_json_schema__(
    cls, core_schema: CoreSchema, handler: GetJsonSchemaHandler
) -> JsonSchemaValue:
    json_schema = cls.root_model.model_json_schema(mode=handler.mode)
    json_schema["title"] = cls.__name__.strip("_")
    if cls.__doc__:
        json_schema["description"] = cls.__doc__

    return json_schema

__new__ ¤

__new__(object: object)
Source code in src/bioimageio/spec/_internal/validated_string.py
19
20
21
22
23
def __new__(cls, object: object):
    _validated = cls.root_model.model_validate(object).root
    self = super().__new__(cls, _validated)
    self._validated = _validated
    return self._after_validator()

CallableFromDepencencyNode pydantic-model ¤

Bases: Node

Show JSON schema:
{
  "additionalProperties": false,
  "properties": {
    "module_name": {
      "description": "The Python module that implements **callable_name**.",
      "title": "Module Name",
      "type": "string"
    },
    "callable_name": {
      "description": "The callable Python identifier implemented in module **module_name**.",
      "minLength": 1,
      "title": "Identifier",
      "type": "string"
    }
  },
  "required": [
    "module_name",
    "callable_name"
  ],
  "title": "model.v0_4.CallableFromDepencencyNode",
  "type": "object"
}

Fields:

Validators:

callable_name pydantic-field ¤

callable_name: Identifier

The callable Python identifier implemented in module module_name.

module_name pydantic-field ¤

module_name: str

The Python module that implements callable_name.

model_validate classmethod ¤

model_validate(
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[
        ValidationContext, Mapping[str, Any], None
    ] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self

Validate a pydantic model instance.

PARAMETER DESCRIPTION

obj ¤

The object to validate.

TYPE: Union[Any, Mapping[str, Any]]

strict ¤

Whether to raise an exception on invalid fields.

TYPE: Optional[bool] DEFAULT: None

from_attributes ¤

Whether to extract data from object attributes.

TYPE: Optional[bool] DEFAULT: None

context ¤

Additional context to pass to the validator.

TYPE: Union[ValidationContext, Mapping[str, Any], None] DEFAULT: None

RAISES DESCRIPTION
ValidationError

If the object failed validation.

RETURNS DESCRIPTION
Self

The validated description instance.

Source code in src/bioimageio/spec/_internal/node.py
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
@classmethod
def model_validate(
    cls,
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[ValidationContext, Mapping[str, Any], None] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self:
    """Validate a pydantic model instance.

    Args:
        obj: The object to validate.
        strict: Whether to raise an exception on invalid fields.
        from_attributes: Whether to extract data from object attributes.
        context: Additional context to pass to the validator.

    Raises:
        ValidationError: If the object failed validation.

    Returns:
        The validated description instance.
    """
    __tracebackhide__ = True

    if context is None:
        context = get_validation_context()
    elif isinstance(context, collections.abc.Mapping):
        context = ValidationContext(**context)

    assert not isinstance(obj, collections.abc.Mapping) or is_kwargs(obj), obj

    with context:
        # use validation context as context manager for equal behavior of __init__ and model_validate
        return super().model_validate(
            obj, strict=strict, from_attributes=from_attributes
        )

CallableFromFile ¤

Bases: ValidatedStringWithInnerNode[CallableFromFileNode]


              flowchart TD
              bioimageio.spec.model.v0_4.CallableFromFile[CallableFromFile]
              bioimageio.spec._internal.validated_string_with_inner_node.ValidatedStringWithInnerNode[ValidatedStringWithInnerNode]
              bioimageio.spec._internal.validated_string.ValidatedString[ValidatedString]

                              bioimageio.spec._internal.validated_string_with_inner_node.ValidatedStringWithInnerNode --> bioimageio.spec.model.v0_4.CallableFromFile
                                bioimageio.spec._internal.validated_string.ValidatedString --> bioimageio.spec._internal.validated_string_with_inner_node.ValidatedStringWithInnerNode
                



              click bioimageio.spec.model.v0_4.CallableFromFile href "" "bioimageio.spec.model.v0_4.CallableFromFile"
              click bioimageio.spec._internal.validated_string_with_inner_node.ValidatedStringWithInnerNode href "" "bioimageio.spec._internal.validated_string_with_inner_node.ValidatedStringWithInnerNode"
              click bioimageio.spec._internal.validated_string.ValidatedString href "" "bioimageio.spec._internal.validated_string.ValidatedString"
            
METHOD DESCRIPTION
__get_pydantic_core_schema__
__get_pydantic_json_schema__
__new__
ATTRIBUTE DESCRIPTION
callable_name

The callable Python identifier implemented in source_file.

root_model

TYPE: Type[RootModel[Any]]

source_file

The Python source file that implements callable_name.

callable_name property ¤

callable_name

The callable Python identifier implemented in source_file.

root_model class-attribute ¤

root_model: Type[RootModel[Any]] = RootModel[str]

source_file property ¤

source_file

The Python source file that implements callable_name.

__get_pydantic_core_schema__ classmethod ¤

__get_pydantic_core_schema__(
    source_type: Any, handler: GetCoreSchemaHandler
) -> CoreSchema
Source code in src/bioimageio/spec/_internal/validated_string.py
29
30
31
32
33
@classmethod
def __get_pydantic_core_schema__(
    cls, source_type: Any, handler: GetCoreSchemaHandler
) -> CoreSchema:
    return no_info_after_validator_function(cls, handler(str))

__get_pydantic_json_schema__ classmethod ¤

__get_pydantic_json_schema__(
    core_schema: CoreSchema, handler: GetJsonSchemaHandler
) -> JsonSchemaValue
Source code in src/bioimageio/spec/_internal/validated_string.py
35
36
37
38
39
40
41
42
43
44
@classmethod
def __get_pydantic_json_schema__(
    cls, core_schema: CoreSchema, handler: GetJsonSchemaHandler
) -> JsonSchemaValue:
    json_schema = cls.root_model.model_json_schema(mode=handler.mode)
    json_schema["title"] = cls.__name__.strip("_")
    if cls.__doc__:
        json_schema["description"] = cls.__doc__

    return json_schema

__new__ ¤

__new__(object: object)
Source code in src/bioimageio/spec/_internal/validated_string.py
19
20
21
22
23
def __new__(cls, object: object):
    _validated = cls.root_model.model_validate(object).root
    self = super().__new__(cls, _validated)
    self._validated = _validated
    return self._after_validator()

CallableFromFileNode pydantic-model ¤

Bases: Node

Show JSON schema:
{
  "$defs": {
    "RelativeFilePath": {
      "description": "A path relative to the `rdf.yaml` file (also if the RDF source is a URL).",
      "format": "path",
      "title": "RelativeFilePath",
      "type": "string"
    }
  },
  "additionalProperties": false,
  "properties": {
    "source_file": {
      "anyOf": [
        {
          "$ref": "#/$defs/RelativeFilePath"
        },
        {
          "description": "A URL with the HTTP or HTTPS scheme.",
          "format": "uri",
          "maxLength": 2083,
          "minLength": 1,
          "title": "HttpUrl",
          "type": "string"
        }
      ],
      "description": "The Python source file that implements **callable_name**.",
      "title": "Source File"
    },
    "callable_name": {
      "description": "The callable Python identifier implemented in **source_file**.",
      "minLength": 1,
      "title": "Identifier",
      "type": "string"
    }
  },
  "required": [
    "source_file",
    "callable_name"
  ],
  "title": "model.v0_4.CallableFromFileNode",
  "type": "object"
}

Fields:

callable_name pydantic-field ¤

callable_name: Identifier

The callable Python identifier implemented in source_file.

source_file pydantic-field ¤

source_file: Union[RelativeFilePath, HttpUrl]

The Python source file that implements callable_name.

model_validate classmethod ¤

model_validate(
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[
        ValidationContext, Mapping[str, Any], None
    ] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self

Validate a pydantic model instance.

PARAMETER DESCRIPTION

obj ¤

The object to validate.

TYPE: Union[Any, Mapping[str, Any]]

strict ¤

Whether to raise an exception on invalid fields.

TYPE: Optional[bool] DEFAULT: None

from_attributes ¤

Whether to extract data from object attributes.

TYPE: Optional[bool] DEFAULT: None

context ¤

Additional context to pass to the validator.

TYPE: Union[ValidationContext, Mapping[str, Any], None] DEFAULT: None

RAISES DESCRIPTION
ValidationError

If the object failed validation.

RETURNS DESCRIPTION
Self

The validated description instance.

Source code in src/bioimageio/spec/_internal/node.py
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
@classmethod
def model_validate(
    cls,
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[ValidationContext, Mapping[str, Any], None] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self:
    """Validate a pydantic model instance.

    Args:
        obj: The object to validate.
        strict: Whether to raise an exception on invalid fields.
        from_attributes: Whether to extract data from object attributes.
        context: Additional context to pass to the validator.

    Raises:
        ValidationError: If the object failed validation.

    Returns:
        The validated description instance.
    """
    __tracebackhide__ = True

    if context is None:
        context = get_validation_context()
    elif isinstance(context, collections.abc.Mapping):
        context = ValidationContext(**context)

    assert not isinstance(obj, collections.abc.Mapping) or is_kwargs(obj), obj

    with context:
        # use validation context as context manager for equal behavior of __init__ and model_validate
        return super().model_validate(
            obj, strict=strict, from_attributes=from_attributes
        )

CiteEntry pydantic-model ¤

Bases: Node

Show JSON schema:
{
  "additionalProperties": false,
  "properties": {
    "text": {
      "description": "free text description",
      "title": "Text",
      "type": "string"
    },
    "doi": {
      "anyOf": [
        {
          "description": "A digital object identifier, see https://www.doi.org/",
          "pattern": "^10\\.[0-9]{4}.+$",
          "title": "Doi",
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "A digital object identifier (DOI) is the prefered citation reference.\nSee https://www.doi.org/ for details. (alternatively specify `url`)",
      "title": "Doi"
    },
    "url": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "URL to cite (preferably specify a `doi` instead)",
      "title": "Url"
    }
  },
  "required": [
    "text"
  ],
  "title": "generic.v0_2.CiteEntry",
  "type": "object"
}

Fields:

Validators:

doi pydantic-field ¤

doi: Optional[Doi] = None

A digital object identifier (DOI) is the prefered citation reference. See https://www.doi.org/ for details. (alternatively specify url)

text pydantic-field ¤

text: str

free text description

url pydantic-field ¤

url: Optional[str] = None

URL to cite (preferably specify a doi instead)

accept_prefixed_doi pydantic-validator ¤

accept_prefixed_doi(doi: Any) -> Any
Source code in src/bioimageio/spec/generic/v0_2.py
184
185
186
187
188
189
190
191
192
193
@field_validator("doi", mode="before")
@classmethod
def accept_prefixed_doi(cls, doi: Any) -> Any:
    if isinstance(doi, str):
        for doi_prefix in ("https://doi.org/", "http://dx.doi.org/"):
            if doi.startswith(doi_prefix):
                doi = doi[len(doi_prefix) :]
                break

    return doi

model_validate classmethod ¤

model_validate(
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[
        ValidationContext, Mapping[str, Any], None
    ] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self

Validate a pydantic model instance.

PARAMETER DESCRIPTION

obj ¤

The object to validate.

TYPE: Union[Any, Mapping[str, Any]]

strict ¤

Whether to raise an exception on invalid fields.

TYPE: Optional[bool] DEFAULT: None

from_attributes ¤

Whether to extract data from object attributes.

TYPE: Optional[bool] DEFAULT: None

context ¤

Additional context to pass to the validator.

TYPE: Union[ValidationContext, Mapping[str, Any], None] DEFAULT: None

RAISES DESCRIPTION
ValidationError

If the object failed validation.

RETURNS DESCRIPTION
Self

The validated description instance.

Source code in src/bioimageio/spec/_internal/node.py
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
@classmethod
def model_validate(
    cls,
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[ValidationContext, Mapping[str, Any], None] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self:
    """Validate a pydantic model instance.

    Args:
        obj: The object to validate.
        strict: Whether to raise an exception on invalid fields.
        from_attributes: Whether to extract data from object attributes.
        context: Additional context to pass to the validator.

    Raises:
        ValidationError: If the object failed validation.

    Returns:
        The validated description instance.
    """
    __tracebackhide__ = True

    if context is None:
        context = get_validation_context()
    elif isinstance(context, collections.abc.Mapping):
        context = ValidationContext(**context)

    assert not isinstance(obj, collections.abc.Mapping) or is_kwargs(obj), obj

    with context:
        # use validation context as context manager for equal behavior of __init__ and model_validate
        return super().model_validate(
            obj, strict=strict, from_attributes=from_attributes
        )

ClipDescr pydantic-model ¤

Bases: ProcessingDescrBase

Clip tensor values to a range.

Set tensor values below ClipKwargs.min to ClipKwargs.min and above ClipKwargs.max to ClipKwargs.max.

Show JSON schema:
{
  "$defs": {
    "ClipKwargs": {
      "additionalProperties": false,
      "description": "key word arguments for `ClipDescr`",
      "properties": {
        "min": {
          "description": "minimum value for clipping",
          "title": "Min",
          "type": "number"
        },
        "max": {
          "description": "maximum value for clipping",
          "title": "Max",
          "type": "number"
        }
      },
      "required": [
        "min",
        "max"
      ],
      "title": "model.v0_4.ClipKwargs",
      "type": "object"
    }
  },
  "additionalProperties": false,
  "description": "Clip tensor values to a range.\n\nSet tensor values below `ClipKwargs.min` to `ClipKwargs.min`\nand above `ClipKwargs.max` to `ClipKwargs.max`.",
  "properties": {
    "name": {
      "const": "clip",
      "title": "Name",
      "type": "string"
    },
    "kwargs": {
      "$ref": "#/$defs/ClipKwargs"
    }
  },
  "required": [
    "name",
    "kwargs"
  ],
  "title": "model.v0_4.ClipDescr",
  "type": "object"
}

Fields:

implemented_name class-attribute ¤

implemented_name: Literal['clip'] = 'clip'

kwargs pydantic-field ¤

kwargs: ClipKwargs

name pydantic-field ¤

name: Literal['clip'] = 'clip'

__pydantic_init_subclass__ classmethod ¤

__pydantic_init_subclass__(**kwargs: Any) -> None
Source code in src/bioimageio/spec/_internal/common_nodes.py
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
@classmethod
def __pydantic_init_subclass__(cls, **kwargs: Any) -> None:
    explict_fields: Dict[str, Any] = {}
    for attr in dir(cls):
        if attr.startswith("implemented_"):
            field_name = attr.replace("implemented_", "")
            if field_name not in cls.model_fields:
                continue

            assert (
                cls.model_fields[field_name].get_default() is PydanticUndefined
            ), field_name
            default = getattr(cls, attr)
            explict_fields[field_name] = default

    cls._fields_to_set_explicitly = MappingProxyType(explict_fields)
    return super().__pydantic_init_subclass__(**kwargs)

model_validate classmethod ¤

model_validate(
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[
        ValidationContext, Mapping[str, Any], None
    ] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self

Validate a pydantic model instance.

PARAMETER DESCRIPTION

obj ¤

The object to validate.

TYPE: Union[Any, Mapping[str, Any]]

strict ¤

Whether to raise an exception on invalid fields.

TYPE: Optional[bool] DEFAULT: None

from_attributes ¤

Whether to extract data from object attributes.

TYPE: Optional[bool] DEFAULT: None

context ¤

Additional context to pass to the validator.

TYPE: Union[ValidationContext, Mapping[str, Any], None] DEFAULT: None

RAISES DESCRIPTION
ValidationError

If the object failed validation.

RETURNS DESCRIPTION
Self

The validated description instance.

Source code in src/bioimageio/spec/_internal/node.py
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
@classmethod
def model_validate(
    cls,
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[ValidationContext, Mapping[str, Any], None] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self:
    """Validate a pydantic model instance.

    Args:
        obj: The object to validate.
        strict: Whether to raise an exception on invalid fields.
        from_attributes: Whether to extract data from object attributes.
        context: Additional context to pass to the validator.

    Raises:
        ValidationError: If the object failed validation.

    Returns:
        The validated description instance.
    """
    __tracebackhide__ = True

    if context is None:
        context = get_validation_context()
    elif isinstance(context, collections.abc.Mapping):
        context = ValidationContext(**context)

    assert not isinstance(obj, collections.abc.Mapping) or is_kwargs(obj), obj

    with context:
        # use validation context as context manager for equal behavior of __init__ and model_validate
        return super().model_validate(
            obj, strict=strict, from_attributes=from_attributes
        )

ClipKwargs pydantic-model ¤

Bases: ProcessingKwargs

key word arguments for ClipDescr

Show JSON schema:
{
  "additionalProperties": false,
  "description": "key word arguments for `ClipDescr`",
  "properties": {
    "min": {
      "description": "minimum value for clipping",
      "title": "Min",
      "type": "number"
    },
    "max": {
      "description": "maximum value for clipping",
      "title": "Max",
      "type": "number"
    }
  },
  "required": [
    "min",
    "max"
  ],
  "title": "model.v0_4.ClipKwargs",
  "type": "object"
}

Fields:

max pydantic-field ¤

max: float

maximum value for clipping

min pydantic-field ¤

min: float

minimum value for clipping

__contains__ ¤

__contains__(item: str) -> bool
Source code in src/bioimageio/spec/_internal/common_nodes.py
425
426
def __contains__(self, item: str) -> bool:
    return item in self.__class__.model_fields

__getitem__ ¤

__getitem__(item: str) -> Any
Source code in src/bioimageio/spec/_internal/common_nodes.py
419
420
421
422
423
def __getitem__(self, item: str) -> Any:
    if item in self.__class__.model_fields:
        return getattr(self, item)
    else:
        raise KeyError(item)

get ¤

get(item: str, default: Any = None) -> Any
Source code in src/bioimageio/spec/_internal/common_nodes.py
416
417
def get(self, item: str, default: Any = None) -> Any:
    return self[item] if item in self else default

model_validate classmethod ¤

model_validate(
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[
        ValidationContext, Mapping[str, Any], None
    ] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self

Validate a pydantic model instance.

PARAMETER DESCRIPTION

obj ¤

The object to validate.

TYPE: Union[Any, Mapping[str, Any]]

strict ¤

Whether to raise an exception on invalid fields.

TYPE: Optional[bool] DEFAULT: None

from_attributes ¤

Whether to extract data from object attributes.

TYPE: Optional[bool] DEFAULT: None

context ¤

Additional context to pass to the validator.

TYPE: Union[ValidationContext, Mapping[str, Any], None] DEFAULT: None

RAISES DESCRIPTION
ValidationError

If the object failed validation.

RETURNS DESCRIPTION
Self

The validated description instance.

Source code in src/bioimageio/spec/_internal/node.py
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
@classmethod
def model_validate(
    cls,
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[ValidationContext, Mapping[str, Any], None] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self:
    """Validate a pydantic model instance.

    Args:
        obj: The object to validate.
        strict: Whether to raise an exception on invalid fields.
        from_attributes: Whether to extract data from object attributes.
        context: Additional context to pass to the validator.

    Raises:
        ValidationError: If the object failed validation.

    Returns:
        The validated description instance.
    """
    __tracebackhide__ = True

    if context is None:
        context = get_validation_context()
    elif isinstance(context, collections.abc.Mapping):
        context = ValidationContext(**context)

    assert not isinstance(obj, collections.abc.Mapping) or is_kwargs(obj), obj

    with context:
        # use validation context as context manager for equal behavior of __init__ and model_validate
        return super().model_validate(
            obj, strict=strict, from_attributes=from_attributes
        )

DatasetDescr pydantic-model ¤

Bases: GenericDescrBase

A bioimage.io dataset resource description file (dataset RDF) describes a dataset relevant to bioimage processing.

Show JSON schema:
{
  "$defs": {
    "AttachmentsDescr": {
      "additionalProperties": true,
      "properties": {
        "files": {
          "description": "File attachments",
          "items": {
            "anyOf": [
              {
                "description": "A URL with the HTTP or HTTPS scheme.",
                "format": "uri",
                "maxLength": 2083,
                "minLength": 1,
                "title": "HttpUrl",
                "type": "string"
              },
              {
                "$ref": "#/$defs/RelativeFilePath"
              },
              {
                "format": "file-path",
                "title": "FilePath",
                "type": "string"
              }
            ]
          },
          "title": "Files",
          "type": "array"
        }
      },
      "title": "generic.v0_2.AttachmentsDescr",
      "type": "object"
    },
    "Author": {
      "additionalProperties": false,
      "properties": {
        "affiliation": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Affiliation",
          "title": "Affiliation"
        },
        "email": {
          "anyOf": [
            {
              "format": "email",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Email",
          "title": "Email"
        },
        "orcid": {
          "anyOf": [
            {
              "description": "An ORCID identifier, see https://orcid.org/",
              "title": "OrcidId",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "An [ORCID iD](https://support.orcid.org/hc/en-us/sections/360001495313-What-is-ORCID\n) in hyphenated groups of 4 digits, (and [valid](\nhttps://support.orcid.org/hc/en-us/articles/360006897674-Structure-of-the-ORCID-Identifier\n) as per ISO 7064 11,2.)",
          "examples": [
            "0000-0001-2345-6789"
          ],
          "title": "Orcid"
        },
        "name": {
          "title": "Name",
          "type": "string"
        },
        "github_user": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Github User"
        }
      },
      "required": [
        "name"
      ],
      "title": "generic.v0_2.Author",
      "type": "object"
    },
    "BadgeDescr": {
      "additionalProperties": false,
      "description": "A custom badge",
      "properties": {
        "label": {
          "description": "badge label to display on hover",
          "examples": [
            "Open in Colab"
          ],
          "title": "Label",
          "type": "string"
        },
        "icon": {
          "anyOf": [
            {
              "format": "file-path",
              "title": "FilePath",
              "type": "string"
            },
            {
              "$ref": "#/$defs/RelativeFilePath"
            },
            {
              "description": "A URL with the HTTP or HTTPS scheme.",
              "format": "uri",
              "maxLength": 2083,
              "minLength": 1,
              "title": "HttpUrl",
              "type": "string"
            },
            {
              "format": "uri",
              "maxLength": 2083,
              "minLength": 1,
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "badge icon (included in bioimage.io package if not a URL)",
          "examples": [
            "https://colab.research.google.com/assets/colab-badge.svg"
          ],
          "title": "Icon"
        },
        "url": {
          "description": "target URL",
          "examples": [
            "https://colab.research.google.com/github/HenriquesLab/ZeroCostDL4Mic/blob/master/Colab_notebooks/U-net_2D_ZeroCostDL4Mic.ipynb"
          ],
          "format": "uri",
          "maxLength": 2083,
          "minLength": 1,
          "title": "HttpUrl",
          "type": "string"
        }
      },
      "required": [
        "label",
        "url"
      ],
      "title": "generic.v0_2.BadgeDescr",
      "type": "object"
    },
    "CiteEntry": {
      "additionalProperties": false,
      "properties": {
        "text": {
          "description": "free text description",
          "title": "Text",
          "type": "string"
        },
        "doi": {
          "anyOf": [
            {
              "description": "A digital object identifier, see https://www.doi.org/",
              "pattern": "^10\\.[0-9]{4}.+$",
              "title": "Doi",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "A digital object identifier (DOI) is the prefered citation reference.\nSee https://www.doi.org/ for details. (alternatively specify `url`)",
          "title": "Doi"
        },
        "url": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "URL to cite (preferably specify a `doi` instead)",
          "title": "Url"
        }
      },
      "required": [
        "text"
      ],
      "title": "generic.v0_2.CiteEntry",
      "type": "object"
    },
    "Maintainer": {
      "additionalProperties": false,
      "properties": {
        "affiliation": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Affiliation",
          "title": "Affiliation"
        },
        "email": {
          "anyOf": [
            {
              "format": "email",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Email",
          "title": "Email"
        },
        "orcid": {
          "anyOf": [
            {
              "description": "An ORCID identifier, see https://orcid.org/",
              "title": "OrcidId",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "An [ORCID iD](https://support.orcid.org/hc/en-us/sections/360001495313-What-is-ORCID\n) in hyphenated groups of 4 digits, (and [valid](\nhttps://support.orcid.org/hc/en-us/articles/360006897674-Structure-of-the-ORCID-Identifier\n) as per ISO 7064 11,2.)",
          "examples": [
            "0000-0001-2345-6789"
          ],
          "title": "Orcid"
        },
        "name": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Name"
        },
        "github_user": {
          "title": "Github User",
          "type": "string"
        }
      },
      "required": [
        "github_user"
      ],
      "title": "generic.v0_2.Maintainer",
      "type": "object"
    },
    "RelativeFilePath": {
      "description": "A path relative to the `rdf.yaml` file (also if the RDF source is a URL).",
      "format": "path",
      "title": "RelativeFilePath",
      "type": "string"
    },
    "Uploader": {
      "additionalProperties": false,
      "properties": {
        "email": {
          "description": "Email",
          "format": "email",
          "title": "Email",
          "type": "string"
        },
        "name": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "name",
          "title": "Name"
        }
      },
      "required": [
        "email"
      ],
      "title": "generic.v0_2.Uploader",
      "type": "object"
    },
    "Version": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "integer"
        },
        {
          "type": "number"
        }
      ],
      "description": "wraps a packaging.version.Version instance for validation in pydantic models",
      "title": "Version"
    },
    "YamlValue": {
      "anyOf": [
        {
          "type": "boolean"
        },
        {
          "format": "date",
          "type": "string"
        },
        {
          "format": "date-time",
          "type": "string"
        },
        {
          "type": "integer"
        },
        {
          "type": "number"
        },
        {
          "type": "string"
        },
        {
          "items": {
            "$ref": "#/$defs/YamlValue"
          },
          "type": "array"
        },
        {
          "additionalProperties": {
            "$ref": "#/$defs/YamlValue"
          },
          "type": "object"
        },
        {
          "type": "null"
        }
      ]
    }
  },
  "additionalProperties": false,
  "description": "A bioimage.io dataset resource description file (dataset RDF) describes a dataset relevant to bioimage\nprocessing.",
  "properties": {
    "name": {
      "description": "A human-friendly name of the resource description",
      "minLength": 1,
      "title": "Name",
      "type": "string"
    },
    "description": {
      "title": "Description",
      "type": "string"
    },
    "covers": {
      "description": "Cover images. Please use an image smaller than 500KB and an aspect ratio width to height of 2:1.\nThe supported image formats are: ('.gif', '.jpeg', '.jpg', '.png', '.svg', '.tif', '.tiff')",
      "examples": [
        [
          "cover.png"
        ]
      ],
      "items": {
        "anyOf": [
          {
            "description": "A URL with the HTTP or HTTPS scheme.",
            "format": "uri",
            "maxLength": 2083,
            "minLength": 1,
            "title": "HttpUrl",
            "type": "string"
          },
          {
            "$ref": "#/$defs/RelativeFilePath"
          },
          {
            "format": "file-path",
            "title": "FilePath",
            "type": "string"
          }
        ]
      },
      "title": "Covers",
      "type": "array"
    },
    "id_emoji": {
      "anyOf": [
        {
          "examples": [
            "\ud83e\udd88",
            "\ud83e\udda5"
          ],
          "maxLength": 1,
          "minLength": 1,
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "UTF-8 emoji for display alongside the `id`.",
      "title": "Id Emoji"
    },
    "authors": {
      "description": "The authors are the creators of the RDF and the primary points of contact.",
      "items": {
        "$ref": "#/$defs/Author"
      },
      "title": "Authors",
      "type": "array"
    },
    "attachments": {
      "anyOf": [
        {
          "$ref": "#/$defs/AttachmentsDescr"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "file and other attachments"
    },
    "cite": {
      "description": "citations",
      "items": {
        "$ref": "#/$defs/CiteEntry"
      },
      "title": "Cite",
      "type": "array"
    },
    "config": {
      "additionalProperties": {
        "$ref": "#/$defs/YamlValue"
      },
      "description": "A field for custom configuration that can contain any keys not present in the RDF spec.\nThis means you should not store, for example, a github repo URL in `config` since we already have the\n`git_repo` field defined in the spec.\nKeys in `config` may be very specific to a tool or consumer software. To avoid conflicting definitions,\nit is recommended to wrap added configuration into a sub-field named with the specific domain or tool name,\nfor example:\n```yaml\nconfig:\n    bioimageio:  # here is the domain name\n        my_custom_key: 3837283\n        another_key:\n            nested: value\n    imagej:       # config specific to ImageJ\n        macro_dir: path/to/macro/file\n```\nIf possible, please use [`snake_case`](https://en.wikipedia.org/wiki/Snake_case) for keys in `config`.\nYou may want to list linked files additionally under `attachments` to include them when packaging a resource\n(packaging a resource means downloading/copying important linked files and creating a ZIP archive that contains\nan altered rdf.yaml file with local references to the downloaded files)",
      "examples": [
        {
          "bioimageio": {
            "another_key": {
              "nested": "value"
            },
            "my_custom_key": 3837283
          },
          "imagej": {
            "macro_dir": "path/to/macro/file"
          }
        }
      ],
      "title": "Config",
      "type": "object"
    },
    "download_url": {
      "anyOf": [
        {
          "description": "A URL with the HTTP or HTTPS scheme.",
          "format": "uri",
          "maxLength": 2083,
          "minLength": 1,
          "title": "HttpUrl",
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "URL to download the resource from (deprecated)",
      "title": "Download Url"
    },
    "git_repo": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "A URL to the Git repository where the resource is being developed.",
      "examples": [
        "https://github.com/bioimage-io/spec-bioimage-io/tree/main/example_descriptions/models/unet2d_nuclei_broad"
      ],
      "title": "Git Repo"
    },
    "icon": {
      "anyOf": [
        {
          "maxLength": 2,
          "minLength": 1,
          "type": "string"
        },
        {
          "description": "A URL with the HTTP or HTTPS scheme.",
          "format": "uri",
          "maxLength": 2083,
          "minLength": 1,
          "title": "HttpUrl",
          "type": "string"
        },
        {
          "$ref": "#/$defs/RelativeFilePath"
        },
        {
          "format": "file-path",
          "title": "FilePath",
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "An icon for illustration",
      "title": "Icon"
    },
    "links": {
      "description": "IDs of other bioimage.io resources",
      "examples": [
        [
          "ilastik/ilastik",
          "deepimagej/deepimagej",
          "zero/notebook_u-net_3d_zerocostdl4mic"
        ]
      ],
      "items": {
        "type": "string"
      },
      "title": "Links",
      "type": "array"
    },
    "uploader": {
      "anyOf": [
        {
          "$ref": "#/$defs/Uploader"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "The person who uploaded the model (e.g. to bioimage.io)"
    },
    "maintainers": {
      "description": "Maintainers of this resource.\nIf not specified `authors` are maintainers and at least some of them should specify their `github_user` name",
      "items": {
        "$ref": "#/$defs/Maintainer"
      },
      "title": "Maintainers",
      "type": "array"
    },
    "rdf_source": {
      "anyOf": [
        {
          "description": "A URL with the HTTP or HTTPS scheme.",
          "format": "uri",
          "maxLength": 2083,
          "minLength": 1,
          "title": "HttpUrl",
          "type": "string"
        },
        {
          "$ref": "#/$defs/RelativeFilePath"
        },
        {
          "format": "file-path",
          "title": "FilePath",
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Resource description file (RDF) source; used to keep track of where an rdf.yaml was loaded from.\nDo not set this field in a YAML file.",
      "title": "Rdf Source"
    },
    "tags": {
      "description": "Associated tags",
      "examples": [
        [
          "unet2d",
          "pytorch",
          "nucleus",
          "segmentation",
          "dsb2018"
        ]
      ],
      "items": {
        "type": "string"
      },
      "title": "Tags",
      "type": "array"
    },
    "version": {
      "anyOf": [
        {
          "$ref": "#/$defs/Version"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "The version of the resource following SemVer 2.0."
    },
    "version_number": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "version number (n-th published version, not the semantic version)",
      "title": "Version Number"
    },
    "format_version": {
      "const": "0.2.4",
      "description": "The format version of this resource specification\n(not the `version` of the resource description)\nWhen creating a new resource always use the latest micro/patch version described here.\nThe `format_version` is important for any consumer software to understand how to parse the fields.",
      "title": "Format Version",
      "type": "string"
    },
    "badges": {
      "description": "badges associated with this resource",
      "items": {
        "$ref": "#/$defs/BadgeDescr"
      },
      "title": "Badges",
      "type": "array"
    },
    "documentation": {
      "anyOf": [
        {
          "description": "A URL with the HTTP or HTTPS scheme.",
          "format": "uri",
          "maxLength": 2083,
          "minLength": 1,
          "title": "HttpUrl",
          "type": "string"
        },
        {
          "$ref": "#/$defs/RelativeFilePath"
        },
        {
          "format": "file-path",
          "title": "FilePath",
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "URL or relative path to a markdown file with additional documentation.\nThe recommended documentation file name is `README.md`. An `.md` suffix is mandatory.",
      "examples": [
        "https://raw.githubusercontent.com/bioimage-io/spec-bioimage-io/main/example_descriptions/models/unet2d_nuclei_broad/README.md",
        "README.md"
      ],
      "title": "Documentation"
    },
    "license": {
      "anyOf": [
        {
          "enum": [
            "0BSD",
            "AAL",
            "Abstyles",
            "AdaCore-doc",
            "Adobe-2006",
            "Adobe-Display-PostScript",
            "Adobe-Glyph",
            "Adobe-Utopia",
            "ADSL",
            "AFL-1.1",
            "AFL-1.2",
            "AFL-2.0",
            "AFL-2.1",
            "AFL-3.0",
            "Afmparse",
            "AGPL-1.0-only",
            "AGPL-1.0-or-later",
            "AGPL-3.0-only",
            "AGPL-3.0-or-later",
            "Aladdin",
            "AMDPLPA",
            "AML",
            "AML-glslang",
            "AMPAS",
            "ANTLR-PD",
            "ANTLR-PD-fallback",
            "Apache-1.0",
            "Apache-1.1",
            "Apache-2.0",
            "APAFML",
            "APL-1.0",
            "App-s2p",
            "APSL-1.0",
            "APSL-1.1",
            "APSL-1.2",
            "APSL-2.0",
            "Arphic-1999",
            "Artistic-1.0",
            "Artistic-1.0-cl8",
            "Artistic-1.0-Perl",
            "Artistic-2.0",
            "ASWF-Digital-Assets-1.0",
            "ASWF-Digital-Assets-1.1",
            "Baekmuk",
            "Bahyph",
            "Barr",
            "bcrypt-Solar-Designer",
            "Beerware",
            "Bitstream-Charter",
            "Bitstream-Vera",
            "BitTorrent-1.0",
            "BitTorrent-1.1",
            "blessing",
            "BlueOak-1.0.0",
            "Boehm-GC",
            "Borceux",
            "Brian-Gladman-2-Clause",
            "Brian-Gladman-3-Clause",
            "BSD-1-Clause",
            "BSD-2-Clause",
            "BSD-2-Clause-Darwin",
            "BSD-2-Clause-Patent",
            "BSD-2-Clause-Views",
            "BSD-3-Clause",
            "BSD-3-Clause-acpica",
            "BSD-3-Clause-Attribution",
            "BSD-3-Clause-Clear",
            "BSD-3-Clause-flex",
            "BSD-3-Clause-HP",
            "BSD-3-Clause-LBNL",
            "BSD-3-Clause-Modification",
            "BSD-3-Clause-No-Military-License",
            "BSD-3-Clause-No-Nuclear-License",
            "BSD-3-Clause-No-Nuclear-License-2014",
            "BSD-3-Clause-No-Nuclear-Warranty",
            "BSD-3-Clause-Open-MPI",
            "BSD-3-Clause-Sun",
            "BSD-4-Clause",
            "BSD-4-Clause-Shortened",
            "BSD-4-Clause-UC",
            "BSD-4.3RENO",
            "BSD-4.3TAHOE",
            "BSD-Advertising-Acknowledgement",
            "BSD-Attribution-HPND-disclaimer",
            "BSD-Inferno-Nettverk",
            "BSD-Protection",
            "BSD-Source-beginning-file",
            "BSD-Source-Code",
            "BSD-Systemics",
            "BSD-Systemics-W3Works",
            "BSL-1.0",
            "BUSL-1.1",
            "bzip2-1.0.6",
            "C-UDA-1.0",
            "CAL-1.0",
            "CAL-1.0-Combined-Work-Exception",
            "Caldera",
            "Caldera-no-preamble",
            "CATOSL-1.1",
            "CC-BY-1.0",
            "CC-BY-2.0",
            "CC-BY-2.5",
            "CC-BY-2.5-AU",
            "CC-BY-3.0",
            "CC-BY-3.0-AT",
            "CC-BY-3.0-AU",
            "CC-BY-3.0-DE",
            "CC-BY-3.0-IGO",
            "CC-BY-3.0-NL",
            "CC-BY-3.0-US",
            "CC-BY-4.0",
            "CC-BY-NC-1.0",
            "CC-BY-NC-2.0",
            "CC-BY-NC-2.5",
            "CC-BY-NC-3.0",
            "CC-BY-NC-3.0-DE",
            "CC-BY-NC-4.0",
            "CC-BY-NC-ND-1.0",
            "CC-BY-NC-ND-2.0",
            "CC-BY-NC-ND-2.5",
            "CC-BY-NC-ND-3.0",
            "CC-BY-NC-ND-3.0-DE",
            "CC-BY-NC-ND-3.0-IGO",
            "CC-BY-NC-ND-4.0",
            "CC-BY-NC-SA-1.0",
            "CC-BY-NC-SA-2.0",
            "CC-BY-NC-SA-2.0-DE",
            "CC-BY-NC-SA-2.0-FR",
            "CC-BY-NC-SA-2.0-UK",
            "CC-BY-NC-SA-2.5",
            "CC-BY-NC-SA-3.0",
            "CC-BY-NC-SA-3.0-DE",
            "CC-BY-NC-SA-3.0-IGO",
            "CC-BY-NC-SA-4.0",
            "CC-BY-ND-1.0",
            "CC-BY-ND-2.0",
            "CC-BY-ND-2.5",
            "CC-BY-ND-3.0",
            "CC-BY-ND-3.0-DE",
            "CC-BY-ND-4.0",
            "CC-BY-SA-1.0",
            "CC-BY-SA-2.0",
            "CC-BY-SA-2.0-UK",
            "CC-BY-SA-2.1-JP",
            "CC-BY-SA-2.5",
            "CC-BY-SA-3.0",
            "CC-BY-SA-3.0-AT",
            "CC-BY-SA-3.0-DE",
            "CC-BY-SA-3.0-IGO",
            "CC-BY-SA-4.0",
            "CC-PDDC",
            "CC0-1.0",
            "CDDL-1.0",
            "CDDL-1.1",
            "CDL-1.0",
            "CDLA-Permissive-1.0",
            "CDLA-Permissive-2.0",
            "CDLA-Sharing-1.0",
            "CECILL-1.0",
            "CECILL-1.1",
            "CECILL-2.0",
            "CECILL-2.1",
            "CECILL-B",
            "CECILL-C",
            "CERN-OHL-1.1",
            "CERN-OHL-1.2",
            "CERN-OHL-P-2.0",
            "CERN-OHL-S-2.0",
            "CERN-OHL-W-2.0",
            "CFITSIO",
            "check-cvs",
            "checkmk",
            "ClArtistic",
            "Clips",
            "CMU-Mach",
            "CMU-Mach-nodoc",
            "CNRI-Jython",
            "CNRI-Python",
            "CNRI-Python-GPL-Compatible",
            "COIL-1.0",
            "Community-Spec-1.0",
            "Condor-1.1",
            "copyleft-next-0.3.0",
            "copyleft-next-0.3.1",
            "Cornell-Lossless-JPEG",
            "CPAL-1.0",
            "CPL-1.0",
            "CPOL-1.02",
            "Cronyx",
            "Crossword",
            "CrystalStacker",
            "CUA-OPL-1.0",
            "Cube",
            "curl",
            "D-FSL-1.0",
            "DEC-3-Clause",
            "diffmark",
            "DL-DE-BY-2.0",
            "DL-DE-ZERO-2.0",
            "DOC",
            "Dotseqn",
            "DRL-1.0",
            "DRL-1.1",
            "DSDP",
            "dtoa",
            "dvipdfm",
            "ECL-1.0",
            "ECL-2.0",
            "EFL-1.0",
            "EFL-2.0",
            "eGenix",
            "Elastic-2.0",
            "Entessa",
            "EPICS",
            "EPL-1.0",
            "EPL-2.0",
            "ErlPL-1.1",
            "etalab-2.0",
            "EUDatagrid",
            "EUPL-1.0",
            "EUPL-1.1",
            "EUPL-1.2",
            "Eurosym",
            "Fair",
            "FBM",
            "FDK-AAC",
            "Ferguson-Twofish",
            "Frameworx-1.0",
            "FreeBSD-DOC",
            "FreeImage",
            "FSFAP",
            "FSFAP-no-warranty-disclaimer",
            "FSFUL",
            "FSFULLR",
            "FSFULLRWD",
            "FTL",
            "Furuseth",
            "fwlw",
            "GCR-docs",
            "GD",
            "GFDL-1.1-invariants-only",
            "GFDL-1.1-invariants-or-later",
            "GFDL-1.1-no-invariants-only",
            "GFDL-1.1-no-invariants-or-later",
            "GFDL-1.1-only",
            "GFDL-1.1-or-later",
            "GFDL-1.2-invariants-only",
            "GFDL-1.2-invariants-or-later",
            "GFDL-1.2-no-invariants-only",
            "GFDL-1.2-no-invariants-or-later",
            "GFDL-1.2-only",
            "GFDL-1.2-or-later",
            "GFDL-1.3-invariants-only",
            "GFDL-1.3-invariants-or-later",
            "GFDL-1.3-no-invariants-only",
            "GFDL-1.3-no-invariants-or-later",
            "GFDL-1.3-only",
            "GFDL-1.3-or-later",
            "Giftware",
            "GL2PS",
            "Glide",
            "Glulxe",
            "GLWTPL",
            "gnuplot",
            "GPL-1.0-only",
            "GPL-1.0-or-later",
            "GPL-2.0-only",
            "GPL-2.0-or-later",
            "GPL-3.0-only",
            "GPL-3.0-or-later",
            "Graphics-Gems",
            "gSOAP-1.3b",
            "gtkbook",
            "HaskellReport",
            "hdparm",
            "Hippocratic-2.1",
            "HP-1986",
            "HP-1989",
            "HPND",
            "HPND-DEC",
            "HPND-doc",
            "HPND-doc-sell",
            "HPND-export-US",
            "HPND-export-US-modify",
            "HPND-Fenneberg-Livingston",
            "HPND-INRIA-IMAG",
            "HPND-Kevlin-Henney",
            "HPND-Markus-Kuhn",
            "HPND-MIT-disclaimer",
            "HPND-Pbmplus",
            "HPND-sell-MIT-disclaimer-xserver",
            "HPND-sell-regexpr",
            "HPND-sell-variant",
            "HPND-sell-variant-MIT-disclaimer",
            "HPND-UC",
            "HTMLTIDY",
            "IBM-pibs",
            "ICU",
            "IEC-Code-Components-EULA",
            "IJG",
            "IJG-short",
            "ImageMagick",
            "iMatix",
            "Imlib2",
            "Info-ZIP",
            "Inner-Net-2.0",
            "Intel",
            "Intel-ACPI",
            "Interbase-1.0",
            "IPA",
            "IPL-1.0",
            "ISC",
            "ISC-Veillard",
            "Jam",
            "JasPer-2.0",
            "JPL-image",
            "JPNIC",
            "JSON",
            "Kastrup",
            "Kazlib",
            "Knuth-CTAN",
            "LAL-1.2",
            "LAL-1.3",
            "Latex2e",
            "Latex2e-translated-notice",
            "Leptonica",
            "LGPL-2.0-only",
            "LGPL-2.0-or-later",
            "LGPL-2.1-only",
            "LGPL-2.1-or-later",
            "LGPL-3.0-only",
            "LGPL-3.0-or-later",
            "LGPLLR",
            "Libpng",
            "libpng-2.0",
            "libselinux-1.0",
            "libtiff",
            "libutil-David-Nugent",
            "LiLiQ-P-1.1",
            "LiLiQ-R-1.1",
            "LiLiQ-Rplus-1.1",
            "Linux-man-pages-1-para",
            "Linux-man-pages-copyleft",
            "Linux-man-pages-copyleft-2-para",
            "Linux-man-pages-copyleft-var",
            "Linux-OpenIB",
            "LOOP",
            "LPD-document",
            "LPL-1.0",
            "LPL-1.02",
            "LPPL-1.0",
            "LPPL-1.1",
            "LPPL-1.2",
            "LPPL-1.3a",
            "LPPL-1.3c",
            "lsof",
            "Lucida-Bitmap-Fonts",
            "LZMA-SDK-9.11-to-9.20",
            "LZMA-SDK-9.22",
            "Mackerras-3-Clause",
            "Mackerras-3-Clause-acknowledgment",
            "magaz",
            "mailprio",
            "MakeIndex",
            "Martin-Birgmeier",
            "McPhee-slideshow",
            "metamail",
            "Minpack",
            "MirOS",
            "MIT",
            "MIT-0",
            "MIT-advertising",
            "MIT-CMU",
            "MIT-enna",
            "MIT-feh",
            "MIT-Festival",
            "MIT-Modern-Variant",
            "MIT-open-group",
            "MIT-testregex",
            "MIT-Wu",
            "MITNFA",
            "MMIXware",
            "Motosoto",
            "MPEG-SSG",
            "mpi-permissive",
            "mpich2",
            "MPL-1.0",
            "MPL-1.1",
            "MPL-2.0",
            "MPL-2.0-no-copyleft-exception",
            "mplus",
            "MS-LPL",
            "MS-PL",
            "MS-RL",
            "MTLL",
            "MulanPSL-1.0",
            "MulanPSL-2.0",
            "Multics",
            "Mup",
            "NAIST-2003",
            "NASA-1.3",
            "Naumen",
            "NBPL-1.0",
            "NCGL-UK-2.0",
            "NCSA",
            "Net-SNMP",
            "NetCDF",
            "Newsletr",
            "NGPL",
            "NICTA-1.0",
            "NIST-PD",
            "NIST-PD-fallback",
            "NIST-Software",
            "NLOD-1.0",
            "NLOD-2.0",
            "NLPL",
            "Nokia",
            "NOSL",
            "Noweb",
            "NPL-1.0",
            "NPL-1.1",
            "NPOSL-3.0",
            "NRL",
            "NTP",
            "NTP-0",
            "O-UDA-1.0",
            "OCCT-PL",
            "OCLC-2.0",
            "ODbL-1.0",
            "ODC-By-1.0",
            "OFFIS",
            "OFL-1.0",
            "OFL-1.0-no-RFN",
            "OFL-1.0-RFN",
            "OFL-1.1",
            "OFL-1.1-no-RFN",
            "OFL-1.1-RFN",
            "OGC-1.0",
            "OGDL-Taiwan-1.0",
            "OGL-Canada-2.0",
            "OGL-UK-1.0",
            "OGL-UK-2.0",
            "OGL-UK-3.0",
            "OGTSL",
            "OLDAP-1.1",
            "OLDAP-1.2",
            "OLDAP-1.3",
            "OLDAP-1.4",
            "OLDAP-2.0",
            "OLDAP-2.0.1",
            "OLDAP-2.1",
            "OLDAP-2.2",
            "OLDAP-2.2.1",
            "OLDAP-2.2.2",
            "OLDAP-2.3",
            "OLDAP-2.4",
            "OLDAP-2.5",
            "OLDAP-2.6",
            "OLDAP-2.7",
            "OLDAP-2.8",
            "OLFL-1.3",
            "OML",
            "OpenPBS-2.3",
            "OpenSSL",
            "OpenSSL-standalone",
            "OpenVision",
            "OPL-1.0",
            "OPL-UK-3.0",
            "OPUBL-1.0",
            "OSET-PL-2.1",
            "OSL-1.0",
            "OSL-1.1",
            "OSL-2.0",
            "OSL-2.1",
            "OSL-3.0",
            "PADL",
            "Parity-6.0.0",
            "Parity-7.0.0",
            "PDDL-1.0",
            "PHP-3.0",
            "PHP-3.01",
            "Pixar",
            "Plexus",
            "pnmstitch",
            "PolyForm-Noncommercial-1.0.0",
            "PolyForm-Small-Business-1.0.0",
            "PostgreSQL",
            "PSF-2.0",
            "psfrag",
            "psutils",
            "Python-2.0",
            "Python-2.0.1",
            "python-ldap",
            "Qhull",
            "QPL-1.0",
            "QPL-1.0-INRIA-2004",
            "radvd",
            "Rdisc",
            "RHeCos-1.1",
            "RPL-1.1",
            "RPL-1.5",
            "RPSL-1.0",
            "RSA-MD",
            "RSCPL",
            "Ruby",
            "SAX-PD",
            "SAX-PD-2.0",
            "Saxpath",
            "SCEA",
            "SchemeReport",
            "Sendmail",
            "Sendmail-8.23",
            "SGI-B-1.0",
            "SGI-B-1.1",
            "SGI-B-2.0",
            "SGI-OpenGL",
            "SGP4",
            "SHL-0.5",
            "SHL-0.51",
            "SimPL-2.0",
            "SISSL",
            "SISSL-1.2",
            "SL",
            "Sleepycat",
            "SMLNJ",
            "SMPPL",
            "SNIA",
            "snprintf",
            "softSurfer",
            "Soundex",
            "Spencer-86",
            "Spencer-94",
            "Spencer-99",
            "SPL-1.0",
            "ssh-keyscan",
            "SSH-OpenSSH",
            "SSH-short",
            "SSLeay-standalone",
            "SSPL-1.0",
            "SugarCRM-1.1.3",
            "Sun-PPP",
            "SunPro",
            "SWL",
            "swrule",
            "Symlinks",
            "TAPR-OHL-1.0",
            "TCL",
            "TCP-wrappers",
            "TermReadKey",
            "TGPPL-1.0",
            "TMate",
            "TORQUE-1.1",
            "TOSL",
            "TPDL",
            "TPL-1.0",
            "TTWL",
            "TTYP0",
            "TU-Berlin-1.0",
            "TU-Berlin-2.0",
            "UCAR",
            "UCL-1.0",
            "ulem",
            "UMich-Merit",
            "Unicode-3.0",
            "Unicode-DFS-2015",
            "Unicode-DFS-2016",
            "Unicode-TOU",
            "UnixCrypt",
            "Unlicense",
            "UPL-1.0",
            "URT-RLE",
            "Vim",
            "VOSTROM",
            "VSL-1.0",
            "W3C",
            "W3C-19980720",
            "W3C-20150513",
            "w3m",
            "Watcom-1.0",
            "Widget-Workshop",
            "Wsuipa",
            "WTFPL",
            "X11",
            "X11-distribute-modifications-variant",
            "Xdebug-1.03",
            "Xerox",
            "Xfig",
            "XFree86-1.1",
            "xinetd",
            "xkeyboard-config-Zinoviev",
            "xlock",
            "Xnet",
            "xpp",
            "XSkat",
            "YPL-1.0",
            "YPL-1.1",
            "Zed",
            "Zeeff",
            "Zend-2.0",
            "Zimbra-1.3",
            "Zimbra-1.4",
            "Zlib",
            "zlib-acknowledgement",
            "ZPL-1.1",
            "ZPL-2.0",
            "ZPL-2.1"
          ],
          "title": "LicenseId",
          "type": "string"
        },
        {
          "enum": [
            "AGPL-1.0",
            "AGPL-3.0",
            "BSD-2-Clause-FreeBSD",
            "BSD-2-Clause-NetBSD",
            "bzip2-1.0.5",
            "eCos-2.0",
            "GFDL-1.1",
            "GFDL-1.2",
            "GFDL-1.3",
            "GPL-1.0",
            "GPL-1.0+",
            "GPL-2.0",
            "GPL-2.0+",
            "GPL-2.0-with-autoconf-exception",
            "GPL-2.0-with-bison-exception",
            "GPL-2.0-with-classpath-exception",
            "GPL-2.0-with-font-exception",
            "GPL-2.0-with-GCC-exception",
            "GPL-3.0",
            "GPL-3.0+",
            "GPL-3.0-with-autoconf-exception",
            "GPL-3.0-with-GCC-exception",
            "LGPL-2.0",
            "LGPL-2.0+",
            "LGPL-2.1",
            "LGPL-2.1+",
            "LGPL-3.0",
            "LGPL-3.0+",
            "Nunit",
            "StandardML-NJ",
            "wxWindows"
          ],
          "title": "DeprecatedLicenseId",
          "type": "string"
        },
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "A [SPDX license identifier](https://spdx.org/licenses/).\nWe do not support custom license beyond the SPDX license list, if you need that please\n[open a GitHub issue](https://github.com/bioimage-io/spec-bioimage-io/issues/new/choose\n) to discuss your intentions with the community.",
      "examples": [
        "CC0-1.0",
        "MIT",
        "BSD-2-Clause"
      ],
      "title": "License"
    },
    "type": {
      "const": "dataset",
      "title": "Type",
      "type": "string"
    },
    "id": {
      "anyOf": [
        {
          "minLength": 1,
          "title": "DatasetId",
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "bioimage.io-wide unique resource identifier\nassigned by bioimage.io; version **un**specific.",
      "title": "Id"
    },
    "source": {
      "anyOf": [
        {
          "description": "A URL with the HTTP or HTTPS scheme.",
          "format": "uri",
          "maxLength": 2083,
          "minLength": 1,
          "title": "HttpUrl",
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "\"URL to the source of the dataset.",
      "title": "Source"
    }
  },
  "required": [
    "name",
    "description",
    "format_version",
    "type"
  ],
  "title": "dataset 0.2.4",
  "type": "object"
}

Fields:

attachments pydantic-field ¤

attachments: Optional[AttachmentsDescr] = None

file and other attachments

authors pydantic-field ¤

authors: List[Author]

The authors are the creators of the RDF and the primary points of contact.

badges pydantic-field ¤

badges: List[BadgeDescr]

badges associated with this resource

cite pydantic-field ¤

cite: List[CiteEntry]

citations

config pydantic-field ¤

config: Dict[str, YamlValue]

A field for custom configuration that can contain any keys not present in the RDF spec. This means you should not store, for example, a github repo URL in config since we already have the git_repo field defined in the spec. Keys in config may be very specific to a tool or consumer software. To avoid conflicting definitions, it is recommended to wrap added configuration into a sub-field named with the specific domain or tool name, for example:

config:
    bioimageio:  # here is the domain name
        my_custom_key: 3837283
        another_key:
            nested: value
    imagej:       # config specific to ImageJ
        macro_dir: path/to/macro/file
If possible, please use snake_case for keys in config. You may want to list linked files additionally under attachments to include them when packaging a resource (packaging a resource means downloading/copying important linked files and creating a ZIP archive that contains an altered rdf.yaml file with local references to the downloaded files)

covers pydantic-field ¤

covers: List[FileSource_cover]

Cover images. Please use an image smaller than 500KB and an aspect ratio width to height of 2:1.

description pydantic-field ¤

description: str

documentation pydantic-field ¤

documentation: Optional[FileSource] = None

URL or relative path to a markdown file with additional documentation. The recommended documentation file name is README.md. An .md suffix is mandatory.

download_url pydantic-field ¤

download_url: Optional[HttpUrl] = None

URL to download the resource from (deprecated)

file_name property ¤

file_name: Optional[FileName]

File name of the bioimageio.yaml file the description was loaded from.

format_version pydantic-field ¤

format_version: Literal['0.2.4'] = '0.2.4'

git_repo pydantic-field ¤

git_repo: Optional[str] = None

A URL to the Git repository where the resource is being developed.

icon pydantic-field ¤

icon: Union[str, FileSource, None] = None

An icon for illustration

id pydantic-field ¤

id: Optional[DatasetId] = None

bioimage.io-wide unique resource identifier assigned by bioimage.io; version unspecific.

id_emoji pydantic-field ¤

id_emoji: Optional[str] = None

UTF-8 emoji for display alongside the id.

implemented_format_version class-attribute ¤

implemented_format_version: Literal['0.2.4'] = '0.2.4'

implemented_format_version_tuple class-attribute ¤

implemented_format_version_tuple: Tuple[int, int, int]

implemented_type class-attribute ¤

implemented_type: Literal['dataset'] = 'dataset'

license pydantic-field ¤

license: Union[
    LicenseId, DeprecatedLicenseId, str, None
] = None

A SPDX license identifier. We do not support custom license beyond the SPDX license list, if you need that please open a GitHub issue to discuss your intentions with the community.

links: List[str]

IDs of other bioimage.io resources

maintainers pydantic-field ¤

maintainers: List[Maintainer]

Maintainers of this resource. If not specified authors are maintainers and at least some of them should specify their github_user name

name pydantic-field ¤

name: NotEmpty[str]

A human-friendly name of the resource description

rdf_source pydantic-field ¤

rdf_source: Optional[FileSource] = None

Resource description file (RDF) source; used to keep track of where an rdf.yaml was loaded from. Do not set this field in a YAML file.

root property ¤

root: Union[RootHttpUrl, DirectoryPath, ZipFile]

The URL/Path prefix to resolve any relative paths with.

source pydantic-field ¤

source: Optional[HttpUrl] = None

"URL to the source of the dataset.

tags pydantic-field ¤

tags: List[str]

Associated tags

type pydantic-field ¤

type: Literal['dataset'] = 'dataset'

uploader pydantic-field ¤

uploader: Optional[Uploader] = None

The person who uploaded the model (e.g. to bioimage.io)

validation_summary property ¤

validation_summary: ValidationSummary

version pydantic-field ¤

version: Optional[Version] = None

The version of the resource following SemVer 2.0.

version_number pydantic-field ¤

version_number: Optional[int] = None

version number (n-th published version, not the semantic version)

__pydantic_init_subclass__ classmethod ¤

__pydantic_init_subclass__(**kwargs: Any)
Source code in src/bioimageio/spec/_internal/common_nodes.py
199
200
201
202
203
204
205
206
207
208
209
210
211
@classmethod
def __pydantic_init_subclass__(cls, **kwargs: Any):
    super().__pydantic_init_subclass__(**kwargs)
    # set classvar implemented_format_version_tuple
    if "format_version" in cls.model_fields:
        if "." not in cls.implemented_format_version:
            cls.implemented_format_version_tuple = (0, 0, 0)
        else:
            fv_tuple = get_format_version_tuple(cls.implemented_format_version)
            assert fv_tuple is not None, (
                f"failed to cast '{cls.implemented_format_version}' to tuple"
            )
            cls.implemented_format_version_tuple = fv_tuple

accept_author_strings classmethod ¤

accept_author_strings(
    authors: Union[Any, Sequence[Any]],
) -> Any

we unofficially accept strings as author entries

Source code in src/bioimageio/spec/generic/v0_2.py
245
246
247
248
249
250
251
252
253
254
255
@field_validator("authors", mode="before")
@classmethod
def accept_author_strings(cls, authors: Union[Any, Sequence[Any]]) -> Any:
    """we unofficially accept strings as author entries"""
    if is_sequence(authors):
        authors = [{"name": a} if isinstance(a, str) else a for a in authors]

    if not authors:
        issue_warning("missing", value=authors, field="authors")

    return authors

deprecated_spdx_license classmethod ¤

deprecated_spdx_license(
    value: Optional[
        Union[LicenseId, DeprecatedLicenseId, str]
    ],
)
Source code in src/bioimageio/spec/generic/v0_2.py
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
@field_validator("license", mode="after")
@classmethod
def deprecated_spdx_license(
    cls, value: Optional[Union[LicenseId, DeprecatedLicenseId, str]]
):
    if isinstance(value, LicenseId):
        pass
    elif value is None:
        issue_warning("missing", value=value, field="license")
    elif isinstance(value, DeprecatedLicenseId):
        issue_warning(
            "'{value}' is a deprecated license identifier.",
            value=value,
            field="license",
        )
    elif isinstance(value, str):
        issue_warning(
            "'{value}' is an unknown license identifier.",
            value=value,
            field="license",
        )
    else:
        assert_never(value)

    return value

get_package_content ¤

get_package_content() -> Dict[
    FileName, Union[FileDescr, BioimageioYamlContent]
]

Returns package content without creating the package.

Source code in src/bioimageio/spec/_internal/common_nodes.py
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
def get_package_content(
    self,
) -> Dict[FileName, Union[FileDescr, BioimageioYamlContent]]:
    """Returns package content without creating the package."""
    content: Dict[FileName, FileDescr] = {}
    with PackagingContext(
        bioimageio_yaml_file_name=BIOIMAGEIO_YAML,
        file_sources=content,
    ):
        rdf_content: BioimageioYamlContent = self.model_dump(
            mode="json", exclude_unset=True
        )

    _ = rdf_content.pop("rdf_source", None)

    return {**content, BIOIMAGEIO_YAML: rdf_content}

load classmethod ¤

load(
    data: BioimageioYamlContentView,
    context: Optional[ValidationContext] = None,
) -> Union[Self, InvalidDescr]

factory method to create a resource description object

Source code in src/bioimageio/spec/_internal/common_nodes.py
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
@classmethod
def load(
    cls,
    data: BioimageioYamlContentView,
    context: Optional[ValidationContext] = None,
) -> Union[Self, InvalidDescr]:
    """factory method to create a resource description object"""
    context = context or get_validation_context()
    if context.perform_io_checks:
        file_descrs = extract_file_descrs({k: v for k, v in data.items()})
        populate_cache(file_descrs)  # TODO: add progress bar

    with context.replace(log_warnings=context.warning_level <= INFO):
        rd, errors, val_warnings = cls._load_impl(deepcopy_yaml_value(data))

    if context.warning_level > INFO:
        all_warnings_context = context.replace(
            warning_level=INFO, log_warnings=False, raise_errors=False
        )
        # raise all validation warnings by reloading
        with all_warnings_context:
            _, _, val_warnings = cls._load_impl(deepcopy_yaml_value(data))

    format_status = "failed" if errors else "passed"
    rd.validation_summary.add_detail(
        ValidationDetail(
            errors=errors,
            name=(
                "bioimageio.spec format validation"
                f" {rd.type} {cls.implemented_format_version}"
            ),
            status=format_status,
            warnings=val_warnings,
        ),
        update_status=False,  # avoid updating status from 'valid-format' to 'passed', but ...
    )
    if format_status == "failed":
        # ... update status in case of failure
        rd.validation_summary.status = "failed"

    return rd

model_validate classmethod ¤

model_validate(
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[
        ValidationContext, Mapping[str, Any], None
    ] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self

Validate a pydantic model instance.

PARAMETER DESCRIPTION

obj ¤

The object to validate.

TYPE: Union[Any, Mapping[str, Any]]

strict ¤

Whether to raise an exception on invalid fields.

TYPE: Optional[bool] DEFAULT: None

from_attributes ¤

Whether to extract data from object attributes.

TYPE: Optional[bool] DEFAULT: None

context ¤

Additional context to pass to the validator.

TYPE: Union[ValidationContext, Mapping[str, Any], None] DEFAULT: None

RAISES DESCRIPTION
ValidationError

If the object failed validation.

RETURNS DESCRIPTION
Self

The validated description instance.

Source code in src/bioimageio/spec/_internal/node.py
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
@classmethod
def model_validate(
    cls,
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[ValidationContext, Mapping[str, Any], None] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self:
    """Validate a pydantic model instance.

    Args:
        obj: The object to validate.
        strict: Whether to raise an exception on invalid fields.
        from_attributes: Whether to extract data from object attributes.
        context: Additional context to pass to the validator.

    Raises:
        ValidationError: If the object failed validation.

    Returns:
        The validated description instance.
    """
    __tracebackhide__ = True

    if context is None:
        context = get_validation_context()
    elif isinstance(context, collections.abc.Mapping):
        context = ValidationContext(**context)

    assert not isinstance(obj, collections.abc.Mapping) or is_kwargs(obj), obj

    with context:
        # use validation context as context manager for equal behavior of __init__ and model_validate
        return super().model_validate(
            obj, strict=strict, from_attributes=from_attributes
        )

package ¤

package(
    dest: Optional[
        Union[ZipFile, IO[bytes], Path, str]
    ] = None,
) -> ZipFile

package the described resource as a zip archive

PARAMETER DESCRIPTION

dest ¤

(path/bytes stream of) destination zipfile

TYPE: Optional[Union[ZipFile, IO[bytes], Path, str]] DEFAULT: None

Source code in src/bioimageio/spec/_internal/common_nodes.py
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
def package(
    self, dest: Optional[Union[ZipFile, IO[bytes], Path, str]] = None, /
) -> ZipFile:
    """package the described resource as a zip archive

    Args:
        dest: (path/bytes stream of) destination zipfile
    """
    if dest is None:
        dest = BytesIO()

    if isinstance(dest, ZipFile):
        zip = dest
        if "r" in zip.mode:
            raise ValueError(
                f"zip file {dest} opened in '{zip.mode}' mode,"
                + " but write access is needed for packaging."
            )
    else:
        zip = ZipFile(dest, mode="w")

    if zip.filename is None:
        zip.filename = (
            str(getattr(self, "id", getattr(self, "name", "bioimageio"))) + ".zip"
        )

    content = self.get_package_content()
    write_content_to_zip(content, zip)
    return zip

warn_about_tag_categories classmethod ¤

warn_about_tag_categories(
    value: List[str], info: ValidationInfo
) -> List[str]
Source code in src/bioimageio/spec/generic/v0_2.py
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
@as_warning
@field_validator("tags")
@classmethod
def warn_about_tag_categories(
    cls, value: List[str], info: ValidationInfo
) -> List[str]:
    categories = TAG_CATEGORIES.get(info.data["type"], {})
    missing_categories: List[Mapping[str, Sequence[str]]] = []
    for cat, entries in categories.items():
        if not any(e in value for e in entries):
            missing_categories.append({cat: entries})

    if missing_categories:
        raise ValueError(
            "Missing tags from bioimage.io categories: {missing_categories}"
        )

    return value

Datetime ¤

Bases: RootModel[datetime]


              flowchart TD
              bioimageio.spec.model.v0_4.Datetime[Datetime]

              

              click bioimageio.spec.model.v0_4.Datetime href "" "bioimageio.spec.model.v0_4.Datetime"
            

Timestamp in ISO 8601 format with a few restrictions listed here.

METHOD DESCRIPTION
now

now classmethod ¤

now()
Source code in src/bioimageio/spec/_internal/types.py
135
136
137
@classmethod
def now(cls):
    return cls(datetime.now(UTC))

Dependencies ¤

Bases: ValidatedStringWithInnerNode[DependenciesNode]


              flowchart TD
              bioimageio.spec.model.v0_4.Dependencies[Dependencies]
              bioimageio.spec._internal.validated_string_with_inner_node.ValidatedStringWithInnerNode[ValidatedStringWithInnerNode]
              bioimageio.spec._internal.validated_string.ValidatedString[ValidatedString]

                              bioimageio.spec._internal.validated_string_with_inner_node.ValidatedStringWithInnerNode --> bioimageio.spec.model.v0_4.Dependencies
                                bioimageio.spec._internal.validated_string.ValidatedString --> bioimageio.spec._internal.validated_string_with_inner_node.ValidatedStringWithInnerNode
                



              click bioimageio.spec.model.v0_4.Dependencies href "" "bioimageio.spec.model.v0_4.Dependencies"
              click bioimageio.spec._internal.validated_string_with_inner_node.ValidatedStringWithInnerNode href "" "bioimageio.spec._internal.validated_string_with_inner_node.ValidatedStringWithInnerNode"
              click bioimageio.spec._internal.validated_string.ValidatedString href "" "bioimageio.spec._internal.validated_string.ValidatedString"
            
METHOD DESCRIPTION
__get_pydantic_core_schema__
__get_pydantic_json_schema__
__new__
ATTRIBUTE DESCRIPTION
file

Dependency file

manager

Dependency manager

root_model

TYPE: Type[RootModel[Any]]

file property ¤

file

Dependency file

manager property ¤

manager

Dependency manager

root_model class-attribute ¤

root_model: Type[RootModel[Any]] = RootModel[str]

__get_pydantic_core_schema__ classmethod ¤

__get_pydantic_core_schema__(
    source_type: Any, handler: GetCoreSchemaHandler
) -> CoreSchema
Source code in src/bioimageio/spec/_internal/validated_string.py
29
30
31
32
33
@classmethod
def __get_pydantic_core_schema__(
    cls, source_type: Any, handler: GetCoreSchemaHandler
) -> CoreSchema:
    return no_info_after_validator_function(cls, handler(str))

__get_pydantic_json_schema__ classmethod ¤

__get_pydantic_json_schema__(
    core_schema: CoreSchema, handler: GetJsonSchemaHandler
) -> JsonSchemaValue
Source code in src/bioimageio/spec/_internal/validated_string.py
35
36
37
38
39
40
41
42
43
44
@classmethod
def __get_pydantic_json_schema__(
    cls, core_schema: CoreSchema, handler: GetJsonSchemaHandler
) -> JsonSchemaValue:
    json_schema = cls.root_model.model_json_schema(mode=handler.mode)
    json_schema["title"] = cls.__name__.strip("_")
    if cls.__doc__:
        json_schema["description"] = cls.__doc__

    return json_schema

__new__ ¤

__new__(object: object)
Source code in src/bioimageio/spec/_internal/validated_string.py
19
20
21
22
23
def __new__(cls, object: object):
    _validated = cls.root_model.model_validate(object).root
    self = super().__new__(cls, _validated)
    self._validated = _validated
    return self._after_validator()

DependenciesNode pydantic-model ¤

Bases: Node

Show JSON schema:
{
  "$defs": {
    "RelativeFilePath": {
      "description": "A path relative to the `rdf.yaml` file (also if the RDF source is a URL).",
      "format": "path",
      "title": "RelativeFilePath",
      "type": "string"
    }
  },
  "additionalProperties": false,
  "properties": {
    "manager": {
      "description": "Dependency manager",
      "examples": [
        "conda",
        "maven",
        "pip"
      ],
      "minLength": 1,
      "title": "Manager",
      "type": "string"
    },
    "file": {
      "anyOf": [
        {
          "description": "A URL with the HTTP or HTTPS scheme.",
          "format": "uri",
          "maxLength": 2083,
          "minLength": 1,
          "title": "HttpUrl",
          "type": "string"
        },
        {
          "$ref": "#/$defs/RelativeFilePath"
        },
        {
          "format": "file-path",
          "title": "FilePath",
          "type": "string"
        }
      ],
      "description": "Dependency file",
      "title": "File"
    }
  },
  "required": [
    "manager",
    "file"
  ],
  "title": "model.v0_4.DependenciesNode",
  "type": "object"
}

Fields:

file pydantic-field ¤

Dependency file

manager pydantic-field ¤

manager: NotEmpty[str]

Dependency manager

model_validate classmethod ¤

model_validate(
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[
        ValidationContext, Mapping[str, Any], None
    ] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self

Validate a pydantic model instance.

PARAMETER DESCRIPTION

obj ¤

The object to validate.

TYPE: Union[Any, Mapping[str, Any]]

strict ¤

Whether to raise an exception on invalid fields.

TYPE: Optional[bool] DEFAULT: None

from_attributes ¤

Whether to extract data from object attributes.

TYPE: Optional[bool] DEFAULT: None

context ¤

Additional context to pass to the validator.

TYPE: Union[ValidationContext, Mapping[str, Any], None] DEFAULT: None

RAISES DESCRIPTION
ValidationError

If the object failed validation.

RETURNS DESCRIPTION
Self

The validated description instance.

Source code in src/bioimageio/spec/_internal/node.py
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
@classmethod
def model_validate(
    cls,
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[ValidationContext, Mapping[str, Any], None] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self:
    """Validate a pydantic model instance.

    Args:
        obj: The object to validate.
        strict: Whether to raise an exception on invalid fields.
        from_attributes: Whether to extract data from object attributes.
        context: Additional context to pass to the validator.

    Raises:
        ValidationError: If the object failed validation.

    Returns:
        The validated description instance.
    """
    __tracebackhide__ = True

    if context is None:
        context = get_validation_context()
    elif isinstance(context, collections.abc.Mapping):
        context = ValidationContext(**context)

    assert not isinstance(obj, collections.abc.Mapping) or is_kwargs(obj), obj

    with context:
        # use validation context as context manager for equal behavior of __init__ and model_validate
        return super().model_validate(
            obj, strict=strict, from_attributes=from_attributes
        )

Doi ¤

Bases: ValidatedString


              flowchart TD
              bioimageio.spec.model.v0_4.Doi[Doi]
              bioimageio.spec._internal.validated_string.ValidatedString[ValidatedString]

                              bioimageio.spec._internal.validated_string.ValidatedString --> bioimageio.spec.model.v0_4.Doi
                


              click bioimageio.spec.model.v0_4.Doi href "" "bioimageio.spec.model.v0_4.Doi"
              click bioimageio.spec._internal.validated_string.ValidatedString href "" "bioimageio.spec._internal.validated_string.ValidatedString"
            

A digital object identifier, see https://www.doi.org/

METHOD DESCRIPTION
__get_pydantic_core_schema__
__get_pydantic_json_schema__
__new__
ATTRIBUTE DESCRIPTION
root_model

TYPE: Type[RootModel[Any]]

root_model class-attribute ¤

root_model: Type[RootModel[Any]] = RootModel[str]

__get_pydantic_core_schema__ classmethod ¤

__get_pydantic_core_schema__(
    source_type: Any, handler: GetCoreSchemaHandler
) -> CoreSchema
Source code in src/bioimageio/spec/_internal/validated_string.py
29
30
31
32
33
@classmethod
def __get_pydantic_core_schema__(
    cls, source_type: Any, handler: GetCoreSchemaHandler
) -> CoreSchema:
    return no_info_after_validator_function(cls, handler(str))

__get_pydantic_json_schema__ classmethod ¤

__get_pydantic_json_schema__(
    core_schema: CoreSchema, handler: GetJsonSchemaHandler
) -> JsonSchemaValue
Source code in src/bioimageio/spec/_internal/validated_string.py
35
36
37
38
39
40
41
42
43
44
@classmethod
def __get_pydantic_json_schema__(
    cls, core_schema: CoreSchema, handler: GetJsonSchemaHandler
) -> JsonSchemaValue:
    json_schema = cls.root_model.model_json_schema(mode=handler.mode)
    json_schema["title"] = cls.__name__.strip("_")
    if cls.__doc__:
        json_schema["description"] = cls.__doc__

    return json_schema

__new__ ¤

__new__(object: object)
Source code in src/bioimageio/spec/_internal/validated_string.py
19
20
21
22
23
def __new__(cls, object: object):
    _validated = cls.root_model.model_validate(object).root
    self = super().__new__(cls, _validated)
    self._validated = _validated
    return self._after_validator()

FileDescr pydantic-model ¤

Bases: Node

A file description

Show JSON schema:
{
  "$defs": {
    "RelativeFilePath": {
      "description": "A path relative to the `rdf.yaml` file (also if the RDF source is a URL).",
      "format": "path",
      "title": "RelativeFilePath",
      "type": "string"
    }
  },
  "additionalProperties": false,
  "description": "A file description",
  "properties": {
    "source": {
      "anyOf": [
        {
          "description": "A URL with the HTTP or HTTPS scheme.",
          "format": "uri",
          "maxLength": 2083,
          "minLength": 1,
          "title": "HttpUrl",
          "type": "string"
        },
        {
          "$ref": "#/$defs/RelativeFilePath"
        },
        {
          "format": "file-path",
          "title": "FilePath",
          "type": "string"
        }
      ],
      "description": "File source",
      "title": "Source"
    },
    "sha256": {
      "anyOf": [
        {
          "description": "A SHA-256 hash value",
          "maxLength": 64,
          "minLength": 64,
          "title": "Sha256",
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "SHA256 hash value of the **source** file.",
      "title": "Sha256"
    }
  },
  "required": [
    "source"
  ],
  "title": "_internal.io.FileDescr",
  "type": "object"
}

Fields:

sha256 pydantic-field ¤

sha256: Optional[Sha256] = None

SHA256 hash value of the source file.

source pydantic-field ¤

source: FileSource

File source

download ¤

download(
    *,
    progressbar: Union[
        Progressbar, Callable[[], Progressbar], bool, None
    ] = None,
)

alias for .get_reader

Source code in src/bioimageio/spec/_internal/io.py
306
307
308
309
310
311
312
def download(
    self,
    *,
    progressbar: Union[Progressbar, Callable[[], Progressbar], bool, None] = None,
):
    """alias for `.get_reader`"""
    return get_reader(self.source, progressbar=progressbar, sha256=self.sha256)

get_reader ¤

get_reader(
    *,
    progressbar: Union[
        Progressbar, Callable[[], Progressbar], bool, None
    ] = None,
)

open the file source (download if needed)

Source code in src/bioimageio/spec/_internal/io.py
298
299
300
301
302
303
304
def get_reader(
    self,
    *,
    progressbar: Union[Progressbar, Callable[[], Progressbar], bool, None] = None,
):
    """open the file source (download if needed)"""
    return get_reader(self.source, progressbar=progressbar, sha256=self.sha256)

model_validate classmethod ¤

model_validate(
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[
        ValidationContext, Mapping[str, Any], None
    ] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self

Validate a pydantic model instance.

PARAMETER DESCRIPTION

obj ¤

The object to validate.

TYPE: Union[Any, Mapping[str, Any]]

strict ¤

Whether to raise an exception on invalid fields.

TYPE: Optional[bool] DEFAULT: None

from_attributes ¤

Whether to extract data from object attributes.

TYPE: Optional[bool] DEFAULT: None

context ¤

Additional context to pass to the validator.

TYPE: Union[ValidationContext, Mapping[str, Any], None] DEFAULT: None

RAISES DESCRIPTION
ValidationError

If the object failed validation.

RETURNS DESCRIPTION
Self

The validated description instance.

Source code in src/bioimageio/spec/_internal/node.py
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
@classmethod
def model_validate(
    cls,
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[ValidationContext, Mapping[str, Any], None] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self:
    """Validate a pydantic model instance.

    Args:
        obj: The object to validate.
        strict: Whether to raise an exception on invalid fields.
        from_attributes: Whether to extract data from object attributes.
        context: Additional context to pass to the validator.

    Raises:
        ValidationError: If the object failed validation.

    Returns:
        The validated description instance.
    """
    __tracebackhide__ = True

    if context is None:
        context = get_validation_context()
    elif isinstance(context, collections.abc.Mapping):
        context = ValidationContext(**context)

    assert not isinstance(obj, collections.abc.Mapping) or is_kwargs(obj), obj

    with context:
        # use validation context as context manager for equal behavior of __init__ and model_validate
        return super().model_validate(
            obj, strict=strict, from_attributes=from_attributes
        )

validate_sha256 ¤

validate_sha256(force_recompute: bool = False) -> None

validate the sha256 hash value of the source file

Source code in src/bioimageio/spec/_internal/io.py
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
def validate_sha256(self, force_recompute: bool = False) -> None:
    """validate the sha256 hash value of the **source** file"""
    context = get_validation_context()
    src_str = str(self.source)
    if not force_recompute and src_str in context.known_files:
        actual_sha = context.known_files[src_str]
    else:
        reader = get_reader(self.source, sha256=self.sha256)
        if force_recompute:
            actual_sha = get_sha256(reader)
        else:
            actual_sha = reader.sha256

        context.known_files[src_str] = actual_sha

    if actual_sha is None:
        return
    elif self.sha256 == actual_sha:
        pass
    elif self.sha256 is None or context.update_hashes:
        self.sha256 = actual_sha
    elif self.sha256 != actual_sha:
        raise ValueError(
            f"Sha256 mismatch for {self.source}. Expected {self.sha256}, got "
            + f"{actual_sha}. Update expected `sha256` or point to the matching "
            + "file."
        )

GenericModelDescrBase pydantic-model ¤

Bases: ResourceDescrBase

Base for all resource descriptions including of model descriptions

Show JSON schema:
{
  "$defs": {
    "AttachmentsDescr": {
      "additionalProperties": true,
      "properties": {
        "files": {
          "description": "File attachments",
          "items": {
            "anyOf": [
              {
                "description": "A URL with the HTTP or HTTPS scheme.",
                "format": "uri",
                "maxLength": 2083,
                "minLength": 1,
                "title": "HttpUrl",
                "type": "string"
              },
              {
                "$ref": "#/$defs/RelativeFilePath"
              },
              {
                "format": "file-path",
                "title": "FilePath",
                "type": "string"
              }
            ]
          },
          "title": "Files",
          "type": "array"
        }
      },
      "title": "generic.v0_2.AttachmentsDescr",
      "type": "object"
    },
    "Author": {
      "additionalProperties": false,
      "properties": {
        "affiliation": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Affiliation",
          "title": "Affiliation"
        },
        "email": {
          "anyOf": [
            {
              "format": "email",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Email",
          "title": "Email"
        },
        "orcid": {
          "anyOf": [
            {
              "description": "An ORCID identifier, see https://orcid.org/",
              "title": "OrcidId",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "An [ORCID iD](https://support.orcid.org/hc/en-us/sections/360001495313-What-is-ORCID\n) in hyphenated groups of 4 digits, (and [valid](\nhttps://support.orcid.org/hc/en-us/articles/360006897674-Structure-of-the-ORCID-Identifier\n) as per ISO 7064 11,2.)",
          "examples": [
            "0000-0001-2345-6789"
          ],
          "title": "Orcid"
        },
        "name": {
          "title": "Name",
          "type": "string"
        },
        "github_user": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Github User"
        }
      },
      "required": [
        "name"
      ],
      "title": "generic.v0_2.Author",
      "type": "object"
    },
    "CiteEntry": {
      "additionalProperties": false,
      "properties": {
        "text": {
          "description": "free text description",
          "title": "Text",
          "type": "string"
        },
        "doi": {
          "anyOf": [
            {
              "description": "A digital object identifier, see https://www.doi.org/",
              "pattern": "^10\\.[0-9]{4}.+$",
              "title": "Doi",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "A digital object identifier (DOI) is the prefered citation reference.\nSee https://www.doi.org/ for details. (alternatively specify `url`)",
          "title": "Doi"
        },
        "url": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "URL to cite (preferably specify a `doi` instead)",
          "title": "Url"
        }
      },
      "required": [
        "text"
      ],
      "title": "generic.v0_2.CiteEntry",
      "type": "object"
    },
    "Maintainer": {
      "additionalProperties": false,
      "properties": {
        "affiliation": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Affiliation",
          "title": "Affiliation"
        },
        "email": {
          "anyOf": [
            {
              "format": "email",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Email",
          "title": "Email"
        },
        "orcid": {
          "anyOf": [
            {
              "description": "An ORCID identifier, see https://orcid.org/",
              "title": "OrcidId",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "An [ORCID iD](https://support.orcid.org/hc/en-us/sections/360001495313-What-is-ORCID\n) in hyphenated groups of 4 digits, (and [valid](\nhttps://support.orcid.org/hc/en-us/articles/360006897674-Structure-of-the-ORCID-Identifier\n) as per ISO 7064 11,2.)",
          "examples": [
            "0000-0001-2345-6789"
          ],
          "title": "Orcid"
        },
        "name": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Name"
        },
        "github_user": {
          "title": "Github User",
          "type": "string"
        }
      },
      "required": [
        "github_user"
      ],
      "title": "generic.v0_2.Maintainer",
      "type": "object"
    },
    "RelativeFilePath": {
      "description": "A path relative to the `rdf.yaml` file (also if the RDF source is a URL).",
      "format": "path",
      "title": "RelativeFilePath",
      "type": "string"
    },
    "Uploader": {
      "additionalProperties": false,
      "properties": {
        "email": {
          "description": "Email",
          "format": "email",
          "title": "Email",
          "type": "string"
        },
        "name": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "name",
          "title": "Name"
        }
      },
      "required": [
        "email"
      ],
      "title": "generic.v0_2.Uploader",
      "type": "object"
    },
    "Version": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "integer"
        },
        {
          "type": "number"
        }
      ],
      "description": "wraps a packaging.version.Version instance for validation in pydantic models",
      "title": "Version"
    },
    "YamlValue": {
      "anyOf": [
        {
          "type": "boolean"
        },
        {
          "format": "date",
          "type": "string"
        },
        {
          "format": "date-time",
          "type": "string"
        },
        {
          "type": "integer"
        },
        {
          "type": "number"
        },
        {
          "type": "string"
        },
        {
          "items": {
            "$ref": "#/$defs/YamlValue"
          },
          "type": "array"
        },
        {
          "additionalProperties": {
            "$ref": "#/$defs/YamlValue"
          },
          "type": "object"
        },
        {
          "type": "null"
        }
      ]
    }
  },
  "additionalProperties": false,
  "description": "Base for all resource descriptions including of model descriptions",
  "properties": {
    "name": {
      "description": "A human-friendly name of the resource description",
      "minLength": 1,
      "title": "Name",
      "type": "string"
    },
    "description": {
      "title": "Description",
      "type": "string"
    },
    "covers": {
      "description": "Cover images. Please use an image smaller than 500KB and an aspect ratio width to height of 2:1.\nThe supported image formats are: ('.gif', '.jpeg', '.jpg', '.png', '.svg', '.tif', '.tiff')",
      "examples": [
        [
          "cover.png"
        ]
      ],
      "items": {
        "anyOf": [
          {
            "description": "A URL with the HTTP or HTTPS scheme.",
            "format": "uri",
            "maxLength": 2083,
            "minLength": 1,
            "title": "HttpUrl",
            "type": "string"
          },
          {
            "$ref": "#/$defs/RelativeFilePath"
          },
          {
            "format": "file-path",
            "title": "FilePath",
            "type": "string"
          }
        ]
      },
      "title": "Covers",
      "type": "array"
    },
    "id_emoji": {
      "anyOf": [
        {
          "examples": [
            "\ud83e\udd88",
            "\ud83e\udda5"
          ],
          "maxLength": 1,
          "minLength": 1,
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "UTF-8 emoji for display alongside the `id`.",
      "title": "Id Emoji"
    },
    "authors": {
      "description": "The authors are the creators of the RDF and the primary points of contact.",
      "items": {
        "$ref": "#/$defs/Author"
      },
      "title": "Authors",
      "type": "array"
    },
    "attachments": {
      "anyOf": [
        {
          "$ref": "#/$defs/AttachmentsDescr"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "file and other attachments"
    },
    "cite": {
      "description": "citations",
      "items": {
        "$ref": "#/$defs/CiteEntry"
      },
      "title": "Cite",
      "type": "array"
    },
    "config": {
      "additionalProperties": {
        "$ref": "#/$defs/YamlValue"
      },
      "description": "A field for custom configuration that can contain any keys not present in the RDF spec.\nThis means you should not store, for example, a github repo URL in `config` since we already have the\n`git_repo` field defined in the spec.\nKeys in `config` may be very specific to a tool or consumer software. To avoid conflicting definitions,\nit is recommended to wrap added configuration into a sub-field named with the specific domain or tool name,\nfor example:\n```yaml\nconfig:\n    bioimageio:  # here is the domain name\n        my_custom_key: 3837283\n        another_key:\n            nested: value\n    imagej:       # config specific to ImageJ\n        macro_dir: path/to/macro/file\n```\nIf possible, please use [`snake_case`](https://en.wikipedia.org/wiki/Snake_case) for keys in `config`.\nYou may want to list linked files additionally under `attachments` to include them when packaging a resource\n(packaging a resource means downloading/copying important linked files and creating a ZIP archive that contains\nan altered rdf.yaml file with local references to the downloaded files)",
      "examples": [
        {
          "bioimageio": {
            "another_key": {
              "nested": "value"
            },
            "my_custom_key": 3837283
          },
          "imagej": {
            "macro_dir": "path/to/macro/file"
          }
        }
      ],
      "title": "Config",
      "type": "object"
    },
    "download_url": {
      "anyOf": [
        {
          "description": "A URL with the HTTP or HTTPS scheme.",
          "format": "uri",
          "maxLength": 2083,
          "minLength": 1,
          "title": "HttpUrl",
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "URL to download the resource from (deprecated)",
      "title": "Download Url"
    },
    "git_repo": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "A URL to the Git repository where the resource is being developed.",
      "examples": [
        "https://github.com/bioimage-io/spec-bioimage-io/tree/main/example_descriptions/models/unet2d_nuclei_broad"
      ],
      "title": "Git Repo"
    },
    "icon": {
      "anyOf": [
        {
          "maxLength": 2,
          "minLength": 1,
          "type": "string"
        },
        {
          "description": "A URL with the HTTP or HTTPS scheme.",
          "format": "uri",
          "maxLength": 2083,
          "minLength": 1,
          "title": "HttpUrl",
          "type": "string"
        },
        {
          "$ref": "#/$defs/RelativeFilePath"
        },
        {
          "format": "file-path",
          "title": "FilePath",
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "An icon for illustration",
      "title": "Icon"
    },
    "links": {
      "description": "IDs of other bioimage.io resources",
      "examples": [
        [
          "ilastik/ilastik",
          "deepimagej/deepimagej",
          "zero/notebook_u-net_3d_zerocostdl4mic"
        ]
      ],
      "items": {
        "type": "string"
      },
      "title": "Links",
      "type": "array"
    },
    "uploader": {
      "anyOf": [
        {
          "$ref": "#/$defs/Uploader"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "The person who uploaded the model (e.g. to bioimage.io)"
    },
    "maintainers": {
      "description": "Maintainers of this resource.\nIf not specified `authors` are maintainers and at least some of them should specify their `github_user` name",
      "items": {
        "$ref": "#/$defs/Maintainer"
      },
      "title": "Maintainers",
      "type": "array"
    },
    "rdf_source": {
      "anyOf": [
        {
          "description": "A URL with the HTTP or HTTPS scheme.",
          "format": "uri",
          "maxLength": 2083,
          "minLength": 1,
          "title": "HttpUrl",
          "type": "string"
        },
        {
          "$ref": "#/$defs/RelativeFilePath"
        },
        {
          "format": "file-path",
          "title": "FilePath",
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Resource description file (RDF) source; used to keep track of where an rdf.yaml was loaded from.\nDo not set this field in a YAML file.",
      "title": "Rdf Source"
    },
    "tags": {
      "description": "Associated tags",
      "examples": [
        [
          "unet2d",
          "pytorch",
          "nucleus",
          "segmentation",
          "dsb2018"
        ]
      ],
      "items": {
        "type": "string"
      },
      "title": "Tags",
      "type": "array"
    },
    "version": {
      "anyOf": [
        {
          "$ref": "#/$defs/Version"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "The version of the resource following SemVer 2.0."
    },
    "version_number": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "version number (n-th published version, not the semantic version)",
      "title": "Version Number"
    }
  },
  "required": [
    "name",
    "description"
  ],
  "title": "generic.v0_2.GenericModelDescrBase",
  "type": "object"
}

Fields:

attachments pydantic-field ¤

attachments: Optional[AttachmentsDescr] = None

file and other attachments

authors pydantic-field ¤

authors: List[Author]

The authors are the creators of the RDF and the primary points of contact.

cite pydantic-field ¤

cite: List[CiteEntry]

citations

config pydantic-field ¤

config: Dict[str, YamlValue]

A field for custom configuration that can contain any keys not present in the RDF spec. This means you should not store, for example, a github repo URL in config since we already have the git_repo field defined in the spec. Keys in config may be very specific to a tool or consumer software. To avoid conflicting definitions, it is recommended to wrap added configuration into a sub-field named with the specific domain or tool name, for example:

config:
    bioimageio:  # here is the domain name
        my_custom_key: 3837283
        another_key:
            nested: value
    imagej:       # config specific to ImageJ
        macro_dir: path/to/macro/file
If possible, please use snake_case for keys in config. You may want to list linked files additionally under attachments to include them when packaging a resource (packaging a resource means downloading/copying important linked files and creating a ZIP archive that contains an altered rdf.yaml file with local references to the downloaded files)

covers pydantic-field ¤

covers: List[FileSource_cover]

Cover images. Please use an image smaller than 500KB and an aspect ratio width to height of 2:1.

description pydantic-field ¤

description: str

download_url pydantic-field ¤

download_url: Optional[HttpUrl] = None

URL to download the resource from (deprecated)

file_name property ¤

file_name: Optional[FileName]

File name of the bioimageio.yaml file the description was loaded from.

git_repo pydantic-field ¤

git_repo: Optional[str] = None

A URL to the Git repository where the resource is being developed.

icon pydantic-field ¤

icon: Union[str, FileSource, None] = None

An icon for illustration

id_emoji pydantic-field ¤

id_emoji: Optional[str] = None

UTF-8 emoji for display alongside the id.

implemented_format_version_tuple class-attribute ¤

implemented_format_version_tuple: Tuple[int, int, int]
links: List[str]

IDs of other bioimage.io resources

maintainers pydantic-field ¤

maintainers: List[Maintainer]

Maintainers of this resource. If not specified authors are maintainers and at least some of them should specify their github_user name

name pydantic-field ¤

name: NotEmpty[str]

A human-friendly name of the resource description

rdf_source pydantic-field ¤

rdf_source: Optional[FileSource] = None

Resource description file (RDF) source; used to keep track of where an rdf.yaml was loaded from. Do not set this field in a YAML file.

root property ¤

root: Union[RootHttpUrl, DirectoryPath, ZipFile]

The URL/Path prefix to resolve any relative paths with.

tags pydantic-field ¤

tags: List[str]

Associated tags

uploader pydantic-field ¤

uploader: Optional[Uploader] = None

The person who uploaded the model (e.g. to bioimage.io)

validation_summary property ¤

validation_summary: ValidationSummary

version pydantic-field ¤

version: Optional[Version] = None

The version of the resource following SemVer 2.0.

version_number pydantic-field ¤

version_number: Optional[int] = None

version number (n-th published version, not the semantic version)

__pydantic_init_subclass__ classmethod ¤

__pydantic_init_subclass__(**kwargs: Any)
Source code in src/bioimageio/spec/_internal/common_nodes.py
199
200
201
202
203
204
205
206
207
208
209
210
211
@classmethod
def __pydantic_init_subclass__(cls, **kwargs: Any):
    super().__pydantic_init_subclass__(**kwargs)
    # set classvar implemented_format_version_tuple
    if "format_version" in cls.model_fields:
        if "." not in cls.implemented_format_version:
            cls.implemented_format_version_tuple = (0, 0, 0)
        else:
            fv_tuple = get_format_version_tuple(cls.implemented_format_version)
            assert fv_tuple is not None, (
                f"failed to cast '{cls.implemented_format_version}' to tuple"
            )
            cls.implemented_format_version_tuple = fv_tuple

accept_author_strings classmethod ¤

accept_author_strings(
    authors: Union[Any, Sequence[Any]],
) -> Any

we unofficially accept strings as author entries

Source code in src/bioimageio/spec/generic/v0_2.py
245
246
247
248
249
250
251
252
253
254
255
@field_validator("authors", mode="before")
@classmethod
def accept_author_strings(cls, authors: Union[Any, Sequence[Any]]) -> Any:
    """we unofficially accept strings as author entries"""
    if is_sequence(authors):
        authors = [{"name": a} if isinstance(a, str) else a for a in authors]

    if not authors:
        issue_warning("missing", value=authors, field="authors")

    return authors

get_package_content ¤

get_package_content() -> Dict[
    FileName, Union[FileDescr, BioimageioYamlContent]
]

Returns package content without creating the package.

Source code in src/bioimageio/spec/_internal/common_nodes.py
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
def get_package_content(
    self,
) -> Dict[FileName, Union[FileDescr, BioimageioYamlContent]]:
    """Returns package content without creating the package."""
    content: Dict[FileName, FileDescr] = {}
    with PackagingContext(
        bioimageio_yaml_file_name=BIOIMAGEIO_YAML,
        file_sources=content,
    ):
        rdf_content: BioimageioYamlContent = self.model_dump(
            mode="json", exclude_unset=True
        )

    _ = rdf_content.pop("rdf_source", None)

    return {**content, BIOIMAGEIO_YAML: rdf_content}

load classmethod ¤

load(
    data: BioimageioYamlContentView,
    context: Optional[ValidationContext] = None,
) -> Union[Self, InvalidDescr]

factory method to create a resource description object

Source code in src/bioimageio/spec/_internal/common_nodes.py
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
@classmethod
def load(
    cls,
    data: BioimageioYamlContentView,
    context: Optional[ValidationContext] = None,
) -> Union[Self, InvalidDescr]:
    """factory method to create a resource description object"""
    context = context or get_validation_context()
    if context.perform_io_checks:
        file_descrs = extract_file_descrs({k: v for k, v in data.items()})
        populate_cache(file_descrs)  # TODO: add progress bar

    with context.replace(log_warnings=context.warning_level <= INFO):
        rd, errors, val_warnings = cls._load_impl(deepcopy_yaml_value(data))

    if context.warning_level > INFO:
        all_warnings_context = context.replace(
            warning_level=INFO, log_warnings=False, raise_errors=False
        )
        # raise all validation warnings by reloading
        with all_warnings_context:
            _, _, val_warnings = cls._load_impl(deepcopy_yaml_value(data))

    format_status = "failed" if errors else "passed"
    rd.validation_summary.add_detail(
        ValidationDetail(
            errors=errors,
            name=(
                "bioimageio.spec format validation"
                f" {rd.type} {cls.implemented_format_version}"
            ),
            status=format_status,
            warnings=val_warnings,
        ),
        update_status=False,  # avoid updating status from 'valid-format' to 'passed', but ...
    )
    if format_status == "failed":
        # ... update status in case of failure
        rd.validation_summary.status = "failed"

    return rd

model_validate classmethod ¤

model_validate(
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[
        ValidationContext, Mapping[str, Any], None
    ] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self

Validate a pydantic model instance.

PARAMETER DESCRIPTION

obj ¤

The object to validate.

TYPE: Union[Any, Mapping[str, Any]]

strict ¤

Whether to raise an exception on invalid fields.

TYPE: Optional[bool] DEFAULT: None

from_attributes ¤

Whether to extract data from object attributes.

TYPE: Optional[bool] DEFAULT: None

context ¤

Additional context to pass to the validator.

TYPE: Union[ValidationContext, Mapping[str, Any], None] DEFAULT: None

RAISES DESCRIPTION
ValidationError

If the object failed validation.

RETURNS DESCRIPTION
Self

The validated description instance.

Source code in src/bioimageio/spec/_internal/node.py
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
@classmethod
def model_validate(
    cls,
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[ValidationContext, Mapping[str, Any], None] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self:
    """Validate a pydantic model instance.

    Args:
        obj: The object to validate.
        strict: Whether to raise an exception on invalid fields.
        from_attributes: Whether to extract data from object attributes.
        context: Additional context to pass to the validator.

    Raises:
        ValidationError: If the object failed validation.

    Returns:
        The validated description instance.
    """
    __tracebackhide__ = True

    if context is None:
        context = get_validation_context()
    elif isinstance(context, collections.abc.Mapping):
        context = ValidationContext(**context)

    assert not isinstance(obj, collections.abc.Mapping) or is_kwargs(obj), obj

    with context:
        # use validation context as context manager for equal behavior of __init__ and model_validate
        return super().model_validate(
            obj, strict=strict, from_attributes=from_attributes
        )

package ¤

package(
    dest: Optional[
        Union[ZipFile, IO[bytes], Path, str]
    ] = None,
) -> ZipFile

package the described resource as a zip archive

PARAMETER DESCRIPTION

dest ¤

(path/bytes stream of) destination zipfile

TYPE: Optional[Union[ZipFile, IO[bytes], Path, str]] DEFAULT: None

Source code in src/bioimageio/spec/_internal/common_nodes.py
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
def package(
    self, dest: Optional[Union[ZipFile, IO[bytes], Path, str]] = None, /
) -> ZipFile:
    """package the described resource as a zip archive

    Args:
        dest: (path/bytes stream of) destination zipfile
    """
    if dest is None:
        dest = BytesIO()

    if isinstance(dest, ZipFile):
        zip = dest
        if "r" in zip.mode:
            raise ValueError(
                f"zip file {dest} opened in '{zip.mode}' mode,"
                + " but write access is needed for packaging."
            )
    else:
        zip = ZipFile(dest, mode="w")

    if zip.filename is None:
        zip.filename = (
            str(getattr(self, "id", getattr(self, "name", "bioimageio"))) + ".zip"
        )

    content = self.get_package_content()
    write_content_to_zip(content, zip)
    return zip

warn_about_tag_categories classmethod ¤

warn_about_tag_categories(
    value: List[str], info: ValidationInfo
) -> List[str]
Source code in src/bioimageio/spec/generic/v0_2.py
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
@as_warning
@field_validator("tags")
@classmethod
def warn_about_tag_categories(
    cls, value: List[str], info: ValidationInfo
) -> List[str]:
    categories = TAG_CATEGORIES.get(info.data["type"], {})
    missing_categories: List[Mapping[str, Sequence[str]]] = []
    for cat, entries in categories.items():
        if not any(e in value for e in entries):
            missing_categories.append({cat: entries})

    if missing_categories:
        raise ValueError(
            "Missing tags from bioimage.io categories: {missing_categories}"
        )

    return value

HttpUrl ¤

Bases: RootHttpUrl


              flowchart TD
              bioimageio.spec.model.v0_4.HttpUrl[HttpUrl]
              bioimageio.spec._internal.root_url.RootHttpUrl[RootHttpUrl]
              bioimageio.spec._internal.validated_string.ValidatedString[ValidatedString]

                              bioimageio.spec._internal.root_url.RootHttpUrl --> bioimageio.spec.model.v0_4.HttpUrl
                                bioimageio.spec._internal.validated_string.ValidatedString --> bioimageio.spec._internal.root_url.RootHttpUrl
                



              click bioimageio.spec.model.v0_4.HttpUrl href "" "bioimageio.spec.model.v0_4.HttpUrl"
              click bioimageio.spec._internal.root_url.RootHttpUrl href "" "bioimageio.spec._internal.root_url.RootHttpUrl"
              click bioimageio.spec._internal.validated_string.ValidatedString href "" "bioimageio.spec._internal.validated_string.ValidatedString"
            

A URL with the HTTP or HTTPS scheme.

METHOD DESCRIPTION
__get_pydantic_core_schema__
__get_pydantic_json_schema__
__new__
absolute

analog to absolute method of pathlib.

exists

True if URL is available

ATTRIBUTE DESCRIPTION
host

TYPE: Optional[str]

parent

TYPE: RootHttpUrl

parents

iterate over all URL parents (max 100)

TYPE: Iterable[RootHttpUrl]

path

TYPE: Optional[str]

root_model

TYPE: Type[RootModel[Any]]

scheme

TYPE: str

host property ¤

host: Optional[str]

parent property ¤

parent: RootHttpUrl

parents property ¤

parents: Iterable[RootHttpUrl]

iterate over all URL parents (max 100)

path property ¤

path: Optional[str]

root_model class-attribute ¤

root_model: Type[RootModel[Any]] = RootModel[
    pydantic.HttpUrl
]

scheme property ¤

scheme: str

__get_pydantic_core_schema__ classmethod ¤

__get_pydantic_core_schema__(
    source_type: Any, handler: GetCoreSchemaHandler
) -> CoreSchema
Source code in src/bioimageio/spec/_internal/validated_string.py
29
30
31
32
33
@classmethod
def __get_pydantic_core_schema__(
    cls, source_type: Any, handler: GetCoreSchemaHandler
) -> CoreSchema:
    return no_info_after_validator_function(cls, handler(str))

__get_pydantic_json_schema__ classmethod ¤

__get_pydantic_json_schema__(
    core_schema: CoreSchema, handler: GetJsonSchemaHandler
) -> JsonSchemaValue
Source code in src/bioimageio/spec/_internal/validated_string.py
35
36
37
38
39
40
41
42
43
44
@classmethod
def __get_pydantic_json_schema__(
    cls, core_schema: CoreSchema, handler: GetJsonSchemaHandler
) -> JsonSchemaValue:
    json_schema = cls.root_model.model_json_schema(mode=handler.mode)
    json_schema["title"] = cls.__name__.strip("_")
    if cls.__doc__:
        json_schema["description"] = cls.__doc__

    return json_schema

__new__ ¤

__new__(object: object)
Source code in src/bioimageio/spec/_internal/validated_string.py
19
20
21
22
23
def __new__(cls, object: object):
    _validated = cls.root_model.model_validate(object).root
    self = super().__new__(cls, _validated)
    self._validated = _validated
    return self._after_validator()

absolute ¤

absolute()

analog to absolute method of pathlib.

Source code in src/bioimageio/spec/_internal/root_url.py
18
19
20
def absolute(self):
    """analog to `absolute` method of pathlib."""
    return self

exists ¤

exists()

True if URL is available

Source code in src/bioimageio/spec/_internal/url.py
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
def exists(self):
    """True if URL is available"""
    if self._exists is None:
        ctxt = get_validation_context()
        try:
            with ctxt.replace(warning_level=warning_levels.WARNING):
                self._validated = _validate_url(self._validated)
        except Exception as e:
            if ctxt.log_warnings:
                logger.info(e)

            self._exists = False
        else:
            self._exists = True

    return self._exists

Identifier ¤

Bases: ValidatedString


              flowchart TD
              bioimageio.spec.model.v0_4.Identifier[Identifier]
              bioimageio.spec._internal.validated_string.ValidatedString[ValidatedString]

                              bioimageio.spec._internal.validated_string.ValidatedString --> bioimageio.spec.model.v0_4.Identifier
                


              click bioimageio.spec.model.v0_4.Identifier href "" "bioimageio.spec.model.v0_4.Identifier"
              click bioimageio.spec._internal.validated_string.ValidatedString href "" "bioimageio.spec._internal.validated_string.ValidatedString"
            
METHOD DESCRIPTION
__get_pydantic_core_schema__
__get_pydantic_json_schema__
__new__
ATTRIBUTE DESCRIPTION
root_model

TYPE: Type[RootModel[Any]]

root_model class-attribute ¤

root_model: Type[RootModel[Any]] = RootModel[IdentifierAnno]

__get_pydantic_core_schema__ classmethod ¤

__get_pydantic_core_schema__(
    source_type: Any, handler: GetCoreSchemaHandler
) -> CoreSchema
Source code in src/bioimageio/spec/_internal/validated_string.py
29
30
31
32
33
@classmethod
def __get_pydantic_core_schema__(
    cls, source_type: Any, handler: GetCoreSchemaHandler
) -> CoreSchema:
    return no_info_after_validator_function(cls, handler(str))

__get_pydantic_json_schema__ classmethod ¤

__get_pydantic_json_schema__(
    core_schema: CoreSchema, handler: GetJsonSchemaHandler
) -> JsonSchemaValue
Source code in src/bioimageio/spec/_internal/validated_string.py
35
36
37
38
39
40
41
42
43
44
@classmethod
def __get_pydantic_json_schema__(
    cls, core_schema: CoreSchema, handler: GetJsonSchemaHandler
) -> JsonSchemaValue:
    json_schema = cls.root_model.model_json_schema(mode=handler.mode)
    json_schema["title"] = cls.__name__.strip("_")
    if cls.__doc__:
        json_schema["description"] = cls.__doc__

    return json_schema

__new__ ¤

__new__(object: object)
Source code in src/bioimageio/spec/_internal/validated_string.py
19
20
21
22
23
def __new__(cls, object: object):
    _validated = cls.root_model.model_validate(object).root
    self = super().__new__(cls, _validated)
    self._validated = _validated
    return self._after_validator()

ImplicitOutputShape pydantic-model ¤

Bases: Node

Output tensor shape depending on an input tensor shape. shape(output_tensor) = shape(input_tensor) * scale + 2 * offset

Show JSON schema:
{
  "additionalProperties": false,
  "description": "Output tensor shape depending on an input tensor shape.\n`shape(output_tensor) = shape(input_tensor) * scale + 2 * offset`",
  "properties": {
    "reference_tensor": {
      "description": "Name of the reference tensor.",
      "minLength": 1,
      "title": "TensorName",
      "type": "string"
    },
    "scale": {
      "description": "output_pix/input_pix for each dimension.\n'null' values indicate new dimensions, whose length is defined by 2*`offset`",
      "items": {
        "anyOf": [
          {
            "type": "number"
          },
          {
            "type": "null"
          }
        ]
      },
      "minItems": 1,
      "title": "Scale",
      "type": "array"
    },
    "offset": {
      "description": "Position of origin wrt to input.",
      "items": {
        "anyOf": [
          {
            "type": "integer"
          },
          {
            "multipleOf": 0.5,
            "type": "number"
          }
        ]
      },
      "minItems": 1,
      "title": "Offset",
      "type": "array"
    }
  },
  "required": [
    "reference_tensor",
    "scale",
    "offset"
  ],
  "title": "model.v0_4.ImplicitOutputShape",
  "type": "object"
}

Fields:

Validators:

offset pydantic-field ¤

offset: NotEmpty[List[Union[int, float]]]

Position of origin wrt to input.

reference_tensor pydantic-field ¤

reference_tensor: TensorName

Name of the reference tensor.

scale pydantic-field ¤

scale: NotEmpty[List[Optional[float]]]

output_pix/input_pix for each dimension. 'null' values indicate new dimensions, whose length is defined by 2*offset

__len__ ¤

__len__() -> int
Source code in src/bioimageio/spec/model/v0_4.py
581
582
def __len__(self) -> int:
    return len(self.scale)

matching_lengths pydantic-validator ¤

matching_lengths() -> Self
Source code in src/bioimageio/spec/model/v0_4.py
584
585
586
587
588
589
590
591
592
593
594
595
@model_validator(mode="after")
def matching_lengths(self) -> Self:
    if len(self.scale) != len(self.offset):
        raise ValueError(
            f"scale {self.scale} has to have same length as offset {self.offset}!"
        )
    # if we have an expanded dimension, make sure that it's offet is not zero
    for sc, off in zip(self.scale, self.offset):
        if sc is None and not off:
            raise ValueError("`offset` must not be zero if `scale` is none/zero")

    return self

model_validate classmethod ¤

model_validate(
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[
        ValidationContext, Mapping[str, Any], None
    ] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self

Validate a pydantic model instance.

PARAMETER DESCRIPTION

obj ¤

The object to validate.

TYPE: Union[Any, Mapping[str, Any]]

strict ¤

Whether to raise an exception on invalid fields.

TYPE: Optional[bool] DEFAULT: None

from_attributes ¤

Whether to extract data from object attributes.

TYPE: Optional[bool] DEFAULT: None

context ¤

Additional context to pass to the validator.

TYPE: Union[ValidationContext, Mapping[str, Any], None] DEFAULT: None

RAISES DESCRIPTION
ValidationError

If the object failed validation.

RETURNS DESCRIPTION
Self

The validated description instance.

Source code in src/bioimageio/spec/_internal/node.py
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
@classmethod
def model_validate(
    cls,
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[ValidationContext, Mapping[str, Any], None] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self:
    """Validate a pydantic model instance.

    Args:
        obj: The object to validate.
        strict: Whether to raise an exception on invalid fields.
        from_attributes: Whether to extract data from object attributes.
        context: Additional context to pass to the validator.

    Raises:
        ValidationError: If the object failed validation.

    Returns:
        The validated description instance.
    """
    __tracebackhide__ = True

    if context is None:
        context = get_validation_context()
    elif isinstance(context, collections.abc.Mapping):
        context = ValidationContext(**context)

    assert not isinstance(obj, collections.abc.Mapping) or is_kwargs(obj), obj

    with context:
        # use validation context as context manager for equal behavior of __init__ and model_validate
        return super().model_validate(
            obj, strict=strict, from_attributes=from_attributes
        )

InputTensorDescr pydantic-model ¤

Bases: TensorDescrBase

Show JSON schema:
{
  "$defs": {
    "BinarizeDescr": {
      "additionalProperties": false,
      "description": "BinarizeDescr the tensor with a fixed `BinarizeKwargs.threshold`.\nValues above the threshold will be set to one, values below the threshold to zero.",
      "properties": {
        "name": {
          "const": "binarize",
          "title": "Name",
          "type": "string"
        },
        "kwargs": {
          "$ref": "#/$defs/BinarizeKwargs"
        }
      },
      "required": [
        "name",
        "kwargs"
      ],
      "title": "model.v0_4.BinarizeDescr",
      "type": "object"
    },
    "BinarizeKwargs": {
      "additionalProperties": false,
      "description": "key word arguments for `BinarizeDescr`",
      "properties": {
        "threshold": {
          "description": "The fixed threshold",
          "title": "Threshold",
          "type": "number"
        }
      },
      "required": [
        "threshold"
      ],
      "title": "model.v0_4.BinarizeKwargs",
      "type": "object"
    },
    "ClipDescr": {
      "additionalProperties": false,
      "description": "Clip tensor values to a range.\n\nSet tensor values below `ClipKwargs.min` to `ClipKwargs.min`\nand above `ClipKwargs.max` to `ClipKwargs.max`.",
      "properties": {
        "name": {
          "const": "clip",
          "title": "Name",
          "type": "string"
        },
        "kwargs": {
          "$ref": "#/$defs/ClipKwargs"
        }
      },
      "required": [
        "name",
        "kwargs"
      ],
      "title": "model.v0_4.ClipDescr",
      "type": "object"
    },
    "ClipKwargs": {
      "additionalProperties": false,
      "description": "key word arguments for `ClipDescr`",
      "properties": {
        "min": {
          "description": "minimum value for clipping",
          "title": "Min",
          "type": "number"
        },
        "max": {
          "description": "maximum value for clipping",
          "title": "Max",
          "type": "number"
        }
      },
      "required": [
        "min",
        "max"
      ],
      "title": "model.v0_4.ClipKwargs",
      "type": "object"
    },
    "ParameterizedInputShape": {
      "additionalProperties": false,
      "description": "A sequence of valid shapes given by `shape_k = min + k * step for k in {0, 1, ...}`.",
      "properties": {
        "min": {
          "description": "The minimum input shape",
          "items": {
            "type": "integer"
          },
          "minItems": 1,
          "title": "Min",
          "type": "array"
        },
        "step": {
          "description": "The minimum shape change",
          "items": {
            "type": "integer"
          },
          "minItems": 1,
          "title": "Step",
          "type": "array"
        }
      },
      "required": [
        "min",
        "step"
      ],
      "title": "model.v0_4.ParameterizedInputShape",
      "type": "object"
    },
    "ScaleLinearDescr": {
      "additionalProperties": false,
      "description": "Fixed linear scaling.",
      "properties": {
        "name": {
          "const": "scale_linear",
          "title": "Name",
          "type": "string"
        },
        "kwargs": {
          "$ref": "#/$defs/ScaleLinearKwargs"
        }
      },
      "required": [
        "name",
        "kwargs"
      ],
      "title": "model.v0_4.ScaleLinearDescr",
      "type": "object"
    },
    "ScaleLinearKwargs": {
      "additionalProperties": false,
      "description": "key word arguments for `ScaleLinearDescr`",
      "properties": {
        "axes": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "The subset of axes to scale jointly.\nFor example xy to scale the two image axes for 2d data jointly.",
          "examples": [
            "xy"
          ],
          "title": "Axes"
        },
        "gain": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "items": {
                "type": "number"
              },
              "type": "array"
            }
          ],
          "default": 1.0,
          "description": "multiplicative factor",
          "title": "Gain"
        },
        "offset": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "items": {
                "type": "number"
              },
              "type": "array"
            }
          ],
          "default": 0.0,
          "description": "additive term",
          "title": "Offset"
        }
      },
      "title": "model.v0_4.ScaleLinearKwargs",
      "type": "object"
    },
    "ScaleRangeDescr": {
      "additionalProperties": false,
      "description": "Scale with percentiles.",
      "properties": {
        "name": {
          "const": "scale_range",
          "title": "Name",
          "type": "string"
        },
        "kwargs": {
          "$ref": "#/$defs/ScaleRangeKwargs"
        }
      },
      "required": [
        "name",
        "kwargs"
      ],
      "title": "model.v0_4.ScaleRangeDescr",
      "type": "object"
    },
    "ScaleRangeKwargs": {
      "additionalProperties": false,
      "description": "key word arguments for `ScaleRangeDescr`\n\nFor `min_percentile`=0.0 (the default) and `max_percentile`=100 (the default)\nthis processing step normalizes data to the [0, 1] intervall.\nFor other percentiles the normalized values will partially be outside the [0, 1]\nintervall. Use `ScaleRange` followed by `ClipDescr` if you want to limit the\nnormalized values to a range.",
      "properties": {
        "mode": {
          "description": "Mode for computing percentiles.\n|     mode    |             description              |\n| ----------- | ------------------------------------ |\n| per_dataset | compute for the entire dataset       |\n| per_sample  | compute for each sample individually |",
          "enum": [
            "per_dataset",
            "per_sample"
          ],
          "title": "Mode",
          "type": "string"
        },
        "axes": {
          "description": "The subset of axes to normalize jointly.\nFor example xy to normalize the two image axes for 2d data jointly.",
          "examples": [
            "xy"
          ],
          "title": "Axes",
          "type": "string"
        },
        "min_percentile": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "number"
            }
          ],
          "default": 0.0,
          "description": "The lower percentile used to determine the value to align with zero.",
          "ge": 0,
          "lt": 100,
          "title": "Min Percentile"
        },
        "max_percentile": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "number"
            }
          ],
          "default": 100.0,
          "description": "The upper percentile used to determine the value to align with one.\nHas to be bigger than `min_percentile`.\nThe range is 1 to 100 instead of 0 to 100 to avoid mistakenly\naccepting percentiles specified in the range 0.0 to 1.0.",
          "gt": 1,
          "le": 100,
          "title": "Max Percentile"
        },
        "eps": {
          "default": 1e-06,
          "description": "Epsilon for numeric stability.\n`out = (tensor - v_lower) / (v_upper - v_lower + eps)`;\nwith `v_lower,v_upper` values at the respective percentiles.",
          "exclusiveMinimum": 0,
          "maximum": 0.1,
          "title": "Eps",
          "type": "number"
        },
        "reference_tensor": {
          "anyOf": [
            {
              "minLength": 1,
              "title": "TensorName",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Tensor name to compute the percentiles from. Default: The tensor itself.\nFor any tensor in `inputs` only input tensor references are allowed.\nFor a tensor in `outputs` only input tensor refereences are allowed if `mode: per_dataset`",
          "title": "Reference Tensor"
        }
      },
      "required": [
        "mode",
        "axes"
      ],
      "title": "model.v0_4.ScaleRangeKwargs",
      "type": "object"
    },
    "SigmoidDescr": {
      "additionalProperties": false,
      "description": "The logistic sigmoid funciton, a.k.a. expit function.",
      "properties": {
        "name": {
          "const": "sigmoid",
          "title": "Name",
          "type": "string"
        }
      },
      "required": [
        "name"
      ],
      "title": "model.v0_4.SigmoidDescr",
      "type": "object"
    },
    "ZeroMeanUnitVarianceDescr": {
      "additionalProperties": false,
      "description": "Subtract mean and divide by variance.",
      "properties": {
        "name": {
          "const": "zero_mean_unit_variance",
          "title": "Name",
          "type": "string"
        },
        "kwargs": {
          "$ref": "#/$defs/ZeroMeanUnitVarianceKwargs"
        }
      },
      "required": [
        "name",
        "kwargs"
      ],
      "title": "model.v0_4.ZeroMeanUnitVarianceDescr",
      "type": "object"
    },
    "ZeroMeanUnitVarianceKwargs": {
      "additionalProperties": false,
      "description": "key word arguments for `ZeroMeanUnitVarianceDescr`",
      "properties": {
        "mode": {
          "default": "fixed",
          "description": "Mode for computing mean and variance.\n|     mode    |             description              |\n| ----------- | ------------------------------------ |\n|   fixed     | Fixed values for mean and variance   |\n| per_dataset | Compute for the entire dataset       |\n| per_sample  | Compute for each sample individually |",
          "enum": [
            "fixed",
            "per_dataset",
            "per_sample"
          ],
          "title": "Mode",
          "type": "string"
        },
        "axes": {
          "description": "The subset of axes to normalize jointly.\nFor example `xy` to normalize the two image axes for 2d data jointly.",
          "examples": [
            "xy"
          ],
          "title": "Axes",
          "type": "string"
        },
        "mean": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "items": {
                "type": "number"
              },
              "minItems": 1,
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "The mean value(s) to use for `mode: fixed`.\nFor example `[1.1, 2.2, 3.3]` in the case of a 3 channel image with `axes: xy`.",
          "examples": [
            [
              1.1,
              2.2,
              3.3
            ]
          ],
          "title": "Mean"
        },
        "std": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "items": {
                "type": "number"
              },
              "minItems": 1,
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "The standard deviation values to use for `mode: fixed`. Analogous to mean.",
          "examples": [
            [
              0.1,
              0.2,
              0.3
            ]
          ],
          "title": "Std"
        },
        "eps": {
          "default": 1e-06,
          "description": "epsilon for numeric stability: `out = (tensor - mean) / (std + eps)`.",
          "exclusiveMinimum": 0,
          "maximum": 0.1,
          "title": "Eps",
          "type": "number"
        }
      },
      "required": [
        "axes"
      ],
      "title": "model.v0_4.ZeroMeanUnitVarianceKwargs",
      "type": "object"
    }
  },
  "additionalProperties": false,
  "properties": {
    "name": {
      "description": "Tensor name. No duplicates are allowed.",
      "minLength": 1,
      "title": "TensorName",
      "type": "string"
    },
    "description": {
      "default": "",
      "title": "Description",
      "type": "string"
    },
    "axes": {
      "description": "Axes identifying characters. Same length and order as the axes in `shape`.\n| axis | description |\n| --- | --- |\n|  b  |  batch (groups multiple samples) |\n|  i  |  instance/index/element |\n|  t  |  time |\n|  c  |  channel |\n|  z  |  spatial dimension z |\n|  y  |  spatial dimension y |\n|  x  |  spatial dimension x |",
      "title": "Axes",
      "type": "string"
    },
    "data_range": {
      "anyOf": [
        {
          "maxItems": 2,
          "minItems": 2,
          "prefixItems": [
            {
              "type": "number"
            },
            {
              "type": "number"
            }
          ],
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Tuple `(minimum, maximum)` specifying the allowed range of the data in this tensor.\nIf not specified, the full data range that can be expressed in `data_type` is allowed.",
      "title": "Data Range"
    },
    "data_type": {
      "description": "For now an input tensor is expected to be given as `float32`.\nThe data flow in bioimage.io models is explained\n[in this diagram.](https://docs.google.com/drawings/d/1FTw8-Rn6a6nXdkZ_SkMumtcjvur9mtIhRqLwnKqZNHM/edit).",
      "enum": [
        "float32",
        "uint8",
        "uint16"
      ],
      "title": "Data Type",
      "type": "string"
    },
    "shape": {
      "anyOf": [
        {
          "items": {
            "type": "integer"
          },
          "type": "array"
        },
        {
          "$ref": "#/$defs/ParameterizedInputShape"
        }
      ],
      "description": "Specification of input tensor shape.",
      "examples": [
        [
          1,
          512,
          512,
          1
        ],
        {
          "min": [
            1,
            64,
            64,
            1
          ],
          "step": [
            0,
            32,
            32,
            0
          ]
        }
      ],
      "title": "Shape"
    },
    "preprocessing": {
      "description": "Description of how this input should be preprocessed.",
      "items": {
        "discriminator": {
          "mapping": {
            "binarize": "#/$defs/BinarizeDescr",
            "clip": "#/$defs/ClipDescr",
            "scale_linear": "#/$defs/ScaleLinearDescr",
            "scale_range": "#/$defs/ScaleRangeDescr",
            "sigmoid": "#/$defs/SigmoidDescr",
            "zero_mean_unit_variance": "#/$defs/ZeroMeanUnitVarianceDescr"
          },
          "propertyName": "name"
        },
        "oneOf": [
          {
            "$ref": "#/$defs/BinarizeDescr"
          },
          {
            "$ref": "#/$defs/ClipDescr"
          },
          {
            "$ref": "#/$defs/ScaleLinearDescr"
          },
          {
            "$ref": "#/$defs/SigmoidDescr"
          },
          {
            "$ref": "#/$defs/ZeroMeanUnitVarianceDescr"
          },
          {
            "$ref": "#/$defs/ScaleRangeDescr"
          }
        ]
      },
      "title": "Preprocessing",
      "type": "array"
    }
  },
  "required": [
    "name",
    "axes",
    "data_type",
    "shape"
  ],
  "title": "model.v0_4.InputTensorDescr",
  "type": "object"
}

Fields:

Validators:

axes pydantic-field ¤

axes: AxesStr

Axes identifying characters. Same length and order as the axes in shape. | axis | description | | --- | --- | | b | batch (groups multiple samples) | | i | instance/index/element | | t | time | | c | channel | | z | spatial dimension z | | y | spatial dimension y | | x | spatial dimension x |

data_range pydantic-field ¤

data_range: Optional[Tuple[float, float]] = None

Tuple (minimum, maximum) specifying the allowed range of the data in this tensor. If not specified, the full data range that can be expressed in data_type is allowed.

data_type pydantic-field ¤

data_type: Literal['float32', 'uint8', 'uint16']

For now an input tensor is expected to be given as float32. The data flow in bioimage.io models is explained in this diagram..

description pydantic-field ¤

description: str = ''

name pydantic-field ¤

name: TensorName

Tensor name. No duplicates are allowed.

preprocessing pydantic-field ¤

preprocessing: List[PreprocessingDescr]

Description of how this input should be preprocessed.

shape pydantic-field ¤

shape: Union[Sequence[int], ParameterizedInputShape]

Specification of input tensor shape.

model_validate classmethod ¤

model_validate(
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[
        ValidationContext, Mapping[str, Any], None
    ] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self

Validate a pydantic model instance.

PARAMETER DESCRIPTION

obj ¤

The object to validate.

TYPE: Union[Any, Mapping[str, Any]]

strict ¤

Whether to raise an exception on invalid fields.

TYPE: Optional[bool] DEFAULT: None

from_attributes ¤

Whether to extract data from object attributes.

TYPE: Optional[bool] DEFAULT: None

context ¤

Additional context to pass to the validator.

TYPE: Union[ValidationContext, Mapping[str, Any], None] DEFAULT: None

RAISES DESCRIPTION
ValidationError

If the object failed validation.

RETURNS DESCRIPTION
Self

The validated description instance.

Source code in src/bioimageio/spec/_internal/node.py
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
@classmethod
def model_validate(
    cls,
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[ValidationContext, Mapping[str, Any], None] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self:
    """Validate a pydantic model instance.

    Args:
        obj: The object to validate.
        strict: Whether to raise an exception on invalid fields.
        from_attributes: Whether to extract data from object attributes.
        context: Additional context to pass to the validator.

    Raises:
        ValidationError: If the object failed validation.

    Returns:
        The validated description instance.
    """
    __tracebackhide__ = True

    if context is None:
        context = get_validation_context()
    elif isinstance(context, collections.abc.Mapping):
        context = ValidationContext(**context)

    assert not isinstance(obj, collections.abc.Mapping) or is_kwargs(obj), obj

    with context:
        # use validation context as context manager for equal behavior of __init__ and model_validate
        return super().model_validate(
            obj, strict=strict, from_attributes=from_attributes
        )

validate_preprocessing_kwargs pydantic-validator ¤

validate_preprocessing_kwargs() -> Self
Source code in src/bioimageio/spec/model/v0_4.py
960
961
962
963
964
965
966
967
968
969
@model_validator(mode="after")
def validate_preprocessing_kwargs(self) -> Self:
    for p in self.preprocessing:
        kwargs_axes = p.kwargs.get("axes")
        if isinstance(kwargs_axes, str) and any(
            a not in self.axes for a in kwargs_axes
        ):
            raise ValueError("`kwargs.axes` needs to be subset of `axes`")

    return self

zero_batch_step_and_one_batch_size pydantic-validator ¤

zero_batch_step_and_one_batch_size() -> Self
Source code in src/bioimageio/spec/model/v0_4.py
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
@model_validator(mode="after")
def zero_batch_step_and_one_batch_size(self) -> Self:
    bidx = self.axes.find("b")
    if bidx == -1:
        return self

    if isinstance(self.shape, ParameterizedInputShape):
        step = self.shape.step
        shape = self.shape.min
        if step[bidx] != 0:
            raise ValueError(
                "Input shape step has to be zero in the batch dimension (the batch"
                + " dimension can always be increased, but `step` should specify how"
                + " to increase the minimal shape to find the largest single batch"
                + " shape)"
            )
    else:
        shape = self.shape

    if shape[bidx] != 1:
        raise ValueError("Input shape has to be 1 in the batch dimension b.")

    return self

KerasHdf5WeightsDescr pydantic-model ¤

Bases: WeightsEntryDescrBase

Show JSON schema:
{
  "$defs": {
    "AttachmentsDescr": {
      "additionalProperties": true,
      "properties": {
        "files": {
          "description": "File attachments",
          "items": {
            "anyOf": [
              {
                "description": "A URL with the HTTP or HTTPS scheme.",
                "format": "uri",
                "maxLength": 2083,
                "minLength": 1,
                "title": "HttpUrl",
                "type": "string"
              },
              {
                "$ref": "#/$defs/RelativeFilePath"
              },
              {
                "format": "file-path",
                "title": "FilePath",
                "type": "string"
              }
            ]
          },
          "title": "Files",
          "type": "array"
        }
      },
      "title": "generic.v0_2.AttachmentsDescr",
      "type": "object"
    },
    "Author": {
      "additionalProperties": false,
      "properties": {
        "affiliation": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Affiliation",
          "title": "Affiliation"
        },
        "email": {
          "anyOf": [
            {
              "format": "email",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Email",
          "title": "Email"
        },
        "orcid": {
          "anyOf": [
            {
              "description": "An ORCID identifier, see https://orcid.org/",
              "title": "OrcidId",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "An [ORCID iD](https://support.orcid.org/hc/en-us/sections/360001495313-What-is-ORCID\n) in hyphenated groups of 4 digits, (and [valid](\nhttps://support.orcid.org/hc/en-us/articles/360006897674-Structure-of-the-ORCID-Identifier\n) as per ISO 7064 11,2.)",
          "examples": [
            "0000-0001-2345-6789"
          ],
          "title": "Orcid"
        },
        "name": {
          "title": "Name",
          "type": "string"
        },
        "github_user": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Github User"
        }
      },
      "required": [
        "name"
      ],
      "title": "generic.v0_2.Author",
      "type": "object"
    },
    "RelativeFilePath": {
      "description": "A path relative to the `rdf.yaml` file (also if the RDF source is a URL).",
      "format": "path",
      "title": "RelativeFilePath",
      "type": "string"
    },
    "Version": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "integer"
        },
        {
          "type": "number"
        }
      ],
      "description": "wraps a packaging.version.Version instance for validation in pydantic models",
      "title": "Version"
    }
  },
  "additionalProperties": false,
  "properties": {
    "source": {
      "anyOf": [
        {
          "description": "A URL with the HTTP or HTTPS scheme.",
          "format": "uri",
          "maxLength": 2083,
          "minLength": 1,
          "title": "HttpUrl",
          "type": "string"
        },
        {
          "$ref": "#/$defs/RelativeFilePath"
        },
        {
          "format": "file-path",
          "title": "FilePath",
          "type": "string"
        }
      ],
      "description": "The weights file.",
      "title": "Source"
    },
    "sha256": {
      "anyOf": [
        {
          "description": "A SHA-256 hash value",
          "maxLength": 64,
          "minLength": 64,
          "title": "Sha256",
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "SHA256 hash value of the **source** file.",
      "title": "Sha256"
    },
    "attachments": {
      "anyOf": [
        {
          "$ref": "#/$defs/AttachmentsDescr"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Attachments that are specific to this weights entry."
    },
    "authors": {
      "anyOf": [
        {
          "items": {
            "$ref": "#/$defs/Author"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Authors\nEither the person(s) that have trained this model resulting in the original weights file.\n    (If this is the initial weights entry, i.e. it does not have a `parent`)\nOr the person(s) who have converted the weights to this weights format.\n    (If this is a child weight, i.e. it has a `parent` field)",
      "title": "Authors"
    },
    "dependencies": {
      "anyOf": [
        {
          "pattern": "^.+:.+$",
          "title": "Dependencies",
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Dependency manager and dependency file, specified as `<dependency manager>:<relative file path>`.",
      "examples": [
        "conda:environment.yaml",
        "maven:./pom.xml",
        "pip:./requirements.txt"
      ],
      "title": "Dependencies"
    },
    "parent": {
      "anyOf": [
        {
          "enum": [
            "keras_hdf5",
            "onnx",
            "pytorch_state_dict",
            "tensorflow_js",
            "tensorflow_saved_model_bundle",
            "torchscript"
          ],
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "The source weights these weights were converted from.\nFor example, if a model's weights were converted from the `pytorch_state_dict` format to `torchscript`,\nThe `pytorch_state_dict` weights entry has no `parent` and is the parent of the `torchscript` weights.\nAll weight entries except one (the initial set of weights resulting from training the model),\nneed to have this field.",
      "examples": [
        "pytorch_state_dict"
      ],
      "title": "Parent"
    },
    "tensorflow_version": {
      "anyOf": [
        {
          "$ref": "#/$defs/Version"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "TensorFlow version used to create these weights"
    }
  },
  "required": [
    "source"
  ],
  "title": "model.v0_4.KerasHdf5WeightsDescr",
  "type": "object"
}

Fields:

Validators:

attachments pydantic-field ¤

attachments: Union[AttachmentsDescr, None] = None

Attachments that are specific to this weights entry.

authors pydantic-field ¤

authors: Union[List[Author], None] = None

Authors Either the person(s) that have trained this model resulting in the original weights file. (If this is the initial weights entry, i.e. it does not have a parent) Or the person(s) who have converted the weights to this weights format. (If this is a child weight, i.e. it has a parent field)

dependencies pydantic-field ¤

dependencies: Optional[Dependencies] = None

Dependency manager and dependency file, specified as <dependency manager>:<relative file path>.

parent pydantic-field ¤

parent: Optional[WeightsFormat] = None

The source weights these weights were converted from. For example, if a model's weights were converted from the pytorch_state_dict format to torchscript, The pytorch_state_dict weights entry has no parent and is the parent of the torchscript weights. All weight entries except one (the initial set of weights resulting from training the model), need to have this field.

sha256 pydantic-field ¤

sha256: Optional[Sha256] = None

SHA256 hash value of the source file.

source pydantic-field ¤

source: FileSource_

The weights file.

tensorflow_version pydantic-field ¤

tensorflow_version: Optional[Version] = None

TensorFlow version used to create these weights

type class-attribute ¤

type: WeightsFormat = 'keras_hdf5'

weights_format_name class-attribute ¤

weights_format_name: str = 'Keras HDF5'

check_parent_is_not_self pydantic-validator ¤

check_parent_is_not_self() -> Self
Source code in src/bioimageio/spec/model/v0_4.py
288
289
290
291
292
293
@model_validator(mode="after")
def check_parent_is_not_self(self) -> Self:
    if self.type == self.parent:
        raise ValueError("Weights entry can't be it's own parent.")

    return self

download ¤

download(
    *,
    progressbar: Union[
        Progressbar, Callable[[], Progressbar], bool, None
    ] = None,
)

alias for .get_reader

Source code in src/bioimageio/spec/_internal/io.py
306
307
308
309
310
311
312
def download(
    self,
    *,
    progressbar: Union[Progressbar, Callable[[], Progressbar], bool, None] = None,
):
    """alias for `.get_reader`"""
    return get_reader(self.source, progressbar=progressbar, sha256=self.sha256)

get_reader ¤

get_reader(
    *,
    progressbar: Union[
        Progressbar, Callable[[], Progressbar], bool, None
    ] = None,
)

open the file source (download if needed)

Source code in src/bioimageio/spec/_internal/io.py
298
299
300
301
302
303
304
def get_reader(
    self,
    *,
    progressbar: Union[Progressbar, Callable[[], Progressbar], bool, None] = None,
):
    """open the file source (download if needed)"""
    return get_reader(self.source, progressbar=progressbar, sha256=self.sha256)

model_validate classmethod ¤

model_validate(
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[
        ValidationContext, Mapping[str, Any], None
    ] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self

Validate a pydantic model instance.

PARAMETER DESCRIPTION

obj ¤

The object to validate.

TYPE: Union[Any, Mapping[str, Any]]

strict ¤

Whether to raise an exception on invalid fields.

TYPE: Optional[bool] DEFAULT: None

from_attributes ¤

Whether to extract data from object attributes.

TYPE: Optional[bool] DEFAULT: None

context ¤

Additional context to pass to the validator.

TYPE: Union[ValidationContext, Mapping[str, Any], None] DEFAULT: None

RAISES DESCRIPTION
ValidationError

If the object failed validation.

RETURNS DESCRIPTION
Self

The validated description instance.

Source code in src/bioimageio/spec/_internal/node.py
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
@classmethod
def model_validate(
    cls,
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[ValidationContext, Mapping[str, Any], None] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self:
    """Validate a pydantic model instance.

    Args:
        obj: The object to validate.
        strict: Whether to raise an exception on invalid fields.
        from_attributes: Whether to extract data from object attributes.
        context: Additional context to pass to the validator.

    Raises:
        ValidationError: If the object failed validation.

    Returns:
        The validated description instance.
    """
    __tracebackhide__ = True

    if context is None:
        context = get_validation_context()
    elif isinstance(context, collections.abc.Mapping):
        context = ValidationContext(**context)

    assert not isinstance(obj, collections.abc.Mapping) or is_kwargs(obj), obj

    with context:
        # use validation context as context manager for equal behavior of __init__ and model_validate
        return super().model_validate(
            obj, strict=strict, from_attributes=from_attributes
        )

validate_sha256 ¤

validate_sha256(force_recompute: bool = False) -> None

validate the sha256 hash value of the source file

Source code in src/bioimageio/spec/_internal/io.py
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
def validate_sha256(self, force_recompute: bool = False) -> None:
    """validate the sha256 hash value of the **source** file"""
    context = get_validation_context()
    src_str = str(self.source)
    if not force_recompute and src_str in context.known_files:
        actual_sha = context.known_files[src_str]
    else:
        reader = get_reader(self.source, sha256=self.sha256)
        if force_recompute:
            actual_sha = get_sha256(reader)
        else:
            actual_sha = reader.sha256

        context.known_files[src_str] = actual_sha

    if actual_sha is None:
        return
    elif self.sha256 == actual_sha:
        pass
    elif self.sha256 is None or context.update_hashes:
        self.sha256 = actual_sha
    elif self.sha256 != actual_sha:
        raise ValueError(
            f"Sha256 mismatch for {self.source}. Expected {self.sha256}, got "
            + f"{actual_sha}. Update expected `sha256` or point to the matching "
            + "file."
        )

KwargsNode pydantic-model ¤

Bases: Node

Show JSON schema:
{
  "additionalProperties": false,
  "properties": {},
  "title": "_internal.common_nodes.KwargsNode",
  "type": "object"
}

__contains__ ¤

__contains__(item: str) -> bool
Source code in src/bioimageio/spec/_internal/common_nodes.py
425
426
def __contains__(self, item: str) -> bool:
    return item in self.__class__.model_fields

__getitem__ ¤

__getitem__(item: str) -> Any
Source code in src/bioimageio/spec/_internal/common_nodes.py
419
420
421
422
423
def __getitem__(self, item: str) -> Any:
    if item in self.__class__.model_fields:
        return getattr(self, item)
    else:
        raise KeyError(item)

get ¤

get(item: str, default: Any = None) -> Any
Source code in src/bioimageio/spec/_internal/common_nodes.py
416
417
def get(self, item: str, default: Any = None) -> Any:
    return self[item] if item in self else default

model_validate classmethod ¤

model_validate(
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[
        ValidationContext, Mapping[str, Any], None
    ] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self

Validate a pydantic model instance.

PARAMETER DESCRIPTION

obj ¤

The object to validate.

TYPE: Union[Any, Mapping[str, Any]]

strict ¤

Whether to raise an exception on invalid fields.

TYPE: Optional[bool] DEFAULT: None

from_attributes ¤

Whether to extract data from object attributes.

TYPE: Optional[bool] DEFAULT: None

context ¤

Additional context to pass to the validator.

TYPE: Union[ValidationContext, Mapping[str, Any], None] DEFAULT: None

RAISES DESCRIPTION
ValidationError

If the object failed validation.

RETURNS DESCRIPTION
Self

The validated description instance.

Source code in src/bioimageio/spec/_internal/node.py
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
@classmethod
def model_validate(
    cls,
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[ValidationContext, Mapping[str, Any], None] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self:
    """Validate a pydantic model instance.

    Args:
        obj: The object to validate.
        strict: Whether to raise an exception on invalid fields.
        from_attributes: Whether to extract data from object attributes.
        context: Additional context to pass to the validator.

    Raises:
        ValidationError: If the object failed validation.

    Returns:
        The validated description instance.
    """
    __tracebackhide__ = True

    if context is None:
        context = get_validation_context()
    elif isinstance(context, collections.abc.Mapping):
        context = ValidationContext(**context)

    assert not isinstance(obj, collections.abc.Mapping) or is_kwargs(obj), obj

    with context:
        # use validation context as context manager for equal behavior of __init__ and model_validate
        return super().model_validate(
            obj, strict=strict, from_attributes=from_attributes
        )

LicenseId ¤

Bases: ValidatedString


              flowchart TD
              bioimageio.spec.model.v0_4.LicenseId[LicenseId]
              bioimageio.spec._internal.validated_string.ValidatedString[ValidatedString]

                              bioimageio.spec._internal.validated_string.ValidatedString --> bioimageio.spec.model.v0_4.LicenseId
                


              click bioimageio.spec.model.v0_4.LicenseId href "" "bioimageio.spec.model.v0_4.LicenseId"
              click bioimageio.spec._internal.validated_string.ValidatedString href "" "bioimageio.spec._internal.validated_string.ValidatedString"
            
METHOD DESCRIPTION
__get_pydantic_core_schema__
__get_pydantic_json_schema__
__new__
ATTRIBUTE DESCRIPTION
root_model

TYPE: Type[RootModel[Any]]

root_model class-attribute ¤

root_model: Type[RootModel[Any]] = RootModel[
    LicenseIdLiteral
]

__get_pydantic_core_schema__ classmethod ¤

__get_pydantic_core_schema__(
    source_type: Any, handler: GetCoreSchemaHandler
) -> CoreSchema
Source code in src/bioimageio/spec/_internal/validated_string.py
29
30
31
32
33
@classmethod
def __get_pydantic_core_schema__(
    cls, source_type: Any, handler: GetCoreSchemaHandler
) -> CoreSchema:
    return no_info_after_validator_function(cls, handler(str))

__get_pydantic_json_schema__ classmethod ¤

__get_pydantic_json_schema__(
    core_schema: CoreSchema, handler: GetJsonSchemaHandler
) -> JsonSchemaValue
Source code in src/bioimageio/spec/_internal/validated_string.py
35
36
37
38
39
40
41
42
43
44
@classmethod
def __get_pydantic_json_schema__(
    cls, core_schema: CoreSchema, handler: GetJsonSchemaHandler
) -> JsonSchemaValue:
    json_schema = cls.root_model.model_json_schema(mode=handler.mode)
    json_schema["title"] = cls.__name__.strip("_")
    if cls.__doc__:
        json_schema["description"] = cls.__doc__

    return json_schema

__new__ ¤

__new__(object: object)
Source code in src/bioimageio/spec/_internal/validated_string.py
19
20
21
22
23
def __new__(cls, object: object):
    _validated = cls.root_model.model_validate(object).root
    self = super().__new__(cls, _validated)
    self._validated = _validated
    return self._after_validator()

LinkedDataset pydantic-model ¤

Bases: Node

Reference to a bioimage.io dataset.

Show JSON schema:
{
  "additionalProperties": false,
  "description": "Reference to a bioimage.io dataset.",
  "properties": {
    "id": {
      "description": "A valid dataset `id` from the bioimage.io collection.",
      "minLength": 1,
      "title": "DatasetId",
      "type": "string"
    },
    "version_number": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "version number (n-th published version, not the semantic version) of linked dataset",
      "title": "Version Number"
    }
  },
  "required": [
    "id"
  ],
  "title": "dataset.v0_2.LinkedDataset",
  "type": "object"
}

Fields:

id pydantic-field ¤

A valid dataset id from the bioimage.io collection.

version_number pydantic-field ¤

version_number: Optional[int] = None

version number (n-th published version, not the semantic version) of linked dataset

model_validate classmethod ¤

model_validate(
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[
        ValidationContext, Mapping[str, Any], None
    ] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self

Validate a pydantic model instance.

PARAMETER DESCRIPTION

obj ¤

The object to validate.

TYPE: Union[Any, Mapping[str, Any]]

strict ¤

Whether to raise an exception on invalid fields.

TYPE: Optional[bool] DEFAULT: None

from_attributes ¤

Whether to extract data from object attributes.

TYPE: Optional[bool] DEFAULT: None

context ¤

Additional context to pass to the validator.

TYPE: Union[ValidationContext, Mapping[str, Any], None] DEFAULT: None

RAISES DESCRIPTION
ValidationError

If the object failed validation.

RETURNS DESCRIPTION
Self

The validated description instance.

Source code in src/bioimageio/spec/_internal/node.py
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
@classmethod
def model_validate(
    cls,
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[ValidationContext, Mapping[str, Any], None] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self:
    """Validate a pydantic model instance.

    Args:
        obj: The object to validate.
        strict: Whether to raise an exception on invalid fields.
        from_attributes: Whether to extract data from object attributes.
        context: Additional context to pass to the validator.

    Raises:
        ValidationError: If the object failed validation.

    Returns:
        The validated description instance.
    """
    __tracebackhide__ = True

    if context is None:
        context = get_validation_context()
    elif isinstance(context, collections.abc.Mapping):
        context = ValidationContext(**context)

    assert not isinstance(obj, collections.abc.Mapping) or is_kwargs(obj), obj

    with context:
        # use validation context as context manager for equal behavior of __init__ and model_validate
        return super().model_validate(
            obj, strict=strict, from_attributes=from_attributes
        )

LinkedModel pydantic-model ¤

Bases: Node

Reference to a bioimage.io model.

Show JSON schema:
{
  "additionalProperties": false,
  "description": "Reference to a bioimage.io model.",
  "properties": {
    "id": {
      "description": "A valid model `id` from the bioimage.io collection.",
      "examples": [
        "affable-shark",
        "ambitious-sloth"
      ],
      "minLength": 1,
      "title": "ModelId",
      "type": "string"
    },
    "version_number": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "version number (n-th published version, not the semantic version) of linked model",
      "title": "Version Number"
    }
  },
  "required": [
    "id"
  ],
  "title": "model.v0_4.LinkedModel",
  "type": "object"
}

Fields:

id pydantic-field ¤

id: ModelId

A valid model id from the bioimage.io collection.

version_number pydantic-field ¤

version_number: Optional[int] = None

version number (n-th published version, not the semantic version) of linked model

model_validate classmethod ¤

model_validate(
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[
        ValidationContext, Mapping[str, Any], None
    ] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self

Validate a pydantic model instance.

PARAMETER DESCRIPTION

obj ¤

The object to validate.

TYPE: Union[Any, Mapping[str, Any]]

strict ¤

Whether to raise an exception on invalid fields.

TYPE: Optional[bool] DEFAULT: None

from_attributes ¤

Whether to extract data from object attributes.

TYPE: Optional[bool] DEFAULT: None

context ¤

Additional context to pass to the validator.

TYPE: Union[ValidationContext, Mapping[str, Any], None] DEFAULT: None

RAISES DESCRIPTION
ValidationError

If the object failed validation.

RETURNS DESCRIPTION
Self

The validated description instance.

Source code in src/bioimageio/spec/_internal/node.py
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
@classmethod
def model_validate(
    cls,
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[ValidationContext, Mapping[str, Any], None] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self:
    """Validate a pydantic model instance.

    Args:
        obj: The object to validate.
        strict: Whether to raise an exception on invalid fields.
        from_attributes: Whether to extract data from object attributes.
        context: Additional context to pass to the validator.

    Raises:
        ValidationError: If the object failed validation.

    Returns:
        The validated description instance.
    """
    __tracebackhide__ = True

    if context is None:
        context = get_validation_context()
    elif isinstance(context, collections.abc.Mapping):
        context = ValidationContext(**context)

    assert not isinstance(obj, collections.abc.Mapping) or is_kwargs(obj), obj

    with context:
        # use validation context as context manager for equal behavior of __init__ and model_validate
        return super().model_validate(
            obj, strict=strict, from_attributes=from_attributes
        )

LinkedResource pydantic-model ¤

Bases: Node

Reference to a bioimage.io resource

Show JSON schema:
{
  "additionalProperties": false,
  "description": "Reference to a bioimage.io resource",
  "properties": {
    "id": {
      "description": "A valid resource `id` from the bioimage.io collection.",
      "minLength": 1,
      "title": "ResourceId",
      "type": "string"
    },
    "version_number": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "version number (n-th published version, not the semantic version) of linked resource",
      "title": "Version Number"
    }
  },
  "required": [
    "id"
  ],
  "title": "generic.v0_2.LinkedResource",
  "type": "object"
}

Fields:

id pydantic-field ¤

A valid resource id from the bioimage.io collection.

version_number pydantic-field ¤

version_number: Optional[int] = None

version number (n-th published version, not the semantic version) of linked resource

model_validate classmethod ¤

model_validate(
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[
        ValidationContext, Mapping[str, Any], None
    ] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self

Validate a pydantic model instance.

PARAMETER DESCRIPTION

obj ¤

The object to validate.

TYPE: Union[Any, Mapping[str, Any]]

strict ¤

Whether to raise an exception on invalid fields.

TYPE: Optional[bool] DEFAULT: None

from_attributes ¤

Whether to extract data from object attributes.

TYPE: Optional[bool] DEFAULT: None

context ¤

Additional context to pass to the validator.

TYPE: Union[ValidationContext, Mapping[str, Any], None] DEFAULT: None

RAISES DESCRIPTION
ValidationError

If the object failed validation.

RETURNS DESCRIPTION
Self

The validated description instance.

Source code in src/bioimageio/spec/_internal/node.py
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
@classmethod
def model_validate(
    cls,
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[ValidationContext, Mapping[str, Any], None] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self:
    """Validate a pydantic model instance.

    Args:
        obj: The object to validate.
        strict: Whether to raise an exception on invalid fields.
        from_attributes: Whether to extract data from object attributes.
        context: Additional context to pass to the validator.

    Raises:
        ValidationError: If the object failed validation.

    Returns:
        The validated description instance.
    """
    __tracebackhide__ = True

    if context is None:
        context = get_validation_context()
    elif isinstance(context, collections.abc.Mapping):
        context = ValidationContext(**context)

    assert not isinstance(obj, collections.abc.Mapping) or is_kwargs(obj), obj

    with context:
        # use validation context as context manager for equal behavior of __init__ and model_validate
        return super().model_validate(
            obj, strict=strict, from_attributes=from_attributes
        )

LowerCaseIdentifier ¤

Bases: ValidatedString


              flowchart TD
              bioimageio.spec.model.v0_4.LowerCaseIdentifier[LowerCaseIdentifier]
              bioimageio.spec._internal.validated_string.ValidatedString[ValidatedString]

                              bioimageio.spec._internal.validated_string.ValidatedString --> bioimageio.spec.model.v0_4.LowerCaseIdentifier
                


              click bioimageio.spec.model.v0_4.LowerCaseIdentifier href "" "bioimageio.spec.model.v0_4.LowerCaseIdentifier"
              click bioimageio.spec._internal.validated_string.ValidatedString href "" "bioimageio.spec._internal.validated_string.ValidatedString"
            
METHOD DESCRIPTION
__get_pydantic_core_schema__
__get_pydantic_json_schema__
__new__
ATTRIBUTE DESCRIPTION
root_model

TYPE: Type[RootModel[Any]]

root_model class-attribute ¤

root_model: Type[RootModel[Any]] = RootModel[
    LowerCaseIdentifierAnno
]

__get_pydantic_core_schema__ classmethod ¤

__get_pydantic_core_schema__(
    source_type: Any, handler: GetCoreSchemaHandler
) -> CoreSchema
Source code in src/bioimageio/spec/_internal/validated_string.py
29
30
31
32
33
@classmethod
def __get_pydantic_core_schema__(
    cls, source_type: Any, handler: GetCoreSchemaHandler
) -> CoreSchema:
    return no_info_after_validator_function(cls, handler(str))

__get_pydantic_json_schema__ classmethod ¤

__get_pydantic_json_schema__(
    core_schema: CoreSchema, handler: GetJsonSchemaHandler
) -> JsonSchemaValue
Source code in src/bioimageio/spec/_internal/validated_string.py
35
36
37
38
39
40
41
42
43
44
@classmethod
def __get_pydantic_json_schema__(
    cls, core_schema: CoreSchema, handler: GetJsonSchemaHandler
) -> JsonSchemaValue:
    json_schema = cls.root_model.model_json_schema(mode=handler.mode)
    json_schema["title"] = cls.__name__.strip("_")
    if cls.__doc__:
        json_schema["description"] = cls.__doc__

    return json_schema

__new__ ¤

__new__(object: object)
Source code in src/bioimageio/spec/_internal/validated_string.py
19
20
21
22
23
def __new__(cls, object: object):
    _validated = cls.root_model.model_validate(object).root
    self = super().__new__(cls, _validated)
    self._validated = _validated
    return self._after_validator()

Maintainer pydantic-model ¤

Bases: _Person

Show JSON schema:
{
  "additionalProperties": false,
  "properties": {
    "affiliation": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Affiliation",
      "title": "Affiliation"
    },
    "email": {
      "anyOf": [
        {
          "format": "email",
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Email",
      "title": "Email"
    },
    "orcid": {
      "anyOf": [
        {
          "description": "An ORCID identifier, see https://orcid.org/",
          "title": "OrcidId",
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "An [ORCID iD](https://support.orcid.org/hc/en-us/sections/360001495313-What-is-ORCID\n) in hyphenated groups of 4 digits, (and [valid](\nhttps://support.orcid.org/hc/en-us/articles/360006897674-Structure-of-the-ORCID-Identifier\n) as per ISO 7064 11,2.)",
      "examples": [
        "0000-0001-2345-6789"
      ],
      "title": "Orcid"
    },
    "name": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Name"
    },
    "github_user": {
      "title": "Github User",
      "type": "string"
    }
  },
  "required": [
    "github_user"
  ],
  "title": "generic.v0_2.Maintainer",
  "type": "object"
}

Fields:

affiliation pydantic-field ¤

affiliation: Optional[str] = None

Affiliation

email pydantic-field ¤

email: Optional[EmailStr] = None

Email

github_user pydantic-field ¤

github_user: str

name pydantic-field ¤

name: Optional[str] = None

orcid pydantic-field ¤

orcid: Optional[OrcidId] = None

An ORCID iD in hyphenated groups of 4 digits, (and valid as per ISO 7064 11,2.)

model_validate classmethod ¤

model_validate(
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[
        ValidationContext, Mapping[str, Any], None
    ] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self

Validate a pydantic model instance.

PARAMETER DESCRIPTION

obj ¤

The object to validate.

TYPE: Union[Any, Mapping[str, Any]]

strict ¤

Whether to raise an exception on invalid fields.

TYPE: Optional[bool] DEFAULT: None

from_attributes ¤

Whether to extract data from object attributes.

TYPE: Optional[bool] DEFAULT: None

context ¤

Additional context to pass to the validator.

TYPE: Union[ValidationContext, Mapping[str, Any], None] DEFAULT: None

RAISES DESCRIPTION
ValidationError

If the object failed validation.

RETURNS DESCRIPTION
Self

The validated description instance.

Source code in src/bioimageio/spec/_internal/node.py
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
@classmethod
def model_validate(
    cls,
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[ValidationContext, Mapping[str, Any], None] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self:
    """Validate a pydantic model instance.

    Args:
        obj: The object to validate.
        strict: Whether to raise an exception on invalid fields.
        from_attributes: Whether to extract data from object attributes.
        context: Additional context to pass to the validator.

    Raises:
        ValidationError: If the object failed validation.

    Returns:
        The validated description instance.
    """
    __tracebackhide__ = True

    if context is None:
        context = get_validation_context()
    elif isinstance(context, collections.abc.Mapping):
        context = ValidationContext(**context)

    assert not isinstance(obj, collections.abc.Mapping) or is_kwargs(obj), obj

    with context:
        # use validation context as context manager for equal behavior of __init__ and model_validate
        return super().model_validate(
            obj, strict=strict, from_attributes=from_attributes
        )

ModelDescr pydantic-model ¤

Bases: GenericModelDescrBase

Specification of the fields used in a bioimage.io-compliant RDF that describes AI models with pretrained weights.

These fields are typically stored in a YAML file which we call a model resource description file (model RDF).

Show JSON schema:
{
  "$defs": {
    "AttachmentsDescr": {
      "additionalProperties": true,
      "properties": {
        "files": {
          "description": "File attachments",
          "items": {
            "anyOf": [
              {
                "description": "A URL with the HTTP or HTTPS scheme.",
                "format": "uri",
                "maxLength": 2083,
                "minLength": 1,
                "title": "HttpUrl",
                "type": "string"
              },
              {
                "$ref": "#/$defs/RelativeFilePath"
              },
              {
                "format": "file-path",
                "title": "FilePath",
                "type": "string"
              }
            ]
          },
          "title": "Files",
          "type": "array"
        }
      },
      "title": "generic.v0_2.AttachmentsDescr",
      "type": "object"
    },
    "Author": {
      "additionalProperties": false,
      "properties": {
        "affiliation": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Affiliation",
          "title": "Affiliation"
        },
        "email": {
          "anyOf": [
            {
              "format": "email",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Email",
          "title": "Email"
        },
        "orcid": {
          "anyOf": [
            {
              "description": "An ORCID identifier, see https://orcid.org/",
              "title": "OrcidId",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "An [ORCID iD](https://support.orcid.org/hc/en-us/sections/360001495313-What-is-ORCID\n) in hyphenated groups of 4 digits, (and [valid](\nhttps://support.orcid.org/hc/en-us/articles/360006897674-Structure-of-the-ORCID-Identifier\n) as per ISO 7064 11,2.)",
          "examples": [
            "0000-0001-2345-6789"
          ],
          "title": "Orcid"
        },
        "name": {
          "title": "Name",
          "type": "string"
        },
        "github_user": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Github User"
        }
      },
      "required": [
        "name"
      ],
      "title": "generic.v0_2.Author",
      "type": "object"
    },
    "BadgeDescr": {
      "additionalProperties": false,
      "description": "A custom badge",
      "properties": {
        "label": {
          "description": "badge label to display on hover",
          "examples": [
            "Open in Colab"
          ],
          "title": "Label",
          "type": "string"
        },
        "icon": {
          "anyOf": [
            {
              "format": "file-path",
              "title": "FilePath",
              "type": "string"
            },
            {
              "$ref": "#/$defs/RelativeFilePath"
            },
            {
              "description": "A URL with the HTTP or HTTPS scheme.",
              "format": "uri",
              "maxLength": 2083,
              "minLength": 1,
              "title": "HttpUrl",
              "type": "string"
            },
            {
              "format": "uri",
              "maxLength": 2083,
              "minLength": 1,
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "badge icon (included in bioimage.io package if not a URL)",
          "examples": [
            "https://colab.research.google.com/assets/colab-badge.svg"
          ],
          "title": "Icon"
        },
        "url": {
          "description": "target URL",
          "examples": [
            "https://colab.research.google.com/github/HenriquesLab/ZeroCostDL4Mic/blob/master/Colab_notebooks/U-net_2D_ZeroCostDL4Mic.ipynb"
          ],
          "format": "uri",
          "maxLength": 2083,
          "minLength": 1,
          "title": "HttpUrl",
          "type": "string"
        }
      },
      "required": [
        "label",
        "url"
      ],
      "title": "generic.v0_2.BadgeDescr",
      "type": "object"
    },
    "BinarizeDescr": {
      "additionalProperties": false,
      "description": "BinarizeDescr the tensor with a fixed `BinarizeKwargs.threshold`.\nValues above the threshold will be set to one, values below the threshold to zero.",
      "properties": {
        "name": {
          "const": "binarize",
          "title": "Name",
          "type": "string"
        },
        "kwargs": {
          "$ref": "#/$defs/BinarizeKwargs"
        }
      },
      "required": [
        "name",
        "kwargs"
      ],
      "title": "model.v0_4.BinarizeDescr",
      "type": "object"
    },
    "BinarizeKwargs": {
      "additionalProperties": false,
      "description": "key word arguments for `BinarizeDescr`",
      "properties": {
        "threshold": {
          "description": "The fixed threshold",
          "title": "Threshold",
          "type": "number"
        }
      },
      "required": [
        "threshold"
      ],
      "title": "model.v0_4.BinarizeKwargs",
      "type": "object"
    },
    "CiteEntry": {
      "additionalProperties": false,
      "properties": {
        "text": {
          "description": "free text description",
          "title": "Text",
          "type": "string"
        },
        "doi": {
          "anyOf": [
            {
              "description": "A digital object identifier, see https://www.doi.org/",
              "pattern": "^10\\.[0-9]{4}.+$",
              "title": "Doi",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "A digital object identifier (DOI) is the prefered citation reference.\nSee https://www.doi.org/ for details. (alternatively specify `url`)",
          "title": "Doi"
        },
        "url": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "URL to cite (preferably specify a `doi` instead)",
          "title": "Url"
        }
      },
      "required": [
        "text"
      ],
      "title": "generic.v0_2.CiteEntry",
      "type": "object"
    },
    "ClipDescr": {
      "additionalProperties": false,
      "description": "Clip tensor values to a range.\n\nSet tensor values below `ClipKwargs.min` to `ClipKwargs.min`\nand above `ClipKwargs.max` to `ClipKwargs.max`.",
      "properties": {
        "name": {
          "const": "clip",
          "title": "Name",
          "type": "string"
        },
        "kwargs": {
          "$ref": "#/$defs/ClipKwargs"
        }
      },
      "required": [
        "name",
        "kwargs"
      ],
      "title": "model.v0_4.ClipDescr",
      "type": "object"
    },
    "ClipKwargs": {
      "additionalProperties": false,
      "description": "key word arguments for `ClipDescr`",
      "properties": {
        "min": {
          "description": "minimum value for clipping",
          "title": "Min",
          "type": "number"
        },
        "max": {
          "description": "maximum value for clipping",
          "title": "Max",
          "type": "number"
        }
      },
      "required": [
        "min",
        "max"
      ],
      "title": "model.v0_4.ClipKwargs",
      "type": "object"
    },
    "DatasetDescr": {
      "additionalProperties": false,
      "description": "A bioimage.io dataset resource description file (dataset RDF) describes a dataset relevant to bioimage\nprocessing.",
      "properties": {
        "name": {
          "description": "A human-friendly name of the resource description",
          "minLength": 1,
          "title": "Name",
          "type": "string"
        },
        "description": {
          "title": "Description",
          "type": "string"
        },
        "covers": {
          "description": "Cover images. Please use an image smaller than 500KB and an aspect ratio width to height of 2:1.\nThe supported image formats are: ('.gif', '.jpeg', '.jpg', '.png', '.svg', '.tif', '.tiff')",
          "examples": [
            [
              "cover.png"
            ]
          ],
          "items": {
            "anyOf": [
              {
                "description": "A URL with the HTTP or HTTPS scheme.",
                "format": "uri",
                "maxLength": 2083,
                "minLength": 1,
                "title": "HttpUrl",
                "type": "string"
              },
              {
                "$ref": "#/$defs/RelativeFilePath"
              },
              {
                "format": "file-path",
                "title": "FilePath",
                "type": "string"
              }
            ]
          },
          "title": "Covers",
          "type": "array"
        },
        "id_emoji": {
          "anyOf": [
            {
              "examples": [
                "\ud83e\udd88",
                "\ud83e\udda5"
              ],
              "maxLength": 1,
              "minLength": 1,
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "UTF-8 emoji for display alongside the `id`.",
          "title": "Id Emoji"
        },
        "authors": {
          "description": "The authors are the creators of the RDF and the primary points of contact.",
          "items": {
            "$ref": "#/$defs/Author"
          },
          "title": "Authors",
          "type": "array"
        },
        "attachments": {
          "anyOf": [
            {
              "$ref": "#/$defs/AttachmentsDescr"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "file and other attachments"
        },
        "cite": {
          "description": "citations",
          "items": {
            "$ref": "#/$defs/CiteEntry"
          },
          "title": "Cite",
          "type": "array"
        },
        "config": {
          "additionalProperties": {
            "$ref": "#/$defs/YamlValue"
          },
          "description": "A field for custom configuration that can contain any keys not present in the RDF spec.\nThis means you should not store, for example, a github repo URL in `config` since we already have the\n`git_repo` field defined in the spec.\nKeys in `config` may be very specific to a tool or consumer software. To avoid conflicting definitions,\nit is recommended to wrap added configuration into a sub-field named with the specific domain or tool name,\nfor example:\n```yaml\nconfig:\n    bioimageio:  # here is the domain name\n        my_custom_key: 3837283\n        another_key:\n            nested: value\n    imagej:       # config specific to ImageJ\n        macro_dir: path/to/macro/file\n```\nIf possible, please use [`snake_case`](https://en.wikipedia.org/wiki/Snake_case) for keys in `config`.\nYou may want to list linked files additionally under `attachments` to include them when packaging a resource\n(packaging a resource means downloading/copying important linked files and creating a ZIP archive that contains\nan altered rdf.yaml file with local references to the downloaded files)",
          "examples": [
            {
              "bioimageio": {
                "another_key": {
                  "nested": "value"
                },
                "my_custom_key": 3837283
              },
              "imagej": {
                "macro_dir": "path/to/macro/file"
              }
            }
          ],
          "title": "Config",
          "type": "object"
        },
        "download_url": {
          "anyOf": [
            {
              "description": "A URL with the HTTP or HTTPS scheme.",
              "format": "uri",
              "maxLength": 2083,
              "minLength": 1,
              "title": "HttpUrl",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "URL to download the resource from (deprecated)",
          "title": "Download Url"
        },
        "git_repo": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "A URL to the Git repository where the resource is being developed.",
          "examples": [
            "https://github.com/bioimage-io/spec-bioimage-io/tree/main/example_descriptions/models/unet2d_nuclei_broad"
          ],
          "title": "Git Repo"
        },
        "icon": {
          "anyOf": [
            {
              "maxLength": 2,
              "minLength": 1,
              "type": "string"
            },
            {
              "description": "A URL with the HTTP or HTTPS scheme.",
              "format": "uri",
              "maxLength": 2083,
              "minLength": 1,
              "title": "HttpUrl",
              "type": "string"
            },
            {
              "$ref": "#/$defs/RelativeFilePath"
            },
            {
              "format": "file-path",
              "title": "FilePath",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "An icon for illustration",
          "title": "Icon"
        },
        "links": {
          "description": "IDs of other bioimage.io resources",
          "examples": [
            [
              "ilastik/ilastik",
              "deepimagej/deepimagej",
              "zero/notebook_u-net_3d_zerocostdl4mic"
            ]
          ],
          "items": {
            "type": "string"
          },
          "title": "Links",
          "type": "array"
        },
        "uploader": {
          "anyOf": [
            {
              "$ref": "#/$defs/Uploader"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "The person who uploaded the model (e.g. to bioimage.io)"
        },
        "maintainers": {
          "description": "Maintainers of this resource.\nIf not specified `authors` are maintainers and at least some of them should specify their `github_user` name",
          "items": {
            "$ref": "#/$defs/Maintainer"
          },
          "title": "Maintainers",
          "type": "array"
        },
        "rdf_source": {
          "anyOf": [
            {
              "description": "A URL with the HTTP or HTTPS scheme.",
              "format": "uri",
              "maxLength": 2083,
              "minLength": 1,
              "title": "HttpUrl",
              "type": "string"
            },
            {
              "$ref": "#/$defs/RelativeFilePath"
            },
            {
              "format": "file-path",
              "title": "FilePath",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Resource description file (RDF) source; used to keep track of where an rdf.yaml was loaded from.\nDo not set this field in a YAML file.",
          "title": "Rdf Source"
        },
        "tags": {
          "description": "Associated tags",
          "examples": [
            [
              "unet2d",
              "pytorch",
              "nucleus",
              "segmentation",
              "dsb2018"
            ]
          ],
          "items": {
            "type": "string"
          },
          "title": "Tags",
          "type": "array"
        },
        "version": {
          "anyOf": [
            {
              "$ref": "#/$defs/Version"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "The version of the resource following SemVer 2.0."
        },
        "version_number": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "version number (n-th published version, not the semantic version)",
          "title": "Version Number"
        },
        "format_version": {
          "const": "0.2.4",
          "description": "The format version of this resource specification\n(not the `version` of the resource description)\nWhen creating a new resource always use the latest micro/patch version described here.\nThe `format_version` is important for any consumer software to understand how to parse the fields.",
          "title": "Format Version",
          "type": "string"
        },
        "badges": {
          "description": "badges associated with this resource",
          "items": {
            "$ref": "#/$defs/BadgeDescr"
          },
          "title": "Badges",
          "type": "array"
        },
        "documentation": {
          "anyOf": [
            {
              "description": "A URL with the HTTP or HTTPS scheme.",
              "format": "uri",
              "maxLength": 2083,
              "minLength": 1,
              "title": "HttpUrl",
              "type": "string"
            },
            {
              "$ref": "#/$defs/RelativeFilePath"
            },
            {
              "format": "file-path",
              "title": "FilePath",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "URL or relative path to a markdown file with additional documentation.\nThe recommended documentation file name is `README.md`. An `.md` suffix is mandatory.",
          "examples": [
            "https://raw.githubusercontent.com/bioimage-io/spec-bioimage-io/main/example_descriptions/models/unet2d_nuclei_broad/README.md",
            "README.md"
          ],
          "title": "Documentation"
        },
        "license": {
          "anyOf": [
            {
              "enum": [
                "0BSD",
                "AAL",
                "Abstyles",
                "AdaCore-doc",
                "Adobe-2006",
                "Adobe-Display-PostScript",
                "Adobe-Glyph",
                "Adobe-Utopia",
                "ADSL",
                "AFL-1.1",
                "AFL-1.2",
                "AFL-2.0",
                "AFL-2.1",
                "AFL-3.0",
                "Afmparse",
                "AGPL-1.0-only",
                "AGPL-1.0-or-later",
                "AGPL-3.0-only",
                "AGPL-3.0-or-later",
                "Aladdin",
                "AMDPLPA",
                "AML",
                "AML-glslang",
                "AMPAS",
                "ANTLR-PD",
                "ANTLR-PD-fallback",
                "Apache-1.0",
                "Apache-1.1",
                "Apache-2.0",
                "APAFML",
                "APL-1.0",
                "App-s2p",
                "APSL-1.0",
                "APSL-1.1",
                "APSL-1.2",
                "APSL-2.0",
                "Arphic-1999",
                "Artistic-1.0",
                "Artistic-1.0-cl8",
                "Artistic-1.0-Perl",
                "Artistic-2.0",
                "ASWF-Digital-Assets-1.0",
                "ASWF-Digital-Assets-1.1",
                "Baekmuk",
                "Bahyph",
                "Barr",
                "bcrypt-Solar-Designer",
                "Beerware",
                "Bitstream-Charter",
                "Bitstream-Vera",
                "BitTorrent-1.0",
                "BitTorrent-1.1",
                "blessing",
                "BlueOak-1.0.0",
                "Boehm-GC",
                "Borceux",
                "Brian-Gladman-2-Clause",
                "Brian-Gladman-3-Clause",
                "BSD-1-Clause",
                "BSD-2-Clause",
                "BSD-2-Clause-Darwin",
                "BSD-2-Clause-Patent",
                "BSD-2-Clause-Views",
                "BSD-3-Clause",
                "BSD-3-Clause-acpica",
                "BSD-3-Clause-Attribution",
                "BSD-3-Clause-Clear",
                "BSD-3-Clause-flex",
                "BSD-3-Clause-HP",
                "BSD-3-Clause-LBNL",
                "BSD-3-Clause-Modification",
                "BSD-3-Clause-No-Military-License",
                "BSD-3-Clause-No-Nuclear-License",
                "BSD-3-Clause-No-Nuclear-License-2014",
                "BSD-3-Clause-No-Nuclear-Warranty",
                "BSD-3-Clause-Open-MPI",
                "BSD-3-Clause-Sun",
                "BSD-4-Clause",
                "BSD-4-Clause-Shortened",
                "BSD-4-Clause-UC",
                "BSD-4.3RENO",
                "BSD-4.3TAHOE",
                "BSD-Advertising-Acknowledgement",
                "BSD-Attribution-HPND-disclaimer",
                "BSD-Inferno-Nettverk",
                "BSD-Protection",
                "BSD-Source-beginning-file",
                "BSD-Source-Code",
                "BSD-Systemics",
                "BSD-Systemics-W3Works",
                "BSL-1.0",
                "BUSL-1.1",
                "bzip2-1.0.6",
                "C-UDA-1.0",
                "CAL-1.0",
                "CAL-1.0-Combined-Work-Exception",
                "Caldera",
                "Caldera-no-preamble",
                "CATOSL-1.1",
                "CC-BY-1.0",
                "CC-BY-2.0",
                "CC-BY-2.5",
                "CC-BY-2.5-AU",
                "CC-BY-3.0",
                "CC-BY-3.0-AT",
                "CC-BY-3.0-AU",
                "CC-BY-3.0-DE",
                "CC-BY-3.0-IGO",
                "CC-BY-3.0-NL",
                "CC-BY-3.0-US",
                "CC-BY-4.0",
                "CC-BY-NC-1.0",
                "CC-BY-NC-2.0",
                "CC-BY-NC-2.5",
                "CC-BY-NC-3.0",
                "CC-BY-NC-3.0-DE",
                "CC-BY-NC-4.0",
                "CC-BY-NC-ND-1.0",
                "CC-BY-NC-ND-2.0",
                "CC-BY-NC-ND-2.5",
                "CC-BY-NC-ND-3.0",
                "CC-BY-NC-ND-3.0-DE",
                "CC-BY-NC-ND-3.0-IGO",
                "CC-BY-NC-ND-4.0",
                "CC-BY-NC-SA-1.0",
                "CC-BY-NC-SA-2.0",
                "CC-BY-NC-SA-2.0-DE",
                "CC-BY-NC-SA-2.0-FR",
                "CC-BY-NC-SA-2.0-UK",
                "CC-BY-NC-SA-2.5",
                "CC-BY-NC-SA-3.0",
                "CC-BY-NC-SA-3.0-DE",
                "CC-BY-NC-SA-3.0-IGO",
                "CC-BY-NC-SA-4.0",
                "CC-BY-ND-1.0",
                "CC-BY-ND-2.0",
                "CC-BY-ND-2.5",
                "CC-BY-ND-3.0",
                "CC-BY-ND-3.0-DE",
                "CC-BY-ND-4.0",
                "CC-BY-SA-1.0",
                "CC-BY-SA-2.0",
                "CC-BY-SA-2.0-UK",
                "CC-BY-SA-2.1-JP",
                "CC-BY-SA-2.5",
                "CC-BY-SA-3.0",
                "CC-BY-SA-3.0-AT",
                "CC-BY-SA-3.0-DE",
                "CC-BY-SA-3.0-IGO",
                "CC-BY-SA-4.0",
                "CC-PDDC",
                "CC0-1.0",
                "CDDL-1.0",
                "CDDL-1.1",
                "CDL-1.0",
                "CDLA-Permissive-1.0",
                "CDLA-Permissive-2.0",
                "CDLA-Sharing-1.0",
                "CECILL-1.0",
                "CECILL-1.1",
                "CECILL-2.0",
                "CECILL-2.1",
                "CECILL-B",
                "CECILL-C",
                "CERN-OHL-1.1",
                "CERN-OHL-1.2",
                "CERN-OHL-P-2.0",
                "CERN-OHL-S-2.0",
                "CERN-OHL-W-2.0",
                "CFITSIO",
                "check-cvs",
                "checkmk",
                "ClArtistic",
                "Clips",
                "CMU-Mach",
                "CMU-Mach-nodoc",
                "CNRI-Jython",
                "CNRI-Python",
                "CNRI-Python-GPL-Compatible",
                "COIL-1.0",
                "Community-Spec-1.0",
                "Condor-1.1",
                "copyleft-next-0.3.0",
                "copyleft-next-0.3.1",
                "Cornell-Lossless-JPEG",
                "CPAL-1.0",
                "CPL-1.0",
                "CPOL-1.02",
                "Cronyx",
                "Crossword",
                "CrystalStacker",
                "CUA-OPL-1.0",
                "Cube",
                "curl",
                "D-FSL-1.0",
                "DEC-3-Clause",
                "diffmark",
                "DL-DE-BY-2.0",
                "DL-DE-ZERO-2.0",
                "DOC",
                "Dotseqn",
                "DRL-1.0",
                "DRL-1.1",
                "DSDP",
                "dtoa",
                "dvipdfm",
                "ECL-1.0",
                "ECL-2.0",
                "EFL-1.0",
                "EFL-2.0",
                "eGenix",
                "Elastic-2.0",
                "Entessa",
                "EPICS",
                "EPL-1.0",
                "EPL-2.0",
                "ErlPL-1.1",
                "etalab-2.0",
                "EUDatagrid",
                "EUPL-1.0",
                "EUPL-1.1",
                "EUPL-1.2",
                "Eurosym",
                "Fair",
                "FBM",
                "FDK-AAC",
                "Ferguson-Twofish",
                "Frameworx-1.0",
                "FreeBSD-DOC",
                "FreeImage",
                "FSFAP",
                "FSFAP-no-warranty-disclaimer",
                "FSFUL",
                "FSFULLR",
                "FSFULLRWD",
                "FTL",
                "Furuseth",
                "fwlw",
                "GCR-docs",
                "GD",
                "GFDL-1.1-invariants-only",
                "GFDL-1.1-invariants-or-later",
                "GFDL-1.1-no-invariants-only",
                "GFDL-1.1-no-invariants-or-later",
                "GFDL-1.1-only",
                "GFDL-1.1-or-later",
                "GFDL-1.2-invariants-only",
                "GFDL-1.2-invariants-or-later",
                "GFDL-1.2-no-invariants-only",
                "GFDL-1.2-no-invariants-or-later",
                "GFDL-1.2-only",
                "GFDL-1.2-or-later",
                "GFDL-1.3-invariants-only",
                "GFDL-1.3-invariants-or-later",
                "GFDL-1.3-no-invariants-only",
                "GFDL-1.3-no-invariants-or-later",
                "GFDL-1.3-only",
                "GFDL-1.3-or-later",
                "Giftware",
                "GL2PS",
                "Glide",
                "Glulxe",
                "GLWTPL",
                "gnuplot",
                "GPL-1.0-only",
                "GPL-1.0-or-later",
                "GPL-2.0-only",
                "GPL-2.0-or-later",
                "GPL-3.0-only",
                "GPL-3.0-or-later",
                "Graphics-Gems",
                "gSOAP-1.3b",
                "gtkbook",
                "HaskellReport",
                "hdparm",
                "Hippocratic-2.1",
                "HP-1986",
                "HP-1989",
                "HPND",
                "HPND-DEC",
                "HPND-doc",
                "HPND-doc-sell",
                "HPND-export-US",
                "HPND-export-US-modify",
                "HPND-Fenneberg-Livingston",
                "HPND-INRIA-IMAG",
                "HPND-Kevlin-Henney",
                "HPND-Markus-Kuhn",
                "HPND-MIT-disclaimer",
                "HPND-Pbmplus",
                "HPND-sell-MIT-disclaimer-xserver",
                "HPND-sell-regexpr",
                "HPND-sell-variant",
                "HPND-sell-variant-MIT-disclaimer",
                "HPND-UC",
                "HTMLTIDY",
                "IBM-pibs",
                "ICU",
                "IEC-Code-Components-EULA",
                "IJG",
                "IJG-short",
                "ImageMagick",
                "iMatix",
                "Imlib2",
                "Info-ZIP",
                "Inner-Net-2.0",
                "Intel",
                "Intel-ACPI",
                "Interbase-1.0",
                "IPA",
                "IPL-1.0",
                "ISC",
                "ISC-Veillard",
                "Jam",
                "JasPer-2.0",
                "JPL-image",
                "JPNIC",
                "JSON",
                "Kastrup",
                "Kazlib",
                "Knuth-CTAN",
                "LAL-1.2",
                "LAL-1.3",
                "Latex2e",
                "Latex2e-translated-notice",
                "Leptonica",
                "LGPL-2.0-only",
                "LGPL-2.0-or-later",
                "LGPL-2.1-only",
                "LGPL-2.1-or-later",
                "LGPL-3.0-only",
                "LGPL-3.0-or-later",
                "LGPLLR",
                "Libpng",
                "libpng-2.0",
                "libselinux-1.0",
                "libtiff",
                "libutil-David-Nugent",
                "LiLiQ-P-1.1",
                "LiLiQ-R-1.1",
                "LiLiQ-Rplus-1.1",
                "Linux-man-pages-1-para",
                "Linux-man-pages-copyleft",
                "Linux-man-pages-copyleft-2-para",
                "Linux-man-pages-copyleft-var",
                "Linux-OpenIB",
                "LOOP",
                "LPD-document",
                "LPL-1.0",
                "LPL-1.02",
                "LPPL-1.0",
                "LPPL-1.1",
                "LPPL-1.2",
                "LPPL-1.3a",
                "LPPL-1.3c",
                "lsof",
                "Lucida-Bitmap-Fonts",
                "LZMA-SDK-9.11-to-9.20",
                "LZMA-SDK-9.22",
                "Mackerras-3-Clause",
                "Mackerras-3-Clause-acknowledgment",
                "magaz",
                "mailprio",
                "MakeIndex",
                "Martin-Birgmeier",
                "McPhee-slideshow",
                "metamail",
                "Minpack",
                "MirOS",
                "MIT",
                "MIT-0",
                "MIT-advertising",
                "MIT-CMU",
                "MIT-enna",
                "MIT-feh",
                "MIT-Festival",
                "MIT-Modern-Variant",
                "MIT-open-group",
                "MIT-testregex",
                "MIT-Wu",
                "MITNFA",
                "MMIXware",
                "Motosoto",
                "MPEG-SSG",
                "mpi-permissive",
                "mpich2",
                "MPL-1.0",
                "MPL-1.1",
                "MPL-2.0",
                "MPL-2.0-no-copyleft-exception",
                "mplus",
                "MS-LPL",
                "MS-PL",
                "MS-RL",
                "MTLL",
                "MulanPSL-1.0",
                "MulanPSL-2.0",
                "Multics",
                "Mup",
                "NAIST-2003",
                "NASA-1.3",
                "Naumen",
                "NBPL-1.0",
                "NCGL-UK-2.0",
                "NCSA",
                "Net-SNMP",
                "NetCDF",
                "Newsletr",
                "NGPL",
                "NICTA-1.0",
                "NIST-PD",
                "NIST-PD-fallback",
                "NIST-Software",
                "NLOD-1.0",
                "NLOD-2.0",
                "NLPL",
                "Nokia",
                "NOSL",
                "Noweb",
                "NPL-1.0",
                "NPL-1.1",
                "NPOSL-3.0",
                "NRL",
                "NTP",
                "NTP-0",
                "O-UDA-1.0",
                "OCCT-PL",
                "OCLC-2.0",
                "ODbL-1.0",
                "ODC-By-1.0",
                "OFFIS",
                "OFL-1.0",
                "OFL-1.0-no-RFN",
                "OFL-1.0-RFN",
                "OFL-1.1",
                "OFL-1.1-no-RFN",
                "OFL-1.1-RFN",
                "OGC-1.0",
                "OGDL-Taiwan-1.0",
                "OGL-Canada-2.0",
                "OGL-UK-1.0",
                "OGL-UK-2.0",
                "OGL-UK-3.0",
                "OGTSL",
                "OLDAP-1.1",
                "OLDAP-1.2",
                "OLDAP-1.3",
                "OLDAP-1.4",
                "OLDAP-2.0",
                "OLDAP-2.0.1",
                "OLDAP-2.1",
                "OLDAP-2.2",
                "OLDAP-2.2.1",
                "OLDAP-2.2.2",
                "OLDAP-2.3",
                "OLDAP-2.4",
                "OLDAP-2.5",
                "OLDAP-2.6",
                "OLDAP-2.7",
                "OLDAP-2.8",
                "OLFL-1.3",
                "OML",
                "OpenPBS-2.3",
                "OpenSSL",
                "OpenSSL-standalone",
                "OpenVision",
                "OPL-1.0",
                "OPL-UK-3.0",
                "OPUBL-1.0",
                "OSET-PL-2.1",
                "OSL-1.0",
                "OSL-1.1",
                "OSL-2.0",
                "OSL-2.1",
                "OSL-3.0",
                "PADL",
                "Parity-6.0.0",
                "Parity-7.0.0",
                "PDDL-1.0",
                "PHP-3.0",
                "PHP-3.01",
                "Pixar",
                "Plexus",
                "pnmstitch",
                "PolyForm-Noncommercial-1.0.0",
                "PolyForm-Small-Business-1.0.0",
                "PostgreSQL",
                "PSF-2.0",
                "psfrag",
                "psutils",
                "Python-2.0",
                "Python-2.0.1",
                "python-ldap",
                "Qhull",
                "QPL-1.0",
                "QPL-1.0-INRIA-2004",
                "radvd",
                "Rdisc",
                "RHeCos-1.1",
                "RPL-1.1",
                "RPL-1.5",
                "RPSL-1.0",
                "RSA-MD",
                "RSCPL",
                "Ruby",
                "SAX-PD",
                "SAX-PD-2.0",
                "Saxpath",
                "SCEA",
                "SchemeReport",
                "Sendmail",
                "Sendmail-8.23",
                "SGI-B-1.0",
                "SGI-B-1.1",
                "SGI-B-2.0",
                "SGI-OpenGL",
                "SGP4",
                "SHL-0.5",
                "SHL-0.51",
                "SimPL-2.0",
                "SISSL",
                "SISSL-1.2",
                "SL",
                "Sleepycat",
                "SMLNJ",
                "SMPPL",
                "SNIA",
                "snprintf",
                "softSurfer",
                "Soundex",
                "Spencer-86",
                "Spencer-94",
                "Spencer-99",
                "SPL-1.0",
                "ssh-keyscan",
                "SSH-OpenSSH",
                "SSH-short",
                "SSLeay-standalone",
                "SSPL-1.0",
                "SugarCRM-1.1.3",
                "Sun-PPP",
                "SunPro",
                "SWL",
                "swrule",
                "Symlinks",
                "TAPR-OHL-1.0",
                "TCL",
                "TCP-wrappers",
                "TermReadKey",
                "TGPPL-1.0",
                "TMate",
                "TORQUE-1.1",
                "TOSL",
                "TPDL",
                "TPL-1.0",
                "TTWL",
                "TTYP0",
                "TU-Berlin-1.0",
                "TU-Berlin-2.0",
                "UCAR",
                "UCL-1.0",
                "ulem",
                "UMich-Merit",
                "Unicode-3.0",
                "Unicode-DFS-2015",
                "Unicode-DFS-2016",
                "Unicode-TOU",
                "UnixCrypt",
                "Unlicense",
                "UPL-1.0",
                "URT-RLE",
                "Vim",
                "VOSTROM",
                "VSL-1.0",
                "W3C",
                "W3C-19980720",
                "W3C-20150513",
                "w3m",
                "Watcom-1.0",
                "Widget-Workshop",
                "Wsuipa",
                "WTFPL",
                "X11",
                "X11-distribute-modifications-variant",
                "Xdebug-1.03",
                "Xerox",
                "Xfig",
                "XFree86-1.1",
                "xinetd",
                "xkeyboard-config-Zinoviev",
                "xlock",
                "Xnet",
                "xpp",
                "XSkat",
                "YPL-1.0",
                "YPL-1.1",
                "Zed",
                "Zeeff",
                "Zend-2.0",
                "Zimbra-1.3",
                "Zimbra-1.4",
                "Zlib",
                "zlib-acknowledgement",
                "ZPL-1.1",
                "ZPL-2.0",
                "ZPL-2.1"
              ],
              "title": "LicenseId",
              "type": "string"
            },
            {
              "enum": [
                "AGPL-1.0",
                "AGPL-3.0",
                "BSD-2-Clause-FreeBSD",
                "BSD-2-Clause-NetBSD",
                "bzip2-1.0.5",
                "eCos-2.0",
                "GFDL-1.1",
                "GFDL-1.2",
                "GFDL-1.3",
                "GPL-1.0",
                "GPL-1.0+",
                "GPL-2.0",
                "GPL-2.0+",
                "GPL-2.0-with-autoconf-exception",
                "GPL-2.0-with-bison-exception",
                "GPL-2.0-with-classpath-exception",
                "GPL-2.0-with-font-exception",
                "GPL-2.0-with-GCC-exception",
                "GPL-3.0",
                "GPL-3.0+",
                "GPL-3.0-with-autoconf-exception",
                "GPL-3.0-with-GCC-exception",
                "LGPL-2.0",
                "LGPL-2.0+",
                "LGPL-2.1",
                "LGPL-2.1+",
                "LGPL-3.0",
                "LGPL-3.0+",
                "Nunit",
                "StandardML-NJ",
                "wxWindows"
              ],
              "title": "DeprecatedLicenseId",
              "type": "string"
            },
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "A [SPDX license identifier](https://spdx.org/licenses/).\nWe do not support custom license beyond the SPDX license list, if you need that please\n[open a GitHub issue](https://github.com/bioimage-io/spec-bioimage-io/issues/new/choose\n) to discuss your intentions with the community.",
          "examples": [
            "CC0-1.0",
            "MIT",
            "BSD-2-Clause"
          ],
          "title": "License"
        },
        "type": {
          "const": "dataset",
          "title": "Type",
          "type": "string"
        },
        "id": {
          "anyOf": [
            {
              "minLength": 1,
              "title": "DatasetId",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "bioimage.io-wide unique resource identifier\nassigned by bioimage.io; version **un**specific.",
          "title": "Id"
        },
        "source": {
          "anyOf": [
            {
              "description": "A URL with the HTTP or HTTPS scheme.",
              "format": "uri",
              "maxLength": 2083,
              "minLength": 1,
              "title": "HttpUrl",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "\"URL to the source of the dataset.",
          "title": "Source"
        }
      },
      "required": [
        "name",
        "description",
        "format_version",
        "type"
      ],
      "title": "dataset 0.2.4",
      "type": "object"
    },
    "Datetime": {
      "description": "Timestamp in [ISO 8601](#https://en.wikipedia.org/wiki/ISO_8601) format\nwith a few restrictions listed [here](https://docs.python.org/3/library/datetime.html#datetime.datetime.fromisoformat).",
      "format": "date-time",
      "title": "Datetime",
      "type": "string"
    },
    "ImplicitOutputShape": {
      "additionalProperties": false,
      "description": "Output tensor shape depending on an input tensor shape.\n`shape(output_tensor) = shape(input_tensor) * scale + 2 * offset`",
      "properties": {
        "reference_tensor": {
          "description": "Name of the reference tensor.",
          "minLength": 1,
          "title": "TensorName",
          "type": "string"
        },
        "scale": {
          "description": "output_pix/input_pix for each dimension.\n'null' values indicate new dimensions, whose length is defined by 2*`offset`",
          "items": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ]
          },
          "minItems": 1,
          "title": "Scale",
          "type": "array"
        },
        "offset": {
          "description": "Position of origin wrt to input.",
          "items": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "multipleOf": 0.5,
                "type": "number"
              }
            ]
          },
          "minItems": 1,
          "title": "Offset",
          "type": "array"
        }
      },
      "required": [
        "reference_tensor",
        "scale",
        "offset"
      ],
      "title": "model.v0_4.ImplicitOutputShape",
      "type": "object"
    },
    "InputTensorDescr": {
      "additionalProperties": false,
      "properties": {
        "name": {
          "description": "Tensor name. No duplicates are allowed.",
          "minLength": 1,
          "title": "TensorName",
          "type": "string"
        },
        "description": {
          "default": "",
          "title": "Description",
          "type": "string"
        },
        "axes": {
          "description": "Axes identifying characters. Same length and order as the axes in `shape`.\n| axis | description |\n| --- | --- |\n|  b  |  batch (groups multiple samples) |\n|  i  |  instance/index/element |\n|  t  |  time |\n|  c  |  channel |\n|  z  |  spatial dimension z |\n|  y  |  spatial dimension y |\n|  x  |  spatial dimension x |",
          "title": "Axes",
          "type": "string"
        },
        "data_range": {
          "anyOf": [
            {
              "maxItems": 2,
              "minItems": 2,
              "prefixItems": [
                {
                  "type": "number"
                },
                {
                  "type": "number"
                }
              ],
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Tuple `(minimum, maximum)` specifying the allowed range of the data in this tensor.\nIf not specified, the full data range that can be expressed in `data_type` is allowed.",
          "title": "Data Range"
        },
        "data_type": {
          "description": "For now an input tensor is expected to be given as `float32`.\nThe data flow in bioimage.io models is explained\n[in this diagram.](https://docs.google.com/drawings/d/1FTw8-Rn6a6nXdkZ_SkMumtcjvur9mtIhRqLwnKqZNHM/edit).",
          "enum": [
            "float32",
            "uint8",
            "uint16"
          ],
          "title": "Data Type",
          "type": "string"
        },
        "shape": {
          "anyOf": [
            {
              "items": {
                "type": "integer"
              },
              "type": "array"
            },
            {
              "$ref": "#/$defs/ParameterizedInputShape"
            }
          ],
          "description": "Specification of input tensor shape.",
          "examples": [
            [
              1,
              512,
              512,
              1
            ],
            {
              "min": [
                1,
                64,
                64,
                1
              ],
              "step": [
                0,
                32,
                32,
                0
              ]
            }
          ],
          "title": "Shape"
        },
        "preprocessing": {
          "description": "Description of how this input should be preprocessed.",
          "items": {
            "discriminator": {
              "mapping": {
                "binarize": "#/$defs/BinarizeDescr",
                "clip": "#/$defs/ClipDescr",
                "scale_linear": "#/$defs/ScaleLinearDescr",
                "scale_range": "#/$defs/ScaleRangeDescr",
                "sigmoid": "#/$defs/SigmoidDescr",
                "zero_mean_unit_variance": "#/$defs/ZeroMeanUnitVarianceDescr"
              },
              "propertyName": "name"
            },
            "oneOf": [
              {
                "$ref": "#/$defs/BinarizeDescr"
              },
              {
                "$ref": "#/$defs/ClipDescr"
              },
              {
                "$ref": "#/$defs/ScaleLinearDescr"
              },
              {
                "$ref": "#/$defs/SigmoidDescr"
              },
              {
                "$ref": "#/$defs/ZeroMeanUnitVarianceDescr"
              },
              {
                "$ref": "#/$defs/ScaleRangeDescr"
              }
            ]
          },
          "title": "Preprocessing",
          "type": "array"
        }
      },
      "required": [
        "name",
        "axes",
        "data_type",
        "shape"
      ],
      "title": "model.v0_4.InputTensorDescr",
      "type": "object"
    },
    "KerasHdf5WeightsDescr": {
      "additionalProperties": false,
      "properties": {
        "source": {
          "anyOf": [
            {
              "description": "A URL with the HTTP or HTTPS scheme.",
              "format": "uri",
              "maxLength": 2083,
              "minLength": 1,
              "title": "HttpUrl",
              "type": "string"
            },
            {
              "$ref": "#/$defs/RelativeFilePath"
            },
            {
              "format": "file-path",
              "title": "FilePath",
              "type": "string"
            }
          ],
          "description": "The weights file.",
          "title": "Source"
        },
        "sha256": {
          "anyOf": [
            {
              "description": "A SHA-256 hash value",
              "maxLength": 64,
              "minLength": 64,
              "title": "Sha256",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "SHA256 hash value of the **source** file.",
          "title": "Sha256"
        },
        "attachments": {
          "anyOf": [
            {
              "$ref": "#/$defs/AttachmentsDescr"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Attachments that are specific to this weights entry."
        },
        "authors": {
          "anyOf": [
            {
              "items": {
                "$ref": "#/$defs/Author"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Authors\nEither the person(s) that have trained this model resulting in the original weights file.\n    (If this is the initial weights entry, i.e. it does not have a `parent`)\nOr the person(s) who have converted the weights to this weights format.\n    (If this is a child weight, i.e. it has a `parent` field)",
          "title": "Authors"
        },
        "dependencies": {
          "anyOf": [
            {
              "pattern": "^.+:.+$",
              "title": "Dependencies",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Dependency manager and dependency file, specified as `<dependency manager>:<relative file path>`.",
          "examples": [
            "conda:environment.yaml",
            "maven:./pom.xml",
            "pip:./requirements.txt"
          ],
          "title": "Dependencies"
        },
        "parent": {
          "anyOf": [
            {
              "enum": [
                "keras_hdf5",
                "onnx",
                "pytorch_state_dict",
                "tensorflow_js",
                "tensorflow_saved_model_bundle",
                "torchscript"
              ],
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "The source weights these weights were converted from.\nFor example, if a model's weights were converted from the `pytorch_state_dict` format to `torchscript`,\nThe `pytorch_state_dict` weights entry has no `parent` and is the parent of the `torchscript` weights.\nAll weight entries except one (the initial set of weights resulting from training the model),\nneed to have this field.",
          "examples": [
            "pytorch_state_dict"
          ],
          "title": "Parent"
        },
        "tensorflow_version": {
          "anyOf": [
            {
              "$ref": "#/$defs/Version"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "TensorFlow version used to create these weights"
        }
      },
      "required": [
        "source"
      ],
      "title": "model.v0_4.KerasHdf5WeightsDescr",
      "type": "object"
    },
    "LinkedDataset": {
      "additionalProperties": false,
      "description": "Reference to a bioimage.io dataset.",
      "properties": {
        "id": {
          "description": "A valid dataset `id` from the bioimage.io collection.",
          "minLength": 1,
          "title": "DatasetId",
          "type": "string"
        },
        "version_number": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "version number (n-th published version, not the semantic version) of linked dataset",
          "title": "Version Number"
        }
      },
      "required": [
        "id"
      ],
      "title": "dataset.v0_2.LinkedDataset",
      "type": "object"
    },
    "LinkedModel": {
      "additionalProperties": false,
      "description": "Reference to a bioimage.io model.",
      "properties": {
        "id": {
          "description": "A valid model `id` from the bioimage.io collection.",
          "examples": [
            "affable-shark",
            "ambitious-sloth"
          ],
          "minLength": 1,
          "title": "ModelId",
          "type": "string"
        },
        "version_number": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "version number (n-th published version, not the semantic version) of linked model",
          "title": "Version Number"
        }
      },
      "required": [
        "id"
      ],
      "title": "model.v0_4.LinkedModel",
      "type": "object"
    },
    "Maintainer": {
      "additionalProperties": false,
      "properties": {
        "affiliation": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Affiliation",
          "title": "Affiliation"
        },
        "email": {
          "anyOf": [
            {
              "format": "email",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Email",
          "title": "Email"
        },
        "orcid": {
          "anyOf": [
            {
              "description": "An ORCID identifier, see https://orcid.org/",
              "title": "OrcidId",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "An [ORCID iD](https://support.orcid.org/hc/en-us/sections/360001495313-What-is-ORCID\n) in hyphenated groups of 4 digits, (and [valid](\nhttps://support.orcid.org/hc/en-us/articles/360006897674-Structure-of-the-ORCID-Identifier\n) as per ISO 7064 11,2.)",
          "examples": [
            "0000-0001-2345-6789"
          ],
          "title": "Orcid"
        },
        "name": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Name"
        },
        "github_user": {
          "title": "Github User",
          "type": "string"
        }
      },
      "required": [
        "github_user"
      ],
      "title": "generic.v0_2.Maintainer",
      "type": "object"
    },
    "OnnxWeightsDescr": {
      "additionalProperties": false,
      "properties": {
        "source": {
          "anyOf": [
            {
              "description": "A URL with the HTTP or HTTPS scheme.",
              "format": "uri",
              "maxLength": 2083,
              "minLength": 1,
              "title": "HttpUrl",
              "type": "string"
            },
            {
              "$ref": "#/$defs/RelativeFilePath"
            },
            {
              "format": "file-path",
              "title": "FilePath",
              "type": "string"
            }
          ],
          "description": "The weights file.",
          "title": "Source"
        },
        "sha256": {
          "anyOf": [
            {
              "description": "A SHA-256 hash value",
              "maxLength": 64,
              "minLength": 64,
              "title": "Sha256",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "SHA256 hash value of the **source** file.",
          "title": "Sha256"
        },
        "attachments": {
          "anyOf": [
            {
              "$ref": "#/$defs/AttachmentsDescr"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Attachments that are specific to this weights entry."
        },
        "authors": {
          "anyOf": [
            {
              "items": {
                "$ref": "#/$defs/Author"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Authors\nEither the person(s) that have trained this model resulting in the original weights file.\n    (If this is the initial weights entry, i.e. it does not have a `parent`)\nOr the person(s) who have converted the weights to this weights format.\n    (If this is a child weight, i.e. it has a `parent` field)",
          "title": "Authors"
        },
        "dependencies": {
          "anyOf": [
            {
              "pattern": "^.+:.+$",
              "title": "Dependencies",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Dependency manager and dependency file, specified as `<dependency manager>:<relative file path>`.",
          "examples": [
            "conda:environment.yaml",
            "maven:./pom.xml",
            "pip:./requirements.txt"
          ],
          "title": "Dependencies"
        },
        "parent": {
          "anyOf": [
            {
              "enum": [
                "keras_hdf5",
                "onnx",
                "pytorch_state_dict",
                "tensorflow_js",
                "tensorflow_saved_model_bundle",
                "torchscript"
              ],
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "The source weights these weights were converted from.\nFor example, if a model's weights were converted from the `pytorch_state_dict` format to `torchscript`,\nThe `pytorch_state_dict` weights entry has no `parent` and is the parent of the `torchscript` weights.\nAll weight entries except one (the initial set of weights resulting from training the model),\nneed to have this field.",
          "examples": [
            "pytorch_state_dict"
          ],
          "title": "Parent"
        },
        "opset_version": {
          "anyOf": [
            {
              "minimum": 7,
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "ONNX opset version",
          "title": "Opset Version"
        }
      },
      "required": [
        "source"
      ],
      "title": "model.v0_4.OnnxWeightsDescr",
      "type": "object"
    },
    "OutputTensorDescr": {
      "additionalProperties": false,
      "properties": {
        "name": {
          "description": "Tensor name. No duplicates are allowed.",
          "minLength": 1,
          "title": "TensorName",
          "type": "string"
        },
        "description": {
          "default": "",
          "title": "Description",
          "type": "string"
        },
        "axes": {
          "description": "Axes identifying characters. Same length and order as the axes in `shape`.\n| axis | description |\n| --- | --- |\n|  b  |  batch (groups multiple samples) |\n|  i  |  instance/index/element |\n|  t  |  time |\n|  c  |  channel |\n|  z  |  spatial dimension z |\n|  y  |  spatial dimension y |\n|  x  |  spatial dimension x |",
          "title": "Axes",
          "type": "string"
        },
        "data_range": {
          "anyOf": [
            {
              "maxItems": 2,
              "minItems": 2,
              "prefixItems": [
                {
                  "type": "number"
                },
                {
                  "type": "number"
                }
              ],
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Tuple `(minimum, maximum)` specifying the allowed range of the data in this tensor.\nIf not specified, the full data range that can be expressed in `data_type` is allowed.",
          "title": "Data Range"
        },
        "data_type": {
          "description": "Data type.\nThe data flow in bioimage.io models is explained\n[in this diagram.](https://docs.google.com/drawings/d/1FTw8-Rn6a6nXdkZ_SkMumtcjvur9mtIhRqLwnKqZNHM/edit).",
          "enum": [
            "float32",
            "float64",
            "uint8",
            "int8",
            "uint16",
            "int16",
            "uint32",
            "int32",
            "uint64",
            "int64",
            "bool"
          ],
          "title": "Data Type",
          "type": "string"
        },
        "shape": {
          "anyOf": [
            {
              "items": {
                "type": "integer"
              },
              "type": "array"
            },
            {
              "$ref": "#/$defs/ImplicitOutputShape"
            }
          ],
          "description": "Output tensor shape.",
          "title": "Shape"
        },
        "halo": {
          "anyOf": [
            {
              "items": {
                "type": "integer"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "The `halo` that should be cropped from the output tensor to avoid boundary effects.\nThe `halo` is to be cropped from both sides, i.e. `shape_after_crop = shape - 2 * halo`.\nTo document a `halo` that is already cropped by the model `shape.offset` has to be used instead.",
          "title": "Halo"
        },
        "postprocessing": {
          "description": "Description of how this output should be postprocessed.",
          "items": {
            "discriminator": {
              "mapping": {
                "binarize": "#/$defs/BinarizeDescr",
                "clip": "#/$defs/ClipDescr",
                "scale_linear": "#/$defs/ScaleLinearDescr",
                "scale_mean_variance": "#/$defs/ScaleMeanVarianceDescr",
                "scale_range": "#/$defs/ScaleRangeDescr",
                "sigmoid": "#/$defs/SigmoidDescr",
                "zero_mean_unit_variance": "#/$defs/ZeroMeanUnitVarianceDescr"
              },
              "propertyName": "name"
            },
            "oneOf": [
              {
                "$ref": "#/$defs/BinarizeDescr"
              },
              {
                "$ref": "#/$defs/ClipDescr"
              },
              {
                "$ref": "#/$defs/ScaleLinearDescr"
              },
              {
                "$ref": "#/$defs/SigmoidDescr"
              },
              {
                "$ref": "#/$defs/ZeroMeanUnitVarianceDescr"
              },
              {
                "$ref": "#/$defs/ScaleRangeDescr"
              },
              {
                "$ref": "#/$defs/ScaleMeanVarianceDescr"
              }
            ]
          },
          "title": "Postprocessing",
          "type": "array"
        }
      },
      "required": [
        "name",
        "axes",
        "data_type",
        "shape"
      ],
      "title": "model.v0_4.OutputTensorDescr",
      "type": "object"
    },
    "ParameterizedInputShape": {
      "additionalProperties": false,
      "description": "A sequence of valid shapes given by `shape_k = min + k * step for k in {0, 1, ...}`.",
      "properties": {
        "min": {
          "description": "The minimum input shape",
          "items": {
            "type": "integer"
          },
          "minItems": 1,
          "title": "Min",
          "type": "array"
        },
        "step": {
          "description": "The minimum shape change",
          "items": {
            "type": "integer"
          },
          "minItems": 1,
          "title": "Step",
          "type": "array"
        }
      },
      "required": [
        "min",
        "step"
      ],
      "title": "model.v0_4.ParameterizedInputShape",
      "type": "object"
    },
    "PytorchStateDictWeightsDescr": {
      "additionalProperties": false,
      "properties": {
        "source": {
          "anyOf": [
            {
              "description": "A URL with the HTTP or HTTPS scheme.",
              "format": "uri",
              "maxLength": 2083,
              "minLength": 1,
              "title": "HttpUrl",
              "type": "string"
            },
            {
              "$ref": "#/$defs/RelativeFilePath"
            },
            {
              "format": "file-path",
              "title": "FilePath",
              "type": "string"
            }
          ],
          "description": "The weights file.",
          "title": "Source"
        },
        "sha256": {
          "anyOf": [
            {
              "description": "A SHA-256 hash value",
              "maxLength": 64,
              "minLength": 64,
              "title": "Sha256",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "SHA256 hash value of the **source** file.",
          "title": "Sha256"
        },
        "attachments": {
          "anyOf": [
            {
              "$ref": "#/$defs/AttachmentsDescr"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Attachments that are specific to this weights entry."
        },
        "authors": {
          "anyOf": [
            {
              "items": {
                "$ref": "#/$defs/Author"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Authors\nEither the person(s) that have trained this model resulting in the original weights file.\n    (If this is the initial weights entry, i.e. it does not have a `parent`)\nOr the person(s) who have converted the weights to this weights format.\n    (If this is a child weight, i.e. it has a `parent` field)",
          "title": "Authors"
        },
        "dependencies": {
          "anyOf": [
            {
              "pattern": "^.+:.+$",
              "title": "Dependencies",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Dependency manager and dependency file, specified as `<dependency manager>:<relative file path>`.",
          "examples": [
            "conda:environment.yaml",
            "maven:./pom.xml",
            "pip:./requirements.txt"
          ],
          "title": "Dependencies"
        },
        "parent": {
          "anyOf": [
            {
              "enum": [
                "keras_hdf5",
                "onnx",
                "pytorch_state_dict",
                "tensorflow_js",
                "tensorflow_saved_model_bundle",
                "torchscript"
              ],
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "The source weights these weights were converted from.\nFor example, if a model's weights were converted from the `pytorch_state_dict` format to `torchscript`,\nThe `pytorch_state_dict` weights entry has no `parent` and is the parent of the `torchscript` weights.\nAll weight entries except one (the initial set of weights resulting from training the model),\nneed to have this field.",
          "examples": [
            "pytorch_state_dict"
          ],
          "title": "Parent"
        },
        "architecture": {
          "anyOf": [
            {
              "pattern": "^.+:.+$",
              "title": "CallableFromFile",
              "type": "string"
            },
            {
              "pattern": "^.+\\..+$",
              "title": "CallableFromDepencency",
              "type": "string"
            }
          ],
          "description": "callable returning a torch.nn.Module instance.\nLocal implementation: `<relative path to file>:<identifier of implementation within the file>`.\nImplementation in a dependency: `<dependency-package>.<[dependency-module]>.<identifier>`.",
          "examples": [
            "my_function.py:MyNetworkClass",
            "my_module.submodule.get_my_model"
          ],
          "title": "Architecture"
        },
        "architecture_sha256": {
          "anyOf": [
            {
              "description": "A SHA-256 hash value",
              "maxLength": 64,
              "minLength": 64,
              "title": "Sha256",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "The SHA256 of the architecture source file, if the architecture is not defined in a module listed in `dependencies`\nYou can drag and drop your file to this\n[online tool](http://emn178.github.io/online-tools/sha256_checksum.html) to generate a SHA256 in your browser.\nOr you can generate a SHA256 checksum with Python's `hashlib`,\n[here is a codesnippet](https://gist.github.com/FynnBe/e64460463df89439cff218bbf59c1100).",
          "title": "Architecture Sha256"
        },
        "kwargs": {
          "additionalProperties": true,
          "description": "key word arguments for the `architecture` callable",
          "title": "Kwargs",
          "type": "object"
        },
        "pytorch_version": {
          "anyOf": [
            {
              "$ref": "#/$defs/Version"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Version of the PyTorch library used.\nIf `depencencies` is specified it should include pytorch and the verison has to match.\n(`dependencies` overrules `pytorch_version`)"
        }
      },
      "required": [
        "source",
        "architecture"
      ],
      "title": "model.v0_4.PytorchStateDictWeightsDescr",
      "type": "object"
    },
    "RelativeFilePath": {
      "description": "A path relative to the `rdf.yaml` file (also if the RDF source is a URL).",
      "format": "path",
      "title": "RelativeFilePath",
      "type": "string"
    },
    "RunMode": {
      "additionalProperties": false,
      "properties": {
        "name": {
          "anyOf": [
            {
              "const": "deepimagej",
              "type": "string"
            },
            {
              "type": "string"
            }
          ],
          "description": "Run mode name",
          "title": "Name"
        },
        "kwargs": {
          "additionalProperties": true,
          "description": "Run mode specific key word arguments",
          "title": "Kwargs",
          "type": "object"
        }
      },
      "required": [
        "name"
      ],
      "title": "model.v0_4.RunMode",
      "type": "object"
    },
    "ScaleLinearDescr": {
      "additionalProperties": false,
      "description": "Fixed linear scaling.",
      "properties": {
        "name": {
          "const": "scale_linear",
          "title": "Name",
          "type": "string"
        },
        "kwargs": {
          "$ref": "#/$defs/ScaleLinearKwargs"
        }
      },
      "required": [
        "name",
        "kwargs"
      ],
      "title": "model.v0_4.ScaleLinearDescr",
      "type": "object"
    },
    "ScaleLinearKwargs": {
      "additionalProperties": false,
      "description": "key word arguments for `ScaleLinearDescr`",
      "properties": {
        "axes": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "The subset of axes to scale jointly.\nFor example xy to scale the two image axes for 2d data jointly.",
          "examples": [
            "xy"
          ],
          "title": "Axes"
        },
        "gain": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "items": {
                "type": "number"
              },
              "type": "array"
            }
          ],
          "default": 1.0,
          "description": "multiplicative factor",
          "title": "Gain"
        },
        "offset": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "items": {
                "type": "number"
              },
              "type": "array"
            }
          ],
          "default": 0.0,
          "description": "additive term",
          "title": "Offset"
        }
      },
      "title": "model.v0_4.ScaleLinearKwargs",
      "type": "object"
    },
    "ScaleMeanVarianceDescr": {
      "additionalProperties": false,
      "description": "Scale the tensor s.t. its mean and variance match a reference tensor.",
      "properties": {
        "name": {
          "const": "scale_mean_variance",
          "title": "Name",
          "type": "string"
        },
        "kwargs": {
          "$ref": "#/$defs/ScaleMeanVarianceKwargs"
        }
      },
      "required": [
        "name",
        "kwargs"
      ],
      "title": "model.v0_4.ScaleMeanVarianceDescr",
      "type": "object"
    },
    "ScaleMeanVarianceKwargs": {
      "additionalProperties": false,
      "description": "key word arguments for `ScaleMeanVarianceDescr`",
      "properties": {
        "mode": {
          "description": "Mode for computing mean and variance.\n|     mode    |             description              |\n| ----------- | ------------------------------------ |\n| per_dataset | Compute for the entire dataset       |\n| per_sample  | Compute for each sample individually |",
          "enum": [
            "per_dataset",
            "per_sample"
          ],
          "title": "Mode",
          "type": "string"
        },
        "reference_tensor": {
          "description": "Name of tensor to match.",
          "minLength": 1,
          "title": "TensorName",
          "type": "string"
        },
        "axes": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "The subset of axes to scale jointly.\nFor example xy to normalize the two image axes for 2d data jointly.\nDefault: scale all non-batch axes jointly.",
          "examples": [
            "xy"
          ],
          "title": "Axes"
        },
        "eps": {
          "default": 1e-06,
          "description": "Epsilon for numeric stability:\n\"`out  = (tensor - mean) / (std + eps) * (ref_std + eps) + ref_mean.",
          "exclusiveMinimum": 0,
          "maximum": 0.1,
          "title": "Eps",
          "type": "number"
        }
      },
      "required": [
        "mode",
        "reference_tensor"
      ],
      "title": "model.v0_4.ScaleMeanVarianceKwargs",
      "type": "object"
    },
    "ScaleRangeDescr": {
      "additionalProperties": false,
      "description": "Scale with percentiles.",
      "properties": {
        "name": {
          "const": "scale_range",
          "title": "Name",
          "type": "string"
        },
        "kwargs": {
          "$ref": "#/$defs/ScaleRangeKwargs"
        }
      },
      "required": [
        "name",
        "kwargs"
      ],
      "title": "model.v0_4.ScaleRangeDescr",
      "type": "object"
    },
    "ScaleRangeKwargs": {
      "additionalProperties": false,
      "description": "key word arguments for `ScaleRangeDescr`\n\nFor `min_percentile`=0.0 (the default) and `max_percentile`=100 (the default)\nthis processing step normalizes data to the [0, 1] intervall.\nFor other percentiles the normalized values will partially be outside the [0, 1]\nintervall. Use `ScaleRange` followed by `ClipDescr` if you want to limit the\nnormalized values to a range.",
      "properties": {
        "mode": {
          "description": "Mode for computing percentiles.\n|     mode    |             description              |\n| ----------- | ------------------------------------ |\n| per_dataset | compute for the entire dataset       |\n| per_sample  | compute for each sample individually |",
          "enum": [
            "per_dataset",
            "per_sample"
          ],
          "title": "Mode",
          "type": "string"
        },
        "axes": {
          "description": "The subset of axes to normalize jointly.\nFor example xy to normalize the two image axes for 2d data jointly.",
          "examples": [
            "xy"
          ],
          "title": "Axes",
          "type": "string"
        },
        "min_percentile": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "number"
            }
          ],
          "default": 0.0,
          "description": "The lower percentile used to determine the value to align with zero.",
          "ge": 0,
          "lt": 100,
          "title": "Min Percentile"
        },
        "max_percentile": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "number"
            }
          ],
          "default": 100.0,
          "description": "The upper percentile used to determine the value to align with one.\nHas to be bigger than `min_percentile`.\nThe range is 1 to 100 instead of 0 to 100 to avoid mistakenly\naccepting percentiles specified in the range 0.0 to 1.0.",
          "gt": 1,
          "le": 100,
          "title": "Max Percentile"
        },
        "eps": {
          "default": 1e-06,
          "description": "Epsilon for numeric stability.\n`out = (tensor - v_lower) / (v_upper - v_lower + eps)`;\nwith `v_lower,v_upper` values at the respective percentiles.",
          "exclusiveMinimum": 0,
          "maximum": 0.1,
          "title": "Eps",
          "type": "number"
        },
        "reference_tensor": {
          "anyOf": [
            {
              "minLength": 1,
              "title": "TensorName",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Tensor name to compute the percentiles from. Default: The tensor itself.\nFor any tensor in `inputs` only input tensor references are allowed.\nFor a tensor in `outputs` only input tensor refereences are allowed if `mode: per_dataset`",
          "title": "Reference Tensor"
        }
      },
      "required": [
        "mode",
        "axes"
      ],
      "title": "model.v0_4.ScaleRangeKwargs",
      "type": "object"
    },
    "SigmoidDescr": {
      "additionalProperties": false,
      "description": "The logistic sigmoid funciton, a.k.a. expit function.",
      "properties": {
        "name": {
          "const": "sigmoid",
          "title": "Name",
          "type": "string"
        }
      },
      "required": [
        "name"
      ],
      "title": "model.v0_4.SigmoidDescr",
      "type": "object"
    },
    "TensorflowJsWeightsDescr": {
      "additionalProperties": false,
      "properties": {
        "source": {
          "anyOf": [
            {
              "description": "A URL with the HTTP or HTTPS scheme.",
              "format": "uri",
              "maxLength": 2083,
              "minLength": 1,
              "title": "HttpUrl",
              "type": "string"
            },
            {
              "$ref": "#/$defs/RelativeFilePath"
            },
            {
              "format": "file-path",
              "title": "FilePath",
              "type": "string"
            }
          ],
          "description": "The multi-file weights.\nAll required files/folders should be a zip archive.",
          "title": "Source"
        },
        "sha256": {
          "anyOf": [
            {
              "description": "A SHA-256 hash value",
              "maxLength": 64,
              "minLength": 64,
              "title": "Sha256",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "SHA256 hash value of the **source** file.",
          "title": "Sha256"
        },
        "attachments": {
          "anyOf": [
            {
              "$ref": "#/$defs/AttachmentsDescr"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Attachments that are specific to this weights entry."
        },
        "authors": {
          "anyOf": [
            {
              "items": {
                "$ref": "#/$defs/Author"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Authors\nEither the person(s) that have trained this model resulting in the original weights file.\n    (If this is the initial weights entry, i.e. it does not have a `parent`)\nOr the person(s) who have converted the weights to this weights format.\n    (If this is a child weight, i.e. it has a `parent` field)",
          "title": "Authors"
        },
        "dependencies": {
          "anyOf": [
            {
              "pattern": "^.+:.+$",
              "title": "Dependencies",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Dependency manager and dependency file, specified as `<dependency manager>:<relative file path>`.",
          "examples": [
            "conda:environment.yaml",
            "maven:./pom.xml",
            "pip:./requirements.txt"
          ],
          "title": "Dependencies"
        },
        "parent": {
          "anyOf": [
            {
              "enum": [
                "keras_hdf5",
                "onnx",
                "pytorch_state_dict",
                "tensorflow_js",
                "tensorflow_saved_model_bundle",
                "torchscript"
              ],
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "The source weights these weights were converted from.\nFor example, if a model's weights were converted from the `pytorch_state_dict` format to `torchscript`,\nThe `pytorch_state_dict` weights entry has no `parent` and is the parent of the `torchscript` weights.\nAll weight entries except one (the initial set of weights resulting from training the model),\nneed to have this field.",
          "examples": [
            "pytorch_state_dict"
          ],
          "title": "Parent"
        },
        "tensorflow_version": {
          "anyOf": [
            {
              "$ref": "#/$defs/Version"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Version of the TensorFlow library used."
        }
      },
      "required": [
        "source"
      ],
      "title": "model.v0_4.TensorflowJsWeightsDescr",
      "type": "object"
    },
    "TensorflowSavedModelBundleWeightsDescr": {
      "additionalProperties": false,
      "properties": {
        "source": {
          "anyOf": [
            {
              "description": "A URL with the HTTP or HTTPS scheme.",
              "format": "uri",
              "maxLength": 2083,
              "minLength": 1,
              "title": "HttpUrl",
              "type": "string"
            },
            {
              "$ref": "#/$defs/RelativeFilePath"
            },
            {
              "format": "file-path",
              "title": "FilePath",
              "type": "string"
            }
          ],
          "description": "The weights file.",
          "title": "Source"
        },
        "sha256": {
          "anyOf": [
            {
              "description": "A SHA-256 hash value",
              "maxLength": 64,
              "minLength": 64,
              "title": "Sha256",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "SHA256 hash value of the **source** file.",
          "title": "Sha256"
        },
        "attachments": {
          "anyOf": [
            {
              "$ref": "#/$defs/AttachmentsDescr"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Attachments that are specific to this weights entry."
        },
        "authors": {
          "anyOf": [
            {
              "items": {
                "$ref": "#/$defs/Author"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Authors\nEither the person(s) that have trained this model resulting in the original weights file.\n    (If this is the initial weights entry, i.e. it does not have a `parent`)\nOr the person(s) who have converted the weights to this weights format.\n    (If this is a child weight, i.e. it has a `parent` field)",
          "title": "Authors"
        },
        "dependencies": {
          "anyOf": [
            {
              "pattern": "^.+:.+$",
              "title": "Dependencies",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Dependency manager and dependency file, specified as `<dependency manager>:<relative file path>`.",
          "examples": [
            "conda:environment.yaml",
            "maven:./pom.xml",
            "pip:./requirements.txt"
          ],
          "title": "Dependencies"
        },
        "parent": {
          "anyOf": [
            {
              "enum": [
                "keras_hdf5",
                "onnx",
                "pytorch_state_dict",
                "tensorflow_js",
                "tensorflow_saved_model_bundle",
                "torchscript"
              ],
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "The source weights these weights were converted from.\nFor example, if a model's weights were converted from the `pytorch_state_dict` format to `torchscript`,\nThe `pytorch_state_dict` weights entry has no `parent` and is the parent of the `torchscript` weights.\nAll weight entries except one (the initial set of weights resulting from training the model),\nneed to have this field.",
          "examples": [
            "pytorch_state_dict"
          ],
          "title": "Parent"
        },
        "tensorflow_version": {
          "anyOf": [
            {
              "$ref": "#/$defs/Version"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Version of the TensorFlow library used."
        }
      },
      "required": [
        "source"
      ],
      "title": "model.v0_4.TensorflowSavedModelBundleWeightsDescr",
      "type": "object"
    },
    "TorchscriptWeightsDescr": {
      "additionalProperties": false,
      "properties": {
        "source": {
          "anyOf": [
            {
              "description": "A URL with the HTTP or HTTPS scheme.",
              "format": "uri",
              "maxLength": 2083,
              "minLength": 1,
              "title": "HttpUrl",
              "type": "string"
            },
            {
              "$ref": "#/$defs/RelativeFilePath"
            },
            {
              "format": "file-path",
              "title": "FilePath",
              "type": "string"
            }
          ],
          "description": "The weights file.",
          "title": "Source"
        },
        "sha256": {
          "anyOf": [
            {
              "description": "A SHA-256 hash value",
              "maxLength": 64,
              "minLength": 64,
              "title": "Sha256",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "SHA256 hash value of the **source** file.",
          "title": "Sha256"
        },
        "attachments": {
          "anyOf": [
            {
              "$ref": "#/$defs/AttachmentsDescr"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Attachments that are specific to this weights entry."
        },
        "authors": {
          "anyOf": [
            {
              "items": {
                "$ref": "#/$defs/Author"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Authors\nEither the person(s) that have trained this model resulting in the original weights file.\n    (If this is the initial weights entry, i.e. it does not have a `parent`)\nOr the person(s) who have converted the weights to this weights format.\n    (If this is a child weight, i.e. it has a `parent` field)",
          "title": "Authors"
        },
        "dependencies": {
          "anyOf": [
            {
              "pattern": "^.+:.+$",
              "title": "Dependencies",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Dependency manager and dependency file, specified as `<dependency manager>:<relative file path>`.",
          "examples": [
            "conda:environment.yaml",
            "maven:./pom.xml",
            "pip:./requirements.txt"
          ],
          "title": "Dependencies"
        },
        "parent": {
          "anyOf": [
            {
              "enum": [
                "keras_hdf5",
                "onnx",
                "pytorch_state_dict",
                "tensorflow_js",
                "tensorflow_saved_model_bundle",
                "torchscript"
              ],
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "The source weights these weights were converted from.\nFor example, if a model's weights were converted from the `pytorch_state_dict` format to `torchscript`,\nThe `pytorch_state_dict` weights entry has no `parent` and is the parent of the `torchscript` weights.\nAll weight entries except one (the initial set of weights resulting from training the model),\nneed to have this field.",
          "examples": [
            "pytorch_state_dict"
          ],
          "title": "Parent"
        },
        "pytorch_version": {
          "anyOf": [
            {
              "$ref": "#/$defs/Version"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Version of the PyTorch library used."
        }
      },
      "required": [
        "source"
      ],
      "title": "model.v0_4.TorchscriptWeightsDescr",
      "type": "object"
    },
    "Uploader": {
      "additionalProperties": false,
      "properties": {
        "email": {
          "description": "Email",
          "format": "email",
          "title": "Email",
          "type": "string"
        },
        "name": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "name",
          "title": "Name"
        }
      },
      "required": [
        "email"
      ],
      "title": "generic.v0_2.Uploader",
      "type": "object"
    },
    "Version": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "integer"
        },
        {
          "type": "number"
        }
      ],
      "description": "wraps a packaging.version.Version instance for validation in pydantic models",
      "title": "Version"
    },
    "WeightsDescr": {
      "additionalProperties": false,
      "properties": {
        "keras_hdf5": {
          "anyOf": [
            {
              "$ref": "#/$defs/KerasHdf5WeightsDescr"
            },
            {
              "type": "null"
            }
          ],
          "default": null
        },
        "onnx": {
          "anyOf": [
            {
              "$ref": "#/$defs/OnnxWeightsDescr"
            },
            {
              "type": "null"
            }
          ],
          "default": null
        },
        "pytorch_state_dict": {
          "anyOf": [
            {
              "$ref": "#/$defs/PytorchStateDictWeightsDescr"
            },
            {
              "type": "null"
            }
          ],
          "default": null
        },
        "tensorflow_js": {
          "anyOf": [
            {
              "$ref": "#/$defs/TensorflowJsWeightsDescr"
            },
            {
              "type": "null"
            }
          ],
          "default": null
        },
        "tensorflow_saved_model_bundle": {
          "anyOf": [
            {
              "$ref": "#/$defs/TensorflowSavedModelBundleWeightsDescr"
            },
            {
              "type": "null"
            }
          ],
          "default": null
        },
        "torchscript": {
          "anyOf": [
            {
              "$ref": "#/$defs/TorchscriptWeightsDescr"
            },
            {
              "type": "null"
            }
          ],
          "default": null
        }
      },
      "title": "model.v0_4.WeightsDescr",
      "type": "object"
    },
    "YamlValue": {
      "anyOf": [
        {
          "type": "boolean"
        },
        {
          "format": "date",
          "type": "string"
        },
        {
          "format": "date-time",
          "type": "string"
        },
        {
          "type": "integer"
        },
        {
          "type": "number"
        },
        {
          "type": "string"
        },
        {
          "items": {
            "$ref": "#/$defs/YamlValue"
          },
          "type": "array"
        },
        {
          "additionalProperties": {
            "$ref": "#/$defs/YamlValue"
          },
          "type": "object"
        },
        {
          "type": "null"
        }
      ]
    },
    "ZeroMeanUnitVarianceDescr": {
      "additionalProperties": false,
      "description": "Subtract mean and divide by variance.",
      "properties": {
        "name": {
          "const": "zero_mean_unit_variance",
          "title": "Name",
          "type": "string"
        },
        "kwargs": {
          "$ref": "#/$defs/ZeroMeanUnitVarianceKwargs"
        }
      },
      "required": [
        "name",
        "kwargs"
      ],
      "title": "model.v0_4.ZeroMeanUnitVarianceDescr",
      "type": "object"
    },
    "ZeroMeanUnitVarianceKwargs": {
      "additionalProperties": false,
      "description": "key word arguments for `ZeroMeanUnitVarianceDescr`",
      "properties": {
        "mode": {
          "default": "fixed",
          "description": "Mode for computing mean and variance.\n|     mode    |             description              |\n| ----------- | ------------------------------------ |\n|   fixed     | Fixed values for mean and variance   |\n| per_dataset | Compute for the entire dataset       |\n| per_sample  | Compute for each sample individually |",
          "enum": [
            "fixed",
            "per_dataset",
            "per_sample"
          ],
          "title": "Mode",
          "type": "string"
        },
        "axes": {
          "description": "The subset of axes to normalize jointly.\nFor example `xy` to normalize the two image axes for 2d data jointly.",
          "examples": [
            "xy"
          ],
          "title": "Axes",
          "type": "string"
        },
        "mean": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "items": {
                "type": "number"
              },
              "minItems": 1,
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "The mean value(s) to use for `mode: fixed`.\nFor example `[1.1, 2.2, 3.3]` in the case of a 3 channel image with `axes: xy`.",
          "examples": [
            [
              1.1,
              2.2,
              3.3
            ]
          ],
          "title": "Mean"
        },
        "std": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "items": {
                "type": "number"
              },
              "minItems": 1,
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "The standard deviation values to use for `mode: fixed`. Analogous to mean.",
          "examples": [
            [
              0.1,
              0.2,
              0.3
            ]
          ],
          "title": "Std"
        },
        "eps": {
          "default": 1e-06,
          "description": "epsilon for numeric stability: `out = (tensor - mean) / (std + eps)`.",
          "exclusiveMinimum": 0,
          "maximum": 0.1,
          "title": "Eps",
          "type": "number"
        }
      },
      "required": [
        "axes"
      ],
      "title": "model.v0_4.ZeroMeanUnitVarianceKwargs",
      "type": "object"
    }
  },
  "additionalProperties": false,
  "description": "Specification of the fields used in a bioimage.io-compliant RDF that describes AI models with pretrained weights.\n\nThese fields are typically stored in a YAML file which we call a model resource description file (model RDF).",
  "properties": {
    "name": {
      "description": "A human-readable name of this model.\nIt should be no longer than 64 characters and only contain letter, number, underscore, minus or space characters.",
      "minLength": 1,
      "title": "Name",
      "type": "string"
    },
    "description": {
      "title": "Description",
      "type": "string"
    },
    "covers": {
      "description": "Cover images. Please use an image smaller than 500KB and an aspect ratio width to height of 2:1.\nThe supported image formats are: ('.gif', '.jpeg', '.jpg', '.png', '.svg', '.tif', '.tiff')",
      "examples": [
        [
          "cover.png"
        ]
      ],
      "items": {
        "anyOf": [
          {
            "description": "A URL with the HTTP or HTTPS scheme.",
            "format": "uri",
            "maxLength": 2083,
            "minLength": 1,
            "title": "HttpUrl",
            "type": "string"
          },
          {
            "$ref": "#/$defs/RelativeFilePath"
          },
          {
            "format": "file-path",
            "title": "FilePath",
            "type": "string"
          }
        ]
      },
      "title": "Covers",
      "type": "array"
    },
    "id_emoji": {
      "anyOf": [
        {
          "examples": [
            "\ud83e\udd88",
            "\ud83e\udda5"
          ],
          "maxLength": 1,
          "minLength": 1,
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "UTF-8 emoji for display alongside the `id`.",
      "title": "Id Emoji"
    },
    "authors": {
      "description": "The authors are the creators of the model RDF and the primary points of contact.",
      "items": {
        "$ref": "#/$defs/Author"
      },
      "minItems": 1,
      "title": "Authors",
      "type": "array"
    },
    "attachments": {
      "anyOf": [
        {
          "$ref": "#/$defs/AttachmentsDescr"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "file and other attachments"
    },
    "cite": {
      "description": "citations",
      "items": {
        "$ref": "#/$defs/CiteEntry"
      },
      "title": "Cite",
      "type": "array"
    },
    "config": {
      "additionalProperties": {
        "$ref": "#/$defs/YamlValue"
      },
      "description": "A field for custom configuration that can contain any keys not present in the RDF spec.\nThis means you should not store, for example, a github repo URL in `config` since we already have the\n`git_repo` field defined in the spec.\nKeys in `config` may be very specific to a tool or consumer software. To avoid conflicting definitions,\nit is recommended to wrap added configuration into a sub-field named with the specific domain or tool name,\nfor example:\n```yaml\nconfig:\n    bioimageio:  # here is the domain name\n        my_custom_key: 3837283\n        another_key:\n            nested: value\n    imagej:       # config specific to ImageJ\n        macro_dir: path/to/macro/file\n```\nIf possible, please use [`snake_case`](https://en.wikipedia.org/wiki/Snake_case) for keys in `config`.\nYou may want to list linked files additionally under `attachments` to include them when packaging a resource\n(packaging a resource means downloading/copying important linked files and creating a ZIP archive that contains\nan altered rdf.yaml file with local references to the downloaded files)",
      "examples": [
        {
          "bioimageio": {
            "another_key": {
              "nested": "value"
            },
            "my_custom_key": 3837283
          },
          "imagej": {
            "macro_dir": "path/to/macro/file"
          }
        }
      ],
      "title": "Config",
      "type": "object"
    },
    "download_url": {
      "anyOf": [
        {
          "description": "A URL with the HTTP or HTTPS scheme.",
          "format": "uri",
          "maxLength": 2083,
          "minLength": 1,
          "title": "HttpUrl",
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "URL to download the resource from (deprecated)",
      "title": "Download Url"
    },
    "git_repo": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "A URL to the Git repository where the resource is being developed.",
      "examples": [
        "https://github.com/bioimage-io/spec-bioimage-io/tree/main/example_descriptions/models/unet2d_nuclei_broad"
      ],
      "title": "Git Repo"
    },
    "icon": {
      "anyOf": [
        {
          "maxLength": 2,
          "minLength": 1,
          "type": "string"
        },
        {
          "description": "A URL with the HTTP or HTTPS scheme.",
          "format": "uri",
          "maxLength": 2083,
          "minLength": 1,
          "title": "HttpUrl",
          "type": "string"
        },
        {
          "$ref": "#/$defs/RelativeFilePath"
        },
        {
          "format": "file-path",
          "title": "FilePath",
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "An icon for illustration",
      "title": "Icon"
    },
    "links": {
      "description": "IDs of other bioimage.io resources",
      "examples": [
        [
          "ilastik/ilastik",
          "deepimagej/deepimagej",
          "zero/notebook_u-net_3d_zerocostdl4mic"
        ]
      ],
      "items": {
        "type": "string"
      },
      "title": "Links",
      "type": "array"
    },
    "uploader": {
      "anyOf": [
        {
          "$ref": "#/$defs/Uploader"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "The person who uploaded the model (e.g. to bioimage.io)"
    },
    "maintainers": {
      "description": "Maintainers of this resource.\nIf not specified `authors` are maintainers and at least some of them should specify their `github_user` name",
      "items": {
        "$ref": "#/$defs/Maintainer"
      },
      "title": "Maintainers",
      "type": "array"
    },
    "rdf_source": {
      "anyOf": [
        {
          "description": "A URL with the HTTP or HTTPS scheme.",
          "format": "uri",
          "maxLength": 2083,
          "minLength": 1,
          "title": "HttpUrl",
          "type": "string"
        },
        {
          "$ref": "#/$defs/RelativeFilePath"
        },
        {
          "format": "file-path",
          "title": "FilePath",
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Resource description file (RDF) source; used to keep track of where an rdf.yaml was loaded from.\nDo not set this field in a YAML file.",
      "title": "Rdf Source"
    },
    "tags": {
      "description": "Associated tags",
      "examples": [
        [
          "unet2d",
          "pytorch",
          "nucleus",
          "segmentation",
          "dsb2018"
        ]
      ],
      "items": {
        "type": "string"
      },
      "title": "Tags",
      "type": "array"
    },
    "version": {
      "anyOf": [
        {
          "$ref": "#/$defs/Version"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "The version of the resource following SemVer 2.0."
    },
    "version_number": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "version number (n-th published version, not the semantic version)",
      "title": "Version Number"
    },
    "format_version": {
      "const": "0.4.10",
      "description": "Version of the bioimage.io model description specification used.\nWhen creating a new model always use the latest micro/patch version described here.\nThe `format_version` is important for any consumer software to understand how to parse the fields.",
      "title": "Format Version",
      "type": "string"
    },
    "type": {
      "const": "model",
      "description": "Specialized resource type 'model'",
      "title": "Type",
      "type": "string"
    },
    "id": {
      "anyOf": [
        {
          "minLength": 1,
          "title": "ModelId",
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "bioimage.io-wide unique resource identifier\nassigned by bioimage.io; version **un**specific.",
      "title": "Id"
    },
    "documentation": {
      "anyOf": [
        {
          "description": "A URL with the HTTP or HTTPS scheme.",
          "format": "uri",
          "maxLength": 2083,
          "minLength": 1,
          "title": "HttpUrl",
          "type": "string"
        },
        {
          "$ref": "#/$defs/RelativeFilePath"
        },
        {
          "format": "file-path",
          "title": "FilePath",
          "type": "string"
        }
      ],
      "description": "URL or relative path to a markdown file with additional documentation.\nThe recommended documentation file name is `README.md`. An `.md` suffix is mandatory.\nThe documentation should include a '[#[#]]# Validation' (sub)section\nwith details on how to quantitatively validate the model on unseen data.",
      "examples": [
        "https://raw.githubusercontent.com/bioimage-io/spec-bioimage-io/main/example_descriptions/models/unet2d_nuclei_broad/README.md",
        "README.md"
      ],
      "title": "Documentation"
    },
    "inputs": {
      "description": "Describes the input tensors expected by this model.",
      "items": {
        "$ref": "#/$defs/InputTensorDescr"
      },
      "minItems": 1,
      "title": "Inputs",
      "type": "array"
    },
    "license": {
      "anyOf": [
        {
          "enum": [
            "0BSD",
            "AAL",
            "Abstyles",
            "AdaCore-doc",
            "Adobe-2006",
            "Adobe-Display-PostScript",
            "Adobe-Glyph",
            "Adobe-Utopia",
            "ADSL",
            "AFL-1.1",
            "AFL-1.2",
            "AFL-2.0",
            "AFL-2.1",
            "AFL-3.0",
            "Afmparse",
            "AGPL-1.0-only",
            "AGPL-1.0-or-later",
            "AGPL-3.0-only",
            "AGPL-3.0-or-later",
            "Aladdin",
            "AMDPLPA",
            "AML",
            "AML-glslang",
            "AMPAS",
            "ANTLR-PD",
            "ANTLR-PD-fallback",
            "Apache-1.0",
            "Apache-1.1",
            "Apache-2.0",
            "APAFML",
            "APL-1.0",
            "App-s2p",
            "APSL-1.0",
            "APSL-1.1",
            "APSL-1.2",
            "APSL-2.0",
            "Arphic-1999",
            "Artistic-1.0",
            "Artistic-1.0-cl8",
            "Artistic-1.0-Perl",
            "Artistic-2.0",
            "ASWF-Digital-Assets-1.0",
            "ASWF-Digital-Assets-1.1",
            "Baekmuk",
            "Bahyph",
            "Barr",
            "bcrypt-Solar-Designer",
            "Beerware",
            "Bitstream-Charter",
            "Bitstream-Vera",
            "BitTorrent-1.0",
            "BitTorrent-1.1",
            "blessing",
            "BlueOak-1.0.0",
            "Boehm-GC",
            "Borceux",
            "Brian-Gladman-2-Clause",
            "Brian-Gladman-3-Clause",
            "BSD-1-Clause",
            "BSD-2-Clause",
            "BSD-2-Clause-Darwin",
            "BSD-2-Clause-Patent",
            "BSD-2-Clause-Views",
            "BSD-3-Clause",
            "BSD-3-Clause-acpica",
            "BSD-3-Clause-Attribution",
            "BSD-3-Clause-Clear",
            "BSD-3-Clause-flex",
            "BSD-3-Clause-HP",
            "BSD-3-Clause-LBNL",
            "BSD-3-Clause-Modification",
            "BSD-3-Clause-No-Military-License",
            "BSD-3-Clause-No-Nuclear-License",
            "BSD-3-Clause-No-Nuclear-License-2014",
            "BSD-3-Clause-No-Nuclear-Warranty",
            "BSD-3-Clause-Open-MPI",
            "BSD-3-Clause-Sun",
            "BSD-4-Clause",
            "BSD-4-Clause-Shortened",
            "BSD-4-Clause-UC",
            "BSD-4.3RENO",
            "BSD-4.3TAHOE",
            "BSD-Advertising-Acknowledgement",
            "BSD-Attribution-HPND-disclaimer",
            "BSD-Inferno-Nettverk",
            "BSD-Protection",
            "BSD-Source-beginning-file",
            "BSD-Source-Code",
            "BSD-Systemics",
            "BSD-Systemics-W3Works",
            "BSL-1.0",
            "BUSL-1.1",
            "bzip2-1.0.6",
            "C-UDA-1.0",
            "CAL-1.0",
            "CAL-1.0-Combined-Work-Exception",
            "Caldera",
            "Caldera-no-preamble",
            "CATOSL-1.1",
            "CC-BY-1.0",
            "CC-BY-2.0",
            "CC-BY-2.5",
            "CC-BY-2.5-AU",
            "CC-BY-3.0",
            "CC-BY-3.0-AT",
            "CC-BY-3.0-AU",
            "CC-BY-3.0-DE",
            "CC-BY-3.0-IGO",
            "CC-BY-3.0-NL",
            "CC-BY-3.0-US",
            "CC-BY-4.0",
            "CC-BY-NC-1.0",
            "CC-BY-NC-2.0",
            "CC-BY-NC-2.5",
            "CC-BY-NC-3.0",
            "CC-BY-NC-3.0-DE",
            "CC-BY-NC-4.0",
            "CC-BY-NC-ND-1.0",
            "CC-BY-NC-ND-2.0",
            "CC-BY-NC-ND-2.5",
            "CC-BY-NC-ND-3.0",
            "CC-BY-NC-ND-3.0-DE",
            "CC-BY-NC-ND-3.0-IGO",
            "CC-BY-NC-ND-4.0",
            "CC-BY-NC-SA-1.0",
            "CC-BY-NC-SA-2.0",
            "CC-BY-NC-SA-2.0-DE",
            "CC-BY-NC-SA-2.0-FR",
            "CC-BY-NC-SA-2.0-UK",
            "CC-BY-NC-SA-2.5",
            "CC-BY-NC-SA-3.0",
            "CC-BY-NC-SA-3.0-DE",
            "CC-BY-NC-SA-3.0-IGO",
            "CC-BY-NC-SA-4.0",
            "CC-BY-ND-1.0",
            "CC-BY-ND-2.0",
            "CC-BY-ND-2.5",
            "CC-BY-ND-3.0",
            "CC-BY-ND-3.0-DE",
            "CC-BY-ND-4.0",
            "CC-BY-SA-1.0",
            "CC-BY-SA-2.0",
            "CC-BY-SA-2.0-UK",
            "CC-BY-SA-2.1-JP",
            "CC-BY-SA-2.5",
            "CC-BY-SA-3.0",
            "CC-BY-SA-3.0-AT",
            "CC-BY-SA-3.0-DE",
            "CC-BY-SA-3.0-IGO",
            "CC-BY-SA-4.0",
            "CC-PDDC",
            "CC0-1.0",
            "CDDL-1.0",
            "CDDL-1.1",
            "CDL-1.0",
            "CDLA-Permissive-1.0",
            "CDLA-Permissive-2.0",
            "CDLA-Sharing-1.0",
            "CECILL-1.0",
            "CECILL-1.1",
            "CECILL-2.0",
            "CECILL-2.1",
            "CECILL-B",
            "CECILL-C",
            "CERN-OHL-1.1",
            "CERN-OHL-1.2",
            "CERN-OHL-P-2.0",
            "CERN-OHL-S-2.0",
            "CERN-OHL-W-2.0",
            "CFITSIO",
            "check-cvs",
            "checkmk",
            "ClArtistic",
            "Clips",
            "CMU-Mach",
            "CMU-Mach-nodoc",
            "CNRI-Jython",
            "CNRI-Python",
            "CNRI-Python-GPL-Compatible",
            "COIL-1.0",
            "Community-Spec-1.0",
            "Condor-1.1",
            "copyleft-next-0.3.0",
            "copyleft-next-0.3.1",
            "Cornell-Lossless-JPEG",
            "CPAL-1.0",
            "CPL-1.0",
            "CPOL-1.02",
            "Cronyx",
            "Crossword",
            "CrystalStacker",
            "CUA-OPL-1.0",
            "Cube",
            "curl",
            "D-FSL-1.0",
            "DEC-3-Clause",
            "diffmark",
            "DL-DE-BY-2.0",
            "DL-DE-ZERO-2.0",
            "DOC",
            "Dotseqn",
            "DRL-1.0",
            "DRL-1.1",
            "DSDP",
            "dtoa",
            "dvipdfm",
            "ECL-1.0",
            "ECL-2.0",
            "EFL-1.0",
            "EFL-2.0",
            "eGenix",
            "Elastic-2.0",
            "Entessa",
            "EPICS",
            "EPL-1.0",
            "EPL-2.0",
            "ErlPL-1.1",
            "etalab-2.0",
            "EUDatagrid",
            "EUPL-1.0",
            "EUPL-1.1",
            "EUPL-1.2",
            "Eurosym",
            "Fair",
            "FBM",
            "FDK-AAC",
            "Ferguson-Twofish",
            "Frameworx-1.0",
            "FreeBSD-DOC",
            "FreeImage",
            "FSFAP",
            "FSFAP-no-warranty-disclaimer",
            "FSFUL",
            "FSFULLR",
            "FSFULLRWD",
            "FTL",
            "Furuseth",
            "fwlw",
            "GCR-docs",
            "GD",
            "GFDL-1.1-invariants-only",
            "GFDL-1.1-invariants-or-later",
            "GFDL-1.1-no-invariants-only",
            "GFDL-1.1-no-invariants-or-later",
            "GFDL-1.1-only",
            "GFDL-1.1-or-later",
            "GFDL-1.2-invariants-only",
            "GFDL-1.2-invariants-or-later",
            "GFDL-1.2-no-invariants-only",
            "GFDL-1.2-no-invariants-or-later",
            "GFDL-1.2-only",
            "GFDL-1.2-or-later",
            "GFDL-1.3-invariants-only",
            "GFDL-1.3-invariants-or-later",
            "GFDL-1.3-no-invariants-only",
            "GFDL-1.3-no-invariants-or-later",
            "GFDL-1.3-only",
            "GFDL-1.3-or-later",
            "Giftware",
            "GL2PS",
            "Glide",
            "Glulxe",
            "GLWTPL",
            "gnuplot",
            "GPL-1.0-only",
            "GPL-1.0-or-later",
            "GPL-2.0-only",
            "GPL-2.0-or-later",
            "GPL-3.0-only",
            "GPL-3.0-or-later",
            "Graphics-Gems",
            "gSOAP-1.3b",
            "gtkbook",
            "HaskellReport",
            "hdparm",
            "Hippocratic-2.1",
            "HP-1986",
            "HP-1989",
            "HPND",
            "HPND-DEC",
            "HPND-doc",
            "HPND-doc-sell",
            "HPND-export-US",
            "HPND-export-US-modify",
            "HPND-Fenneberg-Livingston",
            "HPND-INRIA-IMAG",
            "HPND-Kevlin-Henney",
            "HPND-Markus-Kuhn",
            "HPND-MIT-disclaimer",
            "HPND-Pbmplus",
            "HPND-sell-MIT-disclaimer-xserver",
            "HPND-sell-regexpr",
            "HPND-sell-variant",
            "HPND-sell-variant-MIT-disclaimer",
            "HPND-UC",
            "HTMLTIDY",
            "IBM-pibs",
            "ICU",
            "IEC-Code-Components-EULA",
            "IJG",
            "IJG-short",
            "ImageMagick",
            "iMatix",
            "Imlib2",
            "Info-ZIP",
            "Inner-Net-2.0",
            "Intel",
            "Intel-ACPI",
            "Interbase-1.0",
            "IPA",
            "IPL-1.0",
            "ISC",
            "ISC-Veillard",
            "Jam",
            "JasPer-2.0",
            "JPL-image",
            "JPNIC",
            "JSON",
            "Kastrup",
            "Kazlib",
            "Knuth-CTAN",
            "LAL-1.2",
            "LAL-1.3",
            "Latex2e",
            "Latex2e-translated-notice",
            "Leptonica",
            "LGPL-2.0-only",
            "LGPL-2.0-or-later",
            "LGPL-2.1-only",
            "LGPL-2.1-or-later",
            "LGPL-3.0-only",
            "LGPL-3.0-or-later",
            "LGPLLR",
            "Libpng",
            "libpng-2.0",
            "libselinux-1.0",
            "libtiff",
            "libutil-David-Nugent",
            "LiLiQ-P-1.1",
            "LiLiQ-R-1.1",
            "LiLiQ-Rplus-1.1",
            "Linux-man-pages-1-para",
            "Linux-man-pages-copyleft",
            "Linux-man-pages-copyleft-2-para",
            "Linux-man-pages-copyleft-var",
            "Linux-OpenIB",
            "LOOP",
            "LPD-document",
            "LPL-1.0",
            "LPL-1.02",
            "LPPL-1.0",
            "LPPL-1.1",
            "LPPL-1.2",
            "LPPL-1.3a",
            "LPPL-1.3c",
            "lsof",
            "Lucida-Bitmap-Fonts",
            "LZMA-SDK-9.11-to-9.20",
            "LZMA-SDK-9.22",
            "Mackerras-3-Clause",
            "Mackerras-3-Clause-acknowledgment",
            "magaz",
            "mailprio",
            "MakeIndex",
            "Martin-Birgmeier",
            "McPhee-slideshow",
            "metamail",
            "Minpack",
            "MirOS",
            "MIT",
            "MIT-0",
            "MIT-advertising",
            "MIT-CMU",
            "MIT-enna",
            "MIT-feh",
            "MIT-Festival",
            "MIT-Modern-Variant",
            "MIT-open-group",
            "MIT-testregex",
            "MIT-Wu",
            "MITNFA",
            "MMIXware",
            "Motosoto",
            "MPEG-SSG",
            "mpi-permissive",
            "mpich2",
            "MPL-1.0",
            "MPL-1.1",
            "MPL-2.0",
            "MPL-2.0-no-copyleft-exception",
            "mplus",
            "MS-LPL",
            "MS-PL",
            "MS-RL",
            "MTLL",
            "MulanPSL-1.0",
            "MulanPSL-2.0",
            "Multics",
            "Mup",
            "NAIST-2003",
            "NASA-1.3",
            "Naumen",
            "NBPL-1.0",
            "NCGL-UK-2.0",
            "NCSA",
            "Net-SNMP",
            "NetCDF",
            "Newsletr",
            "NGPL",
            "NICTA-1.0",
            "NIST-PD",
            "NIST-PD-fallback",
            "NIST-Software",
            "NLOD-1.0",
            "NLOD-2.0",
            "NLPL",
            "Nokia",
            "NOSL",
            "Noweb",
            "NPL-1.0",
            "NPL-1.1",
            "NPOSL-3.0",
            "NRL",
            "NTP",
            "NTP-0",
            "O-UDA-1.0",
            "OCCT-PL",
            "OCLC-2.0",
            "ODbL-1.0",
            "ODC-By-1.0",
            "OFFIS",
            "OFL-1.0",
            "OFL-1.0-no-RFN",
            "OFL-1.0-RFN",
            "OFL-1.1",
            "OFL-1.1-no-RFN",
            "OFL-1.1-RFN",
            "OGC-1.0",
            "OGDL-Taiwan-1.0",
            "OGL-Canada-2.0",
            "OGL-UK-1.0",
            "OGL-UK-2.0",
            "OGL-UK-3.0",
            "OGTSL",
            "OLDAP-1.1",
            "OLDAP-1.2",
            "OLDAP-1.3",
            "OLDAP-1.4",
            "OLDAP-2.0",
            "OLDAP-2.0.1",
            "OLDAP-2.1",
            "OLDAP-2.2",
            "OLDAP-2.2.1",
            "OLDAP-2.2.2",
            "OLDAP-2.3",
            "OLDAP-2.4",
            "OLDAP-2.5",
            "OLDAP-2.6",
            "OLDAP-2.7",
            "OLDAP-2.8",
            "OLFL-1.3",
            "OML",
            "OpenPBS-2.3",
            "OpenSSL",
            "OpenSSL-standalone",
            "OpenVision",
            "OPL-1.0",
            "OPL-UK-3.0",
            "OPUBL-1.0",
            "OSET-PL-2.1",
            "OSL-1.0",
            "OSL-1.1",
            "OSL-2.0",
            "OSL-2.1",
            "OSL-3.0",
            "PADL",
            "Parity-6.0.0",
            "Parity-7.0.0",
            "PDDL-1.0",
            "PHP-3.0",
            "PHP-3.01",
            "Pixar",
            "Plexus",
            "pnmstitch",
            "PolyForm-Noncommercial-1.0.0",
            "PolyForm-Small-Business-1.0.0",
            "PostgreSQL",
            "PSF-2.0",
            "psfrag",
            "psutils",
            "Python-2.0",
            "Python-2.0.1",
            "python-ldap",
            "Qhull",
            "QPL-1.0",
            "QPL-1.0-INRIA-2004",
            "radvd",
            "Rdisc",
            "RHeCos-1.1",
            "RPL-1.1",
            "RPL-1.5",
            "RPSL-1.0",
            "RSA-MD",
            "RSCPL",
            "Ruby",
            "SAX-PD",
            "SAX-PD-2.0",
            "Saxpath",
            "SCEA",
            "SchemeReport",
            "Sendmail",
            "Sendmail-8.23",
            "SGI-B-1.0",
            "SGI-B-1.1",
            "SGI-B-2.0",
            "SGI-OpenGL",
            "SGP4",
            "SHL-0.5",
            "SHL-0.51",
            "SimPL-2.0",
            "SISSL",
            "SISSL-1.2",
            "SL",
            "Sleepycat",
            "SMLNJ",
            "SMPPL",
            "SNIA",
            "snprintf",
            "softSurfer",
            "Soundex",
            "Spencer-86",
            "Spencer-94",
            "Spencer-99",
            "SPL-1.0",
            "ssh-keyscan",
            "SSH-OpenSSH",
            "SSH-short",
            "SSLeay-standalone",
            "SSPL-1.0",
            "SugarCRM-1.1.3",
            "Sun-PPP",
            "SunPro",
            "SWL",
            "swrule",
            "Symlinks",
            "TAPR-OHL-1.0",
            "TCL",
            "TCP-wrappers",
            "TermReadKey",
            "TGPPL-1.0",
            "TMate",
            "TORQUE-1.1",
            "TOSL",
            "TPDL",
            "TPL-1.0",
            "TTWL",
            "TTYP0",
            "TU-Berlin-1.0",
            "TU-Berlin-2.0",
            "UCAR",
            "UCL-1.0",
            "ulem",
            "UMich-Merit",
            "Unicode-3.0",
            "Unicode-DFS-2015",
            "Unicode-DFS-2016",
            "Unicode-TOU",
            "UnixCrypt",
            "Unlicense",
            "UPL-1.0",
            "URT-RLE",
            "Vim",
            "VOSTROM",
            "VSL-1.0",
            "W3C",
            "W3C-19980720",
            "W3C-20150513",
            "w3m",
            "Watcom-1.0",
            "Widget-Workshop",
            "Wsuipa",
            "WTFPL",
            "X11",
            "X11-distribute-modifications-variant",
            "Xdebug-1.03",
            "Xerox",
            "Xfig",
            "XFree86-1.1",
            "xinetd",
            "xkeyboard-config-Zinoviev",
            "xlock",
            "Xnet",
            "xpp",
            "XSkat",
            "YPL-1.0",
            "YPL-1.1",
            "Zed",
            "Zeeff",
            "Zend-2.0",
            "Zimbra-1.3",
            "Zimbra-1.4",
            "Zlib",
            "zlib-acknowledgement",
            "ZPL-1.1",
            "ZPL-2.0",
            "ZPL-2.1"
          ],
          "title": "LicenseId",
          "type": "string"
        },
        {
          "type": "string"
        }
      ],
      "description": "A [SPDX license identifier](https://spdx.org/licenses/).\nWe do notsupport custom license beyond the SPDX license list, if you need that please\n[open a GitHub issue](https://github.com/bioimage-io/spec-bioimage-io/issues/new/choose\n) to discuss your intentions with the community.",
      "examples": [
        "CC0-1.0",
        "MIT",
        "BSD-2-Clause"
      ],
      "title": "License"
    },
    "outputs": {
      "description": "Describes the output tensors.",
      "items": {
        "$ref": "#/$defs/OutputTensorDescr"
      },
      "minItems": 1,
      "title": "Outputs",
      "type": "array"
    },
    "packaged_by": {
      "description": "The persons that have packaged and uploaded this model.\nOnly required if those persons differ from the `authors`.",
      "items": {
        "$ref": "#/$defs/Author"
      },
      "title": "Packaged By",
      "type": "array"
    },
    "parent": {
      "anyOf": [
        {
          "$ref": "#/$defs/LinkedModel"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "The model from which this model is derived, e.g. by fine-tuning the weights."
    },
    "run_mode": {
      "anyOf": [
        {
          "$ref": "#/$defs/RunMode"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Custom run mode for this model: for more complex prediction procedures like test time\ndata augmentation that currently cannot be expressed in the specification.\nNo standard run modes are defined yet."
    },
    "sample_inputs": {
      "description": "URLs/relative paths to sample inputs to illustrate possible inputs for the model,\nfor example stored as PNG or TIFF images.\nThe sample files primarily serve to inform a human user about an example use case",
      "items": {
        "anyOf": [
          {
            "description": "A URL with the HTTP or HTTPS scheme.",
            "format": "uri",
            "maxLength": 2083,
            "minLength": 1,
            "title": "HttpUrl",
            "type": "string"
          },
          {
            "$ref": "#/$defs/RelativeFilePath"
          },
          {
            "format": "file-path",
            "title": "FilePath",
            "type": "string"
          }
        ]
      },
      "title": "Sample Inputs",
      "type": "array"
    },
    "sample_outputs": {
      "description": "URLs/relative paths to sample outputs corresponding to the `sample_inputs`.",
      "items": {
        "anyOf": [
          {
            "description": "A URL with the HTTP or HTTPS scheme.",
            "format": "uri",
            "maxLength": 2083,
            "minLength": 1,
            "title": "HttpUrl",
            "type": "string"
          },
          {
            "$ref": "#/$defs/RelativeFilePath"
          },
          {
            "format": "file-path",
            "title": "FilePath",
            "type": "string"
          }
        ]
      },
      "title": "Sample Outputs",
      "type": "array"
    },
    "test_inputs": {
      "description": "Test input tensors compatible with the `inputs` description for a **single test case**.\nThis means if your model has more than one input, you should provide one URL/relative path for each input.\nEach test input should be a file with an ndarray in\n[numpy.lib file format](https://numpy.org/doc/stable/reference/generated/numpy.lib.format.html#module-numpy.lib.format).\nThe extension must be '.npy'.",
      "items": {
        "anyOf": [
          {
            "description": "A URL with the HTTP or HTTPS scheme.",
            "format": "uri",
            "maxLength": 2083,
            "minLength": 1,
            "title": "HttpUrl",
            "type": "string"
          },
          {
            "$ref": "#/$defs/RelativeFilePath"
          },
          {
            "format": "file-path",
            "title": "FilePath",
            "type": "string"
          }
        ]
      },
      "minItems": 1,
      "title": "Test Inputs",
      "type": "array"
    },
    "test_outputs": {
      "description": "Analog to `test_inputs`.",
      "items": {
        "anyOf": [
          {
            "description": "A URL with the HTTP or HTTPS scheme.",
            "format": "uri",
            "maxLength": 2083,
            "minLength": 1,
            "title": "HttpUrl",
            "type": "string"
          },
          {
            "$ref": "#/$defs/RelativeFilePath"
          },
          {
            "format": "file-path",
            "title": "FilePath",
            "type": "string"
          }
        ]
      },
      "minItems": 1,
      "title": "Test Outputs",
      "type": "array"
    },
    "timestamp": {
      "$ref": "#/$defs/Datetime"
    },
    "training_data": {
      "anyOf": [
        {
          "$ref": "#/$defs/LinkedDataset"
        },
        {
          "$ref": "#/$defs/DatasetDescr"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "The dataset used to train this model",
      "title": "Training Data"
    },
    "weights": {
      "$ref": "#/$defs/WeightsDescr",
      "description": "The weights for this model.\nWeights can be given for different formats, but should otherwise be equivalent.\nThe available weight formats determine which consumers can use this model."
    }
  },
  "required": [
    "name",
    "description",
    "authors",
    "format_version",
    "type",
    "documentation",
    "inputs",
    "license",
    "outputs",
    "test_inputs",
    "test_outputs",
    "timestamp",
    "weights"
  ],
  "title": "model 0.4.10",
  "type": "object"
}

Fields:

Validators:

attachments pydantic-field ¤

attachments: Optional[AttachmentsDescr] = None

file and other attachments

authors pydantic-field ¤

authors: NotEmpty[List[Author]]

The authors are the creators of the model RDF and the primary points of contact.

cite pydantic-field ¤

cite: List[CiteEntry]

citations

config pydantic-field ¤

config: Dict[str, YamlValue]

A field for custom configuration that can contain any keys not present in the RDF spec. This means you should not store, for example, a github repo URL in config since we already have the git_repo field defined in the spec. Keys in config may be very specific to a tool or consumer software. To avoid conflicting definitions, it is recommended to wrap added configuration into a sub-field named with the specific domain or tool name, for example:

config:
    bioimageio:  # here is the domain name
        my_custom_key: 3837283
        another_key:
            nested: value
    imagej:       # config specific to ImageJ
        macro_dir: path/to/macro/file
If possible, please use snake_case for keys in config. You may want to list linked files additionally under attachments to include them when packaging a resource (packaging a resource means downloading/copying important linked files and creating a ZIP archive that contains an altered rdf.yaml file with local references to the downloaded files)

covers pydantic-field ¤

covers: List[FileSource_cover]

Cover images. Please use an image smaller than 500KB and an aspect ratio width to height of 2:1.

description pydantic-field ¤

description: str

documentation pydantic-field ¤

documentation: FileSource_

URL or relative path to a markdown file with additional documentation. The recommended documentation file name is README.md. An .md suffix is mandatory. The documentation should include a '[#[#]]# Validation' (sub)section with details on how to quantitatively validate the model on unseen data.

download_url pydantic-field ¤

download_url: Optional[HttpUrl] = None

URL to download the resource from (deprecated)

file_name property ¤

file_name: Optional[FileName]

File name of the bioimageio.yaml file the description was loaded from.

format_version pydantic-field ¤

format_version: Literal['0.4.10'] = '0.4.10'

git_repo pydantic-field ¤

git_repo: Optional[str] = None

A URL to the Git repository where the resource is being developed.

icon pydantic-field ¤

icon: Union[str, FileSource, None] = None

An icon for illustration

id pydantic-field ¤

id: Optional[ModelId] = None

bioimage.io-wide unique resource identifier assigned by bioimage.io; version unspecific.

id_emoji pydantic-field ¤

id_emoji: Optional[str] = None

UTF-8 emoji for display alongside the id.

implemented_format_version class-attribute ¤

implemented_format_version: Literal['0.4.10'] = '0.4.10'

implemented_format_version_tuple class-attribute ¤

implemented_format_version_tuple: Tuple[int, int, int]

implemented_type class-attribute ¤

implemented_type: Literal['model'] = 'model'

inputs pydantic-field ¤

inputs: NotEmpty[List[InputTensorDescr]]

Describes the input tensors expected by this model.

license pydantic-field ¤

license: Union[LicenseId, str]

A SPDX license identifier. We do notsupport custom license beyond the SPDX license list, if you need that please open a GitHub issue to discuss your intentions with the community.

links: List[str]

IDs of other bioimage.io resources

maintainers pydantic-field ¤

maintainers: List[Maintainer]

Maintainers of this resource. If not specified authors are maintainers and at least some of them should specify their github_user name

name pydantic-field ¤

name: str

A human-readable name of this model. It should be no longer than 64 characters and only contain letter, number, underscore, minus or space characters.

outputs pydantic-field ¤

outputs: NotEmpty[List[OutputTensorDescr]]

Describes the output tensors.

packaged_by pydantic-field ¤

packaged_by: List[Author]

The persons that have packaged and uploaded this model. Only required if those persons differ from the authors.

parent pydantic-field ¤

parent: Optional[LinkedModel] = None

The model from which this model is derived, e.g. by fine-tuning the weights.

rdf_source pydantic-field ¤

rdf_source: Optional[FileSource] = None

Resource description file (RDF) source; used to keep track of where an rdf.yaml was loaded from. Do not set this field in a YAML file.

root property ¤

root: Union[RootHttpUrl, DirectoryPath, ZipFile]

The URL/Path prefix to resolve any relative paths with.

run_mode pydantic-field ¤

run_mode: Optional[RunMode] = None

Custom run mode for this model: for more complex prediction procedures like test time data augmentation that currently cannot be expressed in the specification. No standard run modes are defined yet.

sample_inputs pydantic-field ¤

sample_inputs: List[FileSource_]

URLs/relative paths to sample inputs to illustrate possible inputs for the model, for example stored as PNG or TIFF images. The sample files primarily serve to inform a human user about an example use case

sample_outputs pydantic-field ¤

sample_outputs: List[FileSource_]

URLs/relative paths to sample outputs corresponding to the sample_inputs.

tags pydantic-field ¤

tags: List[str]

Associated tags

test_inputs pydantic-field ¤

test_inputs: NotEmpty[List[FileSource_]]

Test input tensors compatible with the inputs description for a single test case. This means if your model has more than one input, you should provide one URL/relative path for each input. Each test input should be a file with an ndarray in numpy.lib file format. The extension must be '.npy'.

test_outputs pydantic-field ¤

test_outputs: NotEmpty[List[FileSource_]]

Analog to test_inputs.

timestamp pydantic-field ¤

timestamp: Datetime

Timestamp in ISO 8601 format with a few restrictions listed here.

training_data pydantic-field ¤

training_data: Union[LinkedDataset, DatasetDescr, None] = (
    None
)

The dataset used to train this model

type pydantic-field ¤

type: Literal['model'] = 'model'

uploader pydantic-field ¤

uploader: Optional[Uploader] = None

The person who uploaded the model (e.g. to bioimage.io)

validation_summary property ¤

validation_summary: ValidationSummary

version pydantic-field ¤

version: Optional[Version] = None

The version of the resource following SemVer 2.0.

version_number pydantic-field ¤

version_number: Optional[int] = None

version number (n-th published version, not the semantic version)

weights pydantic-field ¤

weights: WeightsDescr

The weights for this model. Weights can be given for different formats, but should otherwise be equivalent. The available weight formats determine which consumers can use this model.

__pydantic_init_subclass__ classmethod ¤

__pydantic_init_subclass__(**kwargs: Any)
Source code in src/bioimageio/spec/_internal/common_nodes.py
199
200
201
202
203
204
205
206
207
208
209
210
211
@classmethod
def __pydantic_init_subclass__(cls, **kwargs: Any):
    super().__pydantic_init_subclass__(**kwargs)
    # set classvar implemented_format_version_tuple
    if "format_version" in cls.model_fields:
        if "." not in cls.implemented_format_version:
            cls.implemented_format_version_tuple = (0, 0, 0)
        else:
            fv_tuple = get_format_version_tuple(cls.implemented_format_version)
            assert fv_tuple is not None, (
                f"failed to cast '{cls.implemented_format_version}' to tuple"
            )
            cls.implemented_format_version_tuple = fv_tuple

accept_author_strings classmethod ¤

accept_author_strings(
    authors: Union[Any, Sequence[Any]],
) -> Any

we unofficially accept strings as author entries

Source code in src/bioimageio/spec/generic/v0_2.py
245
246
247
248
249
250
251
252
253
254
255
@field_validator("authors", mode="before")
@classmethod
def accept_author_strings(cls, authors: Union[Any, Sequence[Any]]) -> Any:
    """we unofficially accept strings as author entries"""
    if is_sequence(authors):
        authors = [{"name": a} if isinstance(a, str) else a for a in authors]

    if not authors:
        issue_warning("missing", value=authors, field="authors")

    return authors

get_input_test_arrays ¤

get_input_test_arrays() -> List[NDArray[Any]]
Source code in src/bioimageio/spec/model/v0_4.py
1352
1353
1354
1355
def get_input_test_arrays(self) -> List[NDArray[Any]]:
    data = [load_array(ipt) for ipt in self.test_inputs]
    assert all(isinstance(d, np.ndarray) for d in data)
    return data

get_output_test_arrays ¤

get_output_test_arrays() -> List[NDArray[Any]]
Source code in src/bioimageio/spec/model/v0_4.py
1357
1358
1359
1360
def get_output_test_arrays(self) -> List[NDArray[Any]]:
    data = [load_array(out) for out in self.test_outputs]
    assert all(isinstance(d, np.ndarray) for d in data)
    return data

get_package_content ¤

get_package_content() -> Dict[
    FileName, Union[FileDescr, BioimageioYamlContent]
]

Returns package content without creating the package.

Source code in src/bioimageio/spec/_internal/common_nodes.py
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
def get_package_content(
    self,
) -> Dict[FileName, Union[FileDescr, BioimageioYamlContent]]:
    """Returns package content without creating the package."""
    content: Dict[FileName, FileDescr] = {}
    with PackagingContext(
        bioimageio_yaml_file_name=BIOIMAGEIO_YAML,
        file_sources=content,
    ):
        rdf_content: BioimageioYamlContent = self.model_dump(
            mode="json", exclude_unset=True
        )

    _ = rdf_content.pop("rdf_source", None)

    return {**content, BIOIMAGEIO_YAML: rdf_content}

ignore_url_parent pydantic-validator ¤

ignore_url_parent(parent: Any)
Source code in src/bioimageio/spec/model/v0_4.py
1292
1293
1294
1295
1296
1297
1298
1299
@field_validator("parent", mode="before")
@classmethod
def ignore_url_parent(cls, parent: Any):
    if isinstance(parent, dict):
        return None

    else:
        return parent

load classmethod ¤

load(
    data: BioimageioYamlContentView,
    context: Optional[ValidationContext] = None,
) -> Union[Self, InvalidDescr]

factory method to create a resource description object

Source code in src/bioimageio/spec/_internal/common_nodes.py
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
@classmethod
def load(
    cls,
    data: BioimageioYamlContentView,
    context: Optional[ValidationContext] = None,
) -> Union[Self, InvalidDescr]:
    """factory method to create a resource description object"""
    context = context or get_validation_context()
    if context.perform_io_checks:
        file_descrs = extract_file_descrs({k: v for k, v in data.items()})
        populate_cache(file_descrs)  # TODO: add progress bar

    with context.replace(log_warnings=context.warning_level <= INFO):
        rd, errors, val_warnings = cls._load_impl(deepcopy_yaml_value(data))

    if context.warning_level > INFO:
        all_warnings_context = context.replace(
            warning_level=INFO, log_warnings=False, raise_errors=False
        )
        # raise all validation warnings by reloading
        with all_warnings_context:
            _, _, val_warnings = cls._load_impl(deepcopy_yaml_value(data))

    format_status = "failed" if errors else "passed"
    rd.validation_summary.add_detail(
        ValidationDetail(
            errors=errors,
            name=(
                "bioimageio.spec format validation"
                f" {rd.type} {cls.implemented_format_version}"
            ),
            status=format_status,
            warnings=val_warnings,
        ),
        update_status=False,  # avoid updating status from 'valid-format' to 'passed', but ...
    )
    if format_status == "failed":
        # ... update status in case of failure
        rd.validation_summary.status = "failed"

    return rd

minimum_shape2valid_output pydantic-validator ¤

minimum_shape2valid_output() -> Self
Source code in src/bioimageio/spec/model/v0_4.py
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
@model_validator(mode="after")
def minimum_shape2valid_output(self) -> Self:
    tensors_by_name: Dict[
        TensorName, Union[InputTensorDescr, OutputTensorDescr]
    ] = {t.name: t for t in self.inputs + self.outputs}

    for out in self.outputs:
        if isinstance(out.shape, ImplicitOutputShape):
            ndim_ref = len(tensors_by_name[out.shape.reference_tensor].shape)
            ndim_out_ref = len(
                [scale for scale in out.shape.scale if scale is not None]
            )
            if ndim_ref != ndim_out_ref:
                expanded_dim_note = (
                    " Note that expanded dimensions (`scale`: null) are not"
                    + f" counted for {out.name}'sdimensionality here."
                    if None in out.shape.scale
                    else ""
                )
                raise ValueError(
                    f"Referenced tensor '{out.shape.reference_tensor}' with"
                    + f" {ndim_ref} dimensions does not match output tensor"
                    + f" '{out.name}' with"
                    + f" {ndim_out_ref} dimensions.{expanded_dim_note}"
                )

        min_out_shape = self._get_min_shape(out, tensors_by_name)
        if out.halo:
            halo = out.halo
            halo_msg = f" for halo {out.halo}"
        else:
            halo = [0] * len(min_out_shape)
            halo_msg = ""

        if any([s - 2 * h < 1 for s, h in zip(min_out_shape, halo)]):
            raise ValueError(
                f"Minimal shape {min_out_shape} of output {out.name} is too"
                + f" small{halo_msg}."
            )

    return self

model_validate classmethod ¤

model_validate(
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[
        ValidationContext, Mapping[str, Any], None
    ] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self

Validate a pydantic model instance.

PARAMETER DESCRIPTION

obj ¤

The object to validate.

TYPE: Union[Any, Mapping[str, Any]]

strict ¤

Whether to raise an exception on invalid fields.

TYPE: Optional[bool] DEFAULT: None

from_attributes ¤

Whether to extract data from object attributes.

TYPE: Optional[bool] DEFAULT: None

context ¤

Additional context to pass to the validator.

TYPE: Union[ValidationContext, Mapping[str, Any], None] DEFAULT: None

RAISES DESCRIPTION
ValidationError

If the object failed validation.

RETURNS DESCRIPTION
Self

The validated description instance.

Source code in src/bioimageio/spec/_internal/node.py
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
@classmethod
def model_validate(
    cls,
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[ValidationContext, Mapping[str, Any], None] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self:
    """Validate a pydantic model instance.

    Args:
        obj: The object to validate.
        strict: Whether to raise an exception on invalid fields.
        from_attributes: Whether to extract data from object attributes.
        context: Additional context to pass to the validator.

    Raises:
        ValidationError: If the object failed validation.

    Returns:
        The validated description instance.
    """
    __tracebackhide__ = True

    if context is None:
        context = get_validation_context()
    elif isinstance(context, collections.abc.Mapping):
        context = ValidationContext(**context)

    assert not isinstance(obj, collections.abc.Mapping) or is_kwargs(obj), obj

    with context:
        # use validation context as context manager for equal behavior of __init__ and model_validate
        return super().model_validate(
            obj, strict=strict, from_attributes=from_attributes
        )

package ¤

package(
    dest: Optional[
        Union[ZipFile, IO[bytes], Path, str]
    ] = None,
) -> ZipFile

package the described resource as a zip archive

PARAMETER DESCRIPTION

dest ¤

(path/bytes stream of) destination zipfile

TYPE: Optional[Union[ZipFile, IO[bytes], Path, str]] DEFAULT: None

Source code in src/bioimageio/spec/_internal/common_nodes.py
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
def package(
    self, dest: Optional[Union[ZipFile, IO[bytes], Path, str]] = None, /
) -> ZipFile:
    """package the described resource as a zip archive

    Args:
        dest: (path/bytes stream of) destination zipfile
    """
    if dest is None:
        dest = BytesIO()

    if isinstance(dest, ZipFile):
        zip = dest
        if "r" in zip.mode:
            raise ValueError(
                f"zip file {dest} opened in '{zip.mode}' mode,"
                + " but write access is needed for packaging."
            )
    else:
        zip = ZipFile(dest, mode="w")

    if zip.filename is None:
        zip.filename = (
            str(getattr(self, "id", getattr(self, "name", "bioimageio"))) + ".zip"
        )

    content = self.get_package_content()
    write_content_to_zip(content, zip)
    return zip

unique_io_names pydantic-validator ¤

unique_io_names() -> Self
Source code in src/bioimageio/spec/model/v0_4.py
1160
1161
1162
1163
1164
1165
1166
@model_validator(mode="after")
def unique_io_names(self) -> Self:
    unique_names = {str(ss.name) for s in (self.inputs, self.outputs) for ss in s}
    if len(unique_names) != (len(self.inputs) + len(self.outputs)):
        raise ValueError("Duplicate tensor descriptor names across inputs/outputs")

    return self

unique_tensor_descr_names pydantic-validator ¤

unique_tensor_descr_names(
    value: Sequence[
        Union[InputTensorDescr, OutputTensorDescr]
    ],
) -> Sequence[Union[InputTensorDescr, OutputTensorDescr]]
Source code in src/bioimageio/spec/model/v0_4.py
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
@field_validator("inputs", "outputs")
@classmethod
def unique_tensor_descr_names(
    cls, value: Sequence[Union[InputTensorDescr, OutputTensorDescr]]
) -> Sequence[Union[InputTensorDescr, OutputTensorDescr]]:
    unique_names = {str(v.name) for v in value}
    if len(unique_names) != len(value):
        raise ValueError("Duplicate tensor descriptor names")

    return value

validate_tensor_references_in_inputs pydantic-validator ¤

validate_tensor_references_in_inputs() -> Self
Source code in src/bioimageio/spec/model/v0_4.py
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
@model_validator(mode="after")
def validate_tensor_references_in_inputs(self) -> Self:
    for t in self.inputs:
        for proc in t.preprocessing:
            if "reference_tensor" not in proc.kwargs:
                continue

            ref_tensor = proc.kwargs["reference_tensor"]
            if ref_tensor is not None and str(ref_tensor) not in {
                str(t.name) for t in self.inputs
            }:
                raise ValueError(f"'{ref_tensor}' not found in inputs")

            if ref_tensor == t.name:
                raise ValueError(
                    f"invalid self reference for preprocessing of tensor {t.name}"
                )

    return self

validate_tensor_references_in_outputs pydantic-validator ¤

validate_tensor_references_in_outputs() -> Self
Source code in src/bioimageio/spec/model/v0_4.py
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
@model_validator(mode="after")
def validate_tensor_references_in_outputs(self) -> Self:
    for t in self.outputs:
        for proc in t.postprocessing:
            if "reference_tensor" not in proc.kwargs:
                continue
            ref_tensor = proc.kwargs["reference_tensor"]
            if ref_tensor is not None and str(ref_tensor) not in {
                str(t.name) for t in self.inputs
            }:
                raise ValueError(f"{ref_tensor} not found in inputs")

    return self

warn_about_tag_categories classmethod ¤

warn_about_tag_categories(
    value: List[str], info: ValidationInfo
) -> List[str]
Source code in src/bioimageio/spec/generic/v0_2.py
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
@as_warning
@field_validator("tags")
@classmethod
def warn_about_tag_categories(
    cls, value: List[str], info: ValidationInfo
) -> List[str]:
    categories = TAG_CATEGORIES.get(info.data["type"], {})
    missing_categories: List[Mapping[str, Sequence[str]]] = []
    for cat, entries in categories.items():
        if not any(e in value for e in entries):
            missing_categories.append({cat: entries})

    if missing_categories:
        raise ValueError(
            "Missing tags from bioimage.io categories: {missing_categories}"
        )

    return value

ModelId ¤

Bases: ResourceId


              flowchart TD
              bioimageio.spec.model.v0_4.ModelId[ModelId]
              bioimageio.spec.generic.v0_2.ResourceId[ResourceId]
              bioimageio.spec._internal.validated_string.ValidatedString[ValidatedString]

                              bioimageio.spec.generic.v0_2.ResourceId --> bioimageio.spec.model.v0_4.ModelId
                                bioimageio.spec._internal.validated_string.ValidatedString --> bioimageio.spec.generic.v0_2.ResourceId
                



              click bioimageio.spec.model.v0_4.ModelId href "" "bioimageio.spec.model.v0_4.ModelId"
              click bioimageio.spec.generic.v0_2.ResourceId href "" "bioimageio.spec.generic.v0_2.ResourceId"
              click bioimageio.spec._internal.validated_string.ValidatedString href "" "bioimageio.spec._internal.validated_string.ValidatedString"
            
METHOD DESCRIPTION
__get_pydantic_core_schema__
__get_pydantic_json_schema__
__new__
ATTRIBUTE DESCRIPTION
root_model

TYPE: Type[RootModel[Any]]

root_model class-attribute ¤

root_model: Type[RootModel[Any]] = RootModel[NotEmpty[str]]

__get_pydantic_core_schema__ classmethod ¤

__get_pydantic_core_schema__(
    source_type: Any, handler: GetCoreSchemaHandler
) -> CoreSchema
Source code in src/bioimageio/spec/_internal/validated_string.py
29
30
31
32
33
@classmethod
def __get_pydantic_core_schema__(
    cls, source_type: Any, handler: GetCoreSchemaHandler
) -> CoreSchema:
    return no_info_after_validator_function(cls, handler(str))

__get_pydantic_json_schema__ classmethod ¤

__get_pydantic_json_schema__(
    core_schema: CoreSchema, handler: GetJsonSchemaHandler
) -> JsonSchemaValue
Source code in src/bioimageio/spec/_internal/validated_string.py
35
36
37
38
39
40
41
42
43
44
@classmethod
def __get_pydantic_json_schema__(
    cls, core_schema: CoreSchema, handler: GetJsonSchemaHandler
) -> JsonSchemaValue:
    json_schema = cls.root_model.model_json_schema(mode=handler.mode)
    json_schema["title"] = cls.__name__.strip("_")
    if cls.__doc__:
        json_schema["description"] = cls.__doc__

    return json_schema

__new__ ¤

__new__(object: object)
Source code in src/bioimageio/spec/_internal/validated_string.py
19
20
21
22
23
def __new__(cls, object: object):
    _validated = cls.root_model.model_validate(object).root
    self = super().__new__(cls, _validated)
    self._validated = _validated
    return self._after_validator()

Node pydantic-model ¤

Bases: pydantic.BaseModel

Show JSON schema:
{
  "additionalProperties": false,
  "properties": {},
  "title": "_internal.node.Node",
  "type": "object"
}

model_validate classmethod ¤

model_validate(
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[
        ValidationContext, Mapping[str, Any], None
    ] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self

Validate a pydantic model instance.

PARAMETER DESCRIPTION

obj ¤

The object to validate.

TYPE: Union[Any, Mapping[str, Any]]

strict ¤

Whether to raise an exception on invalid fields.

TYPE: Optional[bool] DEFAULT: None

from_attributes ¤

Whether to extract data from object attributes.

TYPE: Optional[bool] DEFAULT: None

context ¤

Additional context to pass to the validator.

TYPE: Union[ValidationContext, Mapping[str, Any], None] DEFAULT: None

RAISES DESCRIPTION
ValidationError

If the object failed validation.

RETURNS DESCRIPTION
Self

The validated description instance.

Source code in src/bioimageio/spec/_internal/node.py
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
@classmethod
def model_validate(
    cls,
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[ValidationContext, Mapping[str, Any], None] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self:
    """Validate a pydantic model instance.

    Args:
        obj: The object to validate.
        strict: Whether to raise an exception on invalid fields.
        from_attributes: Whether to extract data from object attributes.
        context: Additional context to pass to the validator.

    Raises:
        ValidationError: If the object failed validation.

    Returns:
        The validated description instance.
    """
    __tracebackhide__ = True

    if context is None:
        context = get_validation_context()
    elif isinstance(context, collections.abc.Mapping):
        context = ValidationContext(**context)

    assert not isinstance(obj, collections.abc.Mapping) or is_kwargs(obj), obj

    with context:
        # use validation context as context manager for equal behavior of __init__ and model_validate
        return super().model_validate(
            obj, strict=strict, from_attributes=from_attributes
        )

NodeWithExplicitlySetFields pydantic-model ¤

Bases: Node

Show JSON schema:
{
  "additionalProperties": false,
  "properties": {},
  "title": "_internal.common_nodes.NodeWithExplicitlySetFields",
  "type": "object"
}

__pydantic_init_subclass__ classmethod ¤

__pydantic_init_subclass__(**kwargs: Any) -> None
Source code in src/bioimageio/spec/_internal/common_nodes.py
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
@classmethod
def __pydantic_init_subclass__(cls, **kwargs: Any) -> None:
    explict_fields: Dict[str, Any] = {}
    for attr in dir(cls):
        if attr.startswith("implemented_"):
            field_name = attr.replace("implemented_", "")
            if field_name not in cls.model_fields:
                continue

            assert (
                cls.model_fields[field_name].get_default() is PydanticUndefined
            ), field_name
            default = getattr(cls, attr)
            explict_fields[field_name] = default

    cls._fields_to_set_explicitly = MappingProxyType(explict_fields)
    return super().__pydantic_init_subclass__(**kwargs)

model_validate classmethod ¤

model_validate(
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[
        ValidationContext, Mapping[str, Any], None
    ] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self

Validate a pydantic model instance.

PARAMETER DESCRIPTION

obj ¤

The object to validate.

TYPE: Union[Any, Mapping[str, Any]]

strict ¤

Whether to raise an exception on invalid fields.

TYPE: Optional[bool] DEFAULT: None

from_attributes ¤

Whether to extract data from object attributes.

TYPE: Optional[bool] DEFAULT: None

context ¤

Additional context to pass to the validator.

TYPE: Union[ValidationContext, Mapping[str, Any], None] DEFAULT: None

RAISES DESCRIPTION
ValidationError

If the object failed validation.

RETURNS DESCRIPTION
Self

The validated description instance.

Source code in src/bioimageio/spec/_internal/node.py
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
@classmethod
def model_validate(
    cls,
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[ValidationContext, Mapping[str, Any], None] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self:
    """Validate a pydantic model instance.

    Args:
        obj: The object to validate.
        strict: Whether to raise an exception on invalid fields.
        from_attributes: Whether to extract data from object attributes.
        context: Additional context to pass to the validator.

    Raises:
        ValidationError: If the object failed validation.

    Returns:
        The validated description instance.
    """
    __tracebackhide__ = True

    if context is None:
        context = get_validation_context()
    elif isinstance(context, collections.abc.Mapping):
        context = ValidationContext(**context)

    assert not isinstance(obj, collections.abc.Mapping) or is_kwargs(obj), obj

    with context:
        # use validation context as context manager for equal behavior of __init__ and model_validate
        return super().model_validate(
            obj, strict=strict, from_attributes=from_attributes
        )

OnnxWeightsDescr pydantic-model ¤

Bases: WeightsEntryDescrBase

Show JSON schema:
{
  "$defs": {
    "AttachmentsDescr": {
      "additionalProperties": true,
      "properties": {
        "files": {
          "description": "File attachments",
          "items": {
            "anyOf": [
              {
                "description": "A URL with the HTTP or HTTPS scheme.",
                "format": "uri",
                "maxLength": 2083,
                "minLength": 1,
                "title": "HttpUrl",
                "type": "string"
              },
              {
                "$ref": "#/$defs/RelativeFilePath"
              },
              {
                "format": "file-path",
                "title": "FilePath",
                "type": "string"
              }
            ]
          },
          "title": "Files",
          "type": "array"
        }
      },
      "title": "generic.v0_2.AttachmentsDescr",
      "type": "object"
    },
    "Author": {
      "additionalProperties": false,
      "properties": {
        "affiliation": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Affiliation",
          "title": "Affiliation"
        },
        "email": {
          "anyOf": [
            {
              "format": "email",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Email",
          "title": "Email"
        },
        "orcid": {
          "anyOf": [
            {
              "description": "An ORCID identifier, see https://orcid.org/",
              "title": "OrcidId",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "An [ORCID iD](https://support.orcid.org/hc/en-us/sections/360001495313-What-is-ORCID\n) in hyphenated groups of 4 digits, (and [valid](\nhttps://support.orcid.org/hc/en-us/articles/360006897674-Structure-of-the-ORCID-Identifier\n) as per ISO 7064 11,2.)",
          "examples": [
            "0000-0001-2345-6789"
          ],
          "title": "Orcid"
        },
        "name": {
          "title": "Name",
          "type": "string"
        },
        "github_user": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Github User"
        }
      },
      "required": [
        "name"
      ],
      "title": "generic.v0_2.Author",
      "type": "object"
    },
    "RelativeFilePath": {
      "description": "A path relative to the `rdf.yaml` file (also if the RDF source is a URL).",
      "format": "path",
      "title": "RelativeFilePath",
      "type": "string"
    }
  },
  "additionalProperties": false,
  "properties": {
    "source": {
      "anyOf": [
        {
          "description": "A URL with the HTTP or HTTPS scheme.",
          "format": "uri",
          "maxLength": 2083,
          "minLength": 1,
          "title": "HttpUrl",
          "type": "string"
        },
        {
          "$ref": "#/$defs/RelativeFilePath"
        },
        {
          "format": "file-path",
          "title": "FilePath",
          "type": "string"
        }
      ],
      "description": "The weights file.",
      "title": "Source"
    },
    "sha256": {
      "anyOf": [
        {
          "description": "A SHA-256 hash value",
          "maxLength": 64,
          "minLength": 64,
          "title": "Sha256",
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "SHA256 hash value of the **source** file.",
      "title": "Sha256"
    },
    "attachments": {
      "anyOf": [
        {
          "$ref": "#/$defs/AttachmentsDescr"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Attachments that are specific to this weights entry."
    },
    "authors": {
      "anyOf": [
        {
          "items": {
            "$ref": "#/$defs/Author"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Authors\nEither the person(s) that have trained this model resulting in the original weights file.\n    (If this is the initial weights entry, i.e. it does not have a `parent`)\nOr the person(s) who have converted the weights to this weights format.\n    (If this is a child weight, i.e. it has a `parent` field)",
      "title": "Authors"
    },
    "dependencies": {
      "anyOf": [
        {
          "pattern": "^.+:.+$",
          "title": "Dependencies",
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Dependency manager and dependency file, specified as `<dependency manager>:<relative file path>`.",
      "examples": [
        "conda:environment.yaml",
        "maven:./pom.xml",
        "pip:./requirements.txt"
      ],
      "title": "Dependencies"
    },
    "parent": {
      "anyOf": [
        {
          "enum": [
            "keras_hdf5",
            "onnx",
            "pytorch_state_dict",
            "tensorflow_js",
            "tensorflow_saved_model_bundle",
            "torchscript"
          ],
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "The source weights these weights were converted from.\nFor example, if a model's weights were converted from the `pytorch_state_dict` format to `torchscript`,\nThe `pytorch_state_dict` weights entry has no `parent` and is the parent of the `torchscript` weights.\nAll weight entries except one (the initial set of weights resulting from training the model),\nneed to have this field.",
      "examples": [
        "pytorch_state_dict"
      ],
      "title": "Parent"
    },
    "opset_version": {
      "anyOf": [
        {
          "minimum": 7,
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "ONNX opset version",
      "title": "Opset Version"
    }
  },
  "required": [
    "source"
  ],
  "title": "model.v0_4.OnnxWeightsDescr",
  "type": "object"
}

Fields:

Validators:

attachments pydantic-field ¤

attachments: Union[AttachmentsDescr, None] = None

Attachments that are specific to this weights entry.

authors pydantic-field ¤

authors: Union[List[Author], None] = None

Authors Either the person(s) that have trained this model resulting in the original weights file. (If this is the initial weights entry, i.e. it does not have a parent) Or the person(s) who have converted the weights to this weights format. (If this is a child weight, i.e. it has a parent field)

dependencies pydantic-field ¤

dependencies: Optional[Dependencies] = None

Dependency manager and dependency file, specified as <dependency manager>:<relative file path>.

opset_version pydantic-field ¤

opset_version: Optional[int] = None

ONNX opset version

parent pydantic-field ¤

parent: Optional[WeightsFormat] = None

The source weights these weights were converted from. For example, if a model's weights were converted from the pytorch_state_dict format to torchscript, The pytorch_state_dict weights entry has no parent and is the parent of the torchscript weights. All weight entries except one (the initial set of weights resulting from training the model), need to have this field.

sha256 pydantic-field ¤

sha256: Optional[Sha256] = None

SHA256 hash value of the source file.

source pydantic-field ¤

source: FileSource_

The weights file.

type class-attribute ¤

type: WeightsFormat = 'onnx'

weights_format_name class-attribute ¤

weights_format_name: str = 'ONNX'

check_parent_is_not_self pydantic-validator ¤

check_parent_is_not_self() -> Self
Source code in src/bioimageio/spec/model/v0_4.py
288
289
290
291
292
293
@model_validator(mode="after")
def check_parent_is_not_self(self) -> Self:
    if self.type == self.parent:
        raise ValueError("Weights entry can't be it's own parent.")

    return self

download ¤

download(
    *,
    progressbar: Union[
        Progressbar, Callable[[], Progressbar], bool, None
    ] = None,
)

alias for .get_reader

Source code in src/bioimageio/spec/_internal/io.py
306
307
308
309
310
311
312
def download(
    self,
    *,
    progressbar: Union[Progressbar, Callable[[], Progressbar], bool, None] = None,
):
    """alias for `.get_reader`"""
    return get_reader(self.source, progressbar=progressbar, sha256=self.sha256)

get_reader ¤

get_reader(
    *,
    progressbar: Union[
        Progressbar, Callable[[], Progressbar], bool, None
    ] = None,
)

open the file source (download if needed)

Source code in src/bioimageio/spec/_internal/io.py
298
299
300
301
302
303
304
def get_reader(
    self,
    *,
    progressbar: Union[Progressbar, Callable[[], Progressbar], bool, None] = None,
):
    """open the file source (download if needed)"""
    return get_reader(self.source, progressbar=progressbar, sha256=self.sha256)

model_validate classmethod ¤

model_validate(
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[
        ValidationContext, Mapping[str, Any], None
    ] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self

Validate a pydantic model instance.

PARAMETER DESCRIPTION

obj ¤

The object to validate.

TYPE: Union[Any, Mapping[str, Any]]

strict ¤

Whether to raise an exception on invalid fields.

TYPE: Optional[bool] DEFAULT: None

from_attributes ¤

Whether to extract data from object attributes.

TYPE: Optional[bool] DEFAULT: None

context ¤

Additional context to pass to the validator.

TYPE: Union[ValidationContext, Mapping[str, Any], None] DEFAULT: None

RAISES DESCRIPTION
ValidationError

If the object failed validation.

RETURNS DESCRIPTION
Self

The validated description instance.

Source code in src/bioimageio/spec/_internal/node.py
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
@classmethod
def model_validate(
    cls,
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[ValidationContext, Mapping[str, Any], None] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self:
    """Validate a pydantic model instance.

    Args:
        obj: The object to validate.
        strict: Whether to raise an exception on invalid fields.
        from_attributes: Whether to extract data from object attributes.
        context: Additional context to pass to the validator.

    Raises:
        ValidationError: If the object failed validation.

    Returns:
        The validated description instance.
    """
    __tracebackhide__ = True

    if context is None:
        context = get_validation_context()
    elif isinstance(context, collections.abc.Mapping):
        context = ValidationContext(**context)

    assert not isinstance(obj, collections.abc.Mapping) or is_kwargs(obj), obj

    with context:
        # use validation context as context manager for equal behavior of __init__ and model_validate
        return super().model_validate(
            obj, strict=strict, from_attributes=from_attributes
        )

validate_sha256 ¤

validate_sha256(force_recompute: bool = False) -> None

validate the sha256 hash value of the source file

Source code in src/bioimageio/spec/_internal/io.py
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
def validate_sha256(self, force_recompute: bool = False) -> None:
    """validate the sha256 hash value of the **source** file"""
    context = get_validation_context()
    src_str = str(self.source)
    if not force_recompute and src_str in context.known_files:
        actual_sha = context.known_files[src_str]
    else:
        reader = get_reader(self.source, sha256=self.sha256)
        if force_recompute:
            actual_sha = get_sha256(reader)
        else:
            actual_sha = reader.sha256

        context.known_files[src_str] = actual_sha

    if actual_sha is None:
        return
    elif self.sha256 == actual_sha:
        pass
    elif self.sha256 is None or context.update_hashes:
        self.sha256 = actual_sha
    elif self.sha256 != actual_sha:
        raise ValueError(
            f"Sha256 mismatch for {self.source}. Expected {self.sha256}, got "
            + f"{actual_sha}. Update expected `sha256` or point to the matching "
            + "file."
        )

OrcidId ¤

Bases: ValidatedString


              flowchart TD
              bioimageio.spec.model.v0_4.OrcidId[OrcidId]
              bioimageio.spec._internal.validated_string.ValidatedString[ValidatedString]

                              bioimageio.spec._internal.validated_string.ValidatedString --> bioimageio.spec.model.v0_4.OrcidId
                


              click bioimageio.spec.model.v0_4.OrcidId href "" "bioimageio.spec.model.v0_4.OrcidId"
              click bioimageio.spec._internal.validated_string.ValidatedString href "" "bioimageio.spec._internal.validated_string.ValidatedString"
            

An ORCID identifier, see https://orcid.org/

METHOD DESCRIPTION
__get_pydantic_core_schema__
__get_pydantic_json_schema__
__new__
ATTRIBUTE DESCRIPTION
root_model

TYPE: Type[RootModel[Any]]

root_model class-attribute ¤

root_model: Type[RootModel[Any]] = RootModel[str]

__get_pydantic_core_schema__ classmethod ¤

__get_pydantic_core_schema__(
    source_type: Any, handler: GetCoreSchemaHandler
) -> CoreSchema
Source code in src/bioimageio/spec/_internal/validated_string.py
29
30
31
32
33
@classmethod
def __get_pydantic_core_schema__(
    cls, source_type: Any, handler: GetCoreSchemaHandler
) -> CoreSchema:
    return no_info_after_validator_function(cls, handler(str))

__get_pydantic_json_schema__ classmethod ¤

__get_pydantic_json_schema__(
    core_schema: CoreSchema, handler: GetJsonSchemaHandler
) -> JsonSchemaValue
Source code in src/bioimageio/spec/_internal/validated_string.py
35
36
37
38
39
40
41
42
43
44
@classmethod
def __get_pydantic_json_schema__(
    cls, core_schema: CoreSchema, handler: GetJsonSchemaHandler
) -> JsonSchemaValue:
    json_schema = cls.root_model.model_json_schema(mode=handler.mode)
    json_schema["title"] = cls.__name__.strip("_")
    if cls.__doc__:
        json_schema["description"] = cls.__doc__

    return json_schema

__new__ ¤

__new__(object: object)
Source code in src/bioimageio/spec/_internal/validated_string.py
19
20
21
22
23
def __new__(cls, object: object):
    _validated = cls.root_model.model_validate(object).root
    self = super().__new__(cls, _validated)
    self._validated = _validated
    return self._after_validator()

OutputTensorDescr pydantic-model ¤

Bases: TensorDescrBase

Show JSON schema:
{
  "$defs": {
    "BinarizeDescr": {
      "additionalProperties": false,
      "description": "BinarizeDescr the tensor with a fixed `BinarizeKwargs.threshold`.\nValues above the threshold will be set to one, values below the threshold to zero.",
      "properties": {
        "name": {
          "const": "binarize",
          "title": "Name",
          "type": "string"
        },
        "kwargs": {
          "$ref": "#/$defs/BinarizeKwargs"
        }
      },
      "required": [
        "name",
        "kwargs"
      ],
      "title": "model.v0_4.BinarizeDescr",
      "type": "object"
    },
    "BinarizeKwargs": {
      "additionalProperties": false,
      "description": "key word arguments for `BinarizeDescr`",
      "properties": {
        "threshold": {
          "description": "The fixed threshold",
          "title": "Threshold",
          "type": "number"
        }
      },
      "required": [
        "threshold"
      ],
      "title": "model.v0_4.BinarizeKwargs",
      "type": "object"
    },
    "ClipDescr": {
      "additionalProperties": false,
      "description": "Clip tensor values to a range.\n\nSet tensor values below `ClipKwargs.min` to `ClipKwargs.min`\nand above `ClipKwargs.max` to `ClipKwargs.max`.",
      "properties": {
        "name": {
          "const": "clip",
          "title": "Name",
          "type": "string"
        },
        "kwargs": {
          "$ref": "#/$defs/ClipKwargs"
        }
      },
      "required": [
        "name",
        "kwargs"
      ],
      "title": "model.v0_4.ClipDescr",
      "type": "object"
    },
    "ClipKwargs": {
      "additionalProperties": false,
      "description": "key word arguments for `ClipDescr`",
      "properties": {
        "min": {
          "description": "minimum value for clipping",
          "title": "Min",
          "type": "number"
        },
        "max": {
          "description": "maximum value for clipping",
          "title": "Max",
          "type": "number"
        }
      },
      "required": [
        "min",
        "max"
      ],
      "title": "model.v0_4.ClipKwargs",
      "type": "object"
    },
    "ImplicitOutputShape": {
      "additionalProperties": false,
      "description": "Output tensor shape depending on an input tensor shape.\n`shape(output_tensor) = shape(input_tensor) * scale + 2 * offset`",
      "properties": {
        "reference_tensor": {
          "description": "Name of the reference tensor.",
          "minLength": 1,
          "title": "TensorName",
          "type": "string"
        },
        "scale": {
          "description": "output_pix/input_pix for each dimension.\n'null' values indicate new dimensions, whose length is defined by 2*`offset`",
          "items": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ]
          },
          "minItems": 1,
          "title": "Scale",
          "type": "array"
        },
        "offset": {
          "description": "Position of origin wrt to input.",
          "items": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "multipleOf": 0.5,
                "type": "number"
              }
            ]
          },
          "minItems": 1,
          "title": "Offset",
          "type": "array"
        }
      },
      "required": [
        "reference_tensor",
        "scale",
        "offset"
      ],
      "title": "model.v0_4.ImplicitOutputShape",
      "type": "object"
    },
    "ScaleLinearDescr": {
      "additionalProperties": false,
      "description": "Fixed linear scaling.",
      "properties": {
        "name": {
          "const": "scale_linear",
          "title": "Name",
          "type": "string"
        },
        "kwargs": {
          "$ref": "#/$defs/ScaleLinearKwargs"
        }
      },
      "required": [
        "name",
        "kwargs"
      ],
      "title": "model.v0_4.ScaleLinearDescr",
      "type": "object"
    },
    "ScaleLinearKwargs": {
      "additionalProperties": false,
      "description": "key word arguments for `ScaleLinearDescr`",
      "properties": {
        "axes": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "The subset of axes to scale jointly.\nFor example xy to scale the two image axes for 2d data jointly.",
          "examples": [
            "xy"
          ],
          "title": "Axes"
        },
        "gain": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "items": {
                "type": "number"
              },
              "type": "array"
            }
          ],
          "default": 1.0,
          "description": "multiplicative factor",
          "title": "Gain"
        },
        "offset": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "items": {
                "type": "number"
              },
              "type": "array"
            }
          ],
          "default": 0.0,
          "description": "additive term",
          "title": "Offset"
        }
      },
      "title": "model.v0_4.ScaleLinearKwargs",
      "type": "object"
    },
    "ScaleMeanVarianceDescr": {
      "additionalProperties": false,
      "description": "Scale the tensor s.t. its mean and variance match a reference tensor.",
      "properties": {
        "name": {
          "const": "scale_mean_variance",
          "title": "Name",
          "type": "string"
        },
        "kwargs": {
          "$ref": "#/$defs/ScaleMeanVarianceKwargs"
        }
      },
      "required": [
        "name",
        "kwargs"
      ],
      "title": "model.v0_4.ScaleMeanVarianceDescr",
      "type": "object"
    },
    "ScaleMeanVarianceKwargs": {
      "additionalProperties": false,
      "description": "key word arguments for `ScaleMeanVarianceDescr`",
      "properties": {
        "mode": {
          "description": "Mode for computing mean and variance.\n|     mode    |             description              |\n| ----------- | ------------------------------------ |\n| per_dataset | Compute for the entire dataset       |\n| per_sample  | Compute for each sample individually |",
          "enum": [
            "per_dataset",
            "per_sample"
          ],
          "title": "Mode",
          "type": "string"
        },
        "reference_tensor": {
          "description": "Name of tensor to match.",
          "minLength": 1,
          "title": "TensorName",
          "type": "string"
        },
        "axes": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "The subset of axes to scale jointly.\nFor example xy to normalize the two image axes for 2d data jointly.\nDefault: scale all non-batch axes jointly.",
          "examples": [
            "xy"
          ],
          "title": "Axes"
        },
        "eps": {
          "default": 1e-06,
          "description": "Epsilon for numeric stability:\n\"`out  = (tensor - mean) / (std + eps) * (ref_std + eps) + ref_mean.",
          "exclusiveMinimum": 0,
          "maximum": 0.1,
          "title": "Eps",
          "type": "number"
        }
      },
      "required": [
        "mode",
        "reference_tensor"
      ],
      "title": "model.v0_4.ScaleMeanVarianceKwargs",
      "type": "object"
    },
    "ScaleRangeDescr": {
      "additionalProperties": false,
      "description": "Scale with percentiles.",
      "properties": {
        "name": {
          "const": "scale_range",
          "title": "Name",
          "type": "string"
        },
        "kwargs": {
          "$ref": "#/$defs/ScaleRangeKwargs"
        }
      },
      "required": [
        "name",
        "kwargs"
      ],
      "title": "model.v0_4.ScaleRangeDescr",
      "type": "object"
    },
    "ScaleRangeKwargs": {
      "additionalProperties": false,
      "description": "key word arguments for `ScaleRangeDescr`\n\nFor `min_percentile`=0.0 (the default) and `max_percentile`=100 (the default)\nthis processing step normalizes data to the [0, 1] intervall.\nFor other percentiles the normalized values will partially be outside the [0, 1]\nintervall. Use `ScaleRange` followed by `ClipDescr` if you want to limit the\nnormalized values to a range.",
      "properties": {
        "mode": {
          "description": "Mode for computing percentiles.\n|     mode    |             description              |\n| ----------- | ------------------------------------ |\n| per_dataset | compute for the entire dataset       |\n| per_sample  | compute for each sample individually |",
          "enum": [
            "per_dataset",
            "per_sample"
          ],
          "title": "Mode",
          "type": "string"
        },
        "axes": {
          "description": "The subset of axes to normalize jointly.\nFor example xy to normalize the two image axes for 2d data jointly.",
          "examples": [
            "xy"
          ],
          "title": "Axes",
          "type": "string"
        },
        "min_percentile": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "number"
            }
          ],
          "default": 0.0,
          "description": "The lower percentile used to determine the value to align with zero.",
          "ge": 0,
          "lt": 100,
          "title": "Min Percentile"
        },
        "max_percentile": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "number"
            }
          ],
          "default": 100.0,
          "description": "The upper percentile used to determine the value to align with one.\nHas to be bigger than `min_percentile`.\nThe range is 1 to 100 instead of 0 to 100 to avoid mistakenly\naccepting percentiles specified in the range 0.0 to 1.0.",
          "gt": 1,
          "le": 100,
          "title": "Max Percentile"
        },
        "eps": {
          "default": 1e-06,
          "description": "Epsilon for numeric stability.\n`out = (tensor - v_lower) / (v_upper - v_lower + eps)`;\nwith `v_lower,v_upper` values at the respective percentiles.",
          "exclusiveMinimum": 0,
          "maximum": 0.1,
          "title": "Eps",
          "type": "number"
        },
        "reference_tensor": {
          "anyOf": [
            {
              "minLength": 1,
              "title": "TensorName",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Tensor name to compute the percentiles from. Default: The tensor itself.\nFor any tensor in `inputs` only input tensor references are allowed.\nFor a tensor in `outputs` only input tensor refereences are allowed if `mode: per_dataset`",
          "title": "Reference Tensor"
        }
      },
      "required": [
        "mode",
        "axes"
      ],
      "title": "model.v0_4.ScaleRangeKwargs",
      "type": "object"
    },
    "SigmoidDescr": {
      "additionalProperties": false,
      "description": "The logistic sigmoid funciton, a.k.a. expit function.",
      "properties": {
        "name": {
          "const": "sigmoid",
          "title": "Name",
          "type": "string"
        }
      },
      "required": [
        "name"
      ],
      "title": "model.v0_4.SigmoidDescr",
      "type": "object"
    },
    "ZeroMeanUnitVarianceDescr": {
      "additionalProperties": false,
      "description": "Subtract mean and divide by variance.",
      "properties": {
        "name": {
          "const": "zero_mean_unit_variance",
          "title": "Name",
          "type": "string"
        },
        "kwargs": {
          "$ref": "#/$defs/ZeroMeanUnitVarianceKwargs"
        }
      },
      "required": [
        "name",
        "kwargs"
      ],
      "title": "model.v0_4.ZeroMeanUnitVarianceDescr",
      "type": "object"
    },
    "ZeroMeanUnitVarianceKwargs": {
      "additionalProperties": false,
      "description": "key word arguments for `ZeroMeanUnitVarianceDescr`",
      "properties": {
        "mode": {
          "default": "fixed",
          "description": "Mode for computing mean and variance.\n|     mode    |             description              |\n| ----------- | ------------------------------------ |\n|   fixed     | Fixed values for mean and variance   |\n| per_dataset | Compute for the entire dataset       |\n| per_sample  | Compute for each sample individually |",
          "enum": [
            "fixed",
            "per_dataset",
            "per_sample"
          ],
          "title": "Mode",
          "type": "string"
        },
        "axes": {
          "description": "The subset of axes to normalize jointly.\nFor example `xy` to normalize the two image axes for 2d data jointly.",
          "examples": [
            "xy"
          ],
          "title": "Axes",
          "type": "string"
        },
        "mean": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "items": {
                "type": "number"
              },
              "minItems": 1,
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "The mean value(s) to use for `mode: fixed`.\nFor example `[1.1, 2.2, 3.3]` in the case of a 3 channel image with `axes: xy`.",
          "examples": [
            [
              1.1,
              2.2,
              3.3
            ]
          ],
          "title": "Mean"
        },
        "std": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "items": {
                "type": "number"
              },
              "minItems": 1,
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "The standard deviation values to use for `mode: fixed`. Analogous to mean.",
          "examples": [
            [
              0.1,
              0.2,
              0.3
            ]
          ],
          "title": "Std"
        },
        "eps": {
          "default": 1e-06,
          "description": "epsilon for numeric stability: `out = (tensor - mean) / (std + eps)`.",
          "exclusiveMinimum": 0,
          "maximum": 0.1,
          "title": "Eps",
          "type": "number"
        }
      },
      "required": [
        "axes"
      ],
      "title": "model.v0_4.ZeroMeanUnitVarianceKwargs",
      "type": "object"
    }
  },
  "additionalProperties": false,
  "properties": {
    "name": {
      "description": "Tensor name. No duplicates are allowed.",
      "minLength": 1,
      "title": "TensorName",
      "type": "string"
    },
    "description": {
      "default": "",
      "title": "Description",
      "type": "string"
    },
    "axes": {
      "description": "Axes identifying characters. Same length and order as the axes in `shape`.\n| axis | description |\n| --- | --- |\n|  b  |  batch (groups multiple samples) |\n|  i  |  instance/index/element |\n|  t  |  time |\n|  c  |  channel |\n|  z  |  spatial dimension z |\n|  y  |  spatial dimension y |\n|  x  |  spatial dimension x |",
      "title": "Axes",
      "type": "string"
    },
    "data_range": {
      "anyOf": [
        {
          "maxItems": 2,
          "minItems": 2,
          "prefixItems": [
            {
              "type": "number"
            },
            {
              "type": "number"
            }
          ],
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Tuple `(minimum, maximum)` specifying the allowed range of the data in this tensor.\nIf not specified, the full data range that can be expressed in `data_type` is allowed.",
      "title": "Data Range"
    },
    "data_type": {
      "description": "Data type.\nThe data flow in bioimage.io models is explained\n[in this diagram.](https://docs.google.com/drawings/d/1FTw8-Rn6a6nXdkZ_SkMumtcjvur9mtIhRqLwnKqZNHM/edit).",
      "enum": [
        "float32",
        "float64",
        "uint8",
        "int8",
        "uint16",
        "int16",
        "uint32",
        "int32",
        "uint64",
        "int64",
        "bool"
      ],
      "title": "Data Type",
      "type": "string"
    },
    "shape": {
      "anyOf": [
        {
          "items": {
            "type": "integer"
          },
          "type": "array"
        },
        {
          "$ref": "#/$defs/ImplicitOutputShape"
        }
      ],
      "description": "Output tensor shape.",
      "title": "Shape"
    },
    "halo": {
      "anyOf": [
        {
          "items": {
            "type": "integer"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "The `halo` that should be cropped from the output tensor to avoid boundary effects.\nThe `halo` is to be cropped from both sides, i.e. `shape_after_crop = shape - 2 * halo`.\nTo document a `halo` that is already cropped by the model `shape.offset` has to be used instead.",
      "title": "Halo"
    },
    "postprocessing": {
      "description": "Description of how this output should be postprocessed.",
      "items": {
        "discriminator": {
          "mapping": {
            "binarize": "#/$defs/BinarizeDescr",
            "clip": "#/$defs/ClipDescr",
            "scale_linear": "#/$defs/ScaleLinearDescr",
            "scale_mean_variance": "#/$defs/ScaleMeanVarianceDescr",
            "scale_range": "#/$defs/ScaleRangeDescr",
            "sigmoid": "#/$defs/SigmoidDescr",
            "zero_mean_unit_variance": "#/$defs/ZeroMeanUnitVarianceDescr"
          },
          "propertyName": "name"
        },
        "oneOf": [
          {
            "$ref": "#/$defs/BinarizeDescr"
          },
          {
            "$ref": "#/$defs/ClipDescr"
          },
          {
            "$ref": "#/$defs/ScaleLinearDescr"
          },
          {
            "$ref": "#/$defs/SigmoidDescr"
          },
          {
            "$ref": "#/$defs/ZeroMeanUnitVarianceDescr"
          },
          {
            "$ref": "#/$defs/ScaleRangeDescr"
          },
          {
            "$ref": "#/$defs/ScaleMeanVarianceDescr"
          }
        ]
      },
      "title": "Postprocessing",
      "type": "array"
    }
  },
  "required": [
    "name",
    "axes",
    "data_type",
    "shape"
  ],
  "title": "model.v0_4.OutputTensorDescr",
  "type": "object"
}

Fields:

Validators:

axes pydantic-field ¤

axes: AxesStr

Axes identifying characters. Same length and order as the axes in shape. | axis | description | | --- | --- | | b | batch (groups multiple samples) | | i | instance/index/element | | t | time | | c | channel | | z | spatial dimension z | | y | spatial dimension y | | x | spatial dimension x |

data_range pydantic-field ¤

data_range: Optional[Tuple[float, float]] = None

Tuple (minimum, maximum) specifying the allowed range of the data in this tensor. If not specified, the full data range that can be expressed in data_type is allowed.

data_type pydantic-field ¤

data_type: Literal[
    "float32",
    "float64",
    "uint8",
    "int8",
    "uint16",
    "int16",
    "uint32",
    "int32",
    "uint64",
    "int64",
    "bool",
]

Data type. The data flow in bioimage.io models is explained in this diagram..

description pydantic-field ¤

description: str = ''

halo pydantic-field ¤

halo: Optional[Sequence[int]] = None

The halo that should be cropped from the output tensor to avoid boundary effects. The halo is to be cropped from both sides, i.e. shape_after_crop = shape - 2 * halo. To document a halo that is already cropped by the model shape.offset has to be used instead.

name pydantic-field ¤

name: TensorName

Tensor name. No duplicates are allowed.

postprocessing pydantic-field ¤

postprocessing: List[PostprocessingDescr]

Description of how this output should be postprocessed.

shape pydantic-field ¤

shape: Union[Sequence[int], ImplicitOutputShape]

Output tensor shape.

matching_halo_length pydantic-validator ¤

matching_halo_length() -> Self
Source code in src/bioimageio/spec/model/v0_4.py
1003
1004
1005
1006
1007
1008
1009
1010
@model_validator(mode="after")
def matching_halo_length(self) -> Self:
    if self.halo and len(self.halo) != len(self.shape):
        raise ValueError(
            f"halo {self.halo} has to have same length as shape {self.shape}!"
        )

    return self

model_validate classmethod ¤

model_validate(
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[
        ValidationContext, Mapping[str, Any], None
    ] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self

Validate a pydantic model instance.

PARAMETER DESCRIPTION

obj ¤

The object to validate.

TYPE: Union[Any, Mapping[str, Any]]

strict ¤

Whether to raise an exception on invalid fields.

TYPE: Optional[bool] DEFAULT: None

from_attributes ¤

Whether to extract data from object attributes.

TYPE: Optional[bool] DEFAULT: None

context ¤

Additional context to pass to the validator.

TYPE: Union[ValidationContext, Mapping[str, Any], None] DEFAULT: None

RAISES DESCRIPTION
ValidationError

If the object failed validation.

RETURNS DESCRIPTION
Self

The validated description instance.

Source code in src/bioimageio/spec/_internal/node.py
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
@classmethod
def model_validate(
    cls,
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[ValidationContext, Mapping[str, Any], None] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self:
    """Validate a pydantic model instance.

    Args:
        obj: The object to validate.
        strict: Whether to raise an exception on invalid fields.
        from_attributes: Whether to extract data from object attributes.
        context: Additional context to pass to the validator.

    Raises:
        ValidationError: If the object failed validation.

    Returns:
        The validated description instance.
    """
    __tracebackhide__ = True

    if context is None:
        context = get_validation_context()
    elif isinstance(context, collections.abc.Mapping):
        context = ValidationContext(**context)

    assert not isinstance(obj, collections.abc.Mapping) or is_kwargs(obj), obj

    with context:
        # use validation context as context manager for equal behavior of __init__ and model_validate
        return super().model_validate(
            obj, strict=strict, from_attributes=from_attributes
        )

validate_postprocessing_kwargs pydantic-validator ¤

validate_postprocessing_kwargs() -> Self
Source code in src/bioimageio/spec/model/v0_4.py
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
@model_validator(mode="after")
def validate_postprocessing_kwargs(self) -> Self:
    for p in self.postprocessing:
        kwargs_axes = p.kwargs.get("axes", "")
        if not isinstance(kwargs_axes, str):
            raise ValueError(f"Expected {kwargs_axes} to be a string")

        if any(a not in self.axes for a in kwargs_axes):
            raise ValueError("`kwargs.axes` needs to be subset of axes")

    return self

ParameterizedInputShape pydantic-model ¤

Bases: Node

A sequence of valid shapes given by shape_k = min + k * step for k in {0, 1, ...}.

Show JSON schema:
{
  "additionalProperties": false,
  "description": "A sequence of valid shapes given by `shape_k = min + k * step for k in {0, 1, ...}`.",
  "properties": {
    "min": {
      "description": "The minimum input shape",
      "items": {
        "type": "integer"
      },
      "minItems": 1,
      "title": "Min",
      "type": "array"
    },
    "step": {
      "description": "The minimum shape change",
      "items": {
        "type": "integer"
      },
      "minItems": 1,
      "title": "Step",
      "type": "array"
    }
  },
  "required": [
    "min",
    "step"
  ],
  "title": "model.v0_4.ParameterizedInputShape",
  "type": "object"
}

Fields:

Validators:

min pydantic-field ¤

min: NotEmpty[List[int]]

The minimum input shape

step pydantic-field ¤

step: NotEmpty[List[int]]

The minimum shape change

__len__ ¤

__len__() -> int
Source code in src/bioimageio/spec/model/v0_4.py
556
557
def __len__(self) -> int:
    return len(self.min)

matching_lengths pydantic-validator ¤

matching_lengths() -> Self
Source code in src/bioimageio/spec/model/v0_4.py
559
560
561
562
563
564
@model_validator(mode="after")
def matching_lengths(self) -> Self:
    if len(self.min) != len(self.step):
        raise ValueError("`min` and `step` required to have the same length")

    return self

model_validate classmethod ¤

model_validate(
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[
        ValidationContext, Mapping[str, Any], None
    ] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self

Validate a pydantic model instance.

PARAMETER DESCRIPTION

obj ¤

The object to validate.

TYPE: Union[Any, Mapping[str, Any]]

strict ¤

Whether to raise an exception on invalid fields.

TYPE: Optional[bool] DEFAULT: None

from_attributes ¤

Whether to extract data from object attributes.

TYPE: Optional[bool] DEFAULT: None

context ¤

Additional context to pass to the validator.

TYPE: Union[ValidationContext, Mapping[str, Any], None] DEFAULT: None

RAISES DESCRIPTION
ValidationError

If the object failed validation.

RETURNS DESCRIPTION
Self

The validated description instance.

Source code in src/bioimageio/spec/_internal/node.py
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
@classmethod
def model_validate(
    cls,
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[ValidationContext, Mapping[str, Any], None] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self:
    """Validate a pydantic model instance.

    Args:
        obj: The object to validate.
        strict: Whether to raise an exception on invalid fields.
        from_attributes: Whether to extract data from object attributes.
        context: Additional context to pass to the validator.

    Raises:
        ValidationError: If the object failed validation.

    Returns:
        The validated description instance.
    """
    __tracebackhide__ = True

    if context is None:
        context = get_validation_context()
    elif isinstance(context, collections.abc.Mapping):
        context = ValidationContext(**context)

    assert not isinstance(obj, collections.abc.Mapping) or is_kwargs(obj), obj

    with context:
        # use validation context as context manager for equal behavior of __init__ and model_validate
        return super().model_validate(
            obj, strict=strict, from_attributes=from_attributes
        )

ProcessingDescrBase pydantic-model ¤

Bases: NodeWithExplicitlySetFields

processing base class

Show JSON schema:
{
  "additionalProperties": false,
  "description": "processing base class",
  "properties": {},
  "title": "model.v0_4.ProcessingDescrBase",
  "type": "object"
}

__pydantic_init_subclass__ classmethod ¤

__pydantic_init_subclass__(**kwargs: Any) -> None
Source code in src/bioimageio/spec/_internal/common_nodes.py
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
@classmethod
def __pydantic_init_subclass__(cls, **kwargs: Any) -> None:
    explict_fields: Dict[str, Any] = {}
    for attr in dir(cls):
        if attr.startswith("implemented_"):
            field_name = attr.replace("implemented_", "")
            if field_name not in cls.model_fields:
                continue

            assert (
                cls.model_fields[field_name].get_default() is PydanticUndefined
            ), field_name
            default = getattr(cls, attr)
            explict_fields[field_name] = default

    cls._fields_to_set_explicitly = MappingProxyType(explict_fields)
    return super().__pydantic_init_subclass__(**kwargs)

model_validate classmethod ¤

model_validate(
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[
        ValidationContext, Mapping[str, Any], None
    ] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self

Validate a pydantic model instance.

PARAMETER DESCRIPTION

obj ¤

The object to validate.

TYPE: Union[Any, Mapping[str, Any]]

strict ¤

Whether to raise an exception on invalid fields.

TYPE: Optional[bool] DEFAULT: None

from_attributes ¤

Whether to extract data from object attributes.

TYPE: Optional[bool] DEFAULT: None

context ¤

Additional context to pass to the validator.

TYPE: Union[ValidationContext, Mapping[str, Any], None] DEFAULT: None

RAISES DESCRIPTION
ValidationError

If the object failed validation.

RETURNS DESCRIPTION
Self

The validated description instance.

Source code in src/bioimageio/spec/_internal/node.py
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
@classmethod
def model_validate(
    cls,
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[ValidationContext, Mapping[str, Any], None] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self:
    """Validate a pydantic model instance.

    Args:
        obj: The object to validate.
        strict: Whether to raise an exception on invalid fields.
        from_attributes: Whether to extract data from object attributes.
        context: Additional context to pass to the validator.

    Raises:
        ValidationError: If the object failed validation.

    Returns:
        The validated description instance.
    """
    __tracebackhide__ = True

    if context is None:
        context = get_validation_context()
    elif isinstance(context, collections.abc.Mapping):
        context = ValidationContext(**context)

    assert not isinstance(obj, collections.abc.Mapping) or is_kwargs(obj), obj

    with context:
        # use validation context as context manager for equal behavior of __init__ and model_validate
        return super().model_validate(
            obj, strict=strict, from_attributes=from_attributes
        )

ProcessingKwargs pydantic-model ¤

Bases: KwargsNode

base class for pre-/postprocessing key word arguments

Show JSON schema:
{
  "additionalProperties": false,
  "description": "base class for pre-/postprocessing key word arguments",
  "properties": {},
  "title": "model.v0_4.ProcessingKwargs",
  "type": "object"
}

__contains__ ¤

__contains__(item: str) -> bool
Source code in src/bioimageio/spec/_internal/common_nodes.py
425
426
def __contains__(self, item: str) -> bool:
    return item in self.__class__.model_fields

__getitem__ ¤

__getitem__(item: str) -> Any
Source code in src/bioimageio/spec/_internal/common_nodes.py
419
420
421
422
423
def __getitem__(self, item: str) -> Any:
    if item in self.__class__.model_fields:
        return getattr(self, item)
    else:
        raise KeyError(item)

get ¤

get(item: str, default: Any = None) -> Any
Source code in src/bioimageio/spec/_internal/common_nodes.py
416
417
def get(self, item: str, default: Any = None) -> Any:
    return self[item] if item in self else default

model_validate classmethod ¤

model_validate(
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[
        ValidationContext, Mapping[str, Any], None
    ] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self

Validate a pydantic model instance.

PARAMETER DESCRIPTION

obj ¤

The object to validate.

TYPE: Union[Any, Mapping[str, Any]]

strict ¤

Whether to raise an exception on invalid fields.

TYPE: Optional[bool] DEFAULT: None

from_attributes ¤

Whether to extract data from object attributes.

TYPE: Optional[bool] DEFAULT: None

context ¤

Additional context to pass to the validator.

TYPE: Union[ValidationContext, Mapping[str, Any], None] DEFAULT: None

RAISES DESCRIPTION
ValidationError

If the object failed validation.

RETURNS DESCRIPTION
Self

The validated description instance.

Source code in src/bioimageio/spec/_internal/node.py
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
@classmethod
def model_validate(
    cls,
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[ValidationContext, Mapping[str, Any], None] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self:
    """Validate a pydantic model instance.

    Args:
        obj: The object to validate.
        strict: Whether to raise an exception on invalid fields.
        from_attributes: Whether to extract data from object attributes.
        context: Additional context to pass to the validator.

    Raises:
        ValidationError: If the object failed validation.

    Returns:
        The validated description instance.
    """
    __tracebackhide__ = True

    if context is None:
        context = get_validation_context()
    elif isinstance(context, collections.abc.Mapping):
        context = ValidationContext(**context)

    assert not isinstance(obj, collections.abc.Mapping) or is_kwargs(obj), obj

    with context:
        # use validation context as context manager for equal behavior of __init__ and model_validate
        return super().model_validate(
            obj, strict=strict, from_attributes=from_attributes
        )

PytorchStateDictWeightsDescr pydantic-model ¤

Bases: WeightsEntryDescrBase

Show JSON schema:
{
  "$defs": {
    "AttachmentsDescr": {
      "additionalProperties": true,
      "properties": {
        "files": {
          "description": "File attachments",
          "items": {
            "anyOf": [
              {
                "description": "A URL with the HTTP or HTTPS scheme.",
                "format": "uri",
                "maxLength": 2083,
                "minLength": 1,
                "title": "HttpUrl",
                "type": "string"
              },
              {
                "$ref": "#/$defs/RelativeFilePath"
              },
              {
                "format": "file-path",
                "title": "FilePath",
                "type": "string"
              }
            ]
          },
          "title": "Files",
          "type": "array"
        }
      },
      "title": "generic.v0_2.AttachmentsDescr",
      "type": "object"
    },
    "Author": {
      "additionalProperties": false,
      "properties": {
        "affiliation": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Affiliation",
          "title": "Affiliation"
        },
        "email": {
          "anyOf": [
            {
              "format": "email",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Email",
          "title": "Email"
        },
        "orcid": {
          "anyOf": [
            {
              "description": "An ORCID identifier, see https://orcid.org/",
              "title": "OrcidId",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "An [ORCID iD](https://support.orcid.org/hc/en-us/sections/360001495313-What-is-ORCID\n) in hyphenated groups of 4 digits, (and [valid](\nhttps://support.orcid.org/hc/en-us/articles/360006897674-Structure-of-the-ORCID-Identifier\n) as per ISO 7064 11,2.)",
          "examples": [
            "0000-0001-2345-6789"
          ],
          "title": "Orcid"
        },
        "name": {
          "title": "Name",
          "type": "string"
        },
        "github_user": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Github User"
        }
      },
      "required": [
        "name"
      ],
      "title": "generic.v0_2.Author",
      "type": "object"
    },
    "RelativeFilePath": {
      "description": "A path relative to the `rdf.yaml` file (also if the RDF source is a URL).",
      "format": "path",
      "title": "RelativeFilePath",
      "type": "string"
    },
    "Version": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "integer"
        },
        {
          "type": "number"
        }
      ],
      "description": "wraps a packaging.version.Version instance for validation in pydantic models",
      "title": "Version"
    }
  },
  "additionalProperties": false,
  "properties": {
    "source": {
      "anyOf": [
        {
          "description": "A URL with the HTTP or HTTPS scheme.",
          "format": "uri",
          "maxLength": 2083,
          "minLength": 1,
          "title": "HttpUrl",
          "type": "string"
        },
        {
          "$ref": "#/$defs/RelativeFilePath"
        },
        {
          "format": "file-path",
          "title": "FilePath",
          "type": "string"
        }
      ],
      "description": "The weights file.",
      "title": "Source"
    },
    "sha256": {
      "anyOf": [
        {
          "description": "A SHA-256 hash value",
          "maxLength": 64,
          "minLength": 64,
          "title": "Sha256",
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "SHA256 hash value of the **source** file.",
      "title": "Sha256"
    },
    "attachments": {
      "anyOf": [
        {
          "$ref": "#/$defs/AttachmentsDescr"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Attachments that are specific to this weights entry."
    },
    "authors": {
      "anyOf": [
        {
          "items": {
            "$ref": "#/$defs/Author"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Authors\nEither the person(s) that have trained this model resulting in the original weights file.\n    (If this is the initial weights entry, i.e. it does not have a `parent`)\nOr the person(s) who have converted the weights to this weights format.\n    (If this is a child weight, i.e. it has a `parent` field)",
      "title": "Authors"
    },
    "dependencies": {
      "anyOf": [
        {
          "pattern": "^.+:.+$",
          "title": "Dependencies",
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Dependency manager and dependency file, specified as `<dependency manager>:<relative file path>`.",
      "examples": [
        "conda:environment.yaml",
        "maven:./pom.xml",
        "pip:./requirements.txt"
      ],
      "title": "Dependencies"
    },
    "parent": {
      "anyOf": [
        {
          "enum": [
            "keras_hdf5",
            "onnx",
            "pytorch_state_dict",
            "tensorflow_js",
            "tensorflow_saved_model_bundle",
            "torchscript"
          ],
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "The source weights these weights were converted from.\nFor example, if a model's weights were converted from the `pytorch_state_dict` format to `torchscript`,\nThe `pytorch_state_dict` weights entry has no `parent` and is the parent of the `torchscript` weights.\nAll weight entries except one (the initial set of weights resulting from training the model),\nneed to have this field.",
      "examples": [
        "pytorch_state_dict"
      ],
      "title": "Parent"
    },
    "architecture": {
      "anyOf": [
        {
          "pattern": "^.+:.+$",
          "title": "CallableFromFile",
          "type": "string"
        },
        {
          "pattern": "^.+\\..+$",
          "title": "CallableFromDepencency",
          "type": "string"
        }
      ],
      "description": "callable returning a torch.nn.Module instance.\nLocal implementation: `<relative path to file>:<identifier of implementation within the file>`.\nImplementation in a dependency: `<dependency-package>.<[dependency-module]>.<identifier>`.",
      "examples": [
        "my_function.py:MyNetworkClass",
        "my_module.submodule.get_my_model"
      ],
      "title": "Architecture"
    },
    "architecture_sha256": {
      "anyOf": [
        {
          "description": "A SHA-256 hash value",
          "maxLength": 64,
          "minLength": 64,
          "title": "Sha256",
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "The SHA256 of the architecture source file, if the architecture is not defined in a module listed in `dependencies`\nYou can drag and drop your file to this\n[online tool](http://emn178.github.io/online-tools/sha256_checksum.html) to generate a SHA256 in your browser.\nOr you can generate a SHA256 checksum with Python's `hashlib`,\n[here is a codesnippet](https://gist.github.com/FynnBe/e64460463df89439cff218bbf59c1100).",
      "title": "Architecture Sha256"
    },
    "kwargs": {
      "additionalProperties": true,
      "description": "key word arguments for the `architecture` callable",
      "title": "Kwargs",
      "type": "object"
    },
    "pytorch_version": {
      "anyOf": [
        {
          "$ref": "#/$defs/Version"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Version of the PyTorch library used.\nIf `depencencies` is specified it should include pytorch and the verison has to match.\n(`dependencies` overrules `pytorch_version`)"
    }
  },
  "required": [
    "source",
    "architecture"
  ],
  "title": "model.v0_4.PytorchStateDictWeightsDescr",
  "type": "object"
}

Fields:

Validators:

architecture pydantic-field ¤

architecture: CustomCallable

callable returning a torch.nn.Module instance. Local implementation: <relative path to file>:<identifier of implementation within the file>. Implementation in a dependency: <dependency-package>.<[dependency-module]>.<identifier>.

architecture_sha256 pydantic-field ¤

architecture_sha256: Optional[Sha256] = None

The SHA256 of the architecture source file, if the architecture is not defined in a module listed in dependencies

attachments pydantic-field ¤

attachments: Union[AttachmentsDescr, None] = None

Attachments that are specific to this weights entry.

authors pydantic-field ¤

authors: Union[List[Author], None] = None

Authors Either the person(s) that have trained this model resulting in the original weights file. (If this is the initial weights entry, i.e. it does not have a parent) Or the person(s) who have converted the weights to this weights format. (If this is a child weight, i.e. it has a parent field)

dependencies pydantic-field ¤

dependencies: Optional[Dependencies] = None

Dependency manager and dependency file, specified as <dependency manager>:<relative file path>.

kwargs pydantic-field ¤

kwargs: Dict[str, Any]

key word arguments for the architecture callable

parent pydantic-field ¤

parent: Optional[WeightsFormat] = None

The source weights these weights were converted from. For example, if a model's weights were converted from the pytorch_state_dict format to torchscript, The pytorch_state_dict weights entry has no parent and is the parent of the torchscript weights. All weight entries except one (the initial set of weights resulting from training the model), need to have this field.

pytorch_version pydantic-field ¤

pytorch_version: Optional[Version] = None

Version of the PyTorch library used. If depencencies is specified it should include pytorch and the verison has to match. (dependencies overrules pytorch_version)

sha256 pydantic-field ¤

sha256: Optional[Sha256] = None

SHA256 hash value of the source file.

source pydantic-field ¤

source: FileSource_

The weights file.

type class-attribute ¤

type: WeightsFormat = 'pytorch_state_dict'

weights_format_name class-attribute ¤

weights_format_name: str = 'Pytorch State Dict'

check_architecture_sha256 pydantic-validator ¤

check_architecture_sha256() -> Self
Source code in src/bioimageio/spec/model/v0_4.py
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
@model_validator(mode="after")
def check_architecture_sha256(self) -> Self:
    if isinstance(self.architecture, CallableFromFile):
        if self.architecture_sha256 is None:
            raise ValueError(
                "Missing required `architecture_sha256` for `architecture` with"
                + " source file."
            )
    elif self.architecture_sha256 is not None:
        raise ValueError(
            "Got `architecture_sha256` for architecture that does not have a source"
            + " file."
        )

    return self

check_parent_is_not_self pydantic-validator ¤

check_parent_is_not_self() -> Self
Source code in src/bioimageio/spec/model/v0_4.py
288
289
290
291
292
293
@model_validator(mode="after")
def check_parent_is_not_self(self) -> Self:
    if self.type == self.parent:
        raise ValueError("Weights entry can't be it's own parent.")

    return self

download ¤

download(
    *,
    progressbar: Union[
        Progressbar, Callable[[], Progressbar], bool, None
    ] = None,
)

alias for .get_reader

Source code in src/bioimageio/spec/_internal/io.py
306
307
308
309
310
311
312
def download(
    self,
    *,
    progressbar: Union[Progressbar, Callable[[], Progressbar], bool, None] = None,
):
    """alias for `.get_reader`"""
    return get_reader(self.source, progressbar=progressbar, sha256=self.sha256)

get_reader ¤

get_reader(
    *,
    progressbar: Union[
        Progressbar, Callable[[], Progressbar], bool, None
    ] = None,
)

open the file source (download if needed)

Source code in src/bioimageio/spec/_internal/io.py
298
299
300
301
302
303
304
def get_reader(
    self,
    *,
    progressbar: Union[Progressbar, Callable[[], Progressbar], bool, None] = None,
):
    """open the file source (download if needed)"""
    return get_reader(self.source, progressbar=progressbar, sha256=self.sha256)

model_validate classmethod ¤

model_validate(
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[
        ValidationContext, Mapping[str, Any], None
    ] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self

Validate a pydantic model instance.

PARAMETER DESCRIPTION

obj ¤

The object to validate.

TYPE: Union[Any, Mapping[str, Any]]

strict ¤

Whether to raise an exception on invalid fields.

TYPE: Optional[bool] DEFAULT: None

from_attributes ¤

Whether to extract data from object attributes.

TYPE: Optional[bool] DEFAULT: None

context ¤

Additional context to pass to the validator.

TYPE: Union[ValidationContext, Mapping[str, Any], None] DEFAULT: None

RAISES DESCRIPTION
ValidationError

If the object failed validation.

RETURNS DESCRIPTION
Self

The validated description instance.

Source code in src/bioimageio/spec/_internal/node.py
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
@classmethod
def model_validate(
    cls,
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[ValidationContext, Mapping[str, Any], None] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self:
    """Validate a pydantic model instance.

    Args:
        obj: The object to validate.
        strict: Whether to raise an exception on invalid fields.
        from_attributes: Whether to extract data from object attributes.
        context: Additional context to pass to the validator.

    Raises:
        ValidationError: If the object failed validation.

    Returns:
        The validated description instance.
    """
    __tracebackhide__ = True

    if context is None:
        context = get_validation_context()
    elif isinstance(context, collections.abc.Mapping):
        context = ValidationContext(**context)

    assert not isinstance(obj, collections.abc.Mapping) or is_kwargs(obj), obj

    with context:
        # use validation context as context manager for equal behavior of __init__ and model_validate
        return super().model_validate(
            obj, strict=strict, from_attributes=from_attributes
        )

validate_sha256 ¤

validate_sha256(force_recompute: bool = False) -> None

validate the sha256 hash value of the source file

Source code in src/bioimageio/spec/_internal/io.py
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
def validate_sha256(self, force_recompute: bool = False) -> None:
    """validate the sha256 hash value of the **source** file"""
    context = get_validation_context()
    src_str = str(self.source)
    if not force_recompute and src_str in context.known_files:
        actual_sha = context.known_files[src_str]
    else:
        reader = get_reader(self.source, sha256=self.sha256)
        if force_recompute:
            actual_sha = get_sha256(reader)
        else:
            actual_sha = reader.sha256

        context.known_files[src_str] = actual_sha

    if actual_sha is None:
        return
    elif self.sha256 == actual_sha:
        pass
    elif self.sha256 is None or context.update_hashes:
        self.sha256 = actual_sha
    elif self.sha256 != actual_sha:
        raise ValueError(
            f"Sha256 mismatch for {self.source}. Expected {self.sha256}, got "
            + f"{actual_sha}. Update expected `sha256` or point to the matching "
            + "file."
        )

RelativeFilePath ¤

Bases: RelativePathBase[Union[AbsoluteFilePath, HttpUrl, ZipPath]]


              flowchart TD
              bioimageio.spec.model.v0_4.RelativeFilePath[RelativeFilePath]
              bioimageio.spec._internal.io.RelativePathBase[RelativePathBase]

                              bioimageio.spec._internal.io.RelativePathBase --> bioimageio.spec.model.v0_4.RelativeFilePath
                


              click bioimageio.spec.model.v0_4.RelativeFilePath href "" "bioimageio.spec.model.v0_4.RelativeFilePath"
              click bioimageio.spec._internal.io.RelativePathBase href "" "bioimageio.spec._internal.io.RelativePathBase"
            

A path relative to the rdf.yaml file (also if the RDF source is a URL).

METHOD DESCRIPTION
__repr__
__str__
absolute

get the absolute path/url

format
get_absolute
model_post_init

add validation @private

ATTRIBUTE DESCRIPTION
path

TYPE: PurePath

path property ¤

path: PurePath

__repr__ ¤

__repr__() -> str
Source code in src/bioimageio/spec/_internal/io.py
148
149
def __repr__(self) -> str:
    return f"RelativePath('{self}')"

__str__ ¤

__str__() -> str
Source code in src/bioimageio/spec/_internal/io.py
145
146
def __str__(self) -> str:
    return self.root.as_posix()

absolute ¤

absolute() -> AbsolutePathT

get the absolute path/url

(resolved at time of initialization with the root of the ValidationContext)

Source code in src/bioimageio/spec/_internal/io.py
123
124
125
126
127
128
129
130
def absolute(  # method not property analog to `pathlib.Path.absolute()`
    self,
) -> AbsolutePathT:
    """get the absolute path/url

    (resolved at time of initialization with the root of the ValidationContext)
    """
    return self._absolute

format ¤

format() -> str
Source code in src/bioimageio/spec/_internal/io.py
151
152
153
@model_serializer()
def format(self) -> str:
    return str(self)

get_absolute ¤

get_absolute(
    root: "RootHttpUrl | Path | AnyUrl | ZipFile",
) -> "AbsoluteFilePath | HttpUrl | ZipPath"
Source code in src/bioimageio/spec/_internal/io.py
215
216
217
218
219
220
221
222
223
224
225
226
227
def get_absolute(
    self, root: "RootHttpUrl | Path | AnyUrl | ZipFile"
) -> "AbsoluteFilePath | HttpUrl | ZipPath":
    absolute = self._get_absolute_impl(root)
    if (
        isinstance(absolute, Path)
        and (context := get_validation_context()).perform_io_checks
        and str(self.root) not in context.known_files
        and not absolute.is_file()
    ):
        raise ValueError(f"{absolute} does not point to an existing file")

    return absolute

model_post_init ¤

model_post_init(__context: Any) -> None

add validation @private

Source code in src/bioimageio/spec/_internal/io.py
208
209
210
211
212
213
def model_post_init(self, __context: Any) -> None:
    """add validation @private"""
    if not self.root.parts:  # an empty path can only be a directory
        raise ValueError(f"{self.root} is not a valid file path.")

    super().model_post_init(__context)

ResourceId ¤

Bases: ValidatedString


              flowchart TD
              bioimageio.spec.model.v0_4.ResourceId[ResourceId]
              bioimageio.spec._internal.validated_string.ValidatedString[ValidatedString]

                              bioimageio.spec._internal.validated_string.ValidatedString --> bioimageio.spec.model.v0_4.ResourceId
                


              click bioimageio.spec.model.v0_4.ResourceId href "" "bioimageio.spec.model.v0_4.ResourceId"
              click bioimageio.spec._internal.validated_string.ValidatedString href "" "bioimageio.spec._internal.validated_string.ValidatedString"
            
METHOD DESCRIPTION
__get_pydantic_core_schema__
__get_pydantic_json_schema__
__new__
ATTRIBUTE DESCRIPTION
root_model

TYPE: Type[RootModel[Any]]

root_model class-attribute ¤

root_model: Type[RootModel[Any]] = RootModel[NotEmpty[str]]

__get_pydantic_core_schema__ classmethod ¤

__get_pydantic_core_schema__(
    source_type: Any, handler: GetCoreSchemaHandler
) -> CoreSchema
Source code in src/bioimageio/spec/_internal/validated_string.py
29
30
31
32
33
@classmethod
def __get_pydantic_core_schema__(
    cls, source_type: Any, handler: GetCoreSchemaHandler
) -> CoreSchema:
    return no_info_after_validator_function(cls, handler(str))

__get_pydantic_json_schema__ classmethod ¤

__get_pydantic_json_schema__(
    core_schema: CoreSchema, handler: GetJsonSchemaHandler
) -> JsonSchemaValue
Source code in src/bioimageio/spec/_internal/validated_string.py
35
36
37
38
39
40
41
42
43
44
@classmethod
def __get_pydantic_json_schema__(
    cls, core_schema: CoreSchema, handler: GetJsonSchemaHandler
) -> JsonSchemaValue:
    json_schema = cls.root_model.model_json_schema(mode=handler.mode)
    json_schema["title"] = cls.__name__.strip("_")
    if cls.__doc__:
        json_schema["description"] = cls.__doc__

    return json_schema

__new__ ¤

__new__(object: object)
Source code in src/bioimageio/spec/_internal/validated_string.py
19
20
21
22
23
def __new__(cls, object: object):
    _validated = cls.root_model.model_validate(object).root
    self = super().__new__(cls, _validated)
    self._validated = _validated
    return self._after_validator()

RestrictCharacters dataclass ¤

RestrictCharacters(alphabet: str)
METHOD DESCRIPTION
__get_pydantic_core_schema__
validate
ATTRIBUTE DESCRIPTION
alphabet

TYPE: str

alphabet instance-attribute ¤

alphabet: str

__get_pydantic_core_schema__ ¤

__get_pydantic_core_schema__(
    source: Type[Any], handler: GetCoreSchemaHandler
) -> CoreSchema
Source code in src/bioimageio/spec/_internal/validator_annotations.py
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
def __get_pydantic_core_schema__(
    self, source: Type[Any], handler: GetCoreSchemaHandler
) -> CoreSchema:
    if not self.alphabet:
        raise ValueError("Alphabet may not be empty")

    schema = handler(source)  # get the CoreSchema from the type / inner constraints
    if schema["type"] != "str" and not (
        schema["type"] == "function-after" and schema["schema"]["type"] == "str"
    ):
        raise TypeError("RestrictCharacters can only be applied to strings")

    return no_info_after_validator_function(
        self.validate,
        schema,
    )

validate ¤

validate(value: str) -> str
Source code in src/bioimageio/spec/_internal/validator_annotations.py
54
55
56
57
def validate(self, value: str) -> str:
    if any(c not in self.alphabet for c in value):
        raise ValueError(f"{value!r} is not restricted to {self.alphabet!r}")
    return value

RunMode pydantic-model ¤

Bases: Node

Show JSON schema:
{
  "additionalProperties": false,
  "properties": {
    "name": {
      "anyOf": [
        {
          "const": "deepimagej",
          "type": "string"
        },
        {
          "type": "string"
        }
      ],
      "description": "Run mode name",
      "title": "Name"
    },
    "kwargs": {
      "additionalProperties": true,
      "description": "Run mode specific key word arguments",
      "title": "Kwargs",
      "type": "object"
    }
  },
  "required": [
    "name"
  ],
  "title": "model.v0_4.RunMode",
  "type": "object"
}

Fields:

kwargs pydantic-field ¤

kwargs: Dict[str, Any]

Run mode specific key word arguments

name pydantic-field ¤

name: Union[KnownRunMode, str]

Run mode name

model_validate classmethod ¤

model_validate(
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[
        ValidationContext, Mapping[str, Any], None
    ] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self

Validate a pydantic model instance.

PARAMETER DESCRIPTION

obj ¤

The object to validate.

TYPE: Union[Any, Mapping[str, Any]]

strict ¤

Whether to raise an exception on invalid fields.

TYPE: Optional[bool] DEFAULT: None

from_attributes ¤

Whether to extract data from object attributes.

TYPE: Optional[bool] DEFAULT: None

context ¤

Additional context to pass to the validator.

TYPE: Union[ValidationContext, Mapping[str, Any], None] DEFAULT: None

RAISES DESCRIPTION
ValidationError

If the object failed validation.

RETURNS DESCRIPTION
Self

The validated description instance.

Source code in src/bioimageio/spec/_internal/node.py
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
@classmethod
def model_validate(
    cls,
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[ValidationContext, Mapping[str, Any], None] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self:
    """Validate a pydantic model instance.

    Args:
        obj: The object to validate.
        strict: Whether to raise an exception on invalid fields.
        from_attributes: Whether to extract data from object attributes.
        context: Additional context to pass to the validator.

    Raises:
        ValidationError: If the object failed validation.

    Returns:
        The validated description instance.
    """
    __tracebackhide__ = True

    if context is None:
        context = get_validation_context()
    elif isinstance(context, collections.abc.Mapping):
        context = ValidationContext(**context)

    assert not isinstance(obj, collections.abc.Mapping) or is_kwargs(obj), obj

    with context:
        # use validation context as context manager for equal behavior of __init__ and model_validate
        return super().model_validate(
            obj, strict=strict, from_attributes=from_attributes
        )

ScaleLinearDescr pydantic-model ¤

Bases: ProcessingDescrBase

Fixed linear scaling.

Show JSON schema:
{
  "$defs": {
    "ScaleLinearKwargs": {
      "additionalProperties": false,
      "description": "key word arguments for `ScaleLinearDescr`",
      "properties": {
        "axes": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "The subset of axes to scale jointly.\nFor example xy to scale the two image axes for 2d data jointly.",
          "examples": [
            "xy"
          ],
          "title": "Axes"
        },
        "gain": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "items": {
                "type": "number"
              },
              "type": "array"
            }
          ],
          "default": 1.0,
          "description": "multiplicative factor",
          "title": "Gain"
        },
        "offset": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "items": {
                "type": "number"
              },
              "type": "array"
            }
          ],
          "default": 0.0,
          "description": "additive term",
          "title": "Offset"
        }
      },
      "title": "model.v0_4.ScaleLinearKwargs",
      "type": "object"
    }
  },
  "additionalProperties": false,
  "description": "Fixed linear scaling.",
  "properties": {
    "name": {
      "const": "scale_linear",
      "title": "Name",
      "type": "string"
    },
    "kwargs": {
      "$ref": "#/$defs/ScaleLinearKwargs"
    }
  },
  "required": [
    "name",
    "kwargs"
  ],
  "title": "model.v0_4.ScaleLinearDescr",
  "type": "object"
}

Fields:

implemented_name class-attribute ¤

implemented_name: Literal['scale_linear'] = 'scale_linear'

kwargs pydantic-field ¤

name pydantic-field ¤

name: Literal['scale_linear'] = 'scale_linear'

__pydantic_init_subclass__ classmethod ¤

__pydantic_init_subclass__(**kwargs: Any) -> None
Source code in src/bioimageio/spec/_internal/common_nodes.py
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
@classmethod
def __pydantic_init_subclass__(cls, **kwargs: Any) -> None:
    explict_fields: Dict[str, Any] = {}
    for attr in dir(cls):
        if attr.startswith("implemented_"):
            field_name = attr.replace("implemented_", "")
            if field_name not in cls.model_fields:
                continue

            assert (
                cls.model_fields[field_name].get_default() is PydanticUndefined
            ), field_name
            default = getattr(cls, attr)
            explict_fields[field_name] = default

    cls._fields_to_set_explicitly = MappingProxyType(explict_fields)
    return super().__pydantic_init_subclass__(**kwargs)

model_validate classmethod ¤

model_validate(
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[
        ValidationContext, Mapping[str, Any], None
    ] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self

Validate a pydantic model instance.

PARAMETER DESCRIPTION

obj ¤

The object to validate.

TYPE: Union[Any, Mapping[str, Any]]

strict ¤

Whether to raise an exception on invalid fields.

TYPE: Optional[bool] DEFAULT: None

from_attributes ¤

Whether to extract data from object attributes.

TYPE: Optional[bool] DEFAULT: None

context ¤

Additional context to pass to the validator.

TYPE: Union[ValidationContext, Mapping[str, Any], None] DEFAULT: None

RAISES DESCRIPTION
ValidationError

If the object failed validation.

RETURNS DESCRIPTION
Self

The validated description instance.

Source code in src/bioimageio/spec/_internal/node.py
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
@classmethod
def model_validate(
    cls,
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[ValidationContext, Mapping[str, Any], None] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self:
    """Validate a pydantic model instance.

    Args:
        obj: The object to validate.
        strict: Whether to raise an exception on invalid fields.
        from_attributes: Whether to extract data from object attributes.
        context: Additional context to pass to the validator.

    Raises:
        ValidationError: If the object failed validation.

    Returns:
        The validated description instance.
    """
    __tracebackhide__ = True

    if context is None:
        context = get_validation_context()
    elif isinstance(context, collections.abc.Mapping):
        context = ValidationContext(**context)

    assert not isinstance(obj, collections.abc.Mapping) or is_kwargs(obj), obj

    with context:
        # use validation context as context manager for equal behavior of __init__ and model_validate
        return super().model_validate(
            obj, strict=strict, from_attributes=from_attributes
        )

ScaleLinearKwargs pydantic-model ¤

Bases: ProcessingKwargs

key word arguments for ScaleLinearDescr

Show JSON schema:
{
  "additionalProperties": false,
  "description": "key word arguments for `ScaleLinearDescr`",
  "properties": {
    "axes": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "The subset of axes to scale jointly.\nFor example xy to scale the two image axes for 2d data jointly.",
      "examples": [
        "xy"
      ],
      "title": "Axes"
    },
    "gain": {
      "anyOf": [
        {
          "type": "number"
        },
        {
          "items": {
            "type": "number"
          },
          "type": "array"
        }
      ],
      "default": 1.0,
      "description": "multiplicative factor",
      "title": "Gain"
    },
    "offset": {
      "anyOf": [
        {
          "type": "number"
        },
        {
          "items": {
            "type": "number"
          },
          "type": "array"
        }
      ],
      "default": 0.0,
      "description": "additive term",
      "title": "Offset"
    }
  },
  "title": "model.v0_4.ScaleLinearKwargs",
  "type": "object"
}

Fields:

Validators:

axes pydantic-field ¤

axes: Optional[AxesInCZYX] = None

The subset of axes to scale jointly. For example xy to scale the two image axes for 2d data jointly.

gain pydantic-field ¤

gain: Union[float, List[float]] = 1.0

multiplicative factor

offset pydantic-field ¤

offset: Union[float, List[float]] = 0.0

additive term

__contains__ ¤

__contains__(item: str) -> bool
Source code in src/bioimageio/spec/_internal/common_nodes.py
425
426
def __contains__(self, item: str) -> bool:
    return item in self.__class__.model_fields

__getitem__ ¤

__getitem__(item: str) -> Any
Source code in src/bioimageio/spec/_internal/common_nodes.py
419
420
421
422
423
def __getitem__(self, item: str) -> Any:
    if item in self.__class__.model_fields:
        return getattr(self, item)
    else:
        raise KeyError(item)

either_gain_or_offset pydantic-validator ¤

either_gain_or_offset() -> Self
Source code in src/bioimageio/spec/model/v0_4.py
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
@model_validator(mode="after")
def either_gain_or_offset(self) -> Self:
    if (
        self.gain == 1.0
        or isinstance(self.gain, list)
        and all(g == 1.0 for g in self.gain)
    ) and (
        self.offset == 0.0
        or isinstance(self.offset, list)
        and all(off == 0.0 for off in self.offset)
    ):
        raise ValueError(
            "Redunt linear scaling not allowd. Set `gain` != 1.0 and/or `offset` !="
            + " 0.0."
        )

    return self

get ¤

get(item: str, default: Any = None) -> Any
Source code in src/bioimageio/spec/_internal/common_nodes.py
416
417
def get(self, item: str, default: Any = None) -> Any:
    return self[item] if item in self else default

model_validate classmethod ¤

model_validate(
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[
        ValidationContext, Mapping[str, Any], None
    ] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self

Validate a pydantic model instance.

PARAMETER DESCRIPTION

obj ¤

The object to validate.

TYPE: Union[Any, Mapping[str, Any]]

strict ¤

Whether to raise an exception on invalid fields.

TYPE: Optional[bool] DEFAULT: None

from_attributes ¤

Whether to extract data from object attributes.

TYPE: Optional[bool] DEFAULT: None

context ¤

Additional context to pass to the validator.

TYPE: Union[ValidationContext, Mapping[str, Any], None] DEFAULT: None

RAISES DESCRIPTION
ValidationError

If the object failed validation.

RETURNS DESCRIPTION
Self

The validated description instance.

Source code in src/bioimageio/spec/_internal/node.py
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
@classmethod
def model_validate(
    cls,
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[ValidationContext, Mapping[str, Any], None] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self:
    """Validate a pydantic model instance.

    Args:
        obj: The object to validate.
        strict: Whether to raise an exception on invalid fields.
        from_attributes: Whether to extract data from object attributes.
        context: Additional context to pass to the validator.

    Raises:
        ValidationError: If the object failed validation.

    Returns:
        The validated description instance.
    """
    __tracebackhide__ = True

    if context is None:
        context = get_validation_context()
    elif isinstance(context, collections.abc.Mapping):
        context = ValidationContext(**context)

    assert not isinstance(obj, collections.abc.Mapping) or is_kwargs(obj), obj

    with context:
        # use validation context as context manager for equal behavior of __init__ and model_validate
        return super().model_validate(
            obj, strict=strict, from_attributes=from_attributes
        )

ScaleMeanVarianceDescr pydantic-model ¤

Bases: ProcessingDescrBase

Scale the tensor s.t. its mean and variance match a reference tensor.

Show JSON schema:
{
  "$defs": {
    "ScaleMeanVarianceKwargs": {
      "additionalProperties": false,
      "description": "key word arguments for `ScaleMeanVarianceDescr`",
      "properties": {
        "mode": {
          "description": "Mode for computing mean and variance.\n|     mode    |             description              |\n| ----------- | ------------------------------------ |\n| per_dataset | Compute for the entire dataset       |\n| per_sample  | Compute for each sample individually |",
          "enum": [
            "per_dataset",
            "per_sample"
          ],
          "title": "Mode",
          "type": "string"
        },
        "reference_tensor": {
          "description": "Name of tensor to match.",
          "minLength": 1,
          "title": "TensorName",
          "type": "string"
        },
        "axes": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "The subset of axes to scale jointly.\nFor example xy to normalize the two image axes for 2d data jointly.\nDefault: scale all non-batch axes jointly.",
          "examples": [
            "xy"
          ],
          "title": "Axes"
        },
        "eps": {
          "default": 1e-06,
          "description": "Epsilon for numeric stability:\n\"`out  = (tensor - mean) / (std + eps) * (ref_std + eps) + ref_mean.",
          "exclusiveMinimum": 0,
          "maximum": 0.1,
          "title": "Eps",
          "type": "number"
        }
      },
      "required": [
        "mode",
        "reference_tensor"
      ],
      "title": "model.v0_4.ScaleMeanVarianceKwargs",
      "type": "object"
    }
  },
  "additionalProperties": false,
  "description": "Scale the tensor s.t. its mean and variance match a reference tensor.",
  "properties": {
    "name": {
      "const": "scale_mean_variance",
      "title": "Name",
      "type": "string"
    },
    "kwargs": {
      "$ref": "#/$defs/ScaleMeanVarianceKwargs"
    }
  },
  "required": [
    "name",
    "kwargs"
  ],
  "title": "model.v0_4.ScaleMeanVarianceDescr",
  "type": "object"
}

Fields:

implemented_name class-attribute ¤

implemented_name: Literal["scale_mean_variance"] = (
    "scale_mean_variance"
)

kwargs pydantic-field ¤

name pydantic-field ¤

name: Literal["scale_mean_variance"] = "scale_mean_variance"

__pydantic_init_subclass__ classmethod ¤

__pydantic_init_subclass__(**kwargs: Any) -> None
Source code in src/bioimageio/spec/_internal/common_nodes.py
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
@classmethod
def __pydantic_init_subclass__(cls, **kwargs: Any) -> None:
    explict_fields: Dict[str, Any] = {}
    for attr in dir(cls):
        if attr.startswith("implemented_"):
            field_name = attr.replace("implemented_", "")
            if field_name not in cls.model_fields:
                continue

            assert (
                cls.model_fields[field_name].get_default() is PydanticUndefined
            ), field_name
            default = getattr(cls, attr)
            explict_fields[field_name] = default

    cls._fields_to_set_explicitly = MappingProxyType(explict_fields)
    return super().__pydantic_init_subclass__(**kwargs)

model_validate classmethod ¤

model_validate(
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[
        ValidationContext, Mapping[str, Any], None
    ] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self

Validate a pydantic model instance.

PARAMETER DESCRIPTION

obj ¤

The object to validate.

TYPE: Union[Any, Mapping[str, Any]]

strict ¤

Whether to raise an exception on invalid fields.

TYPE: Optional[bool] DEFAULT: None

from_attributes ¤

Whether to extract data from object attributes.

TYPE: Optional[bool] DEFAULT: None

context ¤

Additional context to pass to the validator.

TYPE: Union[ValidationContext, Mapping[str, Any], None] DEFAULT: None

RAISES DESCRIPTION
ValidationError

If the object failed validation.

RETURNS DESCRIPTION
Self

The validated description instance.

Source code in src/bioimageio/spec/_internal/node.py
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
@classmethod
def model_validate(
    cls,
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[ValidationContext, Mapping[str, Any], None] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self:
    """Validate a pydantic model instance.

    Args:
        obj: The object to validate.
        strict: Whether to raise an exception on invalid fields.
        from_attributes: Whether to extract data from object attributes.
        context: Additional context to pass to the validator.

    Raises:
        ValidationError: If the object failed validation.

    Returns:
        The validated description instance.
    """
    __tracebackhide__ = True

    if context is None:
        context = get_validation_context()
    elif isinstance(context, collections.abc.Mapping):
        context = ValidationContext(**context)

    assert not isinstance(obj, collections.abc.Mapping) or is_kwargs(obj), obj

    with context:
        # use validation context as context manager for equal behavior of __init__ and model_validate
        return super().model_validate(
            obj, strict=strict, from_attributes=from_attributes
        )

ScaleMeanVarianceKwargs pydantic-model ¤

Bases: ProcessingKwargs

key word arguments for ScaleMeanVarianceDescr

Show JSON schema:
{
  "additionalProperties": false,
  "description": "key word arguments for `ScaleMeanVarianceDescr`",
  "properties": {
    "mode": {
      "description": "Mode for computing mean and variance.\n|     mode    |             description              |\n| ----------- | ------------------------------------ |\n| per_dataset | Compute for the entire dataset       |\n| per_sample  | Compute for each sample individually |",
      "enum": [
        "per_dataset",
        "per_sample"
      ],
      "title": "Mode",
      "type": "string"
    },
    "reference_tensor": {
      "description": "Name of tensor to match.",
      "minLength": 1,
      "title": "TensorName",
      "type": "string"
    },
    "axes": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "The subset of axes to scale jointly.\nFor example xy to normalize the two image axes for 2d data jointly.\nDefault: scale all non-batch axes jointly.",
      "examples": [
        "xy"
      ],
      "title": "Axes"
    },
    "eps": {
      "default": 1e-06,
      "description": "Epsilon for numeric stability:\n\"`out  = (tensor - mean) / (std + eps) * (ref_std + eps) + ref_mean.",
      "exclusiveMinimum": 0,
      "maximum": 0.1,
      "title": "Eps",
      "type": "number"
    }
  },
  "required": [
    "mode",
    "reference_tensor"
  ],
  "title": "model.v0_4.ScaleMeanVarianceKwargs",
  "type": "object"
}

Fields:

axes pydantic-field ¤

axes: Optional[AxesInCZYX] = None

The subset of axes to scale jointly. For example xy to normalize the two image axes for 2d data jointly. Default: scale all non-batch axes jointly.

eps pydantic-field ¤

eps: float = 1e-06

Epsilon for numeric stability: "`out = (tensor - mean) / (std + eps) * (ref_std + eps) + ref_mean.

mode pydantic-field ¤

mode: Literal['per_dataset', 'per_sample']

Mode for computing mean and variance. | mode | description | | ----------- | ------------------------------------ | | per_dataset | Compute for the entire dataset | | per_sample | Compute for each sample individually |

reference_tensor pydantic-field ¤

reference_tensor: TensorName

Name of tensor to match.

__contains__ ¤

__contains__(item: str) -> bool
Source code in src/bioimageio/spec/_internal/common_nodes.py
425
426
def __contains__(self, item: str) -> bool:
    return item in self.__class__.model_fields

__getitem__ ¤

__getitem__(item: str) -> Any
Source code in src/bioimageio/spec/_internal/common_nodes.py
419
420
421
422
423
def __getitem__(self, item: str) -> Any:
    if item in self.__class__.model_fields:
        return getattr(self, item)
    else:
        raise KeyError(item)

get ¤

get(item: str, default: Any = None) -> Any
Source code in src/bioimageio/spec/_internal/common_nodes.py
416
417
def get(self, item: str, default: Any = None) -> Any:
    return self[item] if item in self else default

model_validate classmethod ¤

model_validate(
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[
        ValidationContext, Mapping[str, Any], None
    ] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self

Validate a pydantic model instance.

PARAMETER DESCRIPTION

obj ¤

The object to validate.

TYPE: Union[Any, Mapping[str, Any]]

strict ¤

Whether to raise an exception on invalid fields.

TYPE: Optional[bool] DEFAULT: None

from_attributes ¤

Whether to extract data from object attributes.

TYPE: Optional[bool] DEFAULT: None

context ¤

Additional context to pass to the validator.

TYPE: Union[ValidationContext, Mapping[str, Any], None] DEFAULT: None

RAISES DESCRIPTION
ValidationError

If the object failed validation.

RETURNS DESCRIPTION
Self

The validated description instance.

Source code in src/bioimageio/spec/_internal/node.py
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
@classmethod
def model_validate(
    cls,
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[ValidationContext, Mapping[str, Any], None] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self:
    """Validate a pydantic model instance.

    Args:
        obj: The object to validate.
        strict: Whether to raise an exception on invalid fields.
        from_attributes: Whether to extract data from object attributes.
        context: Additional context to pass to the validator.

    Raises:
        ValidationError: If the object failed validation.

    Returns:
        The validated description instance.
    """
    __tracebackhide__ = True

    if context is None:
        context = get_validation_context()
    elif isinstance(context, collections.abc.Mapping):
        context = ValidationContext(**context)

    assert not isinstance(obj, collections.abc.Mapping) or is_kwargs(obj), obj

    with context:
        # use validation context as context manager for equal behavior of __init__ and model_validate
        return super().model_validate(
            obj, strict=strict, from_attributes=from_attributes
        )

ScaleRangeDescr pydantic-model ¤

Bases: ProcessingDescrBase

Scale with percentiles.

Show JSON schema:
{
  "$defs": {
    "ScaleRangeKwargs": {
      "additionalProperties": false,
      "description": "key word arguments for `ScaleRangeDescr`\n\nFor `min_percentile`=0.0 (the default) and `max_percentile`=100 (the default)\nthis processing step normalizes data to the [0, 1] intervall.\nFor other percentiles the normalized values will partially be outside the [0, 1]\nintervall. Use `ScaleRange` followed by `ClipDescr` if you want to limit the\nnormalized values to a range.",
      "properties": {
        "mode": {
          "description": "Mode for computing percentiles.\n|     mode    |             description              |\n| ----------- | ------------------------------------ |\n| per_dataset | compute for the entire dataset       |\n| per_sample  | compute for each sample individually |",
          "enum": [
            "per_dataset",
            "per_sample"
          ],
          "title": "Mode",
          "type": "string"
        },
        "axes": {
          "description": "The subset of axes to normalize jointly.\nFor example xy to normalize the two image axes for 2d data jointly.",
          "examples": [
            "xy"
          ],
          "title": "Axes",
          "type": "string"
        },
        "min_percentile": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "number"
            }
          ],
          "default": 0.0,
          "description": "The lower percentile used to determine the value to align with zero.",
          "ge": 0,
          "lt": 100,
          "title": "Min Percentile"
        },
        "max_percentile": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "number"
            }
          ],
          "default": 100.0,
          "description": "The upper percentile used to determine the value to align with one.\nHas to be bigger than `min_percentile`.\nThe range is 1 to 100 instead of 0 to 100 to avoid mistakenly\naccepting percentiles specified in the range 0.0 to 1.0.",
          "gt": 1,
          "le": 100,
          "title": "Max Percentile"
        },
        "eps": {
          "default": 1e-06,
          "description": "Epsilon for numeric stability.\n`out = (tensor - v_lower) / (v_upper - v_lower + eps)`;\nwith `v_lower,v_upper` values at the respective percentiles.",
          "exclusiveMinimum": 0,
          "maximum": 0.1,
          "title": "Eps",
          "type": "number"
        },
        "reference_tensor": {
          "anyOf": [
            {
              "minLength": 1,
              "title": "TensorName",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Tensor name to compute the percentiles from. Default: The tensor itself.\nFor any tensor in `inputs` only input tensor references are allowed.\nFor a tensor in `outputs` only input tensor refereences are allowed if `mode: per_dataset`",
          "title": "Reference Tensor"
        }
      },
      "required": [
        "mode",
        "axes"
      ],
      "title": "model.v0_4.ScaleRangeKwargs",
      "type": "object"
    }
  },
  "additionalProperties": false,
  "description": "Scale with percentiles.",
  "properties": {
    "name": {
      "const": "scale_range",
      "title": "Name",
      "type": "string"
    },
    "kwargs": {
      "$ref": "#/$defs/ScaleRangeKwargs"
    }
  },
  "required": [
    "name",
    "kwargs"
  ],
  "title": "model.v0_4.ScaleRangeDescr",
  "type": "object"
}

Fields:

implemented_name class-attribute ¤

implemented_name: Literal['scale_range'] = 'scale_range'

kwargs pydantic-field ¤

name pydantic-field ¤

name: Literal['scale_range'] = 'scale_range'

__pydantic_init_subclass__ classmethod ¤

__pydantic_init_subclass__(**kwargs: Any) -> None
Source code in src/bioimageio/spec/_internal/common_nodes.py
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
@classmethod
def __pydantic_init_subclass__(cls, **kwargs: Any) -> None:
    explict_fields: Dict[str, Any] = {}
    for attr in dir(cls):
        if attr.startswith("implemented_"):
            field_name = attr.replace("implemented_", "")
            if field_name not in cls.model_fields:
                continue

            assert (
                cls.model_fields[field_name].get_default() is PydanticUndefined
            ), field_name
            default = getattr(cls, attr)
            explict_fields[field_name] = default

    cls._fields_to_set_explicitly = MappingProxyType(explict_fields)
    return super().__pydantic_init_subclass__(**kwargs)

model_validate classmethod ¤

model_validate(
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[
        ValidationContext, Mapping[str, Any], None
    ] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self

Validate a pydantic model instance.

PARAMETER DESCRIPTION

obj ¤

The object to validate.

TYPE: Union[Any, Mapping[str, Any]]

strict ¤

Whether to raise an exception on invalid fields.

TYPE: Optional[bool] DEFAULT: None

from_attributes ¤

Whether to extract data from object attributes.

TYPE: Optional[bool] DEFAULT: None

context ¤

Additional context to pass to the validator.

TYPE: Union[ValidationContext, Mapping[str, Any], None] DEFAULT: None

RAISES DESCRIPTION
ValidationError

If the object failed validation.

RETURNS DESCRIPTION
Self

The validated description instance.

Source code in src/bioimageio/spec/_internal/node.py
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
@classmethod
def model_validate(
    cls,
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[ValidationContext, Mapping[str, Any], None] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self:
    """Validate a pydantic model instance.

    Args:
        obj: The object to validate.
        strict: Whether to raise an exception on invalid fields.
        from_attributes: Whether to extract data from object attributes.
        context: Additional context to pass to the validator.

    Raises:
        ValidationError: If the object failed validation.

    Returns:
        The validated description instance.
    """
    __tracebackhide__ = True

    if context is None:
        context = get_validation_context()
    elif isinstance(context, collections.abc.Mapping):
        context = ValidationContext(**context)

    assert not isinstance(obj, collections.abc.Mapping) or is_kwargs(obj), obj

    with context:
        # use validation context as context manager for equal behavior of __init__ and model_validate
        return super().model_validate(
            obj, strict=strict, from_attributes=from_attributes
        )

ScaleRangeKwargs pydantic-model ¤

Bases: ProcessingKwargs

key word arguments for ScaleRangeDescr

For min_percentile=0.0 (the default) and max_percentile=100 (the default) this processing step normalizes data to the [0, 1] intervall. For other percentiles the normalized values will partially be outside the [0, 1] intervall. Use ScaleRange followed by ClipDescr if you want to limit the normalized values to a range.

Show JSON schema:
{
  "additionalProperties": false,
  "description": "key word arguments for `ScaleRangeDescr`\n\nFor `min_percentile`=0.0 (the default) and `max_percentile`=100 (the default)\nthis processing step normalizes data to the [0, 1] intervall.\nFor other percentiles the normalized values will partially be outside the [0, 1]\nintervall. Use `ScaleRange` followed by `ClipDescr` if you want to limit the\nnormalized values to a range.",
  "properties": {
    "mode": {
      "description": "Mode for computing percentiles.\n|     mode    |             description              |\n| ----------- | ------------------------------------ |\n| per_dataset | compute for the entire dataset       |\n| per_sample  | compute for each sample individually |",
      "enum": [
        "per_dataset",
        "per_sample"
      ],
      "title": "Mode",
      "type": "string"
    },
    "axes": {
      "description": "The subset of axes to normalize jointly.\nFor example xy to normalize the two image axes for 2d data jointly.",
      "examples": [
        "xy"
      ],
      "title": "Axes",
      "type": "string"
    },
    "min_percentile": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "number"
        }
      ],
      "default": 0.0,
      "description": "The lower percentile used to determine the value to align with zero.",
      "ge": 0,
      "lt": 100,
      "title": "Min Percentile"
    },
    "max_percentile": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "number"
        }
      ],
      "default": 100.0,
      "description": "The upper percentile used to determine the value to align with one.\nHas to be bigger than `min_percentile`.\nThe range is 1 to 100 instead of 0 to 100 to avoid mistakenly\naccepting percentiles specified in the range 0.0 to 1.0.",
      "gt": 1,
      "le": 100,
      "title": "Max Percentile"
    },
    "eps": {
      "default": 1e-06,
      "description": "Epsilon for numeric stability.\n`out = (tensor - v_lower) / (v_upper - v_lower + eps)`;\nwith `v_lower,v_upper` values at the respective percentiles.",
      "exclusiveMinimum": 0,
      "maximum": 0.1,
      "title": "Eps",
      "type": "number"
    },
    "reference_tensor": {
      "anyOf": [
        {
          "minLength": 1,
          "title": "TensorName",
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Tensor name to compute the percentiles from. Default: The tensor itself.\nFor any tensor in `inputs` only input tensor references are allowed.\nFor a tensor in `outputs` only input tensor refereences are allowed if `mode: per_dataset`",
      "title": "Reference Tensor"
    }
  },
  "required": [
    "mode",
    "axes"
  ],
  "title": "model.v0_4.ScaleRangeKwargs",
  "type": "object"
}

Fields:

Validators:

axes pydantic-field ¤

axes: AxesInCZYX

The subset of axes to normalize jointly. For example xy to normalize the two image axes for 2d data jointly.

eps pydantic-field ¤

eps: float = 1e-06

Epsilon for numeric stability. out = (tensor - v_lower) / (v_upper - v_lower + eps); with v_lower,v_upper values at the respective percentiles.

max_percentile pydantic-field ¤

max_percentile: Union[int, float] = 100.0

The upper percentile used to determine the value to align with one. Has to be bigger than min_percentile. The range is 1 to 100 instead of 0 to 100 to avoid mistakenly accepting percentiles specified in the range 0.0 to 1.0.

min_percentile pydantic-field ¤

min_percentile: Union[int, float] = 0.0

The lower percentile used to determine the value to align with zero.

mode pydantic-field ¤

mode: Literal['per_dataset', 'per_sample']

Mode for computing percentiles. | mode | description | | ----------- | ------------------------------------ | | per_dataset | compute for the entire dataset | | per_sample | compute for each sample individually |

reference_tensor pydantic-field ¤

reference_tensor: Optional[TensorName] = None

Tensor name to compute the percentiles from. Default: The tensor itself. For any tensor in inputs only input tensor references are allowed. For a tensor in outputs only input tensor refereences are allowed if mode: per_dataset

__contains__ ¤

__contains__(item: str) -> bool
Source code in src/bioimageio/spec/_internal/common_nodes.py
425
426
def __contains__(self, item: str) -> bool:
    return item in self.__class__.model_fields

__getitem__ ¤

__getitem__(item: str) -> Any
Source code in src/bioimageio/spec/_internal/common_nodes.py
419
420
421
422
423
def __getitem__(self, item: str) -> Any:
    if item in self.__class__.model_fields:
        return getattr(self, item)
    else:
        raise KeyError(item)

get ¤

get(item: str, default: Any = None) -> Any
Source code in src/bioimageio/spec/_internal/common_nodes.py
416
417
def get(self, item: str, default: Any = None) -> Any:
    return self[item] if item in self else default

min_smaller_max pydantic-validator ¤

min_smaller_max(info: ValidationInfo) -> Self
Source code in src/bioimageio/spec/model/v0_4.py
821
822
823
824
825
826
827
828
829
@model_validator(mode="after")
def min_smaller_max(self, info: ValidationInfo) -> Self:
    if self.min_percentile >= self.max_percentile:
        raise ValueError(
            f"min_percentile {self.min_percentile} >= max_percentile"
            + f" {self.max_percentile}"
        )

    return self

model_validate classmethod ¤

model_validate(
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[
        ValidationContext, Mapping[str, Any], None
    ] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self

Validate a pydantic model instance.

PARAMETER DESCRIPTION

obj ¤

The object to validate.

TYPE: Union[Any, Mapping[str, Any]]

strict ¤

Whether to raise an exception on invalid fields.

TYPE: Optional[bool] DEFAULT: None

from_attributes ¤

Whether to extract data from object attributes.

TYPE: Optional[bool] DEFAULT: None

context ¤

Additional context to pass to the validator.

TYPE: Union[ValidationContext, Mapping[str, Any], None] DEFAULT: None

RAISES DESCRIPTION
ValidationError

If the object failed validation.

RETURNS DESCRIPTION
Self

The validated description instance.

Source code in src/bioimageio/spec/_internal/node.py
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
@classmethod
def model_validate(
    cls,
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[ValidationContext, Mapping[str, Any], None] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self:
    """Validate a pydantic model instance.

    Args:
        obj: The object to validate.
        strict: Whether to raise an exception on invalid fields.
        from_attributes: Whether to extract data from object attributes.
        context: Additional context to pass to the validator.

    Raises:
        ValidationError: If the object failed validation.

    Returns:
        The validated description instance.
    """
    __tracebackhide__ = True

    if context is None:
        context = get_validation_context()
    elif isinstance(context, collections.abc.Mapping):
        context = ValidationContext(**context)

    assert not isinstance(obj, collections.abc.Mapping) or is_kwargs(obj), obj

    with context:
        # use validation context as context manager for equal behavior of __init__ and model_validate
        return super().model_validate(
            obj, strict=strict, from_attributes=from_attributes
        )

Sha256 ¤

Bases: ValidatedString


              flowchart TD
              bioimageio.spec.model.v0_4.Sha256[Sha256]
              bioimageio.spec._internal.validated_string.ValidatedString[ValidatedString]

                              bioimageio.spec._internal.validated_string.ValidatedString --> bioimageio.spec.model.v0_4.Sha256
                


              click bioimageio.spec.model.v0_4.Sha256 href "" "bioimageio.spec.model.v0_4.Sha256"
              click bioimageio.spec._internal.validated_string.ValidatedString href "" "bioimageio.spec._internal.validated_string.ValidatedString"
            

A SHA-256 hash value

METHOD DESCRIPTION
__get_pydantic_core_schema__
__get_pydantic_json_schema__
__new__
ATTRIBUTE DESCRIPTION
root_model

TYPE: Type[RootModel[Any]]

root_model class-attribute ¤

root_model: Type[RootModel[Any]] = RootModel[str]

__get_pydantic_core_schema__ classmethod ¤

__get_pydantic_core_schema__(
    source_type: Any, handler: GetCoreSchemaHandler
) -> CoreSchema
Source code in src/bioimageio/spec/_internal/validated_string.py
29
30
31
32
33
@classmethod
def __get_pydantic_core_schema__(
    cls, source_type: Any, handler: GetCoreSchemaHandler
) -> CoreSchema:
    return no_info_after_validator_function(cls, handler(str))

__get_pydantic_json_schema__ classmethod ¤

__get_pydantic_json_schema__(
    core_schema: CoreSchema, handler: GetJsonSchemaHandler
) -> JsonSchemaValue
Source code in src/bioimageio/spec/_internal/validated_string.py
35
36
37
38
39
40
41
42
43
44
@classmethod
def __get_pydantic_json_schema__(
    cls, core_schema: CoreSchema, handler: GetJsonSchemaHandler
) -> JsonSchemaValue:
    json_schema = cls.root_model.model_json_schema(mode=handler.mode)
    json_schema["title"] = cls.__name__.strip("_")
    if cls.__doc__:
        json_schema["description"] = cls.__doc__

    return json_schema

__new__ ¤

__new__(object: object)
Source code in src/bioimageio/spec/_internal/validated_string.py
19
20
21
22
23
def __new__(cls, object: object):
    _validated = cls.root_model.model_validate(object).root
    self = super().__new__(cls, _validated)
    self._validated = _validated
    return self._after_validator()

SigmoidDescr pydantic-model ¤

Bases: ProcessingDescrBase

The logistic sigmoid funciton, a.k.a. expit function.

Show JSON schema:
{
  "additionalProperties": false,
  "description": "The logistic sigmoid funciton, a.k.a. expit function.",
  "properties": {
    "name": {
      "const": "sigmoid",
      "title": "Name",
      "type": "string"
    }
  },
  "required": [
    "name"
  ],
  "title": "model.v0_4.SigmoidDescr",
  "type": "object"
}

Fields:

  • name (Literal['sigmoid'])

implemented_name class-attribute ¤

implemented_name: Literal['sigmoid'] = 'sigmoid'

kwargs property ¤

empty kwargs

name pydantic-field ¤

name: Literal['sigmoid'] = 'sigmoid'

__pydantic_init_subclass__ classmethod ¤

__pydantic_init_subclass__(**kwargs: Any) -> None
Source code in src/bioimageio/spec/_internal/common_nodes.py
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
@classmethod
def __pydantic_init_subclass__(cls, **kwargs: Any) -> None:
    explict_fields: Dict[str, Any] = {}
    for attr in dir(cls):
        if attr.startswith("implemented_"):
            field_name = attr.replace("implemented_", "")
            if field_name not in cls.model_fields:
                continue

            assert (
                cls.model_fields[field_name].get_default() is PydanticUndefined
            ), field_name
            default = getattr(cls, attr)
            explict_fields[field_name] = default

    cls._fields_to_set_explicitly = MappingProxyType(explict_fields)
    return super().__pydantic_init_subclass__(**kwargs)

model_validate classmethod ¤

model_validate(
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[
        ValidationContext, Mapping[str, Any], None
    ] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self

Validate a pydantic model instance.

PARAMETER DESCRIPTION

obj ¤

The object to validate.

TYPE: Union[Any, Mapping[str, Any]]

strict ¤

Whether to raise an exception on invalid fields.

TYPE: Optional[bool] DEFAULT: None

from_attributes ¤

Whether to extract data from object attributes.

TYPE: Optional[bool] DEFAULT: None

context ¤

Additional context to pass to the validator.

TYPE: Union[ValidationContext, Mapping[str, Any], None] DEFAULT: None

RAISES DESCRIPTION
ValidationError

If the object failed validation.

RETURNS DESCRIPTION
Self

The validated description instance.

Source code in src/bioimageio/spec/_internal/node.py
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
@classmethod
def model_validate(
    cls,
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[ValidationContext, Mapping[str, Any], None] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self:
    """Validate a pydantic model instance.

    Args:
        obj: The object to validate.
        strict: Whether to raise an exception on invalid fields.
        from_attributes: Whether to extract data from object attributes.
        context: Additional context to pass to the validator.

    Raises:
        ValidationError: If the object failed validation.

    Returns:
        The validated description instance.
    """
    __tracebackhide__ = True

    if context is None:
        context = get_validation_context()
    elif isinstance(context, collections.abc.Mapping):
        context = ValidationContext(**context)

    assert not isinstance(obj, collections.abc.Mapping) or is_kwargs(obj), obj

    with context:
        # use validation context as context manager for equal behavior of __init__ and model_validate
        return super().model_validate(
            obj, strict=strict, from_attributes=from_attributes
        )

TensorDescrBase pydantic-model ¤

Bases: Node

Show JSON schema:
{
  "additionalProperties": false,
  "properties": {
    "name": {
      "description": "Tensor name. No duplicates are allowed.",
      "minLength": 1,
      "title": "TensorName",
      "type": "string"
    },
    "description": {
      "default": "",
      "title": "Description",
      "type": "string"
    },
    "axes": {
      "description": "Axes identifying characters. Same length and order as the axes in `shape`.\n| axis | description |\n| --- | --- |\n|  b  |  batch (groups multiple samples) |\n|  i  |  instance/index/element |\n|  t  |  time |\n|  c  |  channel |\n|  z  |  spatial dimension z |\n|  y  |  spatial dimension y |\n|  x  |  spatial dimension x |",
      "title": "Axes",
      "type": "string"
    },
    "data_range": {
      "anyOf": [
        {
          "maxItems": 2,
          "minItems": 2,
          "prefixItems": [
            {
              "type": "number"
            },
            {
              "type": "number"
            }
          ],
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Tuple `(minimum, maximum)` specifying the allowed range of the data in this tensor.\nIf not specified, the full data range that can be expressed in `data_type` is allowed.",
      "title": "Data Range"
    }
  },
  "required": [
    "name",
    "axes"
  ],
  "title": "model.v0_4.TensorDescrBase",
  "type": "object"
}

Fields:

axes pydantic-field ¤

axes: AxesStr

Axes identifying characters. Same length and order as the axes in shape. | axis | description | | --- | --- | | b | batch (groups multiple samples) | | i | instance/index/element | | t | time | | c | channel | | z | spatial dimension z | | y | spatial dimension y | | x | spatial dimension x |

data_range pydantic-field ¤

data_range: Optional[Tuple[float, float]] = None

Tuple (minimum, maximum) specifying the allowed range of the data in this tensor. If not specified, the full data range that can be expressed in data_type is allowed.

description pydantic-field ¤

description: str = ''

name pydantic-field ¤

name: TensorName

Tensor name. No duplicates are allowed.

model_validate classmethod ¤

model_validate(
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[
        ValidationContext, Mapping[str, Any], None
    ] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self

Validate a pydantic model instance.

PARAMETER DESCRIPTION

obj ¤

The object to validate.

TYPE: Union[Any, Mapping[str, Any]]

strict ¤

Whether to raise an exception on invalid fields.

TYPE: Optional[bool] DEFAULT: None

from_attributes ¤

Whether to extract data from object attributes.

TYPE: Optional[bool] DEFAULT: None

context ¤

Additional context to pass to the validator.

TYPE: Union[ValidationContext, Mapping[str, Any], None] DEFAULT: None

RAISES DESCRIPTION
ValidationError

If the object failed validation.

RETURNS DESCRIPTION
Self

The validated description instance.

Source code in src/bioimageio/spec/_internal/node.py
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
@classmethod
def model_validate(
    cls,
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[ValidationContext, Mapping[str, Any], None] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self:
    """Validate a pydantic model instance.

    Args:
        obj: The object to validate.
        strict: Whether to raise an exception on invalid fields.
        from_attributes: Whether to extract data from object attributes.
        context: Additional context to pass to the validator.

    Raises:
        ValidationError: If the object failed validation.

    Returns:
        The validated description instance.
    """
    __tracebackhide__ = True

    if context is None:
        context = get_validation_context()
    elif isinstance(context, collections.abc.Mapping):
        context = ValidationContext(**context)

    assert not isinstance(obj, collections.abc.Mapping) or is_kwargs(obj), obj

    with context:
        # use validation context as context manager for equal behavior of __init__ and model_validate
        return super().model_validate(
            obj, strict=strict, from_attributes=from_attributes
        )

TensorName ¤

Bases: LowerCaseIdentifier


              flowchart TD
              bioimageio.spec.model.v0_4.TensorName[TensorName]
              bioimageio.spec._internal.types.LowerCaseIdentifier[LowerCaseIdentifier]
              bioimageio.spec._internal.validated_string.ValidatedString[ValidatedString]

                              bioimageio.spec._internal.types.LowerCaseIdentifier --> bioimageio.spec.model.v0_4.TensorName
                                bioimageio.spec._internal.validated_string.ValidatedString --> bioimageio.spec._internal.types.LowerCaseIdentifier
                



              click bioimageio.spec.model.v0_4.TensorName href "" "bioimageio.spec.model.v0_4.TensorName"
              click bioimageio.spec._internal.types.LowerCaseIdentifier href "" "bioimageio.spec._internal.types.LowerCaseIdentifier"
              click bioimageio.spec._internal.validated_string.ValidatedString href "" "bioimageio.spec._internal.validated_string.ValidatedString"
            
METHOD DESCRIPTION
__get_pydantic_core_schema__
__get_pydantic_json_schema__
__new__
ATTRIBUTE DESCRIPTION
root_model

TYPE: Type[RootModel[Any]]

root_model class-attribute ¤

root_model: Type[RootModel[Any]] = RootModel[
    LowerCaseIdentifierAnno
]

__get_pydantic_core_schema__ classmethod ¤

__get_pydantic_core_schema__(
    source_type: Any, handler: GetCoreSchemaHandler
) -> CoreSchema
Source code in src/bioimageio/spec/_internal/validated_string.py
29
30
31
32
33
@classmethod
def __get_pydantic_core_schema__(
    cls, source_type: Any, handler: GetCoreSchemaHandler
) -> CoreSchema:
    return no_info_after_validator_function(cls, handler(str))

__get_pydantic_json_schema__ classmethod ¤

__get_pydantic_json_schema__(
    core_schema: CoreSchema, handler: GetJsonSchemaHandler
) -> JsonSchemaValue
Source code in src/bioimageio/spec/_internal/validated_string.py
35
36
37
38
39
40
41
42
43
44
@classmethod
def __get_pydantic_json_schema__(
    cls, core_schema: CoreSchema, handler: GetJsonSchemaHandler
) -> JsonSchemaValue:
    json_schema = cls.root_model.model_json_schema(mode=handler.mode)
    json_schema["title"] = cls.__name__.strip("_")
    if cls.__doc__:
        json_schema["description"] = cls.__doc__

    return json_schema

__new__ ¤

__new__(object: object)
Source code in src/bioimageio/spec/_internal/validated_string.py
19
20
21
22
23
def __new__(cls, object: object):
    _validated = cls.root_model.model_validate(object).root
    self = super().__new__(cls, _validated)
    self._validated = _validated
    return self._after_validator()

TensorflowJsWeightsDescr pydantic-model ¤

Bases: WeightsEntryDescrBase

Show JSON schema:
{
  "$defs": {
    "AttachmentsDescr": {
      "additionalProperties": true,
      "properties": {
        "files": {
          "description": "File attachments",
          "items": {
            "anyOf": [
              {
                "description": "A URL with the HTTP or HTTPS scheme.",
                "format": "uri",
                "maxLength": 2083,
                "minLength": 1,
                "title": "HttpUrl",
                "type": "string"
              },
              {
                "$ref": "#/$defs/RelativeFilePath"
              },
              {
                "format": "file-path",
                "title": "FilePath",
                "type": "string"
              }
            ]
          },
          "title": "Files",
          "type": "array"
        }
      },
      "title": "generic.v0_2.AttachmentsDescr",
      "type": "object"
    },
    "Author": {
      "additionalProperties": false,
      "properties": {
        "affiliation": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Affiliation",
          "title": "Affiliation"
        },
        "email": {
          "anyOf": [
            {
              "format": "email",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Email",
          "title": "Email"
        },
        "orcid": {
          "anyOf": [
            {
              "description": "An ORCID identifier, see https://orcid.org/",
              "title": "OrcidId",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "An [ORCID iD](https://support.orcid.org/hc/en-us/sections/360001495313-What-is-ORCID\n) in hyphenated groups of 4 digits, (and [valid](\nhttps://support.orcid.org/hc/en-us/articles/360006897674-Structure-of-the-ORCID-Identifier\n) as per ISO 7064 11,2.)",
          "examples": [
            "0000-0001-2345-6789"
          ],
          "title": "Orcid"
        },
        "name": {
          "title": "Name",
          "type": "string"
        },
        "github_user": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Github User"
        }
      },
      "required": [
        "name"
      ],
      "title": "generic.v0_2.Author",
      "type": "object"
    },
    "RelativeFilePath": {
      "description": "A path relative to the `rdf.yaml` file (also if the RDF source is a URL).",
      "format": "path",
      "title": "RelativeFilePath",
      "type": "string"
    },
    "Version": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "integer"
        },
        {
          "type": "number"
        }
      ],
      "description": "wraps a packaging.version.Version instance for validation in pydantic models",
      "title": "Version"
    }
  },
  "additionalProperties": false,
  "properties": {
    "source": {
      "anyOf": [
        {
          "description": "A URL with the HTTP or HTTPS scheme.",
          "format": "uri",
          "maxLength": 2083,
          "minLength": 1,
          "title": "HttpUrl",
          "type": "string"
        },
        {
          "$ref": "#/$defs/RelativeFilePath"
        },
        {
          "format": "file-path",
          "title": "FilePath",
          "type": "string"
        }
      ],
      "description": "The multi-file weights.\nAll required files/folders should be a zip archive.",
      "title": "Source"
    },
    "sha256": {
      "anyOf": [
        {
          "description": "A SHA-256 hash value",
          "maxLength": 64,
          "minLength": 64,
          "title": "Sha256",
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "SHA256 hash value of the **source** file.",
      "title": "Sha256"
    },
    "attachments": {
      "anyOf": [
        {
          "$ref": "#/$defs/AttachmentsDescr"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Attachments that are specific to this weights entry."
    },
    "authors": {
      "anyOf": [
        {
          "items": {
            "$ref": "#/$defs/Author"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Authors\nEither the person(s) that have trained this model resulting in the original weights file.\n    (If this is the initial weights entry, i.e. it does not have a `parent`)\nOr the person(s) who have converted the weights to this weights format.\n    (If this is a child weight, i.e. it has a `parent` field)",
      "title": "Authors"
    },
    "dependencies": {
      "anyOf": [
        {
          "pattern": "^.+:.+$",
          "title": "Dependencies",
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Dependency manager and dependency file, specified as `<dependency manager>:<relative file path>`.",
      "examples": [
        "conda:environment.yaml",
        "maven:./pom.xml",
        "pip:./requirements.txt"
      ],
      "title": "Dependencies"
    },
    "parent": {
      "anyOf": [
        {
          "enum": [
            "keras_hdf5",
            "onnx",
            "pytorch_state_dict",
            "tensorflow_js",
            "tensorflow_saved_model_bundle",
            "torchscript"
          ],
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "The source weights these weights were converted from.\nFor example, if a model's weights were converted from the `pytorch_state_dict` format to `torchscript`,\nThe `pytorch_state_dict` weights entry has no `parent` and is the parent of the `torchscript` weights.\nAll weight entries except one (the initial set of weights resulting from training the model),\nneed to have this field.",
      "examples": [
        "pytorch_state_dict"
      ],
      "title": "Parent"
    },
    "tensorflow_version": {
      "anyOf": [
        {
          "$ref": "#/$defs/Version"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Version of the TensorFlow library used."
    }
  },
  "required": [
    "source"
  ],
  "title": "model.v0_4.TensorflowJsWeightsDescr",
  "type": "object"
}

Fields:

Validators:

attachments pydantic-field ¤

attachments: Union[AttachmentsDescr, None] = None

Attachments that are specific to this weights entry.

authors pydantic-field ¤

authors: Union[List[Author], None] = None

Authors Either the person(s) that have trained this model resulting in the original weights file. (If this is the initial weights entry, i.e. it does not have a parent) Or the person(s) who have converted the weights to this weights format. (If this is a child weight, i.e. it has a parent field)

dependencies pydantic-field ¤

dependencies: Optional[Dependencies] = None

Dependency manager and dependency file, specified as <dependency manager>:<relative file path>.

parent pydantic-field ¤

parent: Optional[WeightsFormat] = None

The source weights these weights were converted from. For example, if a model's weights were converted from the pytorch_state_dict format to torchscript, The pytorch_state_dict weights entry has no parent and is the parent of the torchscript weights. All weight entries except one (the initial set of weights resulting from training the model), need to have this field.

sha256 pydantic-field ¤

sha256: Optional[Sha256] = None

SHA256 hash value of the source file.

source pydantic-field ¤

source: FileSource_

The multi-file weights. All required files/folders should be a zip archive.

tensorflow_version pydantic-field ¤

tensorflow_version: Optional[Version] = None

Version of the TensorFlow library used.

type class-attribute ¤

type: WeightsFormat = 'tensorflow_js'

weights_format_name class-attribute ¤

weights_format_name: str = 'Tensorflow.js'

check_parent_is_not_self pydantic-validator ¤

check_parent_is_not_self() -> Self
Source code in src/bioimageio/spec/model/v0_4.py
288
289
290
291
292
293
@model_validator(mode="after")
def check_parent_is_not_self(self) -> Self:
    if self.type == self.parent:
        raise ValueError("Weights entry can't be it's own parent.")

    return self

download ¤

download(
    *,
    progressbar: Union[
        Progressbar, Callable[[], Progressbar], bool, None
    ] = None,
)

alias for .get_reader

Source code in src/bioimageio/spec/_internal/io.py
306
307
308
309
310
311
312
def download(
    self,
    *,
    progressbar: Union[Progressbar, Callable[[], Progressbar], bool, None] = None,
):
    """alias for `.get_reader`"""
    return get_reader(self.source, progressbar=progressbar, sha256=self.sha256)

get_reader ¤

get_reader(
    *,
    progressbar: Union[
        Progressbar, Callable[[], Progressbar], bool, None
    ] = None,
)

open the file source (download if needed)

Source code in src/bioimageio/spec/_internal/io.py
298
299
300
301
302
303
304
def get_reader(
    self,
    *,
    progressbar: Union[Progressbar, Callable[[], Progressbar], bool, None] = None,
):
    """open the file source (download if needed)"""
    return get_reader(self.source, progressbar=progressbar, sha256=self.sha256)

model_validate classmethod ¤

model_validate(
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[
        ValidationContext, Mapping[str, Any], None
    ] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self

Validate a pydantic model instance.

PARAMETER DESCRIPTION

obj ¤

The object to validate.

TYPE: Union[Any, Mapping[str, Any]]

strict ¤

Whether to raise an exception on invalid fields.

TYPE: Optional[bool] DEFAULT: None

from_attributes ¤

Whether to extract data from object attributes.

TYPE: Optional[bool] DEFAULT: None

context ¤

Additional context to pass to the validator.

TYPE: Union[ValidationContext, Mapping[str, Any], None] DEFAULT: None

RAISES DESCRIPTION
ValidationError

If the object failed validation.

RETURNS DESCRIPTION
Self

The validated description instance.

Source code in src/bioimageio/spec/_internal/node.py
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
@classmethod
def model_validate(
    cls,
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[ValidationContext, Mapping[str, Any], None] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self:
    """Validate a pydantic model instance.

    Args:
        obj: The object to validate.
        strict: Whether to raise an exception on invalid fields.
        from_attributes: Whether to extract data from object attributes.
        context: Additional context to pass to the validator.

    Raises:
        ValidationError: If the object failed validation.

    Returns:
        The validated description instance.
    """
    __tracebackhide__ = True

    if context is None:
        context = get_validation_context()
    elif isinstance(context, collections.abc.Mapping):
        context = ValidationContext(**context)

    assert not isinstance(obj, collections.abc.Mapping) or is_kwargs(obj), obj

    with context:
        # use validation context as context manager for equal behavior of __init__ and model_validate
        return super().model_validate(
            obj, strict=strict, from_attributes=from_attributes
        )

validate_sha256 ¤

validate_sha256(force_recompute: bool = False) -> None

validate the sha256 hash value of the source file

Source code in src/bioimageio/spec/_internal/io.py
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
def validate_sha256(self, force_recompute: bool = False) -> None:
    """validate the sha256 hash value of the **source** file"""
    context = get_validation_context()
    src_str = str(self.source)
    if not force_recompute and src_str in context.known_files:
        actual_sha = context.known_files[src_str]
    else:
        reader = get_reader(self.source, sha256=self.sha256)
        if force_recompute:
            actual_sha = get_sha256(reader)
        else:
            actual_sha = reader.sha256

        context.known_files[src_str] = actual_sha

    if actual_sha is None:
        return
    elif self.sha256 == actual_sha:
        pass
    elif self.sha256 is None or context.update_hashes:
        self.sha256 = actual_sha
    elif self.sha256 != actual_sha:
        raise ValueError(
            f"Sha256 mismatch for {self.source}. Expected {self.sha256}, got "
            + f"{actual_sha}. Update expected `sha256` or point to the matching "
            + "file."
        )

TensorflowSavedModelBundleWeightsDescr pydantic-model ¤

Bases: WeightsEntryDescrBase

Show JSON schema:
{
  "$defs": {
    "AttachmentsDescr": {
      "additionalProperties": true,
      "properties": {
        "files": {
          "description": "File attachments",
          "items": {
            "anyOf": [
              {
                "description": "A URL with the HTTP or HTTPS scheme.",
                "format": "uri",
                "maxLength": 2083,
                "minLength": 1,
                "title": "HttpUrl",
                "type": "string"
              },
              {
                "$ref": "#/$defs/RelativeFilePath"
              },
              {
                "format": "file-path",
                "title": "FilePath",
                "type": "string"
              }
            ]
          },
          "title": "Files",
          "type": "array"
        }
      },
      "title": "generic.v0_2.AttachmentsDescr",
      "type": "object"
    },
    "Author": {
      "additionalProperties": false,
      "properties": {
        "affiliation": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Affiliation",
          "title": "Affiliation"
        },
        "email": {
          "anyOf": [
            {
              "format": "email",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Email",
          "title": "Email"
        },
        "orcid": {
          "anyOf": [
            {
              "description": "An ORCID identifier, see https://orcid.org/",
              "title": "OrcidId",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "An [ORCID iD](https://support.orcid.org/hc/en-us/sections/360001495313-What-is-ORCID\n) in hyphenated groups of 4 digits, (and [valid](\nhttps://support.orcid.org/hc/en-us/articles/360006897674-Structure-of-the-ORCID-Identifier\n) as per ISO 7064 11,2.)",
          "examples": [
            "0000-0001-2345-6789"
          ],
          "title": "Orcid"
        },
        "name": {
          "title": "Name",
          "type": "string"
        },
        "github_user": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Github User"
        }
      },
      "required": [
        "name"
      ],
      "title": "generic.v0_2.Author",
      "type": "object"
    },
    "RelativeFilePath": {
      "description": "A path relative to the `rdf.yaml` file (also if the RDF source is a URL).",
      "format": "path",
      "title": "RelativeFilePath",
      "type": "string"
    },
    "Version": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "integer"
        },
        {
          "type": "number"
        }
      ],
      "description": "wraps a packaging.version.Version instance for validation in pydantic models",
      "title": "Version"
    }
  },
  "additionalProperties": false,
  "properties": {
    "source": {
      "anyOf": [
        {
          "description": "A URL with the HTTP or HTTPS scheme.",
          "format": "uri",
          "maxLength": 2083,
          "minLength": 1,
          "title": "HttpUrl",
          "type": "string"
        },
        {
          "$ref": "#/$defs/RelativeFilePath"
        },
        {
          "format": "file-path",
          "title": "FilePath",
          "type": "string"
        }
      ],
      "description": "The weights file.",
      "title": "Source"
    },
    "sha256": {
      "anyOf": [
        {
          "description": "A SHA-256 hash value",
          "maxLength": 64,
          "minLength": 64,
          "title": "Sha256",
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "SHA256 hash value of the **source** file.",
      "title": "Sha256"
    },
    "attachments": {
      "anyOf": [
        {
          "$ref": "#/$defs/AttachmentsDescr"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Attachments that are specific to this weights entry."
    },
    "authors": {
      "anyOf": [
        {
          "items": {
            "$ref": "#/$defs/Author"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Authors\nEither the person(s) that have trained this model resulting in the original weights file.\n    (If this is the initial weights entry, i.e. it does not have a `parent`)\nOr the person(s) who have converted the weights to this weights format.\n    (If this is a child weight, i.e. it has a `parent` field)",
      "title": "Authors"
    },
    "dependencies": {
      "anyOf": [
        {
          "pattern": "^.+:.+$",
          "title": "Dependencies",
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Dependency manager and dependency file, specified as `<dependency manager>:<relative file path>`.",
      "examples": [
        "conda:environment.yaml",
        "maven:./pom.xml",
        "pip:./requirements.txt"
      ],
      "title": "Dependencies"
    },
    "parent": {
      "anyOf": [
        {
          "enum": [
            "keras_hdf5",
            "onnx",
            "pytorch_state_dict",
            "tensorflow_js",
            "tensorflow_saved_model_bundle",
            "torchscript"
          ],
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "The source weights these weights were converted from.\nFor example, if a model's weights were converted from the `pytorch_state_dict` format to `torchscript`,\nThe `pytorch_state_dict` weights entry has no `parent` and is the parent of the `torchscript` weights.\nAll weight entries except one (the initial set of weights resulting from training the model),\nneed to have this field.",
      "examples": [
        "pytorch_state_dict"
      ],
      "title": "Parent"
    },
    "tensorflow_version": {
      "anyOf": [
        {
          "$ref": "#/$defs/Version"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Version of the TensorFlow library used."
    }
  },
  "required": [
    "source"
  ],
  "title": "model.v0_4.TensorflowSavedModelBundleWeightsDescr",
  "type": "object"
}

Fields:

Validators:

attachments pydantic-field ¤

attachments: Union[AttachmentsDescr, None] = None

Attachments that are specific to this weights entry.

authors pydantic-field ¤

authors: Union[List[Author], None] = None

Authors Either the person(s) that have trained this model resulting in the original weights file. (If this is the initial weights entry, i.e. it does not have a parent) Or the person(s) who have converted the weights to this weights format. (If this is a child weight, i.e. it has a parent field)

dependencies pydantic-field ¤

dependencies: Optional[Dependencies] = None

Dependency manager and dependency file, specified as <dependency manager>:<relative file path>.

parent pydantic-field ¤

parent: Optional[WeightsFormat] = None

The source weights these weights were converted from. For example, if a model's weights were converted from the pytorch_state_dict format to torchscript, The pytorch_state_dict weights entry has no parent and is the parent of the torchscript weights. All weight entries except one (the initial set of weights resulting from training the model), need to have this field.

sha256 pydantic-field ¤

sha256: Optional[Sha256] = None

SHA256 hash value of the source file.

source pydantic-field ¤

source: FileSource_

The weights file.

tensorflow_version pydantic-field ¤

tensorflow_version: Optional[Version] = None

Version of the TensorFlow library used.

type class-attribute ¤

type: WeightsFormat = 'tensorflow_saved_model_bundle'

weights_format_name class-attribute ¤

weights_format_name: str = 'Tensorflow Saved Model'

check_parent_is_not_self pydantic-validator ¤

check_parent_is_not_self() -> Self
Source code in src/bioimageio/spec/model/v0_4.py
288
289
290
291
292
293
@model_validator(mode="after")
def check_parent_is_not_self(self) -> Self:
    if self.type == self.parent:
        raise ValueError("Weights entry can't be it's own parent.")

    return self

download ¤

download(
    *,
    progressbar: Union[
        Progressbar, Callable[[], Progressbar], bool, None
    ] = None,
)

alias for .get_reader

Source code in src/bioimageio/spec/_internal/io.py
306
307
308
309
310
311
312
def download(
    self,
    *,
    progressbar: Union[Progressbar, Callable[[], Progressbar], bool, None] = None,
):
    """alias for `.get_reader`"""
    return get_reader(self.source, progressbar=progressbar, sha256=self.sha256)

get_reader ¤

get_reader(
    *,
    progressbar: Union[
        Progressbar, Callable[[], Progressbar], bool, None
    ] = None,
)

open the file source (download if needed)

Source code in src/bioimageio/spec/_internal/io.py
298
299
300
301
302
303
304
def get_reader(
    self,
    *,
    progressbar: Union[Progressbar, Callable[[], Progressbar], bool, None] = None,
):
    """open the file source (download if needed)"""
    return get_reader(self.source, progressbar=progressbar, sha256=self.sha256)

model_validate classmethod ¤

model_validate(
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[
        ValidationContext, Mapping[str, Any], None
    ] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self

Validate a pydantic model instance.

PARAMETER DESCRIPTION

obj ¤

The object to validate.

TYPE: Union[Any, Mapping[str, Any]]

strict ¤

Whether to raise an exception on invalid fields.

TYPE: Optional[bool] DEFAULT: None

from_attributes ¤

Whether to extract data from object attributes.

TYPE: Optional[bool] DEFAULT: None

context ¤

Additional context to pass to the validator.

TYPE: Union[ValidationContext, Mapping[str, Any], None] DEFAULT: None

RAISES DESCRIPTION
ValidationError

If the object failed validation.

RETURNS DESCRIPTION
Self

The validated description instance.

Source code in src/bioimageio/spec/_internal/node.py
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
@classmethod
def model_validate(
    cls,
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[ValidationContext, Mapping[str, Any], None] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self:
    """Validate a pydantic model instance.

    Args:
        obj: The object to validate.
        strict: Whether to raise an exception on invalid fields.
        from_attributes: Whether to extract data from object attributes.
        context: Additional context to pass to the validator.

    Raises:
        ValidationError: If the object failed validation.

    Returns:
        The validated description instance.
    """
    __tracebackhide__ = True

    if context is None:
        context = get_validation_context()
    elif isinstance(context, collections.abc.Mapping):
        context = ValidationContext(**context)

    assert not isinstance(obj, collections.abc.Mapping) or is_kwargs(obj), obj

    with context:
        # use validation context as context manager for equal behavior of __init__ and model_validate
        return super().model_validate(
            obj, strict=strict, from_attributes=from_attributes
        )

validate_sha256 ¤

validate_sha256(force_recompute: bool = False) -> None

validate the sha256 hash value of the source file

Source code in src/bioimageio/spec/_internal/io.py
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
def validate_sha256(self, force_recompute: bool = False) -> None:
    """validate the sha256 hash value of the **source** file"""
    context = get_validation_context()
    src_str = str(self.source)
    if not force_recompute and src_str in context.known_files:
        actual_sha = context.known_files[src_str]
    else:
        reader = get_reader(self.source, sha256=self.sha256)
        if force_recompute:
            actual_sha = get_sha256(reader)
        else:
            actual_sha = reader.sha256

        context.known_files[src_str] = actual_sha

    if actual_sha is None:
        return
    elif self.sha256 == actual_sha:
        pass
    elif self.sha256 is None or context.update_hashes:
        self.sha256 = actual_sha
    elif self.sha256 != actual_sha:
        raise ValueError(
            f"Sha256 mismatch for {self.source}. Expected {self.sha256}, got "
            + f"{actual_sha}. Update expected `sha256` or point to the matching "
            + "file."
        )

TorchscriptWeightsDescr pydantic-model ¤

Bases: WeightsEntryDescrBase

Show JSON schema:
{
  "$defs": {
    "AttachmentsDescr": {
      "additionalProperties": true,
      "properties": {
        "files": {
          "description": "File attachments",
          "items": {
            "anyOf": [
              {
                "description": "A URL with the HTTP or HTTPS scheme.",
                "format": "uri",
                "maxLength": 2083,
                "minLength": 1,
                "title": "HttpUrl",
                "type": "string"
              },
              {
                "$ref": "#/$defs/RelativeFilePath"
              },
              {
                "format": "file-path",
                "title": "FilePath",
                "type": "string"
              }
            ]
          },
          "title": "Files",
          "type": "array"
        }
      },
      "title": "generic.v0_2.AttachmentsDescr",
      "type": "object"
    },
    "Author": {
      "additionalProperties": false,
      "properties": {
        "affiliation": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Affiliation",
          "title": "Affiliation"
        },
        "email": {
          "anyOf": [
            {
              "format": "email",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Email",
          "title": "Email"
        },
        "orcid": {
          "anyOf": [
            {
              "description": "An ORCID identifier, see https://orcid.org/",
              "title": "OrcidId",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "An [ORCID iD](https://support.orcid.org/hc/en-us/sections/360001495313-What-is-ORCID\n) in hyphenated groups of 4 digits, (and [valid](\nhttps://support.orcid.org/hc/en-us/articles/360006897674-Structure-of-the-ORCID-Identifier\n) as per ISO 7064 11,2.)",
          "examples": [
            "0000-0001-2345-6789"
          ],
          "title": "Orcid"
        },
        "name": {
          "title": "Name",
          "type": "string"
        },
        "github_user": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Github User"
        }
      },
      "required": [
        "name"
      ],
      "title": "generic.v0_2.Author",
      "type": "object"
    },
    "RelativeFilePath": {
      "description": "A path relative to the `rdf.yaml` file (also if the RDF source is a URL).",
      "format": "path",
      "title": "RelativeFilePath",
      "type": "string"
    },
    "Version": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "integer"
        },
        {
          "type": "number"
        }
      ],
      "description": "wraps a packaging.version.Version instance for validation in pydantic models",
      "title": "Version"
    }
  },
  "additionalProperties": false,
  "properties": {
    "source": {
      "anyOf": [
        {
          "description": "A URL with the HTTP or HTTPS scheme.",
          "format": "uri",
          "maxLength": 2083,
          "minLength": 1,
          "title": "HttpUrl",
          "type": "string"
        },
        {
          "$ref": "#/$defs/RelativeFilePath"
        },
        {
          "format": "file-path",
          "title": "FilePath",
          "type": "string"
        }
      ],
      "description": "The weights file.",
      "title": "Source"
    },
    "sha256": {
      "anyOf": [
        {
          "description": "A SHA-256 hash value",
          "maxLength": 64,
          "minLength": 64,
          "title": "Sha256",
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "SHA256 hash value of the **source** file.",
      "title": "Sha256"
    },
    "attachments": {
      "anyOf": [
        {
          "$ref": "#/$defs/AttachmentsDescr"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Attachments that are specific to this weights entry."
    },
    "authors": {
      "anyOf": [
        {
          "items": {
            "$ref": "#/$defs/Author"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Authors\nEither the person(s) that have trained this model resulting in the original weights file.\n    (If this is the initial weights entry, i.e. it does not have a `parent`)\nOr the person(s) who have converted the weights to this weights format.\n    (If this is a child weight, i.e. it has a `parent` field)",
      "title": "Authors"
    },
    "dependencies": {
      "anyOf": [
        {
          "pattern": "^.+:.+$",
          "title": "Dependencies",
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Dependency manager and dependency file, specified as `<dependency manager>:<relative file path>`.",
      "examples": [
        "conda:environment.yaml",
        "maven:./pom.xml",
        "pip:./requirements.txt"
      ],
      "title": "Dependencies"
    },
    "parent": {
      "anyOf": [
        {
          "enum": [
            "keras_hdf5",
            "onnx",
            "pytorch_state_dict",
            "tensorflow_js",
            "tensorflow_saved_model_bundle",
            "torchscript"
          ],
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "The source weights these weights were converted from.\nFor example, if a model's weights were converted from the `pytorch_state_dict` format to `torchscript`,\nThe `pytorch_state_dict` weights entry has no `parent` and is the parent of the `torchscript` weights.\nAll weight entries except one (the initial set of weights resulting from training the model),\nneed to have this field.",
      "examples": [
        "pytorch_state_dict"
      ],
      "title": "Parent"
    },
    "pytorch_version": {
      "anyOf": [
        {
          "$ref": "#/$defs/Version"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Version of the PyTorch library used."
    }
  },
  "required": [
    "source"
  ],
  "title": "model.v0_4.TorchscriptWeightsDescr",
  "type": "object"
}

Fields:

Validators:

attachments pydantic-field ¤

attachments: Union[AttachmentsDescr, None] = None

Attachments that are specific to this weights entry.

authors pydantic-field ¤

authors: Union[List[Author], None] = None

Authors Either the person(s) that have trained this model resulting in the original weights file. (If this is the initial weights entry, i.e. it does not have a parent) Or the person(s) who have converted the weights to this weights format. (If this is a child weight, i.e. it has a parent field)

dependencies pydantic-field ¤

dependencies: Optional[Dependencies] = None

Dependency manager and dependency file, specified as <dependency manager>:<relative file path>.

parent pydantic-field ¤

parent: Optional[WeightsFormat] = None

The source weights these weights were converted from. For example, if a model's weights were converted from the pytorch_state_dict format to torchscript, The pytorch_state_dict weights entry has no parent and is the parent of the torchscript weights. All weight entries except one (the initial set of weights resulting from training the model), need to have this field.

pytorch_version pydantic-field ¤

pytorch_version: Optional[Version] = None

Version of the PyTorch library used.

sha256 pydantic-field ¤

sha256: Optional[Sha256] = None

SHA256 hash value of the source file.

source pydantic-field ¤

source: FileSource_

The weights file.

type class-attribute ¤

type: WeightsFormat = 'torchscript'

weights_format_name class-attribute ¤

weights_format_name: str = 'TorchScript'

check_parent_is_not_self pydantic-validator ¤

check_parent_is_not_self() -> Self
Source code in src/bioimageio/spec/model/v0_4.py
288
289
290
291
292
293
@model_validator(mode="after")
def check_parent_is_not_self(self) -> Self:
    if self.type == self.parent:
        raise ValueError("Weights entry can't be it's own parent.")

    return self

download ¤

download(
    *,
    progressbar: Union[
        Progressbar, Callable[[], Progressbar], bool, None
    ] = None,
)

alias for .get_reader

Source code in src/bioimageio/spec/_internal/io.py
306
307
308
309
310
311
312
def download(
    self,
    *,
    progressbar: Union[Progressbar, Callable[[], Progressbar], bool, None] = None,
):
    """alias for `.get_reader`"""
    return get_reader(self.source, progressbar=progressbar, sha256=self.sha256)

get_reader ¤

get_reader(
    *,
    progressbar: Union[
        Progressbar, Callable[[], Progressbar], bool, None
    ] = None,
)

open the file source (download if needed)

Source code in src/bioimageio/spec/_internal/io.py
298
299
300
301
302
303
304
def get_reader(
    self,
    *,
    progressbar: Union[Progressbar, Callable[[], Progressbar], bool, None] = None,
):
    """open the file source (download if needed)"""
    return get_reader(self.source, progressbar=progressbar, sha256=self.sha256)

model_validate classmethod ¤

model_validate(
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[
        ValidationContext, Mapping[str, Any], None
    ] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self

Validate a pydantic model instance.

PARAMETER DESCRIPTION

obj ¤

The object to validate.

TYPE: Union[Any, Mapping[str, Any]]

strict ¤

Whether to raise an exception on invalid fields.

TYPE: Optional[bool] DEFAULT: None

from_attributes ¤

Whether to extract data from object attributes.

TYPE: Optional[bool] DEFAULT: None

context ¤

Additional context to pass to the validator.

TYPE: Union[ValidationContext, Mapping[str, Any], None] DEFAULT: None

RAISES DESCRIPTION
ValidationError

If the object failed validation.

RETURNS DESCRIPTION
Self

The validated description instance.

Source code in src/bioimageio/spec/_internal/node.py
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
@classmethod
def model_validate(
    cls,
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[ValidationContext, Mapping[str, Any], None] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self:
    """Validate a pydantic model instance.

    Args:
        obj: The object to validate.
        strict: Whether to raise an exception on invalid fields.
        from_attributes: Whether to extract data from object attributes.
        context: Additional context to pass to the validator.

    Raises:
        ValidationError: If the object failed validation.

    Returns:
        The validated description instance.
    """
    __tracebackhide__ = True

    if context is None:
        context = get_validation_context()
    elif isinstance(context, collections.abc.Mapping):
        context = ValidationContext(**context)

    assert not isinstance(obj, collections.abc.Mapping) or is_kwargs(obj), obj

    with context:
        # use validation context as context manager for equal behavior of __init__ and model_validate
        return super().model_validate(
            obj, strict=strict, from_attributes=from_attributes
        )

validate_sha256 ¤

validate_sha256(force_recompute: bool = False) -> None

validate the sha256 hash value of the source file

Source code in src/bioimageio/spec/_internal/io.py
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
def validate_sha256(self, force_recompute: bool = False) -> None:
    """validate the sha256 hash value of the **source** file"""
    context = get_validation_context()
    src_str = str(self.source)
    if not force_recompute and src_str in context.known_files:
        actual_sha = context.known_files[src_str]
    else:
        reader = get_reader(self.source, sha256=self.sha256)
        if force_recompute:
            actual_sha = get_sha256(reader)
        else:
            actual_sha = reader.sha256

        context.known_files[src_str] = actual_sha

    if actual_sha is None:
        return
    elif self.sha256 == actual_sha:
        pass
    elif self.sha256 is None or context.update_hashes:
        self.sha256 = actual_sha
    elif self.sha256 != actual_sha:
        raise ValueError(
            f"Sha256 mismatch for {self.source}. Expected {self.sha256}, got "
            + f"{actual_sha}. Update expected `sha256` or point to the matching "
            + "file."
        )

Uploader pydantic-model ¤

Bases: Node

Show JSON schema:
{
  "additionalProperties": false,
  "properties": {
    "email": {
      "description": "Email",
      "format": "email",
      "title": "Email",
      "type": "string"
    },
    "name": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "name",
      "title": "Name"
    }
  },
  "required": [
    "email"
  ],
  "title": "generic.v0_2.Uploader",
  "type": "object"
}

Fields:

email pydantic-field ¤

email: EmailStr

Email

name pydantic-field ¤

name: Optional[str] = None

name

model_validate classmethod ¤

model_validate(
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[
        ValidationContext, Mapping[str, Any], None
    ] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self

Validate a pydantic model instance.

PARAMETER DESCRIPTION

obj ¤

The object to validate.

TYPE: Union[Any, Mapping[str, Any]]

strict ¤

Whether to raise an exception on invalid fields.

TYPE: Optional[bool] DEFAULT: None

from_attributes ¤

Whether to extract data from object attributes.

TYPE: Optional[bool] DEFAULT: None

context ¤

Additional context to pass to the validator.

TYPE: Union[ValidationContext, Mapping[str, Any], None] DEFAULT: None

RAISES DESCRIPTION
ValidationError

If the object failed validation.

RETURNS DESCRIPTION
Self

The validated description instance.

Source code in src/bioimageio/spec/_internal/node.py
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
@classmethod
def model_validate(
    cls,
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[ValidationContext, Mapping[str, Any], None] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self:
    """Validate a pydantic model instance.

    Args:
        obj: The object to validate.
        strict: Whether to raise an exception on invalid fields.
        from_attributes: Whether to extract data from object attributes.
        context: Additional context to pass to the validator.

    Raises:
        ValidationError: If the object failed validation.

    Returns:
        The validated description instance.
    """
    __tracebackhide__ = True

    if context is None:
        context = get_validation_context()
    elif isinstance(context, collections.abc.Mapping):
        context = ValidationContext(**context)

    assert not isinstance(obj, collections.abc.Mapping) or is_kwargs(obj), obj

    with context:
        # use validation context as context manager for equal behavior of __init__ and model_validate
        return super().model_validate(
            obj, strict=strict, from_attributes=from_attributes
        )

ValidatedStringWithInnerNode ¤

Bases: ABC, ValidatedString, Generic[InnerNodeT]


              flowchart TD
              bioimageio.spec.model.v0_4.ValidatedStringWithInnerNode[ValidatedStringWithInnerNode]
              bioimageio.spec._internal.validated_string.ValidatedString[ValidatedString]

                              bioimageio.spec._internal.validated_string.ValidatedString --> bioimageio.spec.model.v0_4.ValidatedStringWithInnerNode
                


              click bioimageio.spec.model.v0_4.ValidatedStringWithInnerNode href "" "bioimageio.spec.model.v0_4.ValidatedStringWithInnerNode"
              click bioimageio.spec._internal.validated_string.ValidatedString href "" "bioimageio.spec._internal.validated_string.ValidatedString"
            

A validated string with further validation and serialization using a Node

METHOD DESCRIPTION
__get_pydantic_core_schema__
__get_pydantic_json_schema__
__new__
ATTRIBUTE DESCRIPTION
root_model

the pydantic root model to validate the string

TYPE: Type[RootModel[Any]]

root_model class-attribute ¤

root_model: Type[RootModel[Any]] = RootModel[str]

the pydantic root model to validate the string

__get_pydantic_core_schema__ classmethod ¤

__get_pydantic_core_schema__(
    source_type: Any, handler: GetCoreSchemaHandler
) -> CoreSchema
Source code in src/bioimageio/spec/_internal/validated_string.py
29
30
31
32
33
@classmethod
def __get_pydantic_core_schema__(
    cls, source_type: Any, handler: GetCoreSchemaHandler
) -> CoreSchema:
    return no_info_after_validator_function(cls, handler(str))

__get_pydantic_json_schema__ classmethod ¤

__get_pydantic_json_schema__(
    core_schema: CoreSchema, handler: GetJsonSchemaHandler
) -> JsonSchemaValue
Source code in src/bioimageio/spec/_internal/validated_string.py
35
36
37
38
39
40
41
42
43
44
@classmethod
def __get_pydantic_json_schema__(
    cls, core_schema: CoreSchema, handler: GetJsonSchemaHandler
) -> JsonSchemaValue:
    json_schema = cls.root_model.model_json_schema(mode=handler.mode)
    json_schema["title"] = cls.__name__.strip("_")
    if cls.__doc__:
        json_schema["description"] = cls.__doc__

    return json_schema

__new__ ¤

__new__(object: object)
Source code in src/bioimageio/spec/_internal/validated_string.py
19
20
21
22
23
def __new__(cls, object: object):
    _validated = cls.root_model.model_validate(object).root
    self = super().__new__(cls, _validated)
    self._validated = _validated
    return self._after_validator()

Version ¤

Bases: RootModel[Union[str, int, float]]


              flowchart TD
              bioimageio.spec.model.v0_4.Version[Version]

              

              click bioimageio.spec.model.v0_4.Version href "" "bioimageio.spec.model.v0_4.Version"
            

wraps a packaging.version.Version instance for validation in pydantic models

METHOD DESCRIPTION
__eq__
__lt__
__str__
model_post_init

set _version attribute @private

ATTRIBUTE DESCRIPTION
base_version

The "base version" of the version.

TYPE: str

dev

The development number of the version.

TYPE: Optional[int]

epoch

The epoch of the version.

TYPE: int

is_devrelease

Whether this version is a development release.

TYPE: bool

is_postrelease

Whether this version is a post-release.

TYPE: bool

is_prerelease

Whether this version is a pre-release.

TYPE: bool

local

The local version segment of the version.

TYPE: Optional[str]

major

The first item of :attr:release or 0 if unavailable.

TYPE: int

micro

The third item of :attr:release or 0 if unavailable.

TYPE: int

minor

The second item of :attr:release or 0 if unavailable.

TYPE: int

post

The post-release number of the version.

TYPE: Optional[int]

pre

The pre-release segment of the version.

TYPE: Optional[Tuple[str, int]]

public

The public portion of the version.

TYPE: str

release

The components of the "release" segment of the version.

TYPE: Tuple[int, ...]

base_version property ¤

base_version: str

The "base version" of the version.

Version("1.2.3").base_version '1.2.3' Version("1.2.3+abc").base_version '1.2.3' Version("1!1.2.3+abc.dev1").base_version '1!1.2.3'

The "base version" is the public version of the project without any pre or post release markers.

dev property ¤

dev: Optional[int]

The development number of the version.

print(Version("1.2.3").dev) None Version("1.2.3.dev1").dev 1

epoch property ¤

epoch: int

The epoch of the version.

Version("2.0.0").epoch 0 Version("1!2.0.0").epoch 1

is_devrelease property ¤

is_devrelease: bool

Whether this version is a development release.

Version("1.2.3").is_devrelease False Version("1.2.3.dev1").is_devrelease True

is_postrelease property ¤

is_postrelease: bool

Whether this version is a post-release.

Version("1.2.3").is_postrelease False Version("1.2.3.post1").is_postrelease True

is_prerelease property ¤

is_prerelease: bool

Whether this version is a pre-release.

Version("1.2.3").is_prerelease False Version("1.2.3a1").is_prerelease True Version("1.2.3b1").is_prerelease True Version("1.2.3rc1").is_prerelease True Version("1.2.3dev1").is_prerelease True

local property ¤

local: Optional[str]

The local version segment of the version.

print(Version("1.2.3").local) None Version("1.2.3+abc").local 'abc'

major property ¤

major: int

The first item of :attr:release or 0 if unavailable.

Version("1.2.3").major 1

micro property ¤

micro: int

The third item of :attr:release or 0 if unavailable.

Version("1.2.3").micro 3 Version("1").micro 0

minor property ¤

minor: int

The second item of :attr:release or 0 if unavailable.

Version("1.2.3").minor 2 Version("1").minor 0

post property ¤

post: Optional[int]

The post-release number of the version.

print(Version("1.2.3").post) None Version("1.2.3.post1").post 1

pre property ¤

pre: Optional[Tuple[str, int]]

The pre-release segment of the version.

print(Version("1.2.3").pre) None Version("1.2.3a1").pre ('a', 1) Version("1.2.3b1").pre ('b', 1) Version("1.2.3rc1").pre ('rc', 1)

public property ¤

public: str

The public portion of the version.

Version("1.2.3").public '1.2.3' Version("1.2.3+abc").public '1.2.3' Version("1.2.3+abc.dev1").public '1.2.3'

release property ¤

release: Tuple[int, ...]

The components of the "release" segment of the version.

Version("1.2.3").release (1, 2, 3) Version("2.0.0").release (2, 0, 0) Version("1!2.0.0.post0").release (2, 0, 0)

Includes trailing zeroes but not the epoch or any pre-release / development / post-release suffixes.

__eq__ ¤

__eq__(other: Version)
Source code in src/bioimageio/spec/_internal/version_type.py
25
26
def __eq__(self, other: Version):
    return self._version == other._version

__lt__ ¤

__lt__(other: Version)
Source code in src/bioimageio/spec/_internal/version_type.py
22
23
def __lt__(self, other: Version):
    return self._version < other._version

__str__ ¤

__str__()
Source code in src/bioimageio/spec/_internal/version_type.py
14
15
def __str__(self):
    return str(self._version)

model_post_init ¤

model_post_init(__context: Any) -> None

set _version attribute @private

Source code in src/bioimageio/spec/_internal/version_type.py
17
18
19
20
def model_post_init(self, __context: Any) -> None:
    """set `_version` attribute @private"""
    self._version = packaging.version.Version(str(self.root))
    return super().model_post_init(__context)

WeightsDescr pydantic-model ¤

Bases: Node

Show JSON schema:
{
  "$defs": {
    "AttachmentsDescr": {
      "additionalProperties": true,
      "properties": {
        "files": {
          "description": "File attachments",
          "items": {
            "anyOf": [
              {
                "description": "A URL with the HTTP or HTTPS scheme.",
                "format": "uri",
                "maxLength": 2083,
                "minLength": 1,
                "title": "HttpUrl",
                "type": "string"
              },
              {
                "$ref": "#/$defs/RelativeFilePath"
              },
              {
                "format": "file-path",
                "title": "FilePath",
                "type": "string"
              }
            ]
          },
          "title": "Files",
          "type": "array"
        }
      },
      "title": "generic.v0_2.AttachmentsDescr",
      "type": "object"
    },
    "Author": {
      "additionalProperties": false,
      "properties": {
        "affiliation": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Affiliation",
          "title": "Affiliation"
        },
        "email": {
          "anyOf": [
            {
              "format": "email",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Email",
          "title": "Email"
        },
        "orcid": {
          "anyOf": [
            {
              "description": "An ORCID identifier, see https://orcid.org/",
              "title": "OrcidId",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "An [ORCID iD](https://support.orcid.org/hc/en-us/sections/360001495313-What-is-ORCID\n) in hyphenated groups of 4 digits, (and [valid](\nhttps://support.orcid.org/hc/en-us/articles/360006897674-Structure-of-the-ORCID-Identifier\n) as per ISO 7064 11,2.)",
          "examples": [
            "0000-0001-2345-6789"
          ],
          "title": "Orcid"
        },
        "name": {
          "title": "Name",
          "type": "string"
        },
        "github_user": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Github User"
        }
      },
      "required": [
        "name"
      ],
      "title": "generic.v0_2.Author",
      "type": "object"
    },
    "KerasHdf5WeightsDescr": {
      "additionalProperties": false,
      "properties": {
        "source": {
          "anyOf": [
            {
              "description": "A URL with the HTTP or HTTPS scheme.",
              "format": "uri",
              "maxLength": 2083,
              "minLength": 1,
              "title": "HttpUrl",
              "type": "string"
            },
            {
              "$ref": "#/$defs/RelativeFilePath"
            },
            {
              "format": "file-path",
              "title": "FilePath",
              "type": "string"
            }
          ],
          "description": "The weights file.",
          "title": "Source"
        },
        "sha256": {
          "anyOf": [
            {
              "description": "A SHA-256 hash value",
              "maxLength": 64,
              "minLength": 64,
              "title": "Sha256",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "SHA256 hash value of the **source** file.",
          "title": "Sha256"
        },
        "attachments": {
          "anyOf": [
            {
              "$ref": "#/$defs/AttachmentsDescr"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Attachments that are specific to this weights entry."
        },
        "authors": {
          "anyOf": [
            {
              "items": {
                "$ref": "#/$defs/Author"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Authors\nEither the person(s) that have trained this model resulting in the original weights file.\n    (If this is the initial weights entry, i.e. it does not have a `parent`)\nOr the person(s) who have converted the weights to this weights format.\n    (If this is a child weight, i.e. it has a `parent` field)",
          "title": "Authors"
        },
        "dependencies": {
          "anyOf": [
            {
              "pattern": "^.+:.+$",
              "title": "Dependencies",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Dependency manager and dependency file, specified as `<dependency manager>:<relative file path>`.",
          "examples": [
            "conda:environment.yaml",
            "maven:./pom.xml",
            "pip:./requirements.txt"
          ],
          "title": "Dependencies"
        },
        "parent": {
          "anyOf": [
            {
              "enum": [
                "keras_hdf5",
                "onnx",
                "pytorch_state_dict",
                "tensorflow_js",
                "tensorflow_saved_model_bundle",
                "torchscript"
              ],
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "The source weights these weights were converted from.\nFor example, if a model's weights were converted from the `pytorch_state_dict` format to `torchscript`,\nThe `pytorch_state_dict` weights entry has no `parent` and is the parent of the `torchscript` weights.\nAll weight entries except one (the initial set of weights resulting from training the model),\nneed to have this field.",
          "examples": [
            "pytorch_state_dict"
          ],
          "title": "Parent"
        },
        "tensorflow_version": {
          "anyOf": [
            {
              "$ref": "#/$defs/Version"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "TensorFlow version used to create these weights"
        }
      },
      "required": [
        "source"
      ],
      "title": "model.v0_4.KerasHdf5WeightsDescr",
      "type": "object"
    },
    "OnnxWeightsDescr": {
      "additionalProperties": false,
      "properties": {
        "source": {
          "anyOf": [
            {
              "description": "A URL with the HTTP or HTTPS scheme.",
              "format": "uri",
              "maxLength": 2083,
              "minLength": 1,
              "title": "HttpUrl",
              "type": "string"
            },
            {
              "$ref": "#/$defs/RelativeFilePath"
            },
            {
              "format": "file-path",
              "title": "FilePath",
              "type": "string"
            }
          ],
          "description": "The weights file.",
          "title": "Source"
        },
        "sha256": {
          "anyOf": [
            {
              "description": "A SHA-256 hash value",
              "maxLength": 64,
              "minLength": 64,
              "title": "Sha256",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "SHA256 hash value of the **source** file.",
          "title": "Sha256"
        },
        "attachments": {
          "anyOf": [
            {
              "$ref": "#/$defs/AttachmentsDescr"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Attachments that are specific to this weights entry."
        },
        "authors": {
          "anyOf": [
            {
              "items": {
                "$ref": "#/$defs/Author"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Authors\nEither the person(s) that have trained this model resulting in the original weights file.\n    (If this is the initial weights entry, i.e. it does not have a `parent`)\nOr the person(s) who have converted the weights to this weights format.\n    (If this is a child weight, i.e. it has a `parent` field)",
          "title": "Authors"
        },
        "dependencies": {
          "anyOf": [
            {
              "pattern": "^.+:.+$",
              "title": "Dependencies",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Dependency manager and dependency file, specified as `<dependency manager>:<relative file path>`.",
          "examples": [
            "conda:environment.yaml",
            "maven:./pom.xml",
            "pip:./requirements.txt"
          ],
          "title": "Dependencies"
        },
        "parent": {
          "anyOf": [
            {
              "enum": [
                "keras_hdf5",
                "onnx",
                "pytorch_state_dict",
                "tensorflow_js",
                "tensorflow_saved_model_bundle",
                "torchscript"
              ],
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "The source weights these weights were converted from.\nFor example, if a model's weights were converted from the `pytorch_state_dict` format to `torchscript`,\nThe `pytorch_state_dict` weights entry has no `parent` and is the parent of the `torchscript` weights.\nAll weight entries except one (the initial set of weights resulting from training the model),\nneed to have this field.",
          "examples": [
            "pytorch_state_dict"
          ],
          "title": "Parent"
        },
        "opset_version": {
          "anyOf": [
            {
              "minimum": 7,
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "ONNX opset version",
          "title": "Opset Version"
        }
      },
      "required": [
        "source"
      ],
      "title": "model.v0_4.OnnxWeightsDescr",
      "type": "object"
    },
    "PytorchStateDictWeightsDescr": {
      "additionalProperties": false,
      "properties": {
        "source": {
          "anyOf": [
            {
              "description": "A URL with the HTTP or HTTPS scheme.",
              "format": "uri",
              "maxLength": 2083,
              "minLength": 1,
              "title": "HttpUrl",
              "type": "string"
            },
            {
              "$ref": "#/$defs/RelativeFilePath"
            },
            {
              "format": "file-path",
              "title": "FilePath",
              "type": "string"
            }
          ],
          "description": "The weights file.",
          "title": "Source"
        },
        "sha256": {
          "anyOf": [
            {
              "description": "A SHA-256 hash value",
              "maxLength": 64,
              "minLength": 64,
              "title": "Sha256",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "SHA256 hash value of the **source** file.",
          "title": "Sha256"
        },
        "attachments": {
          "anyOf": [
            {
              "$ref": "#/$defs/AttachmentsDescr"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Attachments that are specific to this weights entry."
        },
        "authors": {
          "anyOf": [
            {
              "items": {
                "$ref": "#/$defs/Author"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Authors\nEither the person(s) that have trained this model resulting in the original weights file.\n    (If this is the initial weights entry, i.e. it does not have a `parent`)\nOr the person(s) who have converted the weights to this weights format.\n    (If this is a child weight, i.e. it has a `parent` field)",
          "title": "Authors"
        },
        "dependencies": {
          "anyOf": [
            {
              "pattern": "^.+:.+$",
              "title": "Dependencies",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Dependency manager and dependency file, specified as `<dependency manager>:<relative file path>`.",
          "examples": [
            "conda:environment.yaml",
            "maven:./pom.xml",
            "pip:./requirements.txt"
          ],
          "title": "Dependencies"
        },
        "parent": {
          "anyOf": [
            {
              "enum": [
                "keras_hdf5",
                "onnx",
                "pytorch_state_dict",
                "tensorflow_js",
                "tensorflow_saved_model_bundle",
                "torchscript"
              ],
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "The source weights these weights were converted from.\nFor example, if a model's weights were converted from the `pytorch_state_dict` format to `torchscript`,\nThe `pytorch_state_dict` weights entry has no `parent` and is the parent of the `torchscript` weights.\nAll weight entries except one (the initial set of weights resulting from training the model),\nneed to have this field.",
          "examples": [
            "pytorch_state_dict"
          ],
          "title": "Parent"
        },
        "architecture": {
          "anyOf": [
            {
              "pattern": "^.+:.+$",
              "title": "CallableFromFile",
              "type": "string"
            },
            {
              "pattern": "^.+\\..+$",
              "title": "CallableFromDepencency",
              "type": "string"
            }
          ],
          "description": "callable returning a torch.nn.Module instance.\nLocal implementation: `<relative path to file>:<identifier of implementation within the file>`.\nImplementation in a dependency: `<dependency-package>.<[dependency-module]>.<identifier>`.",
          "examples": [
            "my_function.py:MyNetworkClass",
            "my_module.submodule.get_my_model"
          ],
          "title": "Architecture"
        },
        "architecture_sha256": {
          "anyOf": [
            {
              "description": "A SHA-256 hash value",
              "maxLength": 64,
              "minLength": 64,
              "title": "Sha256",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "The SHA256 of the architecture source file, if the architecture is not defined in a module listed in `dependencies`\nYou can drag and drop your file to this\n[online tool](http://emn178.github.io/online-tools/sha256_checksum.html) to generate a SHA256 in your browser.\nOr you can generate a SHA256 checksum with Python's `hashlib`,\n[here is a codesnippet](https://gist.github.com/FynnBe/e64460463df89439cff218bbf59c1100).",
          "title": "Architecture Sha256"
        },
        "kwargs": {
          "additionalProperties": true,
          "description": "key word arguments for the `architecture` callable",
          "title": "Kwargs",
          "type": "object"
        },
        "pytorch_version": {
          "anyOf": [
            {
              "$ref": "#/$defs/Version"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Version of the PyTorch library used.\nIf `depencencies` is specified it should include pytorch and the verison has to match.\n(`dependencies` overrules `pytorch_version`)"
        }
      },
      "required": [
        "source",
        "architecture"
      ],
      "title": "model.v0_4.PytorchStateDictWeightsDescr",
      "type": "object"
    },
    "RelativeFilePath": {
      "description": "A path relative to the `rdf.yaml` file (also if the RDF source is a URL).",
      "format": "path",
      "title": "RelativeFilePath",
      "type": "string"
    },
    "TensorflowJsWeightsDescr": {
      "additionalProperties": false,
      "properties": {
        "source": {
          "anyOf": [
            {
              "description": "A URL with the HTTP or HTTPS scheme.",
              "format": "uri",
              "maxLength": 2083,
              "minLength": 1,
              "title": "HttpUrl",
              "type": "string"
            },
            {
              "$ref": "#/$defs/RelativeFilePath"
            },
            {
              "format": "file-path",
              "title": "FilePath",
              "type": "string"
            }
          ],
          "description": "The multi-file weights.\nAll required files/folders should be a zip archive.",
          "title": "Source"
        },
        "sha256": {
          "anyOf": [
            {
              "description": "A SHA-256 hash value",
              "maxLength": 64,
              "minLength": 64,
              "title": "Sha256",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "SHA256 hash value of the **source** file.",
          "title": "Sha256"
        },
        "attachments": {
          "anyOf": [
            {
              "$ref": "#/$defs/AttachmentsDescr"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Attachments that are specific to this weights entry."
        },
        "authors": {
          "anyOf": [
            {
              "items": {
                "$ref": "#/$defs/Author"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Authors\nEither the person(s) that have trained this model resulting in the original weights file.\n    (If this is the initial weights entry, i.e. it does not have a `parent`)\nOr the person(s) who have converted the weights to this weights format.\n    (If this is a child weight, i.e. it has a `parent` field)",
          "title": "Authors"
        },
        "dependencies": {
          "anyOf": [
            {
              "pattern": "^.+:.+$",
              "title": "Dependencies",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Dependency manager and dependency file, specified as `<dependency manager>:<relative file path>`.",
          "examples": [
            "conda:environment.yaml",
            "maven:./pom.xml",
            "pip:./requirements.txt"
          ],
          "title": "Dependencies"
        },
        "parent": {
          "anyOf": [
            {
              "enum": [
                "keras_hdf5",
                "onnx",
                "pytorch_state_dict",
                "tensorflow_js",
                "tensorflow_saved_model_bundle",
                "torchscript"
              ],
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "The source weights these weights were converted from.\nFor example, if a model's weights were converted from the `pytorch_state_dict` format to `torchscript`,\nThe `pytorch_state_dict` weights entry has no `parent` and is the parent of the `torchscript` weights.\nAll weight entries except one (the initial set of weights resulting from training the model),\nneed to have this field.",
          "examples": [
            "pytorch_state_dict"
          ],
          "title": "Parent"
        },
        "tensorflow_version": {
          "anyOf": [
            {
              "$ref": "#/$defs/Version"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Version of the TensorFlow library used."
        }
      },
      "required": [
        "source"
      ],
      "title": "model.v0_4.TensorflowJsWeightsDescr",
      "type": "object"
    },
    "TensorflowSavedModelBundleWeightsDescr": {
      "additionalProperties": false,
      "properties": {
        "source": {
          "anyOf": [
            {
              "description": "A URL with the HTTP or HTTPS scheme.",
              "format": "uri",
              "maxLength": 2083,
              "minLength": 1,
              "title": "HttpUrl",
              "type": "string"
            },
            {
              "$ref": "#/$defs/RelativeFilePath"
            },
            {
              "format": "file-path",
              "title": "FilePath",
              "type": "string"
            }
          ],
          "description": "The weights file.",
          "title": "Source"
        },
        "sha256": {
          "anyOf": [
            {
              "description": "A SHA-256 hash value",
              "maxLength": 64,
              "minLength": 64,
              "title": "Sha256",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "SHA256 hash value of the **source** file.",
          "title": "Sha256"
        },
        "attachments": {
          "anyOf": [
            {
              "$ref": "#/$defs/AttachmentsDescr"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Attachments that are specific to this weights entry."
        },
        "authors": {
          "anyOf": [
            {
              "items": {
                "$ref": "#/$defs/Author"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Authors\nEither the person(s) that have trained this model resulting in the original weights file.\n    (If this is the initial weights entry, i.e. it does not have a `parent`)\nOr the person(s) who have converted the weights to this weights format.\n    (If this is a child weight, i.e. it has a `parent` field)",
          "title": "Authors"
        },
        "dependencies": {
          "anyOf": [
            {
              "pattern": "^.+:.+$",
              "title": "Dependencies",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Dependency manager and dependency file, specified as `<dependency manager>:<relative file path>`.",
          "examples": [
            "conda:environment.yaml",
            "maven:./pom.xml",
            "pip:./requirements.txt"
          ],
          "title": "Dependencies"
        },
        "parent": {
          "anyOf": [
            {
              "enum": [
                "keras_hdf5",
                "onnx",
                "pytorch_state_dict",
                "tensorflow_js",
                "tensorflow_saved_model_bundle",
                "torchscript"
              ],
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "The source weights these weights were converted from.\nFor example, if a model's weights were converted from the `pytorch_state_dict` format to `torchscript`,\nThe `pytorch_state_dict` weights entry has no `parent` and is the parent of the `torchscript` weights.\nAll weight entries except one (the initial set of weights resulting from training the model),\nneed to have this field.",
          "examples": [
            "pytorch_state_dict"
          ],
          "title": "Parent"
        },
        "tensorflow_version": {
          "anyOf": [
            {
              "$ref": "#/$defs/Version"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Version of the TensorFlow library used."
        }
      },
      "required": [
        "source"
      ],
      "title": "model.v0_4.TensorflowSavedModelBundleWeightsDescr",
      "type": "object"
    },
    "TorchscriptWeightsDescr": {
      "additionalProperties": false,
      "properties": {
        "source": {
          "anyOf": [
            {
              "description": "A URL with the HTTP or HTTPS scheme.",
              "format": "uri",
              "maxLength": 2083,
              "minLength": 1,
              "title": "HttpUrl",
              "type": "string"
            },
            {
              "$ref": "#/$defs/RelativeFilePath"
            },
            {
              "format": "file-path",
              "title": "FilePath",
              "type": "string"
            }
          ],
          "description": "The weights file.",
          "title": "Source"
        },
        "sha256": {
          "anyOf": [
            {
              "description": "A SHA-256 hash value",
              "maxLength": 64,
              "minLength": 64,
              "title": "Sha256",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "SHA256 hash value of the **source** file.",
          "title": "Sha256"
        },
        "attachments": {
          "anyOf": [
            {
              "$ref": "#/$defs/AttachmentsDescr"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Attachments that are specific to this weights entry."
        },
        "authors": {
          "anyOf": [
            {
              "items": {
                "$ref": "#/$defs/Author"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Authors\nEither the person(s) that have trained this model resulting in the original weights file.\n    (If this is the initial weights entry, i.e. it does not have a `parent`)\nOr the person(s) who have converted the weights to this weights format.\n    (If this is a child weight, i.e. it has a `parent` field)",
          "title": "Authors"
        },
        "dependencies": {
          "anyOf": [
            {
              "pattern": "^.+:.+$",
              "title": "Dependencies",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Dependency manager and dependency file, specified as `<dependency manager>:<relative file path>`.",
          "examples": [
            "conda:environment.yaml",
            "maven:./pom.xml",
            "pip:./requirements.txt"
          ],
          "title": "Dependencies"
        },
        "parent": {
          "anyOf": [
            {
              "enum": [
                "keras_hdf5",
                "onnx",
                "pytorch_state_dict",
                "tensorflow_js",
                "tensorflow_saved_model_bundle",
                "torchscript"
              ],
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "The source weights these weights were converted from.\nFor example, if a model's weights were converted from the `pytorch_state_dict` format to `torchscript`,\nThe `pytorch_state_dict` weights entry has no `parent` and is the parent of the `torchscript` weights.\nAll weight entries except one (the initial set of weights resulting from training the model),\nneed to have this field.",
          "examples": [
            "pytorch_state_dict"
          ],
          "title": "Parent"
        },
        "pytorch_version": {
          "anyOf": [
            {
              "$ref": "#/$defs/Version"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Version of the PyTorch library used."
        }
      },
      "required": [
        "source"
      ],
      "title": "model.v0_4.TorchscriptWeightsDescr",
      "type": "object"
    },
    "Version": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "integer"
        },
        {
          "type": "number"
        }
      ],
      "description": "wraps a packaging.version.Version instance for validation in pydantic models",
      "title": "Version"
    }
  },
  "additionalProperties": false,
  "properties": {
    "keras_hdf5": {
      "anyOf": [
        {
          "$ref": "#/$defs/KerasHdf5WeightsDescr"
        },
        {
          "type": "null"
        }
      ],
      "default": null
    },
    "onnx": {
      "anyOf": [
        {
          "$ref": "#/$defs/OnnxWeightsDescr"
        },
        {
          "type": "null"
        }
      ],
      "default": null
    },
    "pytorch_state_dict": {
      "anyOf": [
        {
          "$ref": "#/$defs/PytorchStateDictWeightsDescr"
        },
        {
          "type": "null"
        }
      ],
      "default": null
    },
    "tensorflow_js": {
      "anyOf": [
        {
          "$ref": "#/$defs/TensorflowJsWeightsDescr"
        },
        {
          "type": "null"
        }
      ],
      "default": null
    },
    "tensorflow_saved_model_bundle": {
      "anyOf": [
        {
          "$ref": "#/$defs/TensorflowSavedModelBundleWeightsDescr"
        },
        {
          "type": "null"
        }
      ],
      "default": null
    },
    "torchscript": {
      "anyOf": [
        {
          "$ref": "#/$defs/TorchscriptWeightsDescr"
        },
        {
          "type": "null"
        }
      ],
      "default": null
    }
  },
  "title": "model.v0_4.WeightsDescr",
  "type": "object"
}

Fields:

Validators:

available_formats property ¤

available_formats

keras_hdf5 pydantic-field ¤

keras_hdf5: Optional[KerasHdf5WeightsDescr] = None

missing_formats property ¤

missing_formats

onnx pydantic-field ¤

onnx: Optional[OnnxWeightsDescr] = None

pytorch_state_dict pydantic-field ¤

pytorch_state_dict: Optional[
    PytorchStateDictWeightsDescr
] = None

tensorflow_js pydantic-field ¤

tensorflow_js: Optional[TensorflowJsWeightsDescr] = None

tensorflow_saved_model_bundle pydantic-field ¤

tensorflow_saved_model_bundle: Optional[
    TensorflowSavedModelBundleWeightsDescr
] = None

torchscript pydantic-field ¤

torchscript: Optional[TorchscriptWeightsDescr] = None

__getitem__ ¤

__getitem__(key: WeightsFormat)
Source code in src/bioimageio/spec/model/v0_4.py
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
def __getitem__(
    self,
    key: WeightsFormat,
):
    if key == "keras_hdf5":
        ret = self.keras_hdf5
    elif key == "onnx":
        ret = self.onnx
    elif key == "pytorch_state_dict":
        ret = self.pytorch_state_dict
    elif key == "tensorflow_js":
        ret = self.tensorflow_js
    elif key == "tensorflow_saved_model_bundle":
        ret = self.tensorflow_saved_model_bundle
    elif key == "torchscript":
        ret = self.torchscript
    else:
        raise KeyError(key)

    if ret is None:
        raise KeyError(key)

    return ret

check_one_entry pydantic-validator ¤

check_one_entry() -> Self
Source code in src/bioimageio/spec/model/v0_4.py
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
@model_validator(mode="after")
def check_one_entry(self) -> Self:
    if all(
        entry is None
        for entry in [
            self.keras_hdf5,
            self.onnx,
            self.pytorch_state_dict,
            self.tensorflow_js,
            self.tensorflow_saved_model_bundle,
            self.torchscript,
        ]
    ):
        raise ValueError("Missing weights entry")

    return self

model_validate classmethod ¤

model_validate(
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[
        ValidationContext, Mapping[str, Any], None
    ] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self

Validate a pydantic model instance.

PARAMETER DESCRIPTION

obj ¤

The object to validate.

TYPE: Union[Any, Mapping[str, Any]]

strict ¤

Whether to raise an exception on invalid fields.

TYPE: Optional[bool] DEFAULT: None

from_attributes ¤

Whether to extract data from object attributes.

TYPE: Optional[bool] DEFAULT: None

context ¤

Additional context to pass to the validator.

TYPE: Union[ValidationContext, Mapping[str, Any], None] DEFAULT: None

RAISES DESCRIPTION
ValidationError

If the object failed validation.

RETURNS DESCRIPTION
Self

The validated description instance.

Source code in src/bioimageio/spec/_internal/node.py
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
@classmethod
def model_validate(
    cls,
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[ValidationContext, Mapping[str, Any], None] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self:
    """Validate a pydantic model instance.

    Args:
        obj: The object to validate.
        strict: Whether to raise an exception on invalid fields.
        from_attributes: Whether to extract data from object attributes.
        context: Additional context to pass to the validator.

    Raises:
        ValidationError: If the object failed validation.

    Returns:
        The validated description instance.
    """
    __tracebackhide__ = True

    if context is None:
        context = get_validation_context()
    elif isinstance(context, collections.abc.Mapping):
        context = ValidationContext(**context)

    assert not isinstance(obj, collections.abc.Mapping) or is_kwargs(obj), obj

    with context:
        # use validation context as context manager for equal behavior of __init__ and model_validate
        return super().model_validate(
            obj, strict=strict, from_attributes=from_attributes
        )

WeightsEntryDescrBase pydantic-model ¤

Bases: FileDescr

Show JSON schema:
{
  "$defs": {
    "AttachmentsDescr": {
      "additionalProperties": true,
      "properties": {
        "files": {
          "description": "File attachments",
          "items": {
            "anyOf": [
              {
                "description": "A URL with the HTTP or HTTPS scheme.",
                "format": "uri",
                "maxLength": 2083,
                "minLength": 1,
                "title": "HttpUrl",
                "type": "string"
              },
              {
                "$ref": "#/$defs/RelativeFilePath"
              },
              {
                "format": "file-path",
                "title": "FilePath",
                "type": "string"
              }
            ]
          },
          "title": "Files",
          "type": "array"
        }
      },
      "title": "generic.v0_2.AttachmentsDescr",
      "type": "object"
    },
    "Author": {
      "additionalProperties": false,
      "properties": {
        "affiliation": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Affiliation",
          "title": "Affiliation"
        },
        "email": {
          "anyOf": [
            {
              "format": "email",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Email",
          "title": "Email"
        },
        "orcid": {
          "anyOf": [
            {
              "description": "An ORCID identifier, see https://orcid.org/",
              "title": "OrcidId",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "An [ORCID iD](https://support.orcid.org/hc/en-us/sections/360001495313-What-is-ORCID\n) in hyphenated groups of 4 digits, (and [valid](\nhttps://support.orcid.org/hc/en-us/articles/360006897674-Structure-of-the-ORCID-Identifier\n) as per ISO 7064 11,2.)",
          "examples": [
            "0000-0001-2345-6789"
          ],
          "title": "Orcid"
        },
        "name": {
          "title": "Name",
          "type": "string"
        },
        "github_user": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Github User"
        }
      },
      "required": [
        "name"
      ],
      "title": "generic.v0_2.Author",
      "type": "object"
    },
    "RelativeFilePath": {
      "description": "A path relative to the `rdf.yaml` file (also if the RDF source is a URL).",
      "format": "path",
      "title": "RelativeFilePath",
      "type": "string"
    }
  },
  "additionalProperties": false,
  "properties": {
    "source": {
      "anyOf": [
        {
          "description": "A URL with the HTTP or HTTPS scheme.",
          "format": "uri",
          "maxLength": 2083,
          "minLength": 1,
          "title": "HttpUrl",
          "type": "string"
        },
        {
          "$ref": "#/$defs/RelativeFilePath"
        },
        {
          "format": "file-path",
          "title": "FilePath",
          "type": "string"
        }
      ],
      "description": "The weights file.",
      "title": "Source"
    },
    "sha256": {
      "anyOf": [
        {
          "description": "A SHA-256 hash value",
          "maxLength": 64,
          "minLength": 64,
          "title": "Sha256",
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "SHA256 hash value of the **source** file.",
      "title": "Sha256"
    },
    "attachments": {
      "anyOf": [
        {
          "$ref": "#/$defs/AttachmentsDescr"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Attachments that are specific to this weights entry."
    },
    "authors": {
      "anyOf": [
        {
          "items": {
            "$ref": "#/$defs/Author"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Authors\nEither the person(s) that have trained this model resulting in the original weights file.\n    (If this is the initial weights entry, i.e. it does not have a `parent`)\nOr the person(s) who have converted the weights to this weights format.\n    (If this is a child weight, i.e. it has a `parent` field)",
      "title": "Authors"
    },
    "dependencies": {
      "anyOf": [
        {
          "pattern": "^.+:.+$",
          "title": "Dependencies",
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Dependency manager and dependency file, specified as `<dependency manager>:<relative file path>`.",
      "examples": [
        "conda:environment.yaml",
        "maven:./pom.xml",
        "pip:./requirements.txt"
      ],
      "title": "Dependencies"
    },
    "parent": {
      "anyOf": [
        {
          "enum": [
            "keras_hdf5",
            "onnx",
            "pytorch_state_dict",
            "tensorflow_js",
            "tensorflow_saved_model_bundle",
            "torchscript"
          ],
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "The source weights these weights were converted from.\nFor example, if a model's weights were converted from the `pytorch_state_dict` format to `torchscript`,\nThe `pytorch_state_dict` weights entry has no `parent` and is the parent of the `torchscript` weights.\nAll weight entries except one (the initial set of weights resulting from training the model),\nneed to have this field.",
      "examples": [
        "pytorch_state_dict"
      ],
      "title": "Parent"
    }
  },
  "required": [
    "source"
  ],
  "title": "model.v0_4.WeightsEntryDescrBase",
  "type": "object"
}

Fields:

Validators:

attachments pydantic-field ¤

attachments: Union[AttachmentsDescr, None] = None

Attachments that are specific to this weights entry.

authors pydantic-field ¤

authors: Union[List[Author], None] = None

Authors Either the person(s) that have trained this model resulting in the original weights file. (If this is the initial weights entry, i.e. it does not have a parent) Or the person(s) who have converted the weights to this weights format. (If this is a child weight, i.e. it has a parent field)

dependencies pydantic-field ¤

dependencies: Optional[Dependencies] = None

Dependency manager and dependency file, specified as <dependency manager>:<relative file path>.

parent pydantic-field ¤

parent: Optional[WeightsFormat] = None

The source weights these weights were converted from. For example, if a model's weights were converted from the pytorch_state_dict format to torchscript, The pytorch_state_dict weights entry has no parent and is the parent of the torchscript weights. All weight entries except one (the initial set of weights resulting from training the model), need to have this field.

sha256 pydantic-field ¤

sha256: Optional[Sha256] = None

SHA256 hash value of the source file.

source pydantic-field ¤

source: FileSource_

The weights file.

type class-attribute ¤

weights_format_name class-attribute ¤

weights_format_name: str

check_parent_is_not_self pydantic-validator ¤

check_parent_is_not_self() -> Self
Source code in src/bioimageio/spec/model/v0_4.py
288
289
290
291
292
293
@model_validator(mode="after")
def check_parent_is_not_self(self) -> Self:
    if self.type == self.parent:
        raise ValueError("Weights entry can't be it's own parent.")

    return self

download ¤

download(
    *,
    progressbar: Union[
        Progressbar, Callable[[], Progressbar], bool, None
    ] = None,
)

alias for .get_reader

Source code in src/bioimageio/spec/_internal/io.py
306
307
308
309
310
311
312
def download(
    self,
    *,
    progressbar: Union[Progressbar, Callable[[], Progressbar], bool, None] = None,
):
    """alias for `.get_reader`"""
    return get_reader(self.source, progressbar=progressbar, sha256=self.sha256)

get_reader ¤

get_reader(
    *,
    progressbar: Union[
        Progressbar, Callable[[], Progressbar], bool, None
    ] = None,
)

open the file source (download if needed)

Source code in src/bioimageio/spec/_internal/io.py
298
299
300
301
302
303
304
def get_reader(
    self,
    *,
    progressbar: Union[Progressbar, Callable[[], Progressbar], bool, None] = None,
):
    """open the file source (download if needed)"""
    return get_reader(self.source, progressbar=progressbar, sha256=self.sha256)

model_validate classmethod ¤

model_validate(
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[
        ValidationContext, Mapping[str, Any], None
    ] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self

Validate a pydantic model instance.

PARAMETER DESCRIPTION

obj ¤

The object to validate.

TYPE: Union[Any, Mapping[str, Any]]

strict ¤

Whether to raise an exception on invalid fields.

TYPE: Optional[bool] DEFAULT: None

from_attributes ¤

Whether to extract data from object attributes.

TYPE: Optional[bool] DEFAULT: None

context ¤

Additional context to pass to the validator.

TYPE: Union[ValidationContext, Mapping[str, Any], None] DEFAULT: None

RAISES DESCRIPTION
ValidationError

If the object failed validation.

RETURNS DESCRIPTION
Self

The validated description instance.

Source code in src/bioimageio/spec/_internal/node.py
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
@classmethod
def model_validate(
    cls,
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[ValidationContext, Mapping[str, Any], None] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self:
    """Validate a pydantic model instance.

    Args:
        obj: The object to validate.
        strict: Whether to raise an exception on invalid fields.
        from_attributes: Whether to extract data from object attributes.
        context: Additional context to pass to the validator.

    Raises:
        ValidationError: If the object failed validation.

    Returns:
        The validated description instance.
    """
    __tracebackhide__ = True

    if context is None:
        context = get_validation_context()
    elif isinstance(context, collections.abc.Mapping):
        context = ValidationContext(**context)

    assert not isinstance(obj, collections.abc.Mapping) or is_kwargs(obj), obj

    with context:
        # use validation context as context manager for equal behavior of __init__ and model_validate
        return super().model_validate(
            obj, strict=strict, from_attributes=from_attributes
        )

validate_sha256 ¤

validate_sha256(force_recompute: bool = False) -> None

validate the sha256 hash value of the source file

Source code in src/bioimageio/spec/_internal/io.py
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
def validate_sha256(self, force_recompute: bool = False) -> None:
    """validate the sha256 hash value of the **source** file"""
    context = get_validation_context()
    src_str = str(self.source)
    if not force_recompute and src_str in context.known_files:
        actual_sha = context.known_files[src_str]
    else:
        reader = get_reader(self.source, sha256=self.sha256)
        if force_recompute:
            actual_sha = get_sha256(reader)
        else:
            actual_sha = reader.sha256

        context.known_files[src_str] = actual_sha

    if actual_sha is None:
        return
    elif self.sha256 == actual_sha:
        pass
    elif self.sha256 is None or context.update_hashes:
        self.sha256 = actual_sha
    elif self.sha256 != actual_sha:
        raise ValueError(
            f"Sha256 mismatch for {self.source}. Expected {self.sha256}, got "
            + f"{actual_sha}. Update expected `sha256` or point to the matching "
            + "file."
        )

WithSuffix dataclass ¤

WithSuffix(
    suffix: Union[LiteralString, Tuple[LiteralString, ...]],
    case_sensitive: bool,
)
METHOD DESCRIPTION
__get_pydantic_core_schema__
validate
ATTRIBUTE DESCRIPTION
case_sensitive

TYPE: bool

suffix

TYPE: Union[LiteralString, Tuple[LiteralString, ...]]

case_sensitive instance-attribute ¤

case_sensitive: bool

suffix instance-attribute ¤

suffix: Union[LiteralString, Tuple[LiteralString, ...]]

__get_pydantic_core_schema__ ¤

__get_pydantic_core_schema__(
    source: Type[Any], handler: GetCoreSchemaHandler
)
Source code in src/bioimageio/spec/_internal/io.py
325
326
327
328
329
330
331
332
333
334
335
def __get_pydantic_core_schema__(
    self, source: Type[Any], handler: GetCoreSchemaHandler
):
    if not self.suffix:
        raise ValueError("suffix may not be empty")

    schema = handler(source)
    return core_schema.no_info_after_validator_function(
        self.validate,
        schema,
    )

validate ¤

validate(
    value: Union[FileSource, FileDescr],
) -> Union[FileSource, FileDescr]
Source code in src/bioimageio/spec/_internal/io.py
337
338
339
340
def validate(
    self, value: Union[FileSource, FileDescr]
) -> Union[FileSource, FileDescr]:
    return validate_suffix(value, self.suffix, case_sensitive=self.case_sensitive)

ZeroMeanUnitVarianceDescr pydantic-model ¤

Bases: ProcessingDescrBase

Subtract mean and divide by variance.

Show JSON schema:
{
  "$defs": {
    "ZeroMeanUnitVarianceKwargs": {
      "additionalProperties": false,
      "description": "key word arguments for `ZeroMeanUnitVarianceDescr`",
      "properties": {
        "mode": {
          "default": "fixed",
          "description": "Mode for computing mean and variance.\n|     mode    |             description              |\n| ----------- | ------------------------------------ |\n|   fixed     | Fixed values for mean and variance   |\n| per_dataset | Compute for the entire dataset       |\n| per_sample  | Compute for each sample individually |",
          "enum": [
            "fixed",
            "per_dataset",
            "per_sample"
          ],
          "title": "Mode",
          "type": "string"
        },
        "axes": {
          "description": "The subset of axes to normalize jointly.\nFor example `xy` to normalize the two image axes for 2d data jointly.",
          "examples": [
            "xy"
          ],
          "title": "Axes",
          "type": "string"
        },
        "mean": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "items": {
                "type": "number"
              },
              "minItems": 1,
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "The mean value(s) to use for `mode: fixed`.\nFor example `[1.1, 2.2, 3.3]` in the case of a 3 channel image with `axes: xy`.",
          "examples": [
            [
              1.1,
              2.2,
              3.3
            ]
          ],
          "title": "Mean"
        },
        "std": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "items": {
                "type": "number"
              },
              "minItems": 1,
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "The standard deviation values to use for `mode: fixed`. Analogous to mean.",
          "examples": [
            [
              0.1,
              0.2,
              0.3
            ]
          ],
          "title": "Std"
        },
        "eps": {
          "default": 1e-06,
          "description": "epsilon for numeric stability: `out = (tensor - mean) / (std + eps)`.",
          "exclusiveMinimum": 0,
          "maximum": 0.1,
          "title": "Eps",
          "type": "number"
        }
      },
      "required": [
        "axes"
      ],
      "title": "model.v0_4.ZeroMeanUnitVarianceKwargs",
      "type": "object"
    }
  },
  "additionalProperties": false,
  "description": "Subtract mean and divide by variance.",
  "properties": {
    "name": {
      "const": "zero_mean_unit_variance",
      "title": "Name",
      "type": "string"
    },
    "kwargs": {
      "$ref": "#/$defs/ZeroMeanUnitVarianceKwargs"
    }
  },
  "required": [
    "name",
    "kwargs"
  ],
  "title": "model.v0_4.ZeroMeanUnitVarianceDescr",
  "type": "object"
}

Fields:

implemented_name class-attribute ¤

implemented_name: Literal["zero_mean_unit_variance"] = (
    "zero_mean_unit_variance"
)

kwargs pydantic-field ¤

name pydantic-field ¤

name: Literal["zero_mean_unit_variance"] = (
    "zero_mean_unit_variance"
)

__pydantic_init_subclass__ classmethod ¤

__pydantic_init_subclass__(**kwargs: Any) -> None
Source code in src/bioimageio/spec/_internal/common_nodes.py
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
@classmethod
def __pydantic_init_subclass__(cls, **kwargs: Any) -> None:
    explict_fields: Dict[str, Any] = {}
    for attr in dir(cls):
        if attr.startswith("implemented_"):
            field_name = attr.replace("implemented_", "")
            if field_name not in cls.model_fields:
                continue

            assert (
                cls.model_fields[field_name].get_default() is PydanticUndefined
            ), field_name
            default = getattr(cls, attr)
            explict_fields[field_name] = default

    cls._fields_to_set_explicitly = MappingProxyType(explict_fields)
    return super().__pydantic_init_subclass__(**kwargs)

model_validate classmethod ¤

model_validate(
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[
        ValidationContext, Mapping[str, Any], None
    ] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self

Validate a pydantic model instance.

PARAMETER DESCRIPTION

obj ¤

The object to validate.

TYPE: Union[Any, Mapping[str, Any]]

strict ¤

Whether to raise an exception on invalid fields.

TYPE: Optional[bool] DEFAULT: None

from_attributes ¤

Whether to extract data from object attributes.

TYPE: Optional[bool] DEFAULT: None

context ¤

Additional context to pass to the validator.

TYPE: Union[ValidationContext, Mapping[str, Any], None] DEFAULT: None

RAISES DESCRIPTION
ValidationError

If the object failed validation.

RETURNS DESCRIPTION
Self

The validated description instance.

Source code in src/bioimageio/spec/_internal/node.py
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
@classmethod
def model_validate(
    cls,
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[ValidationContext, Mapping[str, Any], None] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self:
    """Validate a pydantic model instance.

    Args:
        obj: The object to validate.
        strict: Whether to raise an exception on invalid fields.
        from_attributes: Whether to extract data from object attributes.
        context: Additional context to pass to the validator.

    Raises:
        ValidationError: If the object failed validation.

    Returns:
        The validated description instance.
    """
    __tracebackhide__ = True

    if context is None:
        context = get_validation_context()
    elif isinstance(context, collections.abc.Mapping):
        context = ValidationContext(**context)

    assert not isinstance(obj, collections.abc.Mapping) or is_kwargs(obj), obj

    with context:
        # use validation context as context manager for equal behavior of __init__ and model_validate
        return super().model_validate(
            obj, strict=strict, from_attributes=from_attributes
        )

ZeroMeanUnitVarianceKwargs pydantic-model ¤

Bases: ProcessingKwargs

key word arguments for ZeroMeanUnitVarianceDescr

Show JSON schema:
{
  "additionalProperties": false,
  "description": "key word arguments for `ZeroMeanUnitVarianceDescr`",
  "properties": {
    "mode": {
      "default": "fixed",
      "description": "Mode for computing mean and variance.\n|     mode    |             description              |\n| ----------- | ------------------------------------ |\n|   fixed     | Fixed values for mean and variance   |\n| per_dataset | Compute for the entire dataset       |\n| per_sample  | Compute for each sample individually |",
      "enum": [
        "fixed",
        "per_dataset",
        "per_sample"
      ],
      "title": "Mode",
      "type": "string"
    },
    "axes": {
      "description": "The subset of axes to normalize jointly.\nFor example `xy` to normalize the two image axes for 2d data jointly.",
      "examples": [
        "xy"
      ],
      "title": "Axes",
      "type": "string"
    },
    "mean": {
      "anyOf": [
        {
          "type": "number"
        },
        {
          "items": {
            "type": "number"
          },
          "minItems": 1,
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "The mean value(s) to use for `mode: fixed`.\nFor example `[1.1, 2.2, 3.3]` in the case of a 3 channel image with `axes: xy`.",
      "examples": [
        [
          1.1,
          2.2,
          3.3
        ]
      ],
      "title": "Mean"
    },
    "std": {
      "anyOf": [
        {
          "type": "number"
        },
        {
          "items": {
            "type": "number"
          },
          "minItems": 1,
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "The standard deviation values to use for `mode: fixed`. Analogous to mean.",
      "examples": [
        [
          0.1,
          0.2,
          0.3
        ]
      ],
      "title": "Std"
    },
    "eps": {
      "default": 1e-06,
      "description": "epsilon for numeric stability: `out = (tensor - mean) / (std + eps)`.",
      "exclusiveMinimum": 0,
      "maximum": 0.1,
      "title": "Eps",
      "type": "number"
    }
  },
  "required": [
    "axes"
  ],
  "title": "model.v0_4.ZeroMeanUnitVarianceKwargs",
  "type": "object"
}

Fields:

Validators:

axes pydantic-field ¤

axes: AxesInCZYX

The subset of axes to normalize jointly. For example xy to normalize the two image axes for 2d data jointly.

eps pydantic-field ¤

eps: float = 1e-06

epsilon for numeric stability: out = (tensor - mean) / (std + eps).

mean pydantic-field ¤

mean: Union[float, NotEmpty[List[float]], None] = None

The mean value(s) to use for mode: fixed. For example [1.1, 2.2, 3.3] in the case of a 3 channel image with axes: xy.

mode pydantic-field ¤

mode: Literal["fixed", "per_dataset", "per_sample"] = (
    "fixed"
)

Mode for computing mean and variance. | mode | description | | ----------- | ------------------------------------ | | fixed | Fixed values for mean and variance | | per_dataset | Compute for the entire dataset | | per_sample | Compute for each sample individually |

std pydantic-field ¤

std: Union[float, NotEmpty[List[float]], None] = None

The standard deviation values to use for mode: fixed. Analogous to mean.

__contains__ ¤

__contains__(item: str) -> bool
Source code in src/bioimageio/spec/_internal/common_nodes.py
425
426
def __contains__(self, item: str) -> bool:
    return item in self.__class__.model_fields

__getitem__ ¤

__getitem__(item: str) -> Any
Source code in src/bioimageio/spec/_internal/common_nodes.py
419
420
421
422
423
def __getitem__(self, item: str) -> Any:
    if item in self.__class__.model_fields:
        return getattr(self, item)
    else:
        raise KeyError(item)

get ¤

get(item: str, default: Any = None) -> Any
Source code in src/bioimageio/spec/_internal/common_nodes.py
416
417
def get(self, item: str, default: Any = None) -> Any:
    return self[item] if item in self else default

mean_and_std_match_mode pydantic-validator ¤

mean_and_std_match_mode() -> Self
Source code in src/bioimageio/spec/model/v0_4.py
767
768
769
770
771
772
773
774
@model_validator(mode="after")
def mean_and_std_match_mode(self) -> Self:
    if self.mode == "fixed" and (self.mean is None or self.std is None):
        raise ValueError("`mean` and `std` are required for `mode: fixed`.")
    elif self.mode != "fixed" and (self.mean is not None or self.std is not None):
        raise ValueError(f"`mean` and `std` not allowed for `mode: {self.mode}`")

    return self

model_validate classmethod ¤

model_validate(
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[
        ValidationContext, Mapping[str, Any], None
    ] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self

Validate a pydantic model instance.

PARAMETER DESCRIPTION

obj ¤

The object to validate.

TYPE: Union[Any, Mapping[str, Any]]

strict ¤

Whether to raise an exception on invalid fields.

TYPE: Optional[bool] DEFAULT: None

from_attributes ¤

Whether to extract data from object attributes.

TYPE: Optional[bool] DEFAULT: None

context ¤

Additional context to pass to the validator.

TYPE: Union[ValidationContext, Mapping[str, Any], None] DEFAULT: None

RAISES DESCRIPTION
ValidationError

If the object failed validation.

RETURNS DESCRIPTION
Self

The validated description instance.

Source code in src/bioimageio/spec/_internal/node.py
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
@classmethod
def model_validate(
    cls,
    obj: Union[Any, Mapping[str, Any]],
    *,
    strict: Optional[bool] = None,
    from_attributes: Optional[bool] = None,
    context: Union[ValidationContext, Mapping[str, Any], None] = None,
    by_alias: bool | None = None,
    by_name: bool | None = None,
) -> Self:
    """Validate a pydantic model instance.

    Args:
        obj: The object to validate.
        strict: Whether to raise an exception on invalid fields.
        from_attributes: Whether to extract data from object attributes.
        context: Additional context to pass to the validator.

    Raises:
        ValidationError: If the object failed validation.

    Returns:
        The validated description instance.
    """
    __tracebackhide__ = True

    if context is None:
        context = get_validation_context()
    elif isinstance(context, collections.abc.Mapping):
        context = ValidationContext(**context)

    assert not isinstance(obj, collections.abc.Mapping) or is_kwargs(obj), obj

    with context:
        # use validation context as context manager for equal behavior of __init__ and model_validate
        return super().model_validate(
            obj, strict=strict, from_attributes=from_attributes
        )

convert_from_older_format ¤

convert_from_older_format(
    data: BioimageioYamlContent,
) -> None
Source code in src/bioimageio/spec/model/_v0_4_converter.py
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
def convert_from_older_format(data: BioimageioYamlContent) -> None:
    fv = data.get("format_version")
    if not isinstance(fv, str):
        return

    major_minor = tuple(map(int, fv.split(".")[:2]))
    if major_minor < (0, 4):
        convert_model_from_v0_3_to_0_4_0(data)
    elif major_minor > (0, 4):
        return

    if data["format_version"] == "0.4.0":
        _convert_model_from_v0_4_0_to_0_4_1(data)

    if data["format_version"] in ("0.4.1", "0.4.2", "0.4.3", "0.4.4"):
        _convert_model_from_v0_4_4_to_0_4_5(data)

    if data["format_version"] in ("0.4.5", "0.4.6"):
        remove_slashes_from_names(data)
        data["format_version"] = "0.4.7"

    if data["format_version"] in ("0.4.7", "0.4.8"):
        data["format_version"] = "0.4.9"

    if data["format_version"] == "0.4.9":
        if isinstance(config := data.get("config"), dict) and isinstance(
            bconfig := config.get("bioimageio"), dict
        ):
            if (nickname := bconfig.get("nickname")) is not None:
                data["id"] = nickname

            if (nickname_icon := bconfig.get("nickname_icon")) is not None:
                data["id_emoji"] = nickname_icon

        data["format_version"] = "0.4.10"

    remove_doi_prefix(data)
    remove_gh_prefix(data)
    # remove 'future' from config if no other than the used future entries exist
    config = data.get("config", {})
    if isinstance(config, dict) and config.get("future") == {}:
        del config["future"]

    # remove 'config' if now empty
    if data.get("config") == {}:
        del data["config"]

issue_warning ¤

issue_warning(
    msg: LiteralString,
    *,
    value: Any,
    severity: WarningSeverity = WARNING,
    msg_context: Optional[Dict[str, Any]] = None,
    field: Optional[str] = None,
    log_depth: int = 1,
)
Source code in src/bioimageio/spec/_internal/field_warning.py
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
def issue_warning(
    msg: LiteralString,
    *,
    value: Any,
    severity: WarningSeverity = WARNING,
    msg_context: Optional[Dict[str, Any]] = None,
    field: Optional[str] = None,
    log_depth: int = 1,
):
    msg_context = {"value": value, "severity": severity, **(msg_context or {})}

    if severity >= (ctxt := get_validation_context()).warning_level:
        raise PydanticCustomError("warning", msg, msg_context)
    elif ctxt.log_warnings:
        log_msg = (field + ": " if field else "") + (msg.format(**msg_context))
        logger.opt(depth=log_depth).log(severity, log_msg)

load_array ¤

load_array(
    source: Union[FileSource, FileDescr, ZipPath],
) -> NDArray[Any]
Source code in src/bioimageio/spec/_internal/io_utils.py
344
345
346
347
348
349
def load_array(source: Union[FileSource, FileDescr, ZipPath]) -> NDArray[Any]:
    reader = get_reader(source)
    if settings.allow_pickle:
        logger.warning("Loading numpy array with `allow_pickle=True`.")

    return numpy.load(reader, allow_pickle=settings.allow_pickle)

package_weights ¤

package_weights(
    value: Node,
    handler: SerializerFunctionWrapHandler,
    info: SerializationInfo,
)
Source code in src/bioimageio/spec/model/v0_4.py
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
def package_weights(
    value: Node,  # Union[v0_4.WeightsDescr, v0_5.WeightsDescr]
    handler: SerializerFunctionWrapHandler,
    info: SerializationInfo,
):
    ctxt = packaging_context_var.get()
    if ctxt is not None and ctxt.weights_priority_order is not None:
        for wf in ctxt.weights_priority_order:
            w = getattr(value, wf, None)
            if w is not None:
                break
        else:
            raise ValueError(
                "None of the weight formats in `weights_priority_order`"
                + f" ({ctxt.weights_priority_order}) is present in the given model."
            )

        assert isinstance(w, Node), type(w)
        # construct WeightsDescr with new single weight format entry
        new_w = w.model_construct(**{k: v for k, v in w if k != "parent"})
        value = value.model_construct(None, **{wf: new_w})

    return handler(
        value,
        info,  # pyright: ignore[reportArgumentType]  # taken from pydantic docs
    )

validate_unique_entries ¤

validate_unique_entries(seq: Sequence[Hashable])
Source code in src/bioimageio/spec/_internal/field_validation.py
54
55
56
57
def validate_unique_entries(seq: Sequence[Hashable]):
    if len(seq) != len(set(seq)):
        raise ValueError("Entries are not unique.")
    return seq

warn ¤

warn(
    typ: Union[AnnotationMetaData, Any],
    msg: LiteralString,
    severity: WarningSeverity = WARNING,
)

treat a type or its annotation metadata as a warning condition

Source code in src/bioimageio/spec/_internal/field_warning.py
30
31
32
33
34
35
36
37
38
39
40
41
42
43
def warn(
    typ: Union[AnnotationMetaData, Any],
    msg: LiteralString,  # warning message, e.g. "'{value}' incompatible with {typ}
    severity: WarningSeverity = WARNING,
):
    """treat a type or its annotation metadata as a warning condition"""
    if isinstance(typ, get_args(AnnotationMetaData)):
        typ = Annotated[Any, typ]

    validator: TypeAdapter[Any] = TypeAdapter(typ)

    return AfterWarner(
        validator.validate_python, severity=severity, msg=msg, context={"typ": typ}
    )