API Reference

This API documentation is not exhaustive, but covers most of the public API that is important to typical Raster Vision usage.

ExperimentConfigBuilder

An ExperimentConfigBuilder is created by calling

rv.ExperimentConfig.builder()
class rastervision.experiment.ExperimentConfigBuilder(prev=None)
build()

Returns the configuration that is built by this builder.

with_analyze_key(key)

Sets the key associated with the analysis stage.

with_analyze_uri(uri)

Sets the location where the results of the analysis stage will be stored.

with_analyzer(analyzer)

Add an analyzer to be used in the analysis stage.

with_analyzers(analyzers)

Add analyzers to be used in the analysis stage.

with_backend(backend)

Specifies the backend to be used, e.g. rv.TF_DEEPLAB.

with_bundle_key(key)

Sets the key associated with the bundling stage.

with_bundle_uri(uri)

Sets the location where the results of the bundling stage will be stored.

with_chip_key(key)

Sets the key associated with the “chip” stage.

with_chip_uri(uri)

Sets the location where the results of the “chip” stage will be stored.

with_dataset(dataset)

Specifies the dataset to be used.

with_eval_key(key)

Sets the key associated with the evaluation stage.

with_eval_uri(uri)

Sets the location where the results of the evaluation stage will be stored.

with_evaluator(evaluator)

Sets the evaluator to use for the evaluation stage.

with_evaluators(evaluators)

Sets the evaluators to use for the evaluation stage.

with_id(id)

Sets an id for the experiment.

with_predict_key(key)

Sets the key associated with the prediction stage.

with_predict_uri(uri)

Sets the location where the results of the prediction stage will be stored.

with_root_uri(uri)

Sets the root directory where all output will be stored unless subsequently overridden.

with_stats_analyzer()

Add a stats analyzer to be used in the analysis stage.

with_task(task)

Sets a specific task type.

Args:

task: A TaskConfig object.

with_train_key(key)

Sets the key associated with the training stage.

with_train_uri(uri)

Sets the location where the results of the training stage will be stored.

DatasetConfigBuilder

A DatasetConfigBuilder is created by calling

rv.DatasetConfig.builder()
class rastervision.data.DatasetConfigBuilder(prev=None)
build()

Returns the configuration that is built by this builder.

with_augmentor(augmentor)

Sets the data augmentor to be used.

with_augmentors(augmentors)

Sets the data augmentors to be used.

with_test_scene(scene)

Sets the scene to be used for testing.

with_test_scenes(scenes)

Sets the scenes to be used for testing.

with_train_scene(scene)

Sets the scene to be used for training.

with_train_scenes(scenes)

Sets the scenes to be used for training.

with_validation_scene(scene)

Sets the scene to be used for validation.

with_validation_scenes(scenes)

Sets the scenes to be used for validation.

TaskConfigBuilder

TaskConfigBuilders are created by calling

rv.TaskConfig.builder(TASK_TYPE)

Where TASK_TYPE is one of the following:

rv.CHIP_CLASSIFICATION

class rastervision.task.ChipClassificationConfigBuilder(prev=None)
build()

Returns the configuration that is built by this builder.

with_chip_size(chip_size)

Set the chip_size for this task.

Args:

chip_size: Integer value chip size

with_classes(classes: Union[rastervision.core.class_map.ClassMap, List[str], List[rastervision.protos.class_item_pb2.ClassItem], List[rastervision.core.class_map.ClassItem], Dict[str, int], Dict[str, Tuple[int, str]]])

Set the classes for this task.

Args:
classes: Either a list of class names, a dict which

maps class names to class ids, or a dict which maps class names to a tuple of (class_id, color), where color is a PIL color string.

with_debug(debug)

Flag for producing debug products.

with_predict_batch_size(predict_batch_size)

Sets the batch size to use during prediction.

with_predict_debug_uri(predict_debug_uri)

Set the directory to place prediction debug images

with_predict_package_uri(predict_package_uri)

Sets the URI to save a predict package URI to during bundle.

rv.OBJECT_DETECTION

class rastervision.task.ObjectDetectionConfigBuilder(prev=None)
build()

Returns the configuration that is built by this builder.

with_chip_options(neg_ratio=1, ioa_thresh=0.8, window_method='chip', label_buffer=0.0)

