mmagic.models.editors.pconv.partial_conv
¶
Module Contents¶
Classes¶
Implementation for partial convolution. |
- class mmagic.models.editors.pconv.partial_conv.PartialConv2d(*args, multi_channel=False, eps=1e-08, **kwargs)[source]¶
Bases:
torch.nn.Conv2d
Implementation for partial convolution.
Image Inpainting for Irregular Holes Using Partial Convolutions [https://arxiv.org/abs/1804.07723]
- Parameters
multi_channel (bool) – If True, the mask is multi-channel. Otherwise, the mask is single-channel.
eps (float) – Need to be changed for mixed precision training. For mixed precision training, you need change 1e-8 to 1e-6.
- forward(input, mask=None, return_mask=True)[source]¶
Forward function for partial conv2d.
- Parameters
input (torch.Tensor) – Tensor with shape of (n, c, h, w).
mask (torch.Tensor) – Tensor with shape of (n, c, h, w) or (n, 1, h, w). If mask is not given, the function will work as standard conv2d. Default: None.
return_mask (bool) – If True and mask is not None, the updated mask will be returned. Default: True.
- Returns
Results after partial conv. torch.Tensor : Updated mask will be returned if mask is given and
return_mask
is True.- Return type
torch.Tensor