cellmap_flow.inferencer

Predicting a chunk and postprocessing it: the Inferencer.

The model itself (the device, the warmup, the forward and the device slots) is inference.runner.ModelRunner; an Inferencer is a ModelRunner that also applies a normalization and postprocessing chain, the layer’s own or the process’s (process_chain()).

predict(read_roi, write_roi, config, **kwargs) and apply_postprocess are what model scripts are written against, so both stay importable from here; predict itself is the runner’s default forward.

Attributes

logger

Classes

Inferencer

A ModelRunner that normalizes its input and postprocesses its output.

Functions

apply_postprocess(data[, postprocess])

Run data through a postprocessing chain.

Module Contents

cellmap_flow.inferencer.logger
cellmap_flow.inferencer.apply_postprocess(data, postprocess=None, **kwargs)

Run data through a postprocessing chain.

postprocess=None means the process’s chain, process_chain().postprocess; the server passes the chain of the layer being requested instead.

class cellmap_flow.inferencer.Inferencer(model_config, use_half_prediction=False, device_slots=None, half_precision=False)

A ModelRunner that normalizes its input and postprocesses its output.

process_chunk(idi, roi, input_norms=None, postprocess=None, grid_origin=None)

Predict roi, read from idi, and postprocess it.

idi is what the model reads from: a RawInput (cellmap_flow.io.raw), or the server’s BlockInput, which already reads through the layer’s chain.

input_norms / postprocess: the chain to use for this chunk; a RawInput is read through input_norms (with_input_norms). None falls back to the process’s chain (process_chain()), for callers (scripts) that set the chain process-wide.

grid_origin: where (nm) the chunk grid roi lies on starts, so the steps get roi’s index on that grid as chunk_corner; None means a grid starting at 0. The server and blockwise both pass the raw data’s corner (see _chunk_index), so a region gets the same unique label ids from either where their chunks are the same: the whole volume, or a box on that grid.