datumaro.plugins.openvino_plugin.samples.otx_custom_object_detection_gen3_ssd_interp#

Classes

OTXSSDModelInterpreter()

class datumaro.plugins.openvino_plugin.samples.otx_custom_object_detection_gen3_ssd_interp.OTXSSDModelInterpreter[source]#

Bases: IModelInterpreter

h_model = 864#
w_model = 864#
preprocess(inp: DatasetItem) Tuple[ndarray | Dict[str, ndarray], PrepInfo][source]#

Preprocessing an dataset item input.

Parameters:

img – DatasetItem input

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

get_categories()[source]#

It should be implemented if the model generate a new categories

class datumaro.plugins.openvino_plugin.samples.otx_custom_object_detection_gen3_ssd_interp.Annotation(*, id: int = 0, attributes: Dict[str, Any] = _Nothing.NOTHING, group: int = 0, object_id: int = -1)[source]#

Bases: object

A base annotation class.

Derived classes must define the ‘_type’ class variable with a value from the AnnotationType enum.

Method generated by attrs for class Annotation.

id: int#
attributes: Dict[str, Any]#
group: int#
object_id: int#
property type: AnnotationType#
as_dict() Dict[str, Any][source]#

Returns a dictionary { field_name: value }

wrap(**kwargs)[source]#

Returns a modified copy of the object

class datumaro.plugins.openvino_plugin.samples.otx_custom_object_detection_gen3_ssd_interp.DatasetItem(id: str, *, subset: str | None = None, media: str | MediaElement | None = None, annotations: List[Annotation] | None = None, attributes: Dict[str, Any] | None = None)[source]#

Bases: object

id: str#
subset: str#
media: MediaElement | None#
annotations: Annotations#
attributes: Dict[str, Any]#
wrap(**kwargs)[source]#
media_as(t: Type[T]) T[source]#
class datumaro.plugins.openvino_plugin.samples.otx_custom_object_detection_gen3_ssd_interp.IModelInterpreter[source]#

Bases: ABC

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

Preprocessing an dataset item input.

Parameters:

img – DatasetItem input

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.

abstract 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

abstract get_categories()[source]#

It should be implemented if the model generate a new categories

class datumaro.plugins.openvino_plugin.samples.otx_custom_object_detection_gen3_ssd_interp.Image(size: Tuple[int, int] | None = None, ext: str | None = None, *args, **kwargs)[source]#

Bases: MediaElement[ndarray]

classmethod from_file(path: str, *args, **kwargs)[source]#
classmethod from_numpy(data: ndarray | Callable[[], ndarray], *args, **kwargs)[source]#
classmethod from_bytes(data: bytes | Callable[[], bytes], *args, **kwargs)[source]#
property has_size: bool#

Indicates that size info is cached and won’t require image loading

property size: Tuple[int, int] | None#

Returns (H, W)

property ext: str | None#

Media file extension (with the leading dot)

set_crypter(crypter: Crypter)[source]#
datumaro.plugins.openvino_plugin.samples.otx_custom_object_detection_gen3_ssd_interp.create_bboxes_with_rescaling(bboxes: ndarray, labels: ndarray, r_scale: float) List[Bbox][source]#
datumaro.plugins.openvino_plugin.samples.otx_custom_object_detection_gen3_ssd_interp.rescale_img_keeping_aspect_ratio(img: ndarray, h_model: int, w_model: int, padding: bool = True) RescaledImage[source]#

Rescale image while maintaining its aspect ratio.

This function rescales the input image to fit the requirements of the model input. It also attempts to preserve the original aspect ratio of the input image. If the aspect ratio of the input image does not match the aspect ratio required by the model, the function applies zero padding to the image boundaries to maintain the aspect ratio if padding option is true.

Parameters:
  • img – The image to be rescaled.

  • h_model – The desired height of the image required by the model.

  • w_model – The desired width of the image required by the model.

  • padding – If true, pad the output image boundaries to make the output image size (h_model, w_model). Otherwise, there is no pad, so that the output image size can be different with `(h_model, w_model).