ObjectDetectionGeoDataWindowConfig#

Note

All Configs are derived from rastervision.pipeline.config.Config, which itself is a pydantic Model.

pydantic model ObjectDetectionGeoDataWindowConfig[source]#

Configure an object detection GeoDataset.

See rastervision.pytorch_learner.dataset.object_detection_dataset.

Show JSON schema
{
   "title": "ObjectDetectionGeoDataWindowConfig",
   "description": "Configure an object detection :class:`.GeoDataset`.\n\nSee :mod:`rastervision.pytorch_learner.dataset.object_detection_dataset`.",
   "type": "object",
   "properties": {
      "method": {
         "default": "sliding",
         "allOf": [
            {
               "$ref": "#/definitions/GeoDataWindowMethod"
            }
         ]
      },
      "size": {
         "title": "Size",
         "description": "If method = sliding, this is the size of sliding window. If method = random, this is the size that all the windows are resized to before they are returned. If method = random and neither size_lims nor h_lims and w_lims have been specified, then size_lims is set to (size, size + 1).",
         "anyOf": [
            {
               "type": "integer",
               "exclusiveMinimum": 0
            },
            {
               "type": "array",
               "minItems": 2,
               "maxItems": 2,
               "items": [
                  {
                     "type": "integer",
                     "exclusiveMinimum": 0
                  },
                  {
                     "type": "integer",
                     "exclusiveMinimum": 0
                  }
               ]
            }
         ]
      },
      "stride": {
         "title": "Stride",
         "description": "Stride of sliding window. Only used if method = sliding.",
         "anyOf": [
            {
               "type": "integer",
               "exclusiveMinimum": 0
            },
            {
               "type": "array",
               "minItems": 2,
               "maxItems": 2,
               "items": [
                  {
                     "type": "integer",
                     "exclusiveMinimum": 0
                  },
                  {
                     "type": "integer",
                     "exclusiveMinimum": 0
                  }
               ]
            }
         ]
      },
      "padding": {
         "title": "Padding",
         "description": "How many pixels are windows allowed to overflow the edges of the raster source.",
         "anyOf": [
            {
               "type": "integer",
               "minimum": 0
            },
            {
               "type": "array",
               "minItems": 2,
               "maxItems": 2,
               "items": [
                  {
                     "type": "integer",
                     "minimum": 0
                  },
                  {
                     "type": "integer",
                     "minimum": 0
                  }
               ]
            }
         ]
      },
      "pad_direction": {
         "title": "Pad Direction",
         "description": "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\".",
         "default": "end",
         "enum": [
            "both",
            "start",
            "end"
         ],
         "type": "string"
      },
      "size_lims": {
         "title": "Size Lims",
         "description": "[min, max) interval from which window sizes will be uniformly randomly sampled. The upper limit is exclusive. To fix the size to a constant value, use size_lims = (sz, sz + 1). Only used if method = random. Specify either size_lims or h_lims and w_lims, but not both. If neither size_lims nor h_lims and w_lims have been specified, then this will be set to (size, size + 1).",
         "type": "array",
         "minItems": 2,
         "maxItems": 2,
         "items": [
            {
               "type": "integer",
               "exclusiveMinimum": 0
            },
            {
               "type": "integer",
               "exclusiveMinimum": 0
            }
         ]
      },
      "h_lims": {
         "title": "H Lims",
         "description": "[min, max] interval from which window heights will be uniformly randomly sampled. Only used if method = random.",
         "type": "array",
         "minItems": 2,
         "maxItems": 2,
         "items": [
            {
               "type": "integer",
               "exclusiveMinimum": 0
            },
            {
               "type": "integer",
               "exclusiveMinimum": 0
            }
         ]
      },
      "w_lims": {
         "title": "W Lims",
         "description": "[min, max] interval from which window widths will be uniformly randomly sampled. Only used if method = random.",
         "type": "array",
         "minItems": 2,
         "maxItems": 2,
         "items": [
            {
               "type": "integer",
               "exclusiveMinimum": 0
            },
            {
               "type": "integer",
               "exclusiveMinimum": 0
            }
         ]
      },
      "max_windows": {
         "title": "Max Windows",
         "description": "Max allowed reads from a GeoDataset. Only used if method = random.",
         "default": 10000,
         "minimum": 0,
         "type": "integer"
      },
      "max_sample_attempts": {
         "title": "Max Sample Attempts",
         "description": "Max attempts when trying to find a window within the AOI of a scene. Only used if method = random and the scene has aoi_polygons specified.",
         "default": 100,
         "exclusiveMinimum": 0,
         "type": "integer"
      },
      "efficient_aoi_sampling": {
         "title": "Efficient Aoi Sampling",
         "description": "If the scene has AOIs, sampling windows at random anywhere in the extent and then checking if they fall within any of the AOIs can be very inefficient. This flag enables the use of an alternate algorithm that only samples window locations inside the AOIs. Only used if method = random and the scene has aoi_polygons specified. Defaults to True",
         "default": true,
         "type": "boolean"
      },
      "type_hint": {
         "title": "Type Hint",
         "default": "object_detection_geo_data_window",
         "enum": [
            "object_detection_geo_data_window"
         ],
         "type": "string"
      },
      "ioa_thresh": {
         "title": "Ioa Thresh",
         "description": "When a box is partially outside of a training chip, it is not clear if (a clipped version) of the box should be included in the chip. If the IOA (intersection over area) of the box with the chip is greater than ioa_thresh, it is included in the chip. Defaults to 0.8.",
         "default": 0.8,
         "type": "number"
      },
      "clip": {
         "title": "Clip",
         "description": "Clip bounding boxes to window limits when retrieving labels for a window.",
         "default": false,
         "type": "boolean"
      },
      "neg_ratio": {
         "title": "Neg Ratio",
         "description": "The ratio of negative chips (those containing no bounding boxes) to positive chips. This can be useful if the statistics of the background is different in positive chips. For example, in car detection, the positive chips will always contain roads, but no examples of rooftops since cars tend to not be near rooftops. Defaults to None.",
         "type": "number"
      },
      "neg_ioa_thresh": {
         "title": "Neg Ioa Thresh",
         "description": "A window will be considered negative if its max IoA with any bounding box is less than this threshold. Defaults to 0.2.",
         "default": 0.2,
         "type": "number"
      }
   },
   "required": [
      "size"
   ],
   "additionalProperties": false,
   "definitions": {
      "GeoDataWindowMethod": {
         "title": "GeoDataWindowMethod",
         "description": "An enumeration.",
         "enum": [
            "sliding",
            "random"
         ]
      }
   }
}

