Engine.predict

Engine.predict(model_name=None, split='test', *, space='model')

Class probabilities, channels-last, one array per source image.

Tiles are reassembled, so an image that went in at 2048x1536 comes back at 2048x1536 rather than as 24 unrelated pieces.

space decides which grid the answer is on, and the two are different enough that the return type differs with it:

  • "model" - one stacked array, every prediction on the model’s grid. What training saw, and the only form that can be a single array, since a stack requires one shape.
  • "source" - a list, one array per sample, each on the grid of the file it came from. What a person asked for when they asked to segment their scan: it can be laid over that scan, written beside it, or measured in millilitres of its voxels. Sources differ in size, so this cannot be stacked, and pretending otherwise by silently resizing is how a mask ends up describing the wrong anatomy.

Parameters

Name Type Description Default
split str Which data to predict on. 'test'
model_name str | None Which model, by name. Defaults to the first. None
space str "model" returns one stacked array on the network’s own grid. "source" maps each prediction back onto the grid of the scan it came from, undoing the resampling and the crop, and returns a list - scans differ in size, a stacked array needs one shape, and quietly resizing them to match is how a mask ends up describing anatomy it was not computed from. 'model'

Returns

Name Type Description
An array for space="model", a list for space="source".

Two losses in source space: interpolation softens a boundary, and where the forward crop cut anatomy away the inverse pads with background - which means not examined rather than nothing there.