dataeval.utils.training.predict¶
-
dataeval.utils.training.predict(x, model, device=
None, batch_size=None, preprocess_fn=None, postprocess_fn=None)¶ Make batch predictions on a model.
- Parameters:¶
- x : Iterable[Array]¶
An iterable of per-instance images (e.g. a numpy array batched along axis 0, a list of arrays, or any iterable yielding one image at a time). Each instance is passed through
preprocess_fnindividually and only then stacked into batches, so instances need not share a common shape on input –preprocess_fnis responsible for normalizing them (e.g. resizing) to a stackable shape. This is what allows variable-size images (such as detection inputs) to be supplied without pre-batching.- model : torch.nn.Module¶
PyTorch model.
- device : DeviceLike or None, default None¶
The hardware device to use if specified, otherwise uses the DataEval default or torch default.
- batch_size : int or None, default None¶
Batch size used during prediction. If None, uses DataEval default (1e10).
- preprocess_fn : PreprocessFn or None, default None¶
Optional per-instance preprocessing applied to each image before it is stacked into a batch. Receives a single image tensor and returns the transformed tensor; use it to normalize variable-size inputs (e.g. resize) to a common, stackable shape.
- postprocess_fn : PostprocessFn or None, default None¶
Optional batch-level decoding applied to each batch’s raw model output before it is moved to the CPU. Receives the model output and must return a tensor or tuple of tensors (e.g. to decode raw detection outputs into per-detection class scores).
- Returns:¶
PyTorch tensor with model outputs, or tuple of tensors if model returns tuple (e.g., VAE models return (reconstruction, mu, logvar)).
- Return type:¶
torch.Tensor or tuple[torch.Tensor, …]