ChipClassificationLabelSource#
- class ChipClassificationLabelSource[source]#
Bases:
LabelSource
A source of chip classification labels.
Ideally the vector_source contains a square for each cell in the grid. But in reality, it can be difficult to label imagery in such an exhaustive way. So, this can also handle sources with non-overlapping polygons that do not necessarily cover the entire extent. It infers the grid of cells and associated class_ids using the extent and options if infer_cells is set to True.
Attributes
- __init__(label_source_config: ChipClassificationLabelSourceConfig, vector_source: VectorSource, extent: Box = None, lazy: bool = False)[source]#
Constructs a LabelSource for chip classification.
- Parameters
label_source_config (ChipClassificationLabelSourceConfig) – Config for class inference.
vector_source (VectorSource) – Source of vector labels.
extent (Box) – Box used to filter the labels by extent or compute grid.
lazy (bool, optional) – If True, labels are not populated during initialization. Defaults to False.
Methods
__init__
(label_source_config, vector_source)Constructs a LabelSource for chip classification.
get_labels
([window])Return labels overlapping with window.
infer_cells
([cells])Infer labels for a list of cells.
populate_labels
([cells])Populate self.labels by either reading or inferring.
validate_labels
(df)- __init__(label_source_config: ChipClassificationLabelSourceConfig, vector_source: VectorSource, extent: Box = None, lazy: bool = False)[source]#
Constructs a LabelSource for chip classification.
- Parameters
label_source_config (ChipClassificationLabelSourceConfig) – Config for class inference.
vector_source (VectorSource) – Source of vector labels.
extent (Box) – Box used to filter the labels by extent or compute grid.
lazy (bool, optional) – If True, labels are not populated during initialization. Defaults to False.
- get_labels(window: Optional[Box] = None) ChipClassificationLabels [source]#
Return labels overlapping with window.
- Parameters
- Returns
- Labels overlapping with window. If window is None,
returns all labels.
- Return type
- infer_cells(cells: Optional[Iterable[Box]] = None) ChipClassificationLabels [source]#
Infer labels for a list of cells. Only cells whose labels are not already known are inferred.
- Parameters
cells (Optional[Iterable[Box]], optional) – Cells whose labels are to be inferred. Defaults to None.
- Returns
labels
- Return type
- populate_labels(cells: Optional[Iterable[Box]] = None) None [source]#
Populate self.labels by either reading or inferring.
If cfg.infer_cells is True or specific cells are given, the labels are inferred. Otherwise, they are read from the geojson.
- validate_labels(df: geopandas.GeoDataFrame) None [source]#
- Parameters
df (geopandas.GeoDataFrame) –
- Return type
None