ObjectDetectionRandomWindowGeoDataset#
- class ObjectDetectionRandomWindowGeoDataset[source]#
Bases:
RandomWindowGeoDatasetAttributes
- __init__(*args, **kwargs)[source]#
Constructor.
- Parameters:
*args – See
RandomWindowGeoDataset.__init__().- Keyword Arguments:
bbox_params – Optional
bbox_paramsto use when resizing windows. Defaults toNone.ioa_thresh – 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 – Clip bounding boxes to window limits when retrieving labels for a window. Defaults to
False.neg_ratio – Ratio of sampling probabilities of negative windows (windows w/o bboxes) vs positive windows (windows w/ at least 1 bbox). E.g.
neg_ratio=2means 2/3 probability of sampling a negative window. IfNone, the default sampling behavior ofRandomWindowGeoDatasetis used, without taking bboxes into account. Defaults toNone.neg_ioa_thresh – 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.
append_resize_transform(transform, out_size)Get transform to use for resizing windows to out_size.
from_uris(image_uri[, label_vector_uri, ...])Create an instance of this class from image and label URIs.
Sample a window with random size and location within the AOI.
sample_window_loc(h, w)Randomly sample coordinates of the top left corner of the window.
Randomly sample the window size.
- __add__(other: Dataset[T_co]) ConcatDataset[T_co]#
- Parameters:
other (Dataset[T_co]) –
- Return type:
ConcatDataset[T_co]
- __init__(*args, **kwargs)[source]#
Constructor.
- Parameters:
*args – See
RandomWindowGeoDataset.__init__().- Keyword Arguments:
bbox_params – Optional
bbox_paramsto use when resizing windows. Defaults toNone.ioa_thresh – 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 – Clip bounding boxes to window limits when retrieving labels for a window. Defaults to
False.neg_ratio – Ratio of sampling probabilities of negative windows (windows w/o bboxes) vs positive windows (windows w/ at least 1 bbox). E.g.
neg_ratio=2means 2/3 probability of sampling a negative window. IfNone, the default sampling behavior ofRandomWindowGeoDatasetis used, without taking bboxes into account. Defaults toNone.neg_ioa_thresh – 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__().
- append_resize_transform(transform: BasicTransform, out_size: tuple[int, int]) BasicTransform[source]#
Get transform to use for resizing windows to out_size.
- classmethod from_uris(image_uri: str | list[str], 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_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 (str | list[str]) – URI or list of URIs of GeoTIFFs to use as the source of image data.
label_vector_uri (str | None) – URI of GeoJSON file to use as the source of label. Defaults to
None.class_config (ClassConfig | None) – The ClassConfig. Must be non-None if creating a scene without a
LabelSource. Defaults toNone.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_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) – Additional arguments to pass to the
RasterioSourceused for image data. See docs forRasterioSourcefor more details. Defaults to{}.label_vector_source_kw (dict) – Additional arguments to pass to the
GeoJSONVectorSourceConfigused for label data, if label_vector_uri is set. See docs forGeoJSONVectorSourceConfigfor more details. Defaults to{}.label_source_kw (dict) – Additional arguments to pass to the
ObjectDetectionLabelSourceConfigused for label data, if label_vector_uri is set. See docs forObjectDetectionLabelSourceConfigfor 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.
- sample_window() Box#
Sample a window with random size and location within the AOI.
If the 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:
- sample_window_loc(h: int, w: int) tuple[int, int]#
Randomly sample coordinates of the top left corner of the window.
- property max_size#
- property min_size#