Sets object detection configurations for the Chip command

Args:
neg_ratio: 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. This option is not used when window_method is sliding.

ioa_thresh: 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.

window_method: Different models in the Object Detection API have

different inputs. Some models allow variable size inputs so several methods of building training data are required

Valid values are: - chip (default) - label

  • each label’s bounding box is the positive window

  • image
    • each image is the positive window

  • sliding
    • each image is from a sliding window with 50% overlap

label_buffer:

If method is “label”, the positive window can be buffered. If value is >= 0. and < 1., the value is treated as a percentage If value is >= 1., the value is treated in number of pixels

with_chip_size(chip_size)

Set the chip_size for this task.

Args:

chip_size: Integer value chip size

with_classes(classes: Union[rastervision.core.class_map.ClassMap, List[str], List[rastervision.protos.class_item_pb2.ClassItem], List[rastervision.core.class_map.ClassItem], Dict[str, int], Dict[str, Tuple[int, str]]])

Set the classes for this task.

Args:
classes: Either a list of class names, a dict which

maps class names to class ids, or a dict which maps class names to a tuple of (class_id, color), where color is a PIL color string.

with_debug(debug)

Flag for producing debug products.

with_predict_batch_size(predict_batch_size)

Sets the batch size to use during prediction.

with_predict_debug_uri(predict_debug_uri)

Set the directory to place prediction debug images

with_predict_options(merge_thresh=0.5, score_thresh=0.5)

Prediction options for this task.

Args:
merge_thresh: If predicted boxes have an IOA (intersection over area)

greater than merge_thresh, then they are merged into a single box during postprocessing. This is needed since the sliding window approach results in some false duplicates.

score_thresh: Predicted boxes are only output if their score is

above score_thresh.

with_predict_package_uri(predict_package_uri)

Sets the URI to save a predict package URI to during bundle.

rv.SEMANTIC_SEGMENTATION

class rastervision.task.SemanticSegmentationConfigBuilder(prev=None)
build()

Returns the configuration that is built by this builder.

with_chip_options(window_method='random_sample', target_classes=None, debug_chip_probability=0.25, negative_survival_probability=1.0, chips_per_scene=1000, target_count_threshold=1000, stride=None)

Sets semantic segmentation configurations for the Chip command.

Args:
window_method: Window method to use for chipping. Options are:

random_sample, sliding

target_classes: list of class ids to train model on debug_chip_probability: probability of generating a debug chip.

Applies to the ‘random_sample’ window method.

negative_survival_probability: probability that a sampled negative

chip will be utilized if it does not contain more pixels than target_count_threshold. Applies to the ‘random_sample’ window method.

chips_per_scene: number of chips to generate per scene. Applies to

the ‘random_sample’ window method.

target_count_threshold: minimum number of pixels covering

target_classes that a chip must have. Applies to the ‘random_sample’ window method.

stride: Stride of windows across image. Defaults to half the chip

size. Applies to the ‘sliding_window’ method.

Returns:

SemanticSegmentationConfigBuilder

with_chip_size(chip_size)

Set the chip_size for this task.

Args:

chip_size: Integer value chip size

with_classes(classes: Union[rastervision.core.class_map.ClassMap, List[str], List[rastervision.protos.class_item_pb2.ClassItem], List[rastervision.core.class_map.ClassItem], Dict[str, int], Dict[str, Tuple[int, str]]])

Set the classes for this task.

Args:
classes: Either a list of class names, a dict which

maps class names to class ids, or a dict which maps class names to a tuple of (class_id, color), where color is a PIL color string.

with_debug(debug)

Flag for producing debug products.

with_predict_batch_size(predict_batch_size)

Sets the batch size to use during prediction.

with_predict_debug_uri(predict_debug_uri)

Set the directory to place prediction debug images

with_predict_package_uri(predict_package_uri)

Sets the URI to save a predict package URI to during bundle.

BackendConfig

BackendConfigBuilders are created by calling

rv.BackendConfig.builder(BACKEND_TYPE)

Where BACKEND_TYPE is one of the following:

rv.KERAS_CLASSIFICATION

class rastervision.backend.KerasClassificationConfigBuilder(prev=None)
build()

Build this configuration.

with_batch_size(batch_size)

