Module delta.config.extensions
Manage extensions to DELTA.
To extend delta, add the name for your extension to the extensions field
in a DELTA config file. It will then be imported when DELTA loads.
The named python module should then call the appropriate registration
function (e.g., register_layer() to register a custom Keras layer) and
the extensions can be used like existing DELTA options.
All extensions can take keyword arguments that can be specified in the config file.
Functions
def augmentation(aug_type: str) ‑> str-
Retrieve a custom augmentation by name.
Parameters
aug_type:str- Name of the augmentation.
Returns
Augmentation Function- The previously registered augmentation function.
def callback(cb_type: str) ‑> str-
Retrieve a custom callback by name.
Parameters
cb_type:str- Name of the callback function.
Returns
Callback- The previously registered callback.
def custom_objects() ‑> Dict[~KT, ~VT]-
Returns a dictionary of all supported custom objects for use by tensorflow. Passed as an argument to load_model.
Returns
dict- A dictionary of registered custom tensorflow objects.
def image_reader(reader_type: str) ‑> DeltaImage-
Get the reader of the given type.
Parameters
reader_type:str- Name of the image reader.
Returns
Type[
delta.imagery.delta_image.DeltaImage] The previously registered image reader. def image_writer(writer_type: str) ‑> DeltaImageWriter-
Get the writer of the given type.
Parameters
writer_type:str- Name of the image writer.
Returns
Type[
delta.imagery.delta_image.DeltaImageWriter] The previously registered image writer. def layer(layer_type: str) ‑> str-
Retrieve a custom layer by name.
Parameters
layer_type:str- Name of the layer.
Returns
Layer- The previously registered layer.
def loss(loss_type: str) ‑> str-
Retrieve a custom loss by name.
Parameters
loss_type:str- Name of the loss function.
Returns
Loss- The previously registered loss function.
def metric(metric_type: str) ‑> str-
Retrieve a custom metric by name.
Parameters
metric_type:str- Name of the metric.
Returns
Metric- The previously registered metric.
def preprocess_function(prep_type: str) ‑> str-
Retrieve a custom preprocessing function by name.
Parameters
prep_type:str- Name of the preprocessing function.
Returns
Preprocessing Function- The previously registered preprocessing function.
def register_augmentation(function_name: str, aug_function)-
Register an augmentation for use in delta.
Augmentations are called on tensors before the data is used for training. Both the image and the label are passed to an augmentation function.
Parameters
function_name:str- Name of the augmentation function.
aug_function: A function of the form aug(image, label), where image and labels are both tensors.
def register_callback(cb_type: str, cb)-
Register a custom training callback for use by DELTA.
Parameters
cb_type:str- Name of the callback.
cb:Type[tensorflow.keras.callbacks.Callback]- A class extending Callback or a function that returns one.
def register_extension(name: str)-
Register an extension python module. For internal use — users should use the config files.
Parameters
name:str- Name of the extension to load.
def register_image_reader(image_type: str, image_class)-
Register a custom image type for reading by DELTA.
Parameters
image_type:str- Name of the image type.
image_class:Type[delta.imagery.delta_image.DeltaImage]- A class that extends
DeltaImage.
def register_image_writer(image_type: str, writer_class)-
Register a custom image type for writing by DELTA.
Parameters
image_type:str- Name of the image type.
writer_class:Type[delta.imagery.delta_image.DeltaImageWriter]- A class that extends
DeltaImageWriter.
def register_layer(layer_type: str, layer_constructor)-
Register a custom layer for use by DELTA.
Parameters
layer_type:str- Name of the layer.
layer_constructor- Either a class extending tensorflow.keras.layers.Layer, or a function that returns a function that inputs and outputs tensors.
See Also
DeltaLayer- Layer wrapper with Delta extensions
def register_loss(loss_type: str, custom_loss)-
Register a custom loss function for use by DELTA.
Note that loss functions can also be used as metrics.
Parameters
loss_type:str- Name of the loss function.
custom_loss: Either a loss extending Loss or a function of the form loss(y_true, y_pred) which returns a tensor of the loss.
def register_metric(metric_type: str, custom_metric)-
Register a custom metric for use by DELTA.
Parameters
metric_type:str- Name of the metric.
custom_metric:Type[tensorflow.keras.metrics.Metric]- A class extending Metric.
def register_preprocess(function_name: str, prep_function)-
Register a preprocessing function for use in delta.
Preprocessing functions are called on numpy arrays when the data is read from disk.
Parameters
function_name:str- Name of the preprocessing function.
prep_function: A function of the form prep_function(data, rectangle, bands_list), where data is an input numpy array, rectangle a
Rectanglespecifying the region covered by data, and bands_list is an integer list of bands loaded. The function must return a numpy array.