SemanticSegmentationLabelStoreConfig#

Note

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

pydantic model SemanticSegmentationLabelStoreConfig[source]#

Configure a SemanticSegmentationLabelStore.

Stores class raster as GeoTIFF, and can optionally vectorizes predictions and stores them in GeoJSON files.

Show JSON schema
{
   "title": "SemanticSegmentationLabelStoreConfig",
   "description": "Configure a :class:`.SemanticSegmentationLabelStore`.\n\nStores class raster as GeoTIFF, and can optionally vectorizes predictions and stores\nthem in GeoJSON files.",
   "type": "object",
   "properties": {
      "type_hint": {
         "title": "Type Hint",
         "default": "semantic_segmentation_label_store",
         "enum": [
            "semantic_segmentation_label_store"
         ],
         "type": "string"
      },
      "uri": {
         "title": "Uri",
         "description": "URI of file with predictions. If None, and this Config is part of a SceneConfig inside an RVPipelineConfig, this fiend will be auto-generated.",
         "type": "string"
      },
      "vector_output": {
         "title": "Vector Output",
         "default": [],
         "type": "array",
         "items": {
            "$ref": "#/definitions/VectorOutputConfig"
         }
      },
      "rgb": {
         "title": "Rgb",
         "description": "If True, save prediction class_ids in RGB format using the colors in class_config.",
         "default": false,
         "type": "boolean"
      },
      "smooth_output": {
         "title": "Smooth Output",
         "description": "If True, expects labels to be continuous values representing class scores and stores both scores and discrete labels.",
         "default": false,
         "type": "boolean"
      },
      "smooth_as_uint8": {
         "title": "Smooth As Uint8",
         "description": "If True, stores smooth scores as uint8, resulting in loss of precision, but reduced file size. Only used if smooth_output=True.",
         "default": false,
         "type": "boolean"
      },
      "rasterio_block_size": {
         "title": "Rasterio Block Size",
         "description": "blockxsize and blockysize params in rasterio.open() will be set to this.",
         "default": 256,
         "type": "integer"
      }
   },
   "additionalProperties": false,
   "definitions": {
      "VectorOutputConfig": {
         "title": "VectorOutputConfig",
         "description": "Config for vectorized semantic segmentation predictions.",
         "type": "object",
         "properties": {
            "class_id": {
               "title": "Class Id",
               "description": "The prediction class that is to turned into vectors.",
               "type": "integer"
            },
            "denoise": {
               "title": "Denoise",
               "description": "Diameter of the circular structural element used to remove high-frequency signals from the image. Smaller values will reduce less noise and make vectorization slower and more memory intensive (especially for large images). Larger values will remove more noise and make vectorization faster but might also remove legitimate detections.",
               "default": 8,
               "type": "integer"
            },
            "threshold": {
               "title": "Threshold",
               "description": "Probability threshold for creating the binary mask for the pixels of this class. Pixels will be considered to belong to this class if their probability for this class is >= ``threshold``. Note that Raster Vision treats classes as mutually exclusive so the threshold should vary with the number of total classes. ``None`` is equivalent to setting this to (1 / num_classes). Defaults to ``None``.",
               "type": "number"
            },
            "type_hint": {
               "title": "Type Hint",
               "default": "vector_output",
               "enum": [
                  "vector_output"
               ],
               "type": "string"
            }
         },
         "required": [
            "class_id"
         ],
         "additionalProperties": false
      }
   }
}

Config
  • extra: str = forbid

  • validate_assignment: bool = True

Fields
field rasterio_block_size: int = 256#

blockxsize and blockysize params in rasterio.open() will be set to this.

field rgb: bool = False#

If True, save prediction class_ids in RGB format using the colors in class_config.

field smooth_as_uint8: bool = False#

If True, stores smooth scores as uint8, resulting in loss of precision, but reduced file size. Only used if smooth_output=True.

field smooth_output: bool = False#

If True, expects labels to be continuous values representing class scores and stores both scores and discrete labels.

field type_hint: Literal['semantic_segmentation_label_store'] = 'semantic_segmentation_label_store'#
field uri: Optional[str] = None#

URI of file with predictions. If None, and this Config is part of a SceneConfig inside an RVPipelineConfig, this fiend will be auto-generated.

field vector_output: List[VectorOutputConfig] = []#
build(class_config: ClassConfig, crs_transformer: CRSTransformer, bbox: Box, tmp_dir: Optional[str] = None) SemanticSegmentationLabelStore[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.

Parameters
Return type

SemanticSegmentationLabelStore

classmethod from_file(uri: str) Config#

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

Parameters

uri (str) – URI to load from.

Return type

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

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: Optional[RVPipelineConfig] = None, scene: Optional[SceneConfig] = 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.

Parameters
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