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)

Returns a copy of these labels filtered by a given set of 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 filter_by_aoi(aoi_polygons)[source]#

Returns a copy of these labels filtered by a given set of AOI polygons

Parameters
  • by (aoi_polygons - A list of AOI polygons to filter) –

  • coordinates. (in pixel) –

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