Detectors are high-level abstractions of Keras object detection architectures. They share a common API.

class mira.detectors.Detector[source]

Abstract base class for a detector.

abstract compute_anchor_boxes(width, height)[source]

Return the list of anchor boxes in xyxy format. You can convert these to dimensions using something like:

detector.compute_anchor_boxes(iwidth, iheight)[:, [0, 2, 1, 3]].reshape((-1, 2, 2))

Return type



Compute the IoU between annotatons for a scene collection and the anchors for the detector. Accounts for scaling depending on this detectors resize configuration.

Return type


detect(items, batch_size=32, progress=False, **kwargs)[source]

Perform object detection on a batch of images or single image.

  • images – A list of images or a single image.

  • threshold – The detection threshold for the images

  • batch_size (int) – The batch size to use with the underlying model

Return type

Union[List[List[Annotation]], List[Annotation], SceneCollection, Scene]


A list of lists of annotations.

mAP(collection, iou_threshold=0.5, min_threshold=0.01, batch_size=32)[source]

Compute the mAP metric for a given collection of ground truth scenes.

  • collection (SceneCollection) – The collection to evaluate

  • min_threshold – The minimum threshold for initial selection of boxes.

  • iou_threshold – The IoU threshold required for a match


mAP score

abstract serve_module_string()[source]

Return the module string used as part of TorchServe.

Return type


to_torchserve(model_name, directory='.', archive_format='default', score_threshold=0.5, model_version='1.0', api_mode='mira')[source]

Build a TorchServe-compatible MAR file for this model.

There are currently four implemented architectures.