Watermark removal (based on nosie2noise optimized code + model)

github link

1. Reception field calculation:

r_{n}: This layer of receptive field;

r_{n-1}: Upper receptive field;

s_{i}: The step size of the i-th layer of convolution or pooling

k: the size of the convolution kernel of this layer

2. Calculation of the hollow convolution convolution kernel: K=k+(k-1)(r-1), k is the size of the original convolution kernel, r is the void rate of the void convolution parameter, and the void volume can be calculated by entering the above formula Accumulate receptive field;

3. Transformation for noise2nosie:

(1). Deepen the network, the original structure's receptive field is only 192, and the scale of the watermark to be removed is relatively large. Change the two-layer network after the original structure to a hollow convolution, set the dilated rate to 6, and enlarge the receptive field to 672, even more It is suitable for 640*640 scale reasoning, so that the global noise can be seen more clearly, and the original image information loss is not very serious;
(2). Modify the loss function and increase the loss with the epoch to deliberately optimize the difficult samples.


class L0Loss(nn.Module):
    """High dynamic range loss."""
    def __init__(self, eps=1e-8, nb_epochs=10):
        """Initializes loss with numerical stability epsilon."""

        super(L0Loss, self).__init__()
        self._eps = eps
        self.nb_epochs =  nb_epochs

    def forward(self, denoised, target, epoch):
        """Computes loss by unpacking render buffer."""
        # gamma = 2.0 * (self.nb_epochs - epoch) / self.nb_epochs
        gamma = 2.0 * (epoch+1) / self.nb_epochs
        loss = ((torch.abs(denoised - target) + self._eps) ** gamma)
        return torch.mean(loss.view(-1))

Effect picture:

   

Disadvantages:

1. Since the loss function is similar to L2loss, it is an average optimization of all pixels. Although the watermark is removed, the image is also smoothed at the same time.

2. Using this loss is to operate on a single pixel without considering spatial information.

 

Receptive field calculation process:

 

Guess you like

Origin blog.csdn.net/fanzonghao/article/details/109389708