This project is an extension to the article Style Generator Inversion for Image Enhancement and Animation by Aviv Gabbay and Yedid Hoshen (GitHub). Two additional applications are introduced to this method: Image deblurring using a known blur kernel and image recoloring of gray images to RGB images.
In this task, images are deblurred using the style-GAN-prior and a known blur kernel.
Input image:
Gaussian Blur | Uniform Blur | Motion Blur |
---|---|---|
Gaussian Reconstruction | Uniform Reconstruction | Motion Reconstruction |
Input image:
Gaussian Blur | Uniform Blur | Motion Blur |
---|---|---|
Gaussian Reconstruction | Uniform Reconstruction | Motion Reconstruction |
In this task, gray images are recolored using the style-GAN-prior. The conversion of an RGB image to a gray image was performed using the formula: Y = 0.2126R + 0.7152G + 0.0722B
RGB Image | Gray Image | Recolored Image |
---|---|---|
- Clone the official StyleGAN repository.
- Add the local StyleGAN project to PYTHONPATH.
Deblurring blurry images using a known blur kernel:
deblurring.py --blurred-imgs-dir <blurred-input-dir> --deblurred-imgs-dir <deblurred-output-dir>
--latents-dir <output-latents-dir> --blur-kernel <blur-method>
[--original-imgs-dir <originl-imgs-dir>]
[--blurred-img-size BLURRED_IMG_HEIGHT BLURRED_IMG_WIDTH]
[--learning-rate LEARNING_RATE]
[--total-iterations TOTAL_ITERATIONS]
Notes:
- The optional values for the blur-kernel flag are: gaussian/uniform/motion-vertical/motion-horizontal.
- If the original-imgs-dir is specified, the chosen blur-kernel will be first applied to all images in this dir and the blurred images will be saved in the blurred-imgs-dir.
- The default input image size is 256X256X3. This can be changed using the --blurred-img-size flag.
Given a gray face image, reconstruct an RGB image:
coloring.py --gray-imgs-dir <gray-input-dir> --colored-imgs-dir <colored-output-dir>
--latents-dir <output-latents-dir>
[--original-imgs-dir <originl-imgs-dir>]
[--img-size GRAY_IMG_HEIGHT GRAY_IMG_WIDTH]
[--learning-rate LEARNING_RATE]
[--total-iterations TOTAL_ITERATIONS]
Notes:
- If the original-imgs-dir is specified, all images in this dir will be first converted to gray images using the formula Y = 0.2126R + 0.7152G + 0.0722B and saved in the gray-imgs-dir.
- The default input image size is 256X256X3. This can be changed using the --img-size flag.