geti_sdk.deployment.data_models package

Module contents

class geti_sdk.deployment.data_models.ROI(labels: List[ScoredLabel], modified: str | datetime | None = None, id: str | None = None, labels_to_revisit: List[str] | None = None, *, shape: Rectangle, original_shape: Shape)

Bases: Annotation

A region of interest for a given image. ROIs are generated for intermediate tasks in the pipeline of a project, if those tasks produce local labels (for instance a detection or segmentation task).

shape: Rectangle
original_shape: Shape
classmethod from_annotation(annotation: Annotation) ROI

Convert an Annotation instance into an ROI.

Parameters:

annotation – Annotation to convert to region of interest

Returns:

ROI containing the annotation

to_absolute_coordinates(parent_roi: ROI) ROI

Convert the ROI to an ROI in absolute coordinates, given it’s parent ROI.

Parameters:

parent_roi – Parent ROI containing the roi instance

Returns:

ROI converted to the coordinate system of the parent ROI

class geti_sdk.deployment.data_models.IntermediateInferenceResult(prediction: Prediction, image: ndarray, rois: List[ROI] | None = None)

Bases: object

Inference results for intermediate tasks in the pipeline

prediction: Prediction
image: ndarray
rois: List[ROI] | None
property image_width: int

Return the width of the image to which the InferenceResult applies.

Returns:

Integer representing the width of the image, in pixels

property image_height: int

Return the height of the image to which the InferenceResult applies.

Returns:

Integer representing the height of the image, in pixels

filter_rois(label: Label | None = None) List[ROI]

Filter the ROIs for the inference results based on an input label.

Parameters:

label – Label to retrieve the ROIs for. If left as None, all the ROIs belonging to the inference result are returned

Returns:

List of ROIs containing an object with the specified label

generate_views(rois: List[ROI] | None = None) List[ndarray]

Generate a list of image views holding the pixel data for the ROIs produced by the last local-label task in the pipeline.

Parameters:

rois – Optional list of ROIs to return the views for. If left as None, views for all ROIs are returned.

Returns:

List of numpy arrays containing the pixel data for the ROI’s in the list of ROI’s associated with this inference result

append_annotation(annotation: Annotation, roi: ROI)

Append an Annotation instance to the prediction results, taking into account the ROI for which the annotation was predicted.

This method can be used to add annotations produced by a downstream local task to the prediction results

Parameters:
  • annotation – Annotation to append to the inference results

  • roi – ROI in which the prediction was made

extend_annotations(annotations: List[Annotation], roi: ROI)

Extend the list of annotations for the current prediction results, taking into account the ROI for which the annotation was predicted.

This method can be used to add labels produced by a global downstream task to the ROI output of it’s upstream local task

Parameters:
  • annotations – List of annotations holding the labels to append

  • roi – ROI for which the annotations are predicted

add_to_infer_queue(roi: ROI)

Add the ROI to the queue of items to infer

Parameters:

roi – ROI for the item to add to the infer queue

get_infer_queue() List[ROI]

Return the full infer queue

clear_infer_queue()

Reset the infer queue

increment_infer_counter()

Increase the infer counter by one

reset_infer_counter()

Reset the infer counter back to zero

all_rois_inferred() bool

Return True if all ROIs in the intermediate result have been inferred