Sets the training batch size.

with_config(config_mod, ignore_missing_keys=False, set_missing_keys=False)

Modify the backend configuration.

Given a dict, modify the tensorflow pipeline configuration such that keys that are found recursively in the configuration are replaced with those values. TODO: better explanation.

with_debug(debug)

Sets the debug flag for this backend.

with_model_defaults(model_defaults_key)

Sets the backend configuration and pretrained model defaults according to the model defaults configuration.

with_model_uri(model_uri)

Sets the filename of the trained model.

with_num_epochs(num_epochs)

Sets the number of training epochs.

with_pretrained_model(uri)

Set a pretrained model URI. The filetype and meaning for this model will be different based on the backend implementation.

with_task(task)

Sets a specific task type.

Args:

task: A TaskConfig object.

with_template(template)

Use a template as the base for configuring Keras Classification.

Args:

template: dict, string or uri

with_train_options(sync_interval=600, do_monitoring=True, replace_model=False)

Sets the train options for this backend.

Args:
sync_interval: How often to sync output of training to

the cloud (in seconds).

do_monitoring: Run process to monitor training (eg. Tensorboard)

replace_model: Replace the model checkpoint if exists.

If false, this will continue training from the checkpoint if it exists, if the backend allows for this.

with_training_data_uri(training_data_uri)

Whence comes the training data?

Args:

training_data_uri: The location of the training data.

with_training_output_uri(training_output_uri)

Whither goes the training output?

Args:
training_output_uri: The location where the training output will

be stored.

rv.TF_OBJECT_DETECTION

class rastervision.backend.TFObjectDetectionConfigBuilder(prev=None)
build()

Build this configuration.

Set any values into the TF object detection pipeline config as necessary.

with_batch_size(batch_size)

Sets the training batch size.

with_config(config_mod, ignore_missing_keys=False, set_missing_keys=False)

Given a dict, modify the tensorflow pipeline configuration.

Modify it such that keys that are found recursively in the configuration are replaced with those values. TODO: better explanation.

with_debug(debug)

Sets the debug flag for this backend.

with_fine_tune_checkpoint_name(fine_tune_checkpoint_name)

Defines the name of the fine tune checkpoint for this model.

with_model_defaults(model_defaults_key)

Sets the backend configuration and pretrained model defaults according to the model defaults configuration.

with_model_uri(model_uri)

Defines the name of the model file that will be created for this model after training.

with_num_steps(num_steps)

Sets the number of training steps.

with_pretrained_model(uri)

Set a pretrained model URI. The filetype and meaning for this model will be different based on the backend implementation.

with_script_locations(model_main_uri='/opt/tf-models/object_detection/model_main.py', export_uri='/opt/tf-models/object_detection/export_inference_graph.py')
with_task(task)

Sets a specific task type.

Args:

task: A TaskConfig object.

with_template(template)

Use a template for TF Object Detection pipeline config.

Args:
template: A dict, string or uri as the base for the TF

Object Detection API model training pipeline, for example those found here: https://github.com/tensorflow/models/tree/eef6bb5bd3b3cd5fcf54306bf29750b7f9f9a5ea/research/object_detection/samples/configs # noqa

with_train_options(sync_interval=600, do_monitoring=True, replace_model=False)

Sets the train options for this backend.

Args:
sync_interval: How often to sync output of training

to the cloud (in seconds).

do_monitoring: Run process to monitor training (eg. Tensorboard)

replace_model: Replace the model checkpoint if exists.

If false, this will continue training from checkpoing if exists, if the backend allows for this.

with_training_data_uri(training_data_uri)

Whence comes the training data?

Args:

training_data_uri: The location of the training data.

with_training_output_uri(training_output_uri)

Whither goes the training output?

Args:
training_output_uri: The location where the training

output will be stored.

rv.TF_DEEPLAB

class rastervision.backend.TFDeeplabConfigBuilder(prev=None)
build()

Build this configuration.

with_batch_size(batch_size)

Sets the training batch size.

with_config(config_mod, ignore_missing_keys=False, set_missing_keys=False)

Given a dict, modify the tensorflow pipeline configuration.

Modify it such that keys that are found recursively in the configuration are replaced with those values.

with_debug(debug)

Sets the debug flag for this backend.

