ObjectDetectionRandomWindowGeoDataset#

class ObjectDetectionRandomWindowGeoDataset[source]#

Bases: RandomWindowGeoDataset

Attributes

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

Constructor.

Parameters

*args – See RandomWindowGeoDataset.__init__().

Keyword Arguments
  • bbox_params (Optional[A.BboxParams], optional) – Optional bbox_params to use when resizing windows. Defaults to None.

  • ioa_thresh (float, optional) – Minimum IoA of a bounding box with a given window for it to be included in the labels for that window. Defaults to 0.9.

  • clip (bool, optional) – Clip bounding boxes to window limits when retrieving labels for a window. Defaults to False.

  • neg_ratio (Optional[float], optional) – Ratio of sampling probabilities of negative windows (windows w/o bboxes) vs positive windows (windows w/ at least 1 bbox). E.g. neg_ratio=2 means 2/3 probability of sampling a negative window. If None, the default sampling behavior of RandomWindowGeoDataset is used, without taking bboxes into account. Defaults to None.

  • neg_ioa_thresh (float, optional) – A window will be considered negative if its max IoA with any bounding box is less than this threshold. Defaults to 0.2.

  • **kwargs – See RandomWindowGeoDataset.__init__().

Methods

__init__(*args, **kwargs)

Constructor.

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

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

get_resize_transform(transform, out_size)

Get transform to use for resizing windows to out_size.

sample_window()

If scene has AOI polygons, try to find a random window that is within the AOI.

sample_window_loc(h, w)

Randomly sample coordinates of the top left corner of the window.

sample_window_size()

Randomly sample the window size.

__contains__(key: str) bool#
Parameters

key (str) –

Return type

bool

__getitem__(idx: int)#
Parameters

idx (int) –

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

Constructor.

Parameters

*args – See RandomWindowGeoDataset.__init__().

Keyword Arguments
  • bbox_params (Optional[A.BboxParams], optional) – Optional bbox_params to use when resizing windows. Defaults to None.

  • ioa_thresh (float, optional) – Minimum IoA of a bounding box with a given window for it to be included in the labels for that window. Defaults to 0.9.

  • clip (bool, optional) – Clip bounding boxes to window limits when retrieving labels for a window. Defaults to False.

  • neg_ratio (Optional[float], optional) – Ratio of sampling probabilities of negative windows (windows w/o bboxes) vs positive windows (windows w/ at least 1 bbox). E.g. neg_ratio=2 means 2/3 probability of sampling a negative window. If None, the default sampling behavior of RandomWindowGeoDataset is used, without taking bboxes into account. Defaults to None.

  • neg_ioa_thresh (float, optional) – A window will be considered negative if its max IoA with any bounding box is less than this threshold. Defaults to 0.2.

  • **kwargs – See RandomWindowGeoDataset.__init__().

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_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_vector_source_kw: dict = {}, label_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_vector_uri (Optional[str], optional) – URI of GeoJSON file to use as the source of segmentation label data. 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 polygons 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_vector_source_kw (dict, optional) – Additional arguments to pass to the GeoJSONVectorSourceConfig used for label data, if label_vector_uri is set. See docs for GeoJSONVectorSourceConfig for more details. Defaults to {}.

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

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

Returns

An instance of this GeoDataset subclass.

get_resize_transform(transform: BasicTransform, out_size: Tuple[int, int]) BasicTransform[source]#

Get transform to use for resizing windows to out_size.

Parameters
  • transform (BasicTransform) –

  • out_size (Tuple[int, int]) –

Return type

BasicTransform

sample_window() Box#

If scene has AOI polygons, try to find a random window that is within the AOI. Otherwise, just return the first sampled window.

Raises

StopIteration – If unable to find a valid window within self.max_sample_attempts attempts.

Returns

The sampled window.

Return type

Box

sample_window_loc(h: int, w: int) Tuple[int, int]#

Randomly sample coordinates of the top left corner of the window.

Parameters
Return type

Tuple[int, int]

sample_window_size() Tuple[int, int]#

Randomly sample the window size.

Return type

Tuple[int, int]

property max_size#
property min_size#