Inpainters Module¶
Interface¶
Deep Prior¶
-
class
picasso.inpainters.deep_prior_inpainter.DeepPrior(input_shape, nd=[16, 32, 64, 128, 128, 128], verbose=False, meshgrid=True)[source]¶ Bases:
objectInpainting class interface for Deep-Prior
-
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)
-
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.
-
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.
-
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:
objectNearest-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.
GAN¶
-
class
picasso.inpainters.contextual_attention_gan.ContextualAttention(modeldir=None, verbose=False)[source]¶ Bases:
picasso.inpainters.generative_inpainting_model.InpaintCAModelInpainting 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)