with_fine_tune_checkpoint_name(fine_tune_checkpoint_name)

Sets the name of the fine tune checkpoint for the model.

with_model_defaults(model_defaults_key)

Sets the backend configuration and pretrained model defaults according to the model defaults configuration.

with_model_uri(model_uri)

Sets the filename for the model that will be trained.

with_num_clones(num_clones)

Sets the number of clones (useful for multi-GPU training).

with_num_steps(num_steps)

Sets the number of training steps.

with_pretrained_model(uri)

Set a pretrained model URI. The filetype and meaning for this model will be different based on the backend implementation.

with_script_locations(train_py='/opt/tf-models/deeplab/train.py', export_py='/opt/tf-models/deeplab/export_model.py', eval_py='/opt/tf-models/deeplab/eval.py')
with_task(task)

Sets a specific task type.

Args:

task: A TaskConfig object.

with_template(template)

Use a TFDL config template from dict, string or uri.

with_train_options(train_restart_dir=None, sync_interval=600, do_monitoring=True, replace_model=False, do_eval=False)

Sets the train options for this backend.

Args:
sync_interval: How often to sync output of training to the cloud

(in seconds).

do_monitoring: Run process to monitor training (eg. Tensorboard) replace_model: Replace the model checkpoint if exists.

If false, this will continue training from checkpoint if exists, if the backend allows for this.

do_eval: Boolean determining whether to run the eval

script.

with_training_data_uri(training_data_uri)

Whence comes the training data?

Args:

training_data_uri: The location of the training data.

with_training_output_uri(training_output_uri)

Whither goes the training output?

Args:
training_output_uri: The location where the training

output will be stored.

SceneConfig

SceneConfigBuilders are created by calling

rv.SceneConfig.builder()
class rastervision.data.SceneConfigBuilder(prev=None)
build()

Returns the configuration that is built by this builder.

clear_aois()

Clears the AOIs for this scene

clear_label_source()

Clears the label source for this scene

clear_label_store()

Clears the label store for this scene

with_aoi_uri(uri)

Sets the Area of Interest for the scene.

Args:

uri: a URI of a GeoJSON file with polygons.

with_aoi_uris(uris)

Sets the areas of interest for the scene.

Args:

uris: List of URIs each to a GeoJSON file with polygons.

with_id(id)

Sets an id for the scene.

with_label_source(label_source: Union[str, rastervision.data.label_source.label_source_config.LabelSourceConfig])

Sets the raster source for this scene.

Args:
label_source: Can either be a label source configuration, or

a string. If a string, the registry will be queried to grab the default LabelSourceConfig for the string.

Note:

A task must be set with with_task before calling this, if calling with a string.

with_label_store(label_store: Union[str, rastervision.data.label_store.label_store_config.LabelStoreConfig, None] = None)

Sets the raster store for this scene.

Args:
label_store: Can either be a label store configuration, or

a string, or None. If a string, the registry will be queried to grab the default LabelStoreConfig for the string. If None, then the default for the task from the regsitry will be used.

Note:

A task must be set with with_task before calling this, if calling with a string.

with_raster_source(raster_source: Union[str, rastervision.data.raster_source.raster_source_config.RasterSourceConfig], channel_order=None)

Sets the raster source for this scene.

Args:
raster_source: Can either be a raster source configuration, or

a string. If a string, the registry will be queried to grab the default RasterSourceConfig for the string.

channel_order: Optional channel order for this raster source.

with_task(task)

Sets a specific task type, e.g. rv.OBJECT_DETECTION.

RasterSourceConfig

RasterSourceConfigBuilders are created by calling

rv.RasterSourceConfig.builder(SOURCE_TYPE)

Where SOURCE_TYPE is one of the following:

rv.RASTERIO_SOURCE

class rastervision.data.RasterioSourceConfigBuilder(prev=None)

This RasterSource can read any file that can be opened by Rasterio/GDAL.

This includes georeferenced formats such as GeoTIFF and non-georeferenced formats such as JPG. See https://www.gdal.org/formats_list.html for more details.

build()

Returns the configuration that is built by this builder.

with_channel_order(channel_order)

Defines the channel order for this raster source.

This defines the subset of channel indices and their order to use when extracting chips from raw imagery.

Args:

