SemanticSegmentationSlidingWindowGeoDataset#
- class SemanticSegmentationSlidingWindowGeoDataset[source]#
Bases:
SlidingWindowGeoDataset- __init__(*args, **kwargs)[source]#
Constructor.
- Parameters
object. (scene A Scene) –
size – Window size.
stride – Step size between windows.
to (out_size Resize chips to this size before returning. Defaults) –
None.padding – How many pixels the windows are allowed to overflow the sides of the raster source. If
None, will be automatically calculated such that the windows cover the entire extent. Defaults toNone.pad_direction – 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. If'both'pad all sides. Has no effect if padding is zero. Defaults to'end'.AOI (within_aoi If True and if the scene has an) – windows that lie fully within the AOI. If False, windows only partially intersecting the AOI will also be allowed. Defaults to
True.sample (only) – windows that lie fully within the AOI. If False, windows only partially intersecting the AOI will also be allowed. Defaults to
True.transform – 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 asMinMaxTransformerorStatsTransformer.transform_type – Type of transform. Defaults to
None.normalize – If
True, the sampled chips are normalized to [0, 1] based on their data type. Defaults toTrue.to_pytorch – If
True, the sampled chips and labels are converted to pytorch tensors. Defaults toTrue.return_window – Make
__getitem__return the window coordinates used to generate the image. Defaults toFalse.
Methods
__init__(*args, **kwargs)Constructor.
append_resize_transform(transform, out_size)Get transform to use for resizing windows to out_size.
from_uris(image_uri[, label_raster_uri, ...])Create an instance of this class from image and label URIs.
Pre-compute windows.
- __add__(other: Dataset[_T_co]) ConcatDataset[_T_co]#
- Parameters
other (Dataset[_T_co]) –
- Return type
ConcatDataset[_T_co]
- __init__(*args, **kwargs)[source]#
Constructor.
- Parameters
object. (scene A Scene) –
size – Window size.
stride – Step size between windows.
to (out_size Resize chips to this size before returning. Defaults) –
None.padding – How many pixels the windows are allowed to overflow the sides of the raster source. If
None, will be automatically calculated such that the windows cover the entire extent. Defaults toNone.pad_direction – 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. If'both'pad all sides. Has no effect if padding is zero. Defaults to'end'.AOI (within_aoi If True and if the scene has an) – windows that lie fully within the AOI. If False, windows only partially intersecting the AOI will also be allowed. Defaults to
True.sample (only) – windows that lie fully within the AOI. If False, windows only partially intersecting the AOI will also be allowed. Defaults to
True.transform – 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 asMinMaxTransformerorStatsTransformer.transform_type – Type of transform. Defaults to
None.normalize – If
True, the sampled chips are normalized to [0, 1] based on their data type. Defaults toTrue.to_pytorch – If
True, the sampled chips and labels are converted to pytorch tensors. Defaults toTrue.return_window – Make
__getitem__return the window coordinates used to generate the image. Defaults toFalse.
- append_resize_transform(transform: albumentations.core.transforms_interface.BasicTransform | None, out_size: tuple[int, int]) albumentations.augmentations.geometric.resize.Resize | albumentations.core.composition.Compose#
Get transform to use for resizing windows to out_size.
- classmethod from_uris(image_uri: str | list[str], label_raster_uri: str | list[str] | None = None, label_vector_uri: str | None = None, class_config: ClassConfig | None = None, aoi_uri: str | list[str] = [], label_vector_default_class_id: int | None = 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 (str | list[str]) – URI or list of URIs of GeoTIFFs to use as the source of image data.
label_raster_uri (str | list[str] | None) – 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_uriinstead. Defaults toNone.label_vector_uri (str | None) – 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_uriinstead. Defaults toNone.class_config (ClassConfig | None) – The
ClassConfig. Can beNoneif not using any labels.aoi_uri (str | list[str]) – 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 (int | None) – If using
label_vector_uriand all polygons in that file belong to the same class and they do not contain aclass_idproperty, then use this argument to map all of the polygons to the appropriate class ID. See docs forClassInferenceTransformerfor more details. Defaults toNone.image_raster_source_kw (dict) – Additional arguments to pass to the
RasterioSourceused for image data. See docs forRasterioSourcefor more details. Defaults to{}.label_raster_source_kw (dict) – Additional arguments to pass to the
RasterioSourceused for label data, iflabel_raster_uriis used. See docs forRasterioSourcefor more details. Defaults to{}.label_vector_source_kw (dict) – Additional arguments to pass to the
GeoJSONVectorSourceused for label data, iflabel_vector_uriis used. See docs forGeoJSONVectorSourcefor 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.