Skip to content
This repository has been archived by the owner on Mar 19, 2024. It is now read-only.

inference.py

Andrew Player edited this page Aug 17, 2022 · 1 revision

module src.inference

Created By: Andrew Player
File Name: inference.py
Description: Functions related to inference with the model


function test_model

test_model(
    model_path: str,
    seed: int,
    tile_size: int,
    crop_size: int = 0
) → None

Predicts the event-mask on a synthetic wrapped interferogram and plots the results.

Parameters:

  • model_path : str
    The path to the model.
  • seed : int
    A seed for the random functions. For the same seed, with all other values the same as well, the interferogram generation will have the same results. If left at 0, the results will be different every time.
  • tile_size : int
    The dimensional size of the simulated interferograms to generate, this must match the input shape of the model.
  • crop_size : int, Optional
    If the models output shape is different than the input shape, this value needs to be equal to the output shape.

Returns:

None


function mask

mask(
    model_path: str,
    arr_w: ndarray,
    tile_size: int,
    crop_size: int = 0
) → ndarray

Use a keras model prediction to mask events in a wrapped interferogram.

Parameters:

  • model_path : str
    The path to the model to use for masking.
  • arr_w : np.ndarray
    The wrapped interferogram array.
  • tile_size : int
    The width and height of the tiles that the image will be broken into, this needs to match the input shape of the model.
  • crop_size : int, Optional
    If the models output shape is different than the input shape, this value needs to be equal to the output shape.

Returns:

  • prediction : np.ndarray(shape=(tile_size, tile_size) or (crop_size, crop_size))
    The array containing the event-mask array as predicted by the model.

function mask_and_plot

mask_and_plot(
    model_path: str,
    product_path: str,
    tile_size: int,
    crop_size: int = 0
) → ndarray

Generate a mask over potential events in a wrapped insar product and plot it.

Parameters:

  • model_path : str
    The path to the model to use for generating the event-mask.
  • product_path : str
    The path to the InSAR product from ASF that should be masked.
  • tile_size : int
    The width and height of the tiles that the image will be broken into, this needs to match the input shape of the model.
  • crop_size : int, Optional
    If the models output shape is different than the input shape, this value needs to be equal to the output shape.

Returns:

  • prediction : np.ndarray(shape=(tile_size, tile_size) or (crop_size, crop_size))
    The array containing the event-mask array as predicted by the model.

function visualize_layers

visualize_layers(model_path: str, save_path: str, seed: int = 0) → None

Visualize the layers in the model.

Parameters:

  • model_path : str
    The path to the model to be visualized.
  • save_path : str
    The path to the folder where the resulting tifs should be saved.
  • seed : int
    An integer value to seed the random function (the same seed results in the same image, all else equal).

Returns:

None


This file was automatically generated via andrewplayer3's fork of lazydocs.