channel_order: list of channel indices

with_shifts(x, y)

Set the x- and y-shifts in meters.

This will only have an effect on georeferenced imagery.

Args:
x: A number of meters to shift along the x-axis. A

positive shift moves the “camera” to the right.

y: A number of meters to shift along the y-axis. A

positive shift moves the “camera” down.

with_stats_transformer()

Add a stats transformer to the raster source.

with_transformer(transformer)

A transformer to be applied to the raster data.

Args:
transformer: A transformer to apply to the raster

data.

with_transformers(transformers)

Transformers to be applied to the raster data.

Args:
transformers: A list of transformers to apply to the

raster data.

with_uri(uri)

Set URI for raster files that can be read by Rasterio.

with_uris(uris)

Set URIs for raster files that can be read by Rasterio.

rv.RASTERIZED_SOURCE

class rastervision.data.RasterizedSourceConfigBuilder(prev=None)
build()

Returns the configuration that is built by this builder.

with_channel_order(channel_order)

Defines the channel order for this raster source.

This defines the subset of channel indices and their order to use when extracting chips from raw imagery.

Args:

channel_order: list of channel indices

with_rasterizer_options(background_class_id)

Specify options for converting GeoJSON to raster.

Args:
background_class_id: The class_id to use for background pixels that don’t

overlap with any shapes in the GeoJSON file.

with_stats_transformer()

Add a stats transformer to the raster source.

with_transformer(transformer)

A transformer to be applied to the raster data.

Args:
transformer: A transformer to apply to the raster

data.

with_transformers(transformers)

Transformers to be applied to the raster data.

Args:
transformers: A list of transformers to apply to the

raster data.

with_uri(uri)
with_vector_source(vector_source)

Set the vector_source.

Args:
vector_source (str or VectorSource) if a string, assume it is

a URI and use the default provider to construct a VectorSource.

LabelSourceConfig

LabelSourceConfigBuilders are created by calling

rv.LabelSourceConfig.builder(SOURCE_TYPE)

Where SOURCE_TYPE is one of the following:

rv.CHIP_CLASSIFICATION

class rastervision.data.ChipClassificationLabelSourceConfigBuilder(prev=None)
build()

Returns the configuration that is built by this builder.

with_background_class_id(background_class_id)

Sets the background class ID.

Optional class_id to use as the background class; ie. the one that is used when a window contains no boxes. If not set, empty windows have None set as their class_id.

with_cell_size(cell_size)

Sets the cell size of the chips.

with_infer_cells(infer_cells)

Set if this label source should infer cells.

If true, the label source will infer the cell polygon and label from the polygons in the vector_source. If the labels are already cells and properly labeled, this can be False.

with_ioa_thresh(ioa_thresh)

The minimum IOA of a polygon and cell.

with_pick_min_class_id(pick_min_class_id)

Set this label source to pick min class ID

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.

with_uri(uri)
with_use_intersection_over_cell(use_intersection_over_cell)

Set this label source to use intersection over cell or not.

If use_intersection_over_cell is true, then use the area of the cell as the denominator in the IOA. Otherwise, use the area of the polygon.

with_vector_source(vector_source)

Set the vector_source.

Args:
vector_source (str or VectorSource) if a string, assume it is

a URI and use the default provider to construct a VectorSource.

rv.OBJECT_DETECTION

class rastervision.data.ObjectDetectionLabelSourceConfigBuilder(prev=None)
build()

Returns the configuration that is built by this builder.

with_uri(uri)
with_vector_source(vector_source)

Set the vector_source.

Args:
vector_source (str or VectorSource) if a string, assume it is

a URI and use the default provider to construct a VectorSource.

rv.SEMANTIC_SEGMENTATION

class rastervision.data.SemanticSegmentationLabelSourceConfigBuilder(prev=None)
build()

Returns the configuration that is built by this builder.

with_raster_source(source, channel_order=None)

Set raster_source.

Args:
source: (RasterSourceConfig) A RasterSource assumed to have RGB values that

are mapped to class_ids using the rgb_class_map.

Returns:

SemanticSegmentationLabelSourceConfigBuilder

with_rgb_class_map(rgb_class_map)

Set rgb_class_map.

Args:
rgb_class_map: (something accepted by ClassMap.construct_from) a class

