PlotOptions#

Note

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

pydantic model PlotOptions[source]#

Config related to plotting.

Show JSON schema
{
   "title": "PlotOptions",
   "description": "Config related to plotting.",
   "type": "object",
   "properties": {
      "transform": {
         "anyOf": [
            {
               "type": "object"
            },
            {
               "type": "null"
            }
         ],
         "default": {
            "__version__": "1.4.14",
            "transform": {
               "__class_fullname__": "rastervision.pytorch_learner.utils.utils.MinMaxNormalize",
               "dtype": 5,
               "max_val": 1.0,
               "min_val": 0.0,
               "p": 1.0
            }
         },
         "description": "An Albumentations transform serialized as a dict that will be applied to each image before it is plotted. Mainly useful for undoing any data transformation that you do not want included in the plot, such as normalization. The default value will shift and scale the image so the values range from 0.0 to 1.0 which is the expected range for the plotting function. This default is useful for cases where the values after normalization are close to zero which makes the plot difficult to see.",
         "title": "Transform"
      },
      "channel_display_groups": {
         "anyOf": [
            {
               "additionalProperties": {
                  "items": {
                     "minimum": 0,
                     "type": "integer"
                  },
                  "type": "array"
               },
               "type": "object"
            },
            {
               "items": {
                  "items": {
                     "minimum": 0,
                     "type": "integer"
                  },
                  "type": "array"
               },
               "type": "array"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "description": "Groups of image channels to display together as a subplot when plotting the data and predictions. Can be a list or tuple of groups (e.g. [(0, 1, 2), (3,)]) or a dict containing title-to-group mappings (e.g. {\"RGB\": [0, 1, 2], \"IR\": [3]}), where each group is a list or tuple of channel indices and title is a string that will be used as the title of the subplot for that group.",
         "title": "Channel Display Groups"
      },
      "type_hint": {
         "const": "plot_options",
         "default": "plot_options",
         "enum": [
            "plot_options"
         ],
         "title": "Type Hint",
         "type": "string"
      }
   },
   "additionalProperties": false
}

Config:
  • extra: str = forbid

  • validate_assignment: bool = True

Fields:
Validators:
field channel_display_groups: dict[str, ChannelInds] | Sequence[ChannelInds] | None = None#

Groups of image channels to display together as a subplot when plotting the data and predictions. Can be a list or tuple of groups (e.g. [(0, 1, 2), (3,)]) or a dict containing title-to-group mappings (e.g. {“RGB”: [0, 1, 2], “IR”: [3]}), where each group is a list or tuple of channel indices and title is a string that will be used as the title of the subplot for that group.

Validated by:
field transform: dict | None = {'__version__': '1.4.14', 'transform': {'__class_fullname__': 'rastervision.pytorch_learner.utils.utils.MinMaxNormalize', 'dtype': 5, 'max_val': 1.0, 'min_val': 0.0, 'p': 1.0}}#

An Albumentations transform serialized as a dict that will be applied to each image before it is plotted. Mainly useful for undoing any data transformation that you do not want included in the plot, such as normalization. The default value will shift and scale the image so the values range from 0.0 to 1.0 which is the expected range for the plotting function. This default is useful for cases where the values after normalization are close to zero which makes the plot difficult to see.

Validated by:
field type_hint: Literal['plot_options'] = 'plot_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.

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

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().

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(**kwargs) 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.

Return type:

None

validator validate_channel_display_groups  »  channel_display_groups[source]#
Parameters:

v (Optional[Union[dict[str, Sequence[int]], Sequence[Sequence[int]]]]) –

Return type:

dict[str, Sequence[int]] | None

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