dataeval.models.ModelIOSpec

class dataeval.models.ModelIOSpec

Typed, immutable view of a model-metadata.json input/output contract.

Produced by read_model_metadata() and consumed by build_model_input() and the opinionated predictors to shape and normalize images to the contract a model expects. Instances are frozen (hashable, read-only).

task

Declared model interface (io.interface in the metadata file).

Type:

{“IMAGE_CLASSIFICATION”, “IMAGE_OBJECT_DETECTION”}

channels

Expected input color layout. "RGB" is 3-channel, "GRAYSCALE" is 1-channel; input images are converted to match.

Type:

{“RGB”, “GRAYSCALE”}

height

Expected input height in pixels. -1 marks a variable dimension that callers must override explicitly.

Type:

int

width

Expected input width in pixels. -1 marks a variable dimension that callers must override explicitly.

Type:

int

batch_size

Declared batch size (io.batchSize). -1 marks a dynamic batch.

Type:

int

n_classes

Number of output classes (io.output.nClasses).

Type:

int

n_boxes

Number of detection boxes (io.output.nBoxes); None for classification models.

Type:

int or None, default None

See also

read_model_metadata

Parse a metadata file into a ModelIOSpec.

build_model_input

Shape images to this contract.

Examples

>>> spec = ModelIOSpec(
...     task="IMAGE_CLASSIFICATION",
...     channels="RGB",
...     height=8,
...     width=8,
...     batch_size=-1,
...     n_classes=4,
... )
>>> spec.channels
'RGB'
>>> spec.n_boxes is None
True