map with color values used to map RGB values to class ids

Returns:

SemanticSegmentationLabelSourceConfigBuilder

VectorSourceConfig

VectorSourceConfigBuilders are created by calling

rv.VectorSourceConfig.builder(SOURCE_TYPE)

Where SOURCE_TYPE is one of the following:

rv.GEOJSON_SOURCE

class rastervision.data.GeoJSONVectorSourceConfigBuilder(prev=None)
build()

Returns the configuration that is built by this builder.

with_buffers(line_bufs=None, point_bufs=None)

Set options for buffering lines and points into polygons.

For example, this is useful for buffering lines representing roads so that their width roughly matches the width of roads in the imagery.

Args:
line_bufs: (dict or None) If none, uses default buffer value of 1.

Otherwise, a map from class_id to number of pixels to buffer by. If the buffer value is None, then no buffering will be performed and the LineString or Point won’t get converted to a Polygon. Not converting to Polygon is incompatible with the currently available LabelSources, but may be useful in the future.

point_bufs: (dict or None) same as above, but used for buffering

Points into Polygons.

with_class_inference(class_id_to_filter=None, default_class_id=1)

Set options for inferring the class of each feature.

For more info on how class inference works, see ClassInference.infer_class()

Args:
class_id_to_filter: (dict) map from class_id to JSON filter.

The filter schema is according to https://github.com/mapbox/mapbox-gl-js/blob/c9900db279db776f493ce8b6749966cedc2d6b8a/src/style-spec/feature_filter/index.js # noqa

default_class_id: (int) the default class_id to use if class can’t be

inferred using other mechanisms. If a feature defaults to a class_id of None, then that feature will be deleted.

with_uri(uri)

rv.VECTOR_TILE_SOURCE

class rastervision.data.VectorTileVectorSourceConfigBuilder(prev=None)
build()

Returns the configuration that is built by this builder.

with_buffers(line_bufs=None, point_bufs=None)

Set options for buffering lines and points into polygons.

For example, this is useful for buffering lines representing roads so that their width roughly matches the width of roads in the imagery.

Args:
line_bufs: (dict or None) If none, uses default buffer value of 1.

Otherwise, a map from class_id to number of pixels to buffer by. If the buffer value is None, then no buffering will be performed and the LineString or Point won’t get converted to a Polygon. Not converting to Polygon is incompatible with the currently available LabelSources, but may be useful in the future.

point_bufs: (dict or None) same as above, but used for buffering

Points into Polygons.

with_class_inference(class_id_to_filter=None, default_class_id=1)

Set options for inferring the class of each feature.

For more info on how class inference works, see ClassInference.infer_class()

Args:
class_id_to_filter: (dict) map from class_id to JSON filter.

The filter schema is according to https://github.com/mapbox/mapbox-gl-js/blob/c9900db279db776f493ce8b6749966cedc2d6b8a/src/style-spec/feature_filter/index.js # noqa

default_class_id: (int) the default class_id to use if class can’t be

inferred using other mechanisms. If a feature defaults to a class_id of None, then that feature will be deleted.

with_id_field(id_field='@id')

Set the name of the id field.

Args:
id_field: (str) name of field in feature[‘properties’] that

contains the feature’s unique id. Used for merging features that are split across tile boundaries.

with_uri(uri)

Set the URI of the vector tiles.

Args:
uri: (str) URI of vector tile endpoint. Should either contain

{z}/{x}/{y} or point to .mbtiles file.

with_zoom(zoom)

Set the zoom level to use when accessing vector tiles.

Note: the vector tiles need to support the zoom level. Typically only a subset of zoom levels are supported.

LabelStoreConfig

LabelStoreConfigBuilders are created by calling

rv.LabelStoreConfig.builder(STORE_TYPE)

Where STORE_TYPE is one of the following:

rv.CHIP_CLASSIFICATION_GEOJSON

class rastervision.data.ChipClassificationGeoJSONStoreConfigBuilder(prev=None)
build()

Returns the configuration that is built by this builder.

with_uri(uri)

Set URI for a GeoJSON used to read/write predictions.

For rv.OBJECT_DETECTION:

rv.OBJECT_DETECTION_GEOJSON

class rastervision.data.ObjectDetectionGeoJSONStoreConfigBuilder(prev=None)
build()

