emmi_inference.preprocess ========================= .. py:module:: emmi_inference.preprocess Classes ------- .. autoapisummary:: emmi_inference.preprocess.Compose emmi_inference.preprocess.AddBatch emmi_inference.preprocess.NormalizeAny Module Contents --------------- .. py:class:: Compose(*ops) Chain multiple preprocessing ops. Each op must be a callable that accepts and returns the same data structure (e.g., a `torch.Tensor` or a `dict[str, torch.Tensor]`). Ops that are `None` are ignored, which makes conditional composition convenient. .. attribute:: ops A list of callables applied in order. .. py:attribute:: ops .. py:class:: AddBatch(dim = 0) Insert a batch dimension. Works for a single `torch.Tensor` or a mapping of tensors; in the latter case, the dimension is inserted for every value. .. attribute:: dim Dimension index at which to insert the batch. Configure the batch insertion. :param dim: Dimension index along which to insert the new batch axis. Defaults to 0. .. py:attribute:: dim :value: 0 .. py:class:: NormalizeAny Normalize tensors or dicts of tensors using scalar or per-channel stats. This transform supports two modes: 1. Tensor input: `mean`/`std` can be a scalar or 1-D sequences for per-channel normalization. Broadcasting is performed along `dim`. 2. Dict input: `per_key` maps keys to their own `NormalizeAny` to apply to each value. Keys without a configured normalizer are left unchanged. .. attribute:: mean Scalar or 1-D sequence of means for tensor normalization. If `None`, no normalization is applied. .. attribute:: std Scalar or 1-D sequence of standard deviations matching `mean`. Zero values are clamped to 1 to avoid division by zero. .. attribute:: per_key Optional mapping from key to a `NormalizeAny` applied to dict inputs. .. attribute:: dim Feature/channel dimension for broadcasting vector stats. .. py:attribute:: mean :type: float | collections.abc.Sequence[float] | None :value: None .. py:attribute:: std :type: float | collections.abc.Sequence[float] | None :value: None .. py:attribute:: per_key :type: collections.abc.Mapping[str, NormalizeAny] | None :value: None .. py:attribute:: dim :type: int :value: -1