ObjectDetectionLabelSource#
- class ObjectDetectionLabelSource[source]#
Bases:
LabelSource
A read-only label source for object detection.
Attributes
Bounding box applied to the source.
Associated
CRSTransformer
.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’.
- __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:
window (rastervision.core.box.Box | None) – Window coords.
ioa_thresh (float) –
clip (bool) –
- 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:
- set_bbox(bbox: Box) None [source]#
Set self.extent to the given value.
Note
This method is idempotent.
- property crs_transformer: CRSTransformer#
Associated
CRSTransformer
.