Returns the configuration that is built by this builder.

with_uri(uri)

Set URI for a GeoJSON used to read/write predictions.

rv.SEMANTIC_SEGMENTATION_RASTER

class rastervision.data.SemanticSegmentationRasterStoreConfigBuilder(prev=None)
build()

Returns the configuration that is built by this builder.

with_rgb(rgb)

Set flag for writing RGB data using the class map.

Otherwise this method will write the class ID into a single band.

with_uri(uri)

Set URI for a GeoTIFF used to read/write predictions.

with_vector_output(vector_output)

Configure vector output for predictions.

Args:
vector_output: Either a list of dictionaries or a

protobuf object. The dictionary or the object contain (respectively) keys (attributes) called ‘denoise’, ‘uri’, ‘class_id’, and ‘mode’. The value associated with the ‘denoise’ key specifies the radius of the structural element used to perform a low-pass filtering process on the mask (see https://en.wikipedia.org/wiki/Mathematical_morphology#Opening). The value associated with the ‘uri’ key is either a file where the GeoJSON prediction will be written, or “” indicating that the filename should be auto-generated. ‘class_id’ is the integer prediction class that is of interest. The ‘mode’ key must be set to ‘buildings’ or ‘polygons’.

RasterTransformerConfig

RasterTransformerConfigBuilders are created by calling

rv.RasterTransformerConfig.builder(TRANSFORMER_TYPE)

Where TRANSFORMER_TYPE is one of the following:

rv.STATS_TRANSFORMER

class rastervision.data.StatsTransformerConfigBuilder(prev=None)
build()

Returns the configuration that is built by this builder.

with_stats_uri(stats_uri)

Set the stats_uri.

Args:

stats_uri: URI to the stats json to use

AugmentorConfig

AugmentorConfigBuilders are created by calling

rv.AugmentorConfig.builder(AUGMENTOR_TYPE)

Where AUGMENTOR_TYPE is one of the following:

rv.NODATA_AUGMENTOR

class rastervision.augmentor.NodataAugmentorConfigBuilder(prev=None)
build()

Returns the configuration that is built by this builder.

with_probability(aug_prob)

Sets the probability for this augmentation.

Determines how probable this augmentation will happen to negative chips.

Args:

aug_prob: Float value between 0.0 and 1.0

AnalyzerConfig

AnalyzerConfigBuilders are created by calling

rv.AnalyzerConfig.builder(ANALYZER_TYPE)

Where ANALYZER_TYPE is one of the following:

rv.STATS_ANALYZER

class rastervision.analyzer.StatsAnalyzerConfigBuilder(prev=None)
build()

Returns the configuration that is built by this builder.

with_sample_prob(sample_prob)

Set the sample_prob used to sample a subset of each scene.

If sample_prob is set, then a subset of each scene is used to compute stats which speeds up the computation. Roughly speaking, if sample_prob=0.5, then half the pixels in the scene will be used. More precisely, the number of chips is equal to sample_prob * (width * height / 300^2), or 1, whichever is greater. Each chip is uniformly sampled from the scene with replacement. Otherwise, it uses a sliding window over the entire scene to compute stats.

Args:

sample_prob: (float or None) between 0 and 1

with_stats_uri(stats_uri)

Set the stats_uri.

Args:

stats_uri: URI to the stats json to use

EvaluatorConfig

EvaluatorConfigBuilders are created by calling

rv.EvaluatorConfig.builder(Evaluator_TYPE)

Where Evaluator_TYPE is one of the following:

rv.CHIP_CLASSIFICATION_EVALUATOR

class rastervision.evaluation.ChipClassificationEvaluatorConfigBuilder(prev=None)
build()

Returns the configuration that is built by this builder.

with_class_map(class_map)

Set the class map to be used for evaluation.

Args:

class_map: The class map to be used

with_output_uri(output_uri)

Set the output_uri.

Args:

output_uri: URI to the stats json to use

with_task(task)

Sets a specific task type, e.g. rv.OBJECT_DETECTION.

with_vector_output_uri(vector_output_uri)

Set the vector_output_uri.

Args:

vector_output_uri: URI to the vector stats json to use

rv.OBJECT_DETECTION_EVALUATOR

class rastervision.evaluation.ObjectDetectionEvaluatorConfigBuilder(prev=None)
build()

Returns the configuration that is built by this builder.

with_class_map(class_map)

Set the class map to be used for evaluation.

Args:

class_map: The class map to be used

with_output_uri(output_uri)

Set the output_uri.

Args:

output_uri: URI to the stats json to use

with_task(task)

Sets a specific task type, e.g. rv.OBJECT_DETECTION.

with_vector_output_uri(vector_output_uri)

Set the vector_output_uri.

Args:

vector_output_uri: URI to the vector stats json to use

rv.SEMANTIC_SEGMENTATION_EVALUATOR

class rastervision.evaluation.SemanticSegmentationEvaluatorConfigBuilder(prev=None)
build()

Returns the configuration that is built by this builder.

with_class_map(class_map)

Set the class map to be used for evaluation.

Args:

class_map: The class map to be used

with_output_uri(output_uri)

Set the output_uri.

Args:

output_uri: URI to the stats json to use

with_task(task)

Sets a specific task type, e.g. rv.OBJECT_DETECTION.

with_vector_output_uri(vector_output_uri)

Set the vector_output_uri.

Args:

vector_output_uri: URI to the vector stats json to use

Predictor

class rastervision.Predictor(prediction_package_uri, tmp_dir, update_stats=False, channel_order=None)

Class for making predictions based off of a prediction package.

__init__(prediction_package_uri, tmp_dir, update_stats=False, channel_order=None)

Creates a new Predictor.

Args:
prediction_package_uri: The URI of the prediction package to use.

Can be any type of URI that Raster Vision can read.

tmp_dir: Temporary directory in which to store files that are used

by the Predictor. This directory is not cleaned up by this class.

update_stats: Option indicating if any Analyzers should be run on

the image to be predicted on. Otherwise, the Predictor will use the output of Analyzers that are bundled with the predict package. This is useful, for instance, if you are predicting against imagery that needs to be normalized with a StatsAnalyzer, and the color profile of the new imagery is significantly different then the imagery the model was trained on.

channel_order: Option for a new channel order to use for the

imagery being predicted against. If not present, the channel_order from the original configuration in the predict package will be used.

load_model()

Load the model for this Predictor.

This is useful if you are going to make multiple predictions with the model, and want it to be fast on the first prediction.

Note: This is called implicitly on the first call of ‘predict’ if it hasn’t been called already.

predict(image_uri, label_uri=None, config_uri=None)

Generate predictions for the given image.

Args:
image_uri: URI of the image to make predictions against.

This can be any type of URI readable by Raster Vision FileSystems.

label_uri: Optional URI to save labels off into. config_uri: Optional URI in which to save the bundle_config,

which can be useful to client applications for understanding how to interpret the labels.

Returns:

rastervision.data.labels.Labels containing the predicted labels.

Plugin Registry

class rastervision.plugin.PluginRegistry(plugin_config, rv_home)
register_config_builder(group, key, builder_class)

Registers a ConfigBuilder as a plugin.

Args:

group - The Config group, e.g. rv.BACKEND, rv.TASK. key - The key used for this plugin. This will be used to

construct the builder in a “.builder(key)” call.

builder_class - The subclass of ConfigBuilder that builds

the Config for this plugin.

register_default_evaluator(provider_class)

Registers an EvaluatorDefaultProvider for use as a plugin.

register_default_label_source(provider_class)

Registers a LabelSourceDefaultProvider for use as a plugin.

register_default_label_store(provider_class)

Registers a LabelStoreDefaultProvider for use as a plugin.

register_default_raster_source(provider_class)

Registers a RasterSourceDefaultProvider for use as a plugin.

register_default_vector_source(provider_class)

Registers a VectorSourceDefaultProvider for use as a plugin.

register_experiment_runner(runner_key, runner_class)

Registers an ExperimentRunner as a plugin.

Args:
runner_key - The key used to reference this plugin runner.

This is a string that will match the command line argument used to reference this runner; e.g. if the key is “FOO_RUNNER”, then users can use the runner by issuing a “rastervision run foo_runner …” command.

runner_class - The class of the ExperimentRunner plugin.

register_filesystem(filesystem_class)

Registers a FileSystem as a plugin.