# API Reference¶

This part of the documentation lists the full API reference of public classes and functions.

Note

This 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)

Args:

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.

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)

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, setting 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 such that keys that are found recursively in the configuration are replaced with those values. TODO: better explination.

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)

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

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)

Args:

with_template(template)

Use a template from the dict, string or uri as the base for the Keras Classification API.

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_OBJECT_DETECTION¶

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

Build this configuration, setting 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 such that keys that are found recursively in the configuration are replaced with those values. TODO: better explination.

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 that will be created for this model after training.

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)

Args:

with_template(template)

Use a template for TF Object Detection pipeline config.

Args:
template: A dict, string or uri as the base for the tensorflow 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, setting any values into the TFDL 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 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)

Defines the name of the fine tune checkpoint that will be created for this model after training.

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(train_py='/opt/tf-models/deeplab/train.py', export_py='/opt/tf-models/deeplab/export_model.py')
with_task(task)

Args:

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)

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.

## 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_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: The URI points to the AoI (nominally a GeoJSON

polygon).

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.GEOTIFF_SOURCE¶

class rastervision.data.GeoTiffSourceConfigBuilder(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.

Args:
channel_order: numpy array of length n where n is the number of

channels to use and the values are channel indices

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 a GeoTIFF containing raster data.

with_uris(uris)

Set URIs for a GeoTIFFs containing as raster data.

### rv.IMAGE_SOURCE¶

class rastervision.data.ImageSourceConfigBuilder(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.

Args:
channel_order: numpy array of length n where n is the number of

channels to use and the values are channel indices

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 an image.

Args:
uri: A URI pointing to some (non-georeferenced) raster

file (TIFs, PNGs, and JPEGs are supported, and possibly others).

### rv.GEOJSON_SOURCE¶

class rastervision.data.GeoJSONSourceConfigBuilder(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.

Args:
channel_order: numpy array of length n where n is the number of

channels to use and the values are channel indices

with_rasterizer_options(background_class_id, line_buffer=15)

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.

line_buffer: Number of pixels to add to each side of line when rasterized.

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 a GeoJSON file used to read labels.

## LabelSourceConfig¶

LabelSourceConfigBuilders are created by calling

rv.LabelSourceConfig.builder(SOURCE_TYPE)


Where SOURCE_TYPE is one of the following:

### rv.CHIP_CLASSIFICATION_GEOJSON¶

class rastervision.data.ChipClassificationGeoJSONSourceConfigBuilder(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 polyongs of the GeoJSON. 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)

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

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.

For rv.OBJECT_DETECTION:

### rv.OBJECT_DETECTION_GEOJSON¶

class rastervision.data.ObjectDetectionGeoJSONSourceConfigBuilder(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.SemanticSegmentationRasterSourceConfigBuilder(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:

SemanticSegmentationRasterSourceConfigBuilder

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:

SemanticSegmentationRasterSourceConfigBuilder

## 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.

## 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_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.

### 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.

### 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.

## 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_packaage_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 indicating 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

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_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.