ChipClassificationLabelSourceConfig#

Note

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

pydantic model ChipClassificationLabelSourceConfig[source]#

Configure a ChipClassificationLabelSource.

This can be provided explicitly as a grid of cells, or a grid of cells can be inferred from arbitrary polygons.

Show JSON schema
{
   "title": "ChipClassificationLabelSourceConfig",
   "description": "Configure a :class:`.ChipClassificationLabelSource`.\n\nThis can be provided explicitly as a grid of cells, or a grid of cells can\nbe inferred from arbitrary polygons.",
   "type": "object",
   "properties": {
      "type_hint": {
         "title": "Type Hint",
         "default": "chip_classification_label_source",
         "enum": [
            "chip_classification_label_source"
         ],
         "type": "string"
      },
      "vector_source": {
         "$ref": "#/definitions/VectorSourceConfig"
      },
      "ioa_thresh": {
         "title": "Ioa Thresh",
         "description": "Minimum IOA of a polygon and cell for that polygon to be a candidate for setting the class_id.",
         "default": 0.5,
         "type": "number"
      },
      "use_intersection_over_cell": {
         "title": "Use Intersection Over Cell",
         "description": "If True, then use the area of the cell as the denominator in the IOA. Otherwise, use the area of the polygon.",
         "default": false,
         "type": "boolean"
      },
      "pick_min_class_id": {
         "title": "Pick Min Class Id",
         "description": "If True, the class_id for a cell is the minimum class_id of the boxes in that cell. Otherwise, pick the class_id of the box covering the greatest area.",
         "default": false,
         "type": "boolean"
      },
      "background_class_id": {
         "title": "Background Class Id",
         "description": "If not None, class_id to use as the background class; ie. the one that is used when a window contains no boxes. Cannot be None if infer_cells=True.",
         "type": "integer"
      },
      "infer_cells": {
         "title": "Infer Cells",
         "description": "If True, infers a grid of cells based on the cell_sz.",
         "default": false,
         "type": "boolean"
      },
      "cell_sz": {
         "title": "Cell Sz",
         "description": "Size of a cell to use in pixels. If None, and this Config is part of an RVPipeline, this field will be set from RVPipeline.chip_options.",
         "type": "integer"
      },
      "lazy": {
         "title": "Lazy",
         "description": "If True, labels will not be populated automatically during initialization of the label source.",
         "default": false,
         "type": "boolean"
      }
   },
   "additionalProperties": false,
   "definitions": {
      "VectorTransformerConfig": {
         "title": "VectorTransformerConfig",
         "description": "Configure a :class:`.VectorTransformer`.",
         "type": "object",
         "properties": {
            "type_hint": {
               "title": "Type Hint",
               "default": "vector_transformer",
               "enum": [
                  "vector_transformer"
               ],
               "type": "string"
            }
         },
         "additionalProperties": false
      },
      "VectorSourceConfig": {
         "title": "VectorSourceConfig",
         "description": "Configure a :class:`.VectorSource`.",
         "type": "object",
         "properties": {
            "transformers": {
               "title": "Transformers",
               "description": "List of VectorTransformers.",
               "default": [],
               "type": "array",
               "items": {
                  "$ref": "#/definitions/VectorTransformerConfig"
               }
            },
            "type_hint": {
               "title": "Type Hint",
               "default": "vector_source",
               "enum": [
                  "vector_source"
               ],
               "type": "string"
            }
         },
         "additionalProperties": false
      }
   }
}

Config
  • extra: str = forbid

  • validate_assignment: bool = True

Fields
Validators
field background_class_id: Optional[int] = None#

If not None, class_id to use as the background class; ie. the one that is used when a window contains no boxes. Cannot be None if infer_cells=True.

Validated by
field cell_sz: Optional[int] = None#

Size of a cell to use in pixels. If None, and this Config is part of an RVPipeline, this field will be set from RVPipeline.chip_options.

Validated by
field infer_cells: bool = False#

If True, infers a grid of cells based on the cell_sz.

Validated by
field ioa_thresh: float = 0.5#

Minimum IOA of a polygon and cell for that polygon to be a candidate for setting the class_id.

Validated by
field lazy: bool = False#

If True, labels will not be populated automatically during initialization of the label source.

Validated by
field pick_min_class_id: bool = False#

If True, the class_id for a cell is the minimum class_id of the boxes in that cell. Otherwise, pick the class_id of the box covering the greatest area.

Validated by
field type_hint: Literal['chip_classification_label_source'] = 'chip_classification_label_source'#
Validated by
field use_intersection_over_cell: bool = False#

If True, then use the area of the cell as the denominator in the IOA. Otherwise, use the area of the polygon.

Validated by
field vector_source: Optional[VectorSourceConfig] = None#
Validated by
build(class_config, crs_transformer, bbox=None, tmp_dir=None) ChipClassificationLabelSource[source]#

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.

Return type

ChipClassificationLabelSource

classmethod deserialize(inp: str | dict | Config) Self#

Deserialize Config from a JSON file or dict, upgrading if possible.

If inp is already a Config, it is returned as is.

Parameters

inp (str | dict | Config) – a URI to a JSON file or a dict.

Return type

Self

validator ensure_bg_class_id_if_inferring  »  all fields[source]#
Parameters

values (dict) –

Return type

dict

validator ensure_required_transformers  »  vector_source[source]#

Add class-inference and buffer transformers if absent.

Parameters

v (VectorSourceConfig) –

Return type

VectorSourceConfig

classmethod from_dict(cfg_dict: dict) Self#

Deserialize Config from a dict.

Parameters

cfg_dict (dict) – Dict to deserialize.

Return type

Self

classmethod from_file(uri: str) Self#

Deserialize Config from a JSON file, upgrading if possible.

Parameters

uri (str) – URI to load from.

Return type

Self

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

to_file(uri: str, with_rv_metadata: bool = True) None#

Save a Config to a JSON file, optionally with RV metadata.

Parameters
  • uri (str) – URI to save to.

  • with_rv_metadata (bool) – If True, inject Raster Vision metadata such as plugin_versions, so that the config can be upgraded when loaded.

Return type

None

update(pipeline=None, scene=None)[source]#

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