cellmap_flow.models.geometry
A model’s geometry: what it reads and writes, and at what voxel size.
The inference server, blockwise, the server’s model_info and the
dashboard’s geometry cache each read these numbers off ModelConfig.config
one attribute at a time, with their own conversions. ModelGeometry is
them, read once: sizes in nm as given (whole numbers as ints, so 5.24 nm
stays 5.24), and the shapes in voxels, the context and the block shape
derived from them.
from_config reads anything with the config attributes: a built config, or
the stand-ins serving.client and models.geometry_cache build from a
server’s model_info or the cache, which carry no block shape.
Importing this module is cheap: numpy, funlib.geometry and io.ome only.
Attributes
Classes
What a model reads and writes. Sizes are in nm unless named |
Functions
|
|
|
The channel names a config gives, as a tuple, or None: the first |
Module Contents
- cellmap_flow.models.geometry.DEFAULT_OUTPUT_AXES = ('c', 'z', 'y', 'x')
- cellmap_flow.models.geometry.number(value)
valueas an int when it is whole, else as a float.int()truncated a 5.24 nm voxel size to 5, which put crops and layers on the wrong grid.
- cellmap_flow.models.geometry.channel_names_of(config)
The channel names a config gives, as a tuple, or None: the first non-empty one of channels, channels_names (Hugging Face), classes, or a ModelGeometry’s channel_names. A string is one name, so
channels = "mito"is("mito",).
- class cellmap_flow.models.geometry.ModelGeometry
What a model reads and writes. Sizes are in nm unless named
*_shapein voxels.- input_voxel_size: Tuple[float, ...]
- output_voxel_size: Tuple[float, ...]
- read_shape: Tuple[float, ...]
- write_shape: Tuple[float, ...]
- output_channels: int
- channel_names: Tuple[str, ...] | None = None
- chunk_output_axes: Tuple[str, ...] = ('c', 'z', 'y', 'x')
- output_dtype: numpy.dtype | None = None
- input_channels: int = 1
- declared_block_shape: Tuple[int, ...] | None = None
- property ndim: int
Spatial dimensions.
- property input_shape: Tuple[int, ...]
Voxels the model reads.
- property output_shape: Tuple[int, ...]
Voxels the model writes.
- property context: funlib.geometry.Coordinate
nm read beyond the written region on each side.
funlib arithmetic, as the Inferencer and blockwise always computed it: Coordinate truncates each size to an int, and
/floors.
- property has_channel_axis: bool
Whether a chunk the model outputs has a channel axis.
- classmethod from_config(config, chunk_output_axes=None, output_dtype=None) ModelGeometry
From
ModelConfig.config, or anything with its geometry attributes.chunk_output_axesandoutput_dtype, when given, win over the config’s own (ModelConfigpasses its properties, with their defaults); otherwise the config’s are used, if it has them.
- to_model_info(spatial_axes=None, actual_input_voxel_size=None) dict
The geometry keys of the server’s
/__control__/model_info.spatial_axes: the served array’s, which are the raw data’s (the spatial axes of chunk_output_axes by default).output_axesis them in order, then “c” when the output has a channel axis.actual_input_voxel_size: what the input really is. When it is not input_voxel_size, the data was read at another level as if it were at input_voxel_size, voxel for voxel, so an output voxel really isactual_in * output_voxel_size / input_voxel_size: that iseffective_output_voxel_size, otherwise output_voxel_size. The served .zattrs still say output_voxel_size.