Config
  • extra: str = forbid

  • validate_assignment: bool = True

Fields
field clip: bool = False#

Clip bounding boxes to window limits when retrieving labels for a window.

Validated by
  • validate_options

field efficient_aoi_sampling: bool = True#

If the scene has AOIs, sampling windows at random anywhere in the extent and then checking if they fall within any of the AOIs can be very inefficient. This flag enables the use of an alternate algorithm that only samples window locations inside the AOIs. Only used if method = random and the scene has aoi_polygons specified. Defaults to True

Validated by
  • validate_options

field h_lims: Optional[Tuple[PosInt, PosInt]] = None#

[min, max] interval from which window heights will be uniformly randomly sampled. Only used if method = random.

Validated by
  • validate_options

field ioa_thresh: float = 0.8#

When a box is partially outside of a training chip, it is not clear if (a clipped version) of the box should be included in the chip. If the IOA (intersection over area) of the box with the chip is greater than ioa_thresh, it is included in the chip. Defaults to 0.8.

Validated by
  • validate_options

field max_sample_attempts: PosInt = 100#

Max attempts when trying to find a window within the AOI of a scene. Only used if method = random and the scene has aoi_polygons specified.

Constraints
  • exclusiveMinimum = 0

Validated by
  • validate_options

field max_windows: NonNegInt = 10000#

Max allowed reads from a GeoDataset. Only used if method = random.

Constraints
  • minimum = 0

Validated by
  • validate_options

field method: GeoDataWindowMethod = GeoDataWindowMethod.sliding#
Validated by
  • validate_options

field neg_ioa_thresh: float = 0.2#

A window will be considered negative if its max IoA with any bounding box is less than this threshold. Defaults to 0.2.

Validated by
  • validate_options

field neg_ratio: Optional[float] = None#

The ratio of negative chips (those containing no bounding boxes) to positive chips. This can be useful if the statistics of the background is different in positive chips. For example, in car detection, the positive chips will always contain roads, but no examples of rooftops since cars tend to not be near rooftops. Defaults to None.

Validated by
  • validate_options

field pad_direction: Literal['both', 'start', 'end'] = '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”.

Validated by
  • validate_options

field padding: Optional[Union[NonNegInt, Tuple[NonNegInt, NonNegInt]]] = None#

How many pixels are windows allowed to overflow the edges of the raster source.

Validated by
  • validate_options

field size: Union[PosInt, Tuple[PosInt, PosInt]] [Required]#

If method = sliding, this is the size of sliding window. If method = random, this is the size that all the windows are resized to before they are returned. If method = random and neither size_lims nor h_lims and w_lims have been specified, then size_lims is set to (size, size + 1).

Validated by
  • validate_options

field size_lims: Optional[Tuple[PosInt, PosInt]] = None#

[min, max) interval from which window sizes will be uniformly randomly sampled. The upper limit is exclusive. To fix the size to a constant value, use size_lims = (sz, sz + 1). Only used if method = random. Specify either size_lims or h_lims and w_lims, but not both. If neither size_lims nor h_lims and w_lims have been specified, then this will be set to (size, size + 1).

Validated by
  • validate_options

field stride: Optional[Union[PosInt, Tuple[PosInt, PosInt]]] = None#

Stride of sliding window. Only used if method = sliding.

Validated by
  • validate_options

field type_hint: Literal['object_detection_geo_data_window'] = 'object_detection_geo_data_window'#
Validated by
  • validate_options

field w_lims: Optional[Tuple[PosInt, PosInt]] = None#

[min, max] interval from which window widths will be uniformly randomly sampled. Only used if method = random.

Validated by
  • validate_options

build()#

Build an instance of the corresponding type of object using this config.

For example, BackendConfig will build a Backend object. The arguments to this method will vary depending on the type of Config.

recursive_validate_config()#

Recursively validate hierarchies of Configs.

This uses reflection to call validate_config on a hierarchy of Configs using a depth-first pre-order traversal.

revalidate()#

Re-validate an instantiated Config.

Runs all Pydantic validators plus self.validate_config().

Adapted from: https://github.com/samuelcolvin/pydantic/issues/1864#issuecomment-679044432

update(*args, **kwargs)#

Update any fields before validation.

Subclasses should override this to provide complex default behavior, for example, setting default values as a function of the values of other fields. The arguments to this method will vary depending on the type of Config.

validate_config()#

Validate fields that should be checked after update is called.

This is to complement the builtin validation that Pydantic performs at the time of object construction.

validate_list(field: str, valid_options: List[str])#

Validate a list field.

Parameters
  • field (str) – name of field to validate

  • valid_options (List[str]) – values that field is allowed to take

Raises

ConfigError – if field is invalid

validator validate_options  »  all fields#
Parameters

values (dict) –

Return type

dict