datumaro.components.launcher#

Classes

Launcher([model_dir])

LauncherWithModelInterpreter(...)

class datumaro.components.launcher.Launcher(model_dir: str | None = None)[source]#

Bases: CliPlugin

preprocess(item: DatasetItem) Tuple[ndarray | Dict[str, ndarray], PrepInfo][source]#

Preprocess single dataset item before launch()

There are two output types:

1. The output is np.ndarray. For example, it can be image data as np.ndarray with BGR format (H, W, C). In this step, you usually implement resizing, normalizing, or color channel conversion for your launcher (or model).

2. The output is Dict[str, np.ndarray]. For example, it can be image and text pairs. Therefore, this can be used for the model having multi modality for image and text inputs.

infer(inputs: Dict[str, ndarray]) List[Dict[str, ndarray] | List[Dict[str, ndarray]]][source]#
infer(inputs: ndarray) List[Dict[str, ndarray] | List[Dict[str, ndarray]]]
postprocess(pred: Dict[str, ndarray] | List[Dict[str, ndarray]], info: PrepInfo) List[Annotation][source]#
launch(batch: Sequence[DatasetItem], stack: bool = True) List[List[Annotation]][source]#

Launch to obtain the inference outputs of items.

Parameters:
  • inputs – batch of Datasetitems

  • stack – If true, launch inference for the stacked input for the batch-wise dimension Otherwise, launch inference for each input.

Returns:

A list of annotation list. Each annotation list is mapped to the input DatasetItem. These annotation list are pseudo-labels obtained by the model inference.

infos()[source]#
categories()[source]#
type_check(item: DatasetItem) bool[source]#

Check the media type of dataset item.

If False, the item is excluded from the input batch.

class datumaro.components.launcher.LauncherWithModelInterpreter(model_interpreter_path: str)[source]#

Bases: Launcher

preprocess(item: DatasetItem) Tuple[ndarray | Dict[str, ndarray], PrepInfo][source]#

Preprocessing an input DatasetItem.

Parameters:

img – Input Datasetitem

Returns:

It returns a tuple of preprocessed input and preprocessing information. The preprocessing information will be used in the postprocessing step. One use case for this would be an affine transformation of the output bounding box obtained by object detection models. Input images for those models are usually resized to fit the model input dimensions. As a result, the postprocessing step should refine the model output bounding box to match the original input image size.

postprocess(pred: Dict[str, ndarray] | List[Dict[str, ndarray]], info: PrepInfo) List[Annotation][source]#

Postprocess a model prediction.

Parameters:
  • pred – Model prediction

  • info – Preprocessing information coming from the preprocessing step

Returns:

A list of annotations which is created from the model predictions

categories()[source]#