Skip to content

Object Detection (2D)#

Experimental Feature

This pre-built workflow is an experimental feature. Experimental features are under active development and may occasionally undergo API-breaking changes.

Object Detection (OD) is a computer vision task that aims to classify and locate objects of interest presented in an image. So, it can be viewed as a combination of localization and classification tasks.

This pre-built workflow is prepared for a 2D Object Detection problem and here is an example of using this workflow on the COCO dataset.

TestSample #

Bases: Image

The Image sample type for the pre-built 2D Object Detection workflow.

metadata: Metadata = dataclasses.field(default_factory=dict) class-attribute instance-attribute #

The optional Metadata dictionary.

GroundTruth #

Bases: GroundTruth

Ground truth type for the pre-built 2D Object Detection workflow.

bboxes: List[Union[LabeledBoundingBox, LabeledPolygon]] instance-attribute #

The ground truth LabeledBoundingBoxes or LabeledPolygons associated with an image.

ignored_bboxes: List[Union[LabeledBoundingBox, LabeledPolygon]] = dataclasses.field(default_factory=list) class-attribute instance-attribute #

The ground truth LabeledBoundingBoxes or LabeledPolygons to be ignored in evaluation associated with an image.

Inference #

Bases: Inference

Inference type for the pre-built 2D Object Detection workflow.

bboxes: List[Union[ScoredLabeledBoundingBox, ScoredLabeledPolygon]] instance-attribute #

The inference ScoredLabeledBoundingBoxes or ScoredLabeledPolygons associated with an image.

ignored: bool = False class-attribute instance-attribute #

Whether the image (and its associated inference bboxes) should be ignored in evaluating the results of the model.

ThresholdConfiguration #

Bases: EvaluatorConfiguration

Confidence and IoU ↗ threshold configuration for the pre-built 2D Object Detection workflow. Specify a confidence and IoU threshold to apply to all classes.

threshold_strategy: Union[Literal['F1-Optimal'], float] = 'F1-Optimal' class-attribute instance-attribute #

The confidence threshold strategy. It can either be a fixed confidence threshold such as 0.3 or 0.75, or the F1-optimal threshold by default.

iou_threshold: float = 0.5 class-attribute instance-attribute #

The IoU ↗ threshold, defaulting to 0.5.

min_confidence_score: float = 0.0 class-attribute instance-attribute #

The minimum confidence score to consider for the evaluation. This is usually set to reduce noise by excluding inferences with low confidence score.

multiclass: Optional[bool] = None class-attribute instance-attribute #

Optional flag to choose whether the SingleClass or Multiclass evaluator is run. If unset, the evaluator is determined based on the number of distinct labels in test data.

ObjectDetectionEvaluator(configurations=None) #

Bases: Evaluator

This ObjectDetectionEvaluator transforms inferences into metrics for the object detection workflow for a single class or multiple classes.

When a ThresholdConfiguration is configured to use an F1-Optimal threshold strategy, the evaluator requires that the first test case retrieved for a test suite contains the complete sample set.

For additional functionality, see the associated base class documentation.

upload_object_detection_results(dataset_name, model_name, df, *, ground_truths_field='ground_truths', raw_inferences_field='raw_inferences', iou_threshold=0.5, threshold_strategy='F1-Optimal', min_confidence_score=0.01) #

Compute metrics and upload results of the model for the dataset.

Dataframe df should include a locator column that would match to that of corresponding datapoint. Column :inference in the Dataframe df should be a list of scored BoundingBoxes.

Parameters:

Name Type Description Default
dataset_name str

Dataset name.

required
model_name str

Model name.

required
df DataFrame

Dataframe for model results.

required
ground_truths_field str

Field name in datapoint with ground truth bounding boxes, defaulting to "ground_truths".

'ground_truths'
raw_inferences_field str

Column in model result DataFrame with raw inference bounding boxes, defaulting to "raw_inferences".

'raw_inferences'
iou_threshold float

The IoU ↗ threshold, defaulting to 0.5.

0.5
threshold_strategy Union[Literal['F1-Optimal'], float, Dict[str, float]]

The confidence threshold strategy. It can either be a fixed confidence threshold such as 0.5 or 0.75, or "F1-Optimal" to find the threshold maximizing F1 score..

'F1-Optimal'
min_confidence_score float

The minimum confidence score to consider for the evaluation. This is usually set to reduce noise by excluding inferences with low confidence score.

0.01

Returns:

Type Description
None