Inpainters Module

Interface

class picasso.inpainters.interfaces.HoleInpainter(args, Npix=128, meshgrid=True)[source]

Bases: object

This class provides an interface to the 3 inpainting techniques. One of the key parameters is args importing arguments input by the user in the inpainting scripts.

DPinpaint(reuse)[source]

Set of instructions to inpaint with DeepPrior

GANinpaint(reuse)[source]

Set of instructions to inpaint with ContextualAttention

NNinpaint()[source]

Set of instructions to inpaint with NearestNeighbours

setup_input(fname, rdseed=None)[source]

Pre-process the flat map by renormalizing and reshaping it as it required by the inpainting method

Deep Prior

class picasso.inpainters.deep_prior_inpainter.DeepPrior(input_shape, nd=[16, 32, 64, 128, 128, 128], verbose=False, meshgrid=True)[source]

Bases: object

Inpainting class interface for Deep-Prior

compile(optimizer)[source]

Compile the architecture

downsampling_block(X, f, filters, stage, block, s=2)[source]

Implementation of a down-sampling block

Parameters

  • X:

    input tensor of shape (m, n_H_prev, n_W_prev, n_C_prev)

  • f: {int}

    specifying the shape of the middle CONV’s window for the main path

  • filters :{int}

    defining the number of filters in the CONV layers of the main path

  • stage :{int}

    used to name the layers, depending on their position in the network

  • block: {string}

    used to name the layers, depending on their position in the network

Returns

  • X:

    output of the convolutional block, tensor of shape (n_H, n_W, n_C)

evaluate(z, X)[source]
my_accuracy(y_true, y_pred)[source]

Accuracy defined as the ratio between the 2-norms of the prediction and of the ground-truth.

myloss(y_true, y_pred)[source]

Loss function evaluated outside the masked region and normalized by the ground-truth norm.

predict()[source]

Inpainting with Deep -Prior

rescale_back(v)[source]

rescale inpainted map to physical units .

setup_input(fname_masked)[source]

Preprocessing the corrupted image and setting up the generative images. By default deep-prior will generate pixel values starting from an image with uniformly random distributed pixels (in \([0,1/10]\)). Otherwise if meshgrid==True, generator is a set of 4 images, i.e. a upward, downward, leftward and rightward diagonal gradients_summary. This mitigates the gridding pattern injected in the reconstruction area.

summary()[source]

Returns the model summary

train(z, X, epochs=2000, verbose=False)[source]

Iterate over the epochs

upsampling_block(X, f, filters, stage, block)[source]

Implementation of the up-sampling block

Parameters

  • X:

    input tensor of shape (m, n_H_prev, n_W_prev, n_C_prev)

  • f: {int}

    specifying the shape of the middle CONV’s window for the main path

  • filters :{int}

    defining the number of filters in the CONV layers of the main path

  • stage :{int}

    used to name the layers, depending on their position in the network

  • block: {string}

    used to name the layers, depending on their position in the network

Returns

  • X:

    output of the convolutional block, tensor of shape (n_H, n_W, n_C)

Nearest Neighbours

class picasso.inpainters.nearest_neighbours_inpainter.NearestNeighbours(Npix=128, verbose=False, tol=1e-08)[source]

Bases: object

Nearest-neighbours inpainting by diffusing the average of the nearest pixel values.

Inpainting can be performed on a generic location in the map. It is performed in a loop and it is stopped when the inpainted array in two subsequent iterations is essentially the same for a given tolerance threshold tol. Default tolerance is the one set from numpy.allclose, 1e-8.

predict()[source]

Inpainting the map with Nearest-Neighbours .

setup_input(fname_masked)[source]

Setup the the masked image to be inpainted and the mask

Parameters

  • fname_masked:{string}

    loading .npy file of the masked image

GAN

class picasso.inpainters.contextual_attention_gan.ContextualAttention(modeldir=None, verbose=False)[source]

Bases: picasso.inpainters.generative_inpainting_model.InpaintCAModel

Inpainting with GAN.

It requires a pre-trained network with weights stored in modeldir. This is a further interface layer to the Generative inpainting developed by Jiahui Yu (https://github.com/JiahuiYu/generative_inpainting)

postprocess_output(output, sess)[source]
predict(reuse)[source]

Inpainting with GAN

preprocess_input()[source]
rescale_back(v)[source]

MinMax rescale to the map to the physical units

setup_input(fname_masked)[source]

Pre-process the map to be inpainted with GAN.