ObjectDetectionLabelSource#

class ObjectDetectionLabelSource[source]#

Bases: LabelSource

A read-only label source for object detection.

Attributes

bbox

Bounding box applied to the source.

crs_transformer

Associated CRSTransformer.

extent

Extent of the LabelSource.

__init__(vector_source: VectorSource, bbox: rastervision.core.box.Box | None = None, ioa_thresh: float | None = None, clip: bool = False)[source]#

Constructor.

Parameters:
  • vector_source (VectorSource) – A VectorSource.

  • bbox (rastervision.core.box.Box | None) – User-specified crop of the extent. If None, the full extent available in the source file is used.

  • ioa_thresh (float | None) – IOA threshold to apply when retrieving labels for a window. Defaults to None.

  • clip (bool) – Clip bounding boxes to window limits when retrieving labels for a window. Defaults to False.

Methods

__init__(vector_source[, bbox, ioa_thresh, clip])

Constructor.

get_labels([window, ioa_thresh, clip])

Get labels (in global coords) for a window.

set_bbox(bbox)

Set self.extent to the given value.

validate_geojson(geojson)

__getitem__(key: Any) tuple[numpy.ndarray, numpy.ndarray, str][source]#

Get labels (in window coords) for a window.

Returns a 3-tuple: (npboxes, class_ids, box_format). - npboxes is a float np.ndarray of shape (num_boxes, 4) representing pixel coords of bounding boxes in the form [ymin, xmin, ymax, xmax]. - class_ids is a np.ndarray of shape (num_boxes,) representing the class labels for each of the boxes. - box_format is the format of npboxes which, in this case, is always ‘yxyx’.

Parameters:
  • window (Box) – Window coords.

  • key (Any) –

Returns:

3-tuple of (npboxes, class_ids, box_format). The returned npboxes are in window coords (i.e. coords within the window).

Return type:

tuple[np.ndarray, np.ndarray, str]

__init__(vector_source: VectorSource, bbox: rastervision.core.box.Box | None = None, ioa_thresh: float | None = None, clip: bool = False)[source]#

Constructor.

Parameters:
  • vector_source (VectorSource) – A VectorSource.

  • bbox (rastervision.core.box.Box | None) – User-specified crop of the extent. If None, the full extent available in the source file is used.

  • ioa_thresh (float | None) – IOA threshold to apply when retrieving labels for a window. Defaults to None.

  • clip (bool) – Clip bounding boxes to window limits when retrieving labels for a window. Defaults to False.

get_labels(window: rastervision.core.box.Box | None = None, ioa_thresh: float = 1e-06, clip: bool = False) ObjectDetectionLabels[source]#

Get labels (in global coords) for a window.

Parameters:
Returns:

Labels with sufficient overlap with the window. The returned labels are in global coods (i.e. coords within the full extent of the source).

Return type:

ObjectDetectionLabels

set_bbox(bbox: Box) None[source]#

Set self.extent to the given value.

Note

This method is idempotent.

Parameters:
  • extent (Box) – User-specified extent in pixel coordinates.

  • bbox (Box) –

Return type:

None

validate_geojson(geojson: dict) None[source]#
Parameters:

geojson (dict) –

Return type:

None

property bbox: Box#

Bounding box applied to the source.

property crs_transformer: CRSTransformer#

Associated CRSTransformer.

property extent: Box#

Extent of the LabelSource.