ChipClassificationLabels#

class ChipClassificationLabels[source]#

Bases: Labels

Represents a spatial grid of cells associated with classes.

__init__(cell_to_label: dict[rastervision.core.box.Box, tuple[int, Optional[Sequence[float]]]] | None = None)[source]#
Parameters:

cell_to_label (dict[rastervision.core.box.Box, tuple[int, Optional[Sequence[float]]]] | None) –

Methods

__init__([cell_to_label])

extend(labels)

Adds cells contained in labels.

filter_by_aoi(aoi_polygons)

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

from_predictions(windows, predictions)

Overrid to convert predictions to (class_id, scores) pairs.

get_cell_class_id(cell)

Return class_id for a cell.

get_cell_scores(cell)

Return scores for a cell.

get_cells()

Return list of all cells (list of Box).

get_class_ids()

Return list of class_ids for all cells.

get_scores()

Return list of scores for all cells.

get_singleton_labels(cell)

Return Labels object representing a single cell.

get_values()

Return list of class_ids and scores for all cells.

make_empty()

Instantiate an empty instance of this class.

save(uri, class_config, crs_transformer[, bbox])

Save labels as a GeoJSON file.

set_cell(cell, class_id[, scores])

Set cell and its class_id.

__add__(other: Self) Self[source]#

Add labels to these labels.

Returns a concatenation of this and the other labels.

Parameters:

other (Self) –

Return type:

Self

__contains__(cell: Box) bool[source]#
Parameters:

cell (Box) –

Return type:

bool

__getitem__(cell: Box) ClassificationLabel[source]#
Parameters:

cell (Box) –

Return type:

ClassificationLabel

__init__(cell_to_label: dict[rastervision.core.box.Box, tuple[int, Optional[Sequence[float]]]] | None = None)[source]#
Parameters:

cell_to_label (dict[rastervision.core.box.Box, tuple[int, Optional[Sequence[float]]]] | None) –

__setitem__(window: Box, value: tuple[int, Optional[Sequence[float]]])[source]#
Parameters:
extend(labels: Self) None[source]#

Adds cells contained in labels.

Parameters:

labels (Self) – ChipClassificationLabels

Return type:

None

filter_by_aoi(aoi_polygons: Iterable[Polygon])[source]#

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

Parameters:

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

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

Overrid to convert predictions to (class_id, scores) pairs.

Parameters:
get_cell_class_id(cell: Box) int[source]#

Return class_id for a cell.

Parameters:

cell (Box) –

Return type:

int

get_cell_scores(cell: Box) Optional[Sequence[float]][source]#

Return scores for a cell.

Parameters:

cell (Box) – (Box)

Return type:

Optional[Sequence[float]]

get_cells() list[rastervision.core.box.Box][source]#

Return list of all cells (list of Box).

Return type:

list[rastervision.core.box.Box]

get_class_ids() list[int][source]#

Return list of class_ids for all cells.

Return type:

list[int]

get_scores() list[Optional[Sequence[float]]][source]#

Return list of scores for all cells.

Return type:

list[Optional[Sequence[float]]]

get_singleton_labels(cell: Box)[source]#

Return Labels object representing a single cell.

Parameters:

cell (Box) – (Box)

get_values() list[rastervision.core.data.label.chip_classification_labels.ClassificationLabel][source]#

Return list of class_ids and scores for all cells.

Return type:

list[rastervision.core.data.label.chip_classification_labels.ClassificationLabel]

classmethod make_empty() Self[source]#

Instantiate an empty instance of this class.

Returns:

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

Return type:

Labels

save(uri: str, class_config: ClassConfig, crs_transformer: CRSTransformer, bbox: rastervision.core.box.Box | None = None) None[source]#

Save labels as a GeoJSON file.

Parameters:
  • uri (str) – URI of the output file.

  • class_config (ClassConfig) – ClassConfig to map class IDs to names.

  • crs_transformer (CRSTransformer) – CRSTransformer to convert from pixel-coords to map-coords before saving.

  • bbox (rastervision.core.box.Box | None) – User-specified crop of the extent. Must be provided if the corresponding RasterSource has bbox != extent.

Return type:

None

set_cell(cell: Box, class_id: int, scores: Optional[Union[ndarray, Sequence[float]]] = None) None[source]#

Set cell and its class_id.

Parameters:
Return type:

None