• Stars
    star
    288
  • Rank 143,298 (Top 3 %)
  • Language
    Python
  • Created over 4 years ago
  • Updated about 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

[CVPR 2020] Image Processing Using Multi-Code GAN Prior

Image Processing Using Multi-Code GAN Prior

Python 3.7 pytorch 1.1.0 CUDA 10.1

image Figure: Multi-code GAN prior facilitates many image processing applications using the reconstruction from fixed GAN models.

In this work, we propose a new inversion approach to applying well-trained GANs as effective prior to a variety of image processing tasks, such as image colorization, super-resolution, image inpainting, and semantic manipulation.

Image Processing Using Multi-Code GAN Prior
Jinjin Gu, Yujun Shen, Bolei Zhou
Computer Vision and Pattern Recognition (CVPR), 2020

[Paper] [Project Page]

How To Use

Install dependencies

Install dependencies using the following code before performing Multi-Code GAN Inversion.

python -m pip install -r requirements.txt

Download the Pre-train GAN Models

In this work, we use the well-trained GAN models as prior, including PGGAN and StyleGAN. Pytorch version models are borrowed from HiGAN. See here for more details.

As both PGGAN and StyleGAN use aligned face for GAN training, all faces used in this repo are pre-aligned. The alignment method can be found at stylegan-encoder.

Invert Images with Multi-Code GAN Inversion

With a given GAN model and a target image, you can invert the image to multiple latent codes by running

python multi_code_inversion.py
       --gan_model pggan_bedroom
       --target_images ./examples/gan_inversion/bedroom
       --outputs ./gan_inversion_bedroom
       --composing_layer 8
       --z_number 20

Colorization

For image colorization task, run

python colorization.py
       --gan_model pggan_bedroom
       --target_images ./examples/colorization/bedroom
       --outputs ./colorization
       --composing_layer 6
       --z_number 20

Inpainting

For image inpainting task (inpainting mask should be known in advance), run

python inpainting.py
       --gan_model pggan_churchoutdoor
       --target_images ./examples/inpainting/church
       --outputs ./inpainting
       --mask ./examples/masks/mask-1.png
       --composing_layer 4
       --z_number 30

Super-Resolution

For image super-resolution task (SR factor should be known in advance), run

python super_resolution.py
       --gan_model pggan_celebahq
       --target_images ./examples/superresolution
       --outputs ./SR_face
       --factor 16
       --composing_layer 6
       --z_number 20

Semantic Face Editing

We achieve semantic face editing together with InterfaceGAN. Please refer to this repo to see how to train semantic boundaries in the latent space as well as how to achieve face manipulation by varying the latent code.

In this project, you can simply run

python face_semantic_editing.py
       --gan_model pggan_celebahq
       --target_images ./examples/face
       --outputs ./face_manipulation
       --attribute_name gender
       --composing_layer 6
       --z_number 30

BibTeX

@inproceedings{gu2020image,
  title     = {Image Processing Using Multi-Code GAN Prior},
  author    = {Gu, Jinjin and Shen, Yujun and Zhou, Bolei},
  booktitle = {CVPR},
  year      = {2020}
}

More Repositories

1

interfacegan

[CVPR 2020] Interpreting the Latent Space of GANs for Semantic Face Editing
Python
1,483
star
2

sefa

[CVPR 2021] Closed-Form Factorization of Latent Semantics in GANs
Python
960
star
3

genforce

An efficient PyTorch library for deep generative modeling.
Python
907
star
4

idinvert

[ECCV 2020] In-Domain GAN Inversion for Real Image Editing
Python
459
star
5

idinvert_pytorch

[ECCV 2020] In-Domain GAN Inversion for Real Image Editing (PyTorch code)
Python
407
star
6

freecontrol

Official implementation of CVPR 2024 paper: "FreeControl: Training-Free Spatial Control of Any Text-to-Image Diffusion Model with Any Condition"
Python
383
star
7

higan

[IJCV 2020] Semantic Hierarchy Emerges in Deep Generative Representations for Scene Synthesis
Python
159
star
8

eqgan-sa

[CVPR 2022] Improving GAN Equilibrium by Raising Spatial Awareness
Python
156
star
9

ghfeat

[CVPR 2021] Generative Hierarchical Features from Synthesizing Images
Python
156
star
10

volumegan

CVPR 2022 VolumeGAN - 3D-aware Image Synthesis via Learning Structural and Textural Representations
Python
126
star
11

insgen

[NeurIPS 2021] Data-Efficient Instance Generation from Instance Discrimination
Python
101
star
12

lia

[IJCV 2022] Disentangled Inference for GANs with Latently Invertible Autoencoder
Python
90
star
13

StyleSV

[ICLR 2023] Towards Smooth Video Composition
Python
83
star
14

dynamicd

[NeurIPS 2022] Improving GANs with A Dynamic Discriminator
Python
63
star
15

genda

[ICCV 2023] One-Shot Generative Domain Adaptation
56
star
16

trgan

Unsupervised Image Transformation Learning via Generative Adversarial Networks
32
star
17

fairgen

Code for paper `Improving the Fairness of Deep Generative Models without Retraining`
Python
29
star
18

SpatialGAN

Spatial Steerability of GANs via Self-Supervision from Discriminator
8
star
19

genforce.github.io

Homepage.
HTML
6
star