Labels#

class Labels[source]#

Bases: ABC

A source-agnostic, in-memory representation of labels in a scene.

This class can represent labels obtained via a LabelSource, a LabelStore, or directly from model predictions.

__init__()#

Methods

__init__()

filter_by_aoi(aoi_polygons)

Return a copy of these labels filtered by given AOI polygons.

from_predictions(windows, predictions)

Instantiate from windows and their corresponding predictions.

make_empty()

Instantiate an empty instance of this class.

save(uri)

Save to file.

abstract __add__(other: Labels)[source]#

Add labels to these labels.

Returns a concatenation of this and the other labels.

Parameters

other (Labels) –

abstract __setitem__(key, value)[source]#
abstract filter_by_aoi(aoi_polygons: List[Polygon]) Labels[source]#

Return a copy of these labels filtered by given AOI polygons.

Parameters

aoi_polygons (List[Polygon]) – List of AOI polygons to filter by, in pixel coordinates.

Return type

Labels

classmethod from_predictions(windows: Iterable[Box], predictions: Iterable[Any]) Labels[source]#

Instantiate from windows and their corresponding predictions.

This makes no assumptions about the type or format of the predictions. Subclasses should implement the __setitem__ method to correctly handle the predictions.

Parameters
  • windows (Iterable[Box]) – Boxes in pixel coords, specifying chips in the raster.

  • predictions (Iterable[Any]) – The model predictions for each chip specified by the windows.

Returns

An object of the Label subclass on which this method is called.

Return type

Labels

abstract classmethod make_empty() Labels[source]#

Instantiate an empty instance of this class.

Returns

An object of the Label subclass on which this method is called.

Return type

Labels

abstract save(uri: str) None[source]#

Save to file.

Parameters

uri (str) –

Return type

None