SemanticSegmentationSlidingWindowGeoDataset#

class SemanticSegmentationSlidingWindowGeoDataset[source]#

Bases: SlidingWindowGeoDataset

__init__(*args, **kwargs)[source]#

Constructor.

Parameters
  • scene (Scene) – A Scene object.

  • size (Union[PosInt, Tuple[PosInt, PosInt]]) – Window size.

  • stride (Union[PosInt, Tuple[PosInt, PosInt]]) – Step size between windows.

  • padding (Optional[Union[NonNegInt, Tuple[NonNegInt, NonNegInt]]]) – How many pixels the windows are allowed to overflow the sides of the raster source. If None, padding is set to size // 2. Defaults to None.

  • pad_direction (Literal['both', 'start', 'end']) – If ‘end’, only pad ymax and xmax (bottom and right). If ‘start’, only pad ymin and xmin (top and left). If ‘both’, pad all sides. Has no effect if paddiong is zero. Defaults to ‘end’.

  • transform (Optional[A.BasicTransform], optional) – Albumentations transform to apply to the windows. Defaults to None. Each transform in Albumentations takes images of type uint8, and sometimes other data types. The data type requirements can be seen at https://albumentations.ai/docs/api_reference/augmentations/transforms/ # noqa If there is a mismatch between the data type of imagery and the transform requirements, a RasterTransformer should be set on the RasterSource that converts to uint8, such as MinMaxTransformer or StatsTransformer.

  • transform_type (Optional[TransformType], optional) – Type of transform. Defaults to None.

  • normalize (bool, optional) – If True, x is normalized to [0, 1] based on its data type. Defaults to True.

  • to_pytorch (bool, optional) – If True, x and y are converted to pytorch tensors. Defaults to True.

Methods

__init__(*args, **kwargs)

Constructor.

from_uris(image_uri[, label_raster_uri, ...])

Create an instance of this class from image and label URIs.

init_windows()

Pre-compute windows.

__init__(*args, **kwargs)[source]#

Constructor.

Parameters
  • scene (Scene) – A Scene object.

  • size (Union[PosInt, Tuple[PosInt, PosInt]]) – Window size.

  • stride (Union[PosInt, Tuple[PosInt, PosInt]]) – Step size between windows.

  • padding (Optional[Union[NonNegInt, Tuple[NonNegInt, NonNegInt]]]) – How many pixels the windows are allowed to overflow the sides of the raster source. If None, padding is set to size // 2. Defaults to None.

  • pad_direction (Literal['both', 'start', 'end']) – If ‘end’, only pad ymax and xmax (bottom and right). If ‘start’, only pad ymin and xmin (top and left). If ‘both’, pad all sides. Has no effect if paddiong is zero. Defaults to ‘end’.

  • transform (Optional[A.BasicTransform], optional) – Albumentations transform to apply to the windows. Defaults to None. Each transform in Albumentations takes images of type uint8, and sometimes other data types. The data type requirements can be seen at https://albumentations.ai/docs/api_reference/augmentations/transforms/ # noqa If there is a mismatch between the data type of imagery and the transform requirements, a RasterTransformer should be set on the RasterSource that converts to uint8, such as MinMaxTransformer or StatsTransformer.

  • transform_type (Optional[TransformType], optional) – Type of transform. Defaults to None.

  • normalize (bool, optional) – If True, x is normalized to [0, 1] based on its data type. Defaults to True.

  • to_pytorch (bool, optional) – If True, x and y are converted to pytorch tensors. Defaults to True.

static __new__(cls, *args: Any, **kwargs: Any) Any#
Parameters
  • args (Any) –

  • kwargs (Any) –

Return type

Any

classmethod from_uris(image_uri: Union[str, List[str]], label_raster_uri: Optional[Union[str, List[str]]] = None, label_vector_uri: Optional[str] = None, class_config: Optional[ClassConfig] = None, aoi_uri: Union[str, List[str]] = [], label_vector_default_class_id: Optional[int] = None, image_raster_source_kw: dict = {}, label_raster_source_kw: dict = {}, label_vector_source_kw: dict = {}, **kwargs)#

Create an instance of this class from image and label URIs.

This is a convenience method. For more fine-grained control, it is recommended to use the default constructor.

Parameters
  • image_uri (Union[str, List[str]]) – URI or list of URIs of GeoTIFFs to use as the source of image data.

  • label_raster_uri (Optional[Union[str, List[str]]], optional) – URI or list of URIs of GeoTIFFs to use as the source of segmentation label data. If the labels are in the form of GeoJSONs, use label_vector_uri instead. Defaults to None.

  • label_vector_uri (Optional[str], optional) – URI of GeoJSON file to use as the source of segmentation label data. If the labels are in the form of GeoTIFFs, use label_raster_uri instead. Defaults to None.

  • class_config (Optional['ClassConfig']) – The ClassConfig. Can be None if not using any labels.

  • aoi_uri (Union[str, List[str]], optional) – URI or list of URIs of GeoJSONs that specify the area-of-interest. If provided, the dataset will only access data from this area. Defaults to [].

  • label_vector_default_class_id (Optional[int], optional) – If using label_vector_uri and all polygons in that file belong to the same class and they do not contain a class_id property, then use this argument to map all of the polgons to the appropriate class ID. See docs for ClassInferenceTransformer for more details. Defaults to None.

  • image_raster_source_kw (dict, optional) – Additional arguments to pass to the RasterioSource used for image data. See docs for RasterioSource for more details. Defaults to {}.

  • label_raster_source_kw (dict, optional) – Additional arguments to pass to the RasterioSource used for label data, if label_raster_uri is used. See docs for RasterioSource for more details. Defaults to {}.

  • label_vector_source_kw (dict, optional) – Additional arguments to pass to the GeoJSONVectorSource used for label data, if label_vector_uri is used. See docs for GeoJSONVectorSource for more details. Defaults to {}.

  • **kwargs – All other keyword args are passed to the default constructor for this class.

Raises

ValueError – If both label_raster_uri and label_vector_uri are specified.

Returns

An instance of this GeoDataset subclass.

init_windows() None#

Pre-compute windows.

Return type

None