Using Estimated Kernels for training
July 24, 2021 ยท View on GitHub
It is possible to use kernels estimated from real images to use during the on-the-fly downscale of HR images while training. For this, you can use the modified KernelGAN version from DLIP and follow the instructions as in this example:
- In the DLIP root create the
./imagesand./resultsdirectories. - Place the images to estimate the kernels from in
./images - Change to the
./kgandirectory and execute:python train.py --input-dir "../images" --X4 -o "../results". This will extract all the kernels from the images in ../images and save them in ../results, one directory per image. - Each image directory will contain 4 files:
kernel_x2.mat,kernel_x2.npy,kernel_x4.matandkernel_x4.npy - Now in your traiNNer training options file you have to set the path to the kernels like:
dataroot_kernels: D:/DLIP/results/, corresponding to the directory where the estimated kernels are located. - Finally, set the downscale types to use the realistic kernels estimated by kernelGAN:
lr_downscale_types: ["realistic"]
Note that the use of estimated kernels can lead to results that are extremelly sharp, so two options that have worked well to get better results are to add noise to the LR images (for example, JPEG or gaussian, etc) or using a combination of multiple downscale types, like ["cubic", "realistic"] while using the estimated kernels.