Skip to content

inputs= — Input Shape

inputs= is optional. If you pass tensors (images, point clouds) straight to the model, you do not need to write it.

You need it when MLdebugger cannot see the input the model actually processed.


InputSchema fields

Field Type Contents
structure structure node The input container structure. "H" / "W" labels on an S.Array leaf are what per-sample image sizes are derived from
resolve callable For models called with non-tensor sources (paths, URLs): resolve(model_input, model_output) -> per-sample input tensors

At least one of structure / resolve is required (omitting both raises at construction time).

The reference size for normalized coordinates lives on the output side

The size a normalized box is denormalized against is declared with S.Coords(size_from=...), not here.


Why the input matters

MLdebugger derives two things from the input:

Purpose Contents
Input identity The identifier for recognizing inference over the same data as the same sample
Image size The reference size used to convert normalized coordinates back to pixels

When the model is called with file paths or URLs and loads the data internally, neither is available. In that case declare one of the following.


1. The model returns the tensor it loaded

Declare its location with an S.Array(input_tensor=True) leaf on the output side.

spec = ModelSpec(
    labels=LabelSchema(n_class=3, ground_truth=gt),
    output=S.BatchAxis[S.Dict(
        boxes=S.DetAxis[S.Coords("xyxy", "pixel")],
        scores=S.DetAxis[S.Score("raw")],
        labels=S.DetAxis[S.LabelId(0)],
        image=S.Array(("C", "H", "W"), input_tensor=True),   # the input the model actually read
    )],
)

The image size is derived from the axis labels in the first argument (("C", "H", "W"), ("H", "W", "C"), …), so samples of differing sizes are handled correctly.

Where it can go

S.Array(input_tensor=True) is a per-sample leaf. It cannot be placed under a detection axis (S.DetAxis).


2. It is not in the output: InputSchema(resolve=fn)

Declare a function that returns the per-sample input tensors — useful when you want to re-run preprocessing to reproduce the input.

from ml_debugger.spec import InputSchema

spec = ModelSpec(
    labels=LabelSchema(n_class=3, ground_truth=gt),
    inputs=InputSchema(resolve=lambda paths, output: [load_image(p) for p in paths]),
    output=S.BatchAxis[S.Dict(
        boxes=S.DetAxis[S.Coords("xyxy", "pixel")],
        scores=S.DetAxis[S.Score("raw")],
        labels=S.DetAxis[S.LabelId(0)],
    )],
)

The function signature is fn(model_input, model_output) -> list of per-sample input tensors.


3. Neither is declared

The input_ids you pass at call time are used as the sample identity (if you pass no input_ids either, identity is undefined).

Since no image size can be derived from the input, declare the reference size with S.Coords(..., size_from=...) if you use normalized coordinates (see output=).

tracer(image_paths, ground_truth, input_ids=["img0", "img1"])   # identity comes from input_ids

  • invoke= — when the call is not model(input)
  • output= — coordinate formats and reference sizes