• Stars
    star
    407
  • Rank 105,806 (Top 3 %)
  • Language
    Python
  • License
    MIT License
  • Created about 4 years ago
  • Updated about 3 years ago

Reviews

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

Repository Details

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

In-Domain GAN Inversion for Real Image Editing

Python 3.6 PyTorch 1.2.0

image

Figure: Real image editing using the proposed In-Domain GAN inversion with a fixed GAN generator.

In-Domain GAN Inversion for Real Image Editing
Jiapeng Zhu*, Yujun Shen*, Deli Zhao, Bolei Zhou
European Conference on Computer Vision (ECCV) 2020

[Paper] [Project Page] [Demo] [Colab]

NOTE: This repository is a simple PyTorch version of this repo, and ONLY supports inference.

Editing Tasks

Pre-trained Models

Please download the pre-trained models from the following links and save them to models/pretrain/

Description Generator Encoder
Model trained on FFHQ dataset. face_256x256_generator face_256x256_encoder
Model trained on LSUN Tower dataset. tower_256x256_generator tower_256x256_encoder
Model trained on LSUN Bedroom dataset. bedroom_256x256_generator bedroom_256x256_encoder
Perceptual Model

Inversion

MODEL_NAME='styleganinv_ffhq256'
IMAGE_LIST='examples/test.list'
python invert.py $MODEL_NAME $IMAGE_LIST

NOTE: We find that 100 iterations are good enough for inverting an image, which takes about 8s (on P40). But users can always use more iterations (much slower) for a more precise reconstruction.

Semantic Diffusion

MODEL_NAME='styleganinv_ffhq256'
TARGET_LIST='examples/target.list'
CONTEXT_LIST='examples/context.list'
python diffuse.py $MODEL_NAME $TARGET_LIST $CONTEXT_LIST

NOTE: The diffusion process is highly similar to image inversion. The main difference is that only the target patch is used to compute loss for masked optimization.

Interpolation

SRC_DIR='results/inversion/test'
DST_DIR='results/inversion/test'
python interpolate.py $MODEL_NAME $SRC_DIR $DST_DIR

Manipulation

IMAGE_DIR='results/inversion/test'
BOUNDARY='boundaries/expression.npy'
python manipulate.py $MODEL_NAME $IMAGE_DIR $BOUNDARY

NOTE: Boundaries are obtained using InterFaceGAN.

Style Mixing

STYLE_DIR='results/inversion/test'
CONTENT_DIR='results/inversion/test'
python mix_style.py $MODEL_NAME $STYLE_DIR $CONTENT_DIR

BibTeX

@inproceedings{zhu2020indomain,
  title     = {In-domain GAN Inversion for Real Image Editing},
  author    = {Zhu, Jiapeng and Shen, Yujun and Zhao, Deli and Zhou, Bolei},
  booktitle = {Proceedings of European Conference on Computer Vision (ECCV)},
  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

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
6

mganprior

[CVPR 2020] Image Processing Using Multi-Code GAN Prior
Python
288
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