• Stars
    star
    960
  • Rank 47,640 (Top 1.0 %)
  • Language
    Python
  • License
    MIT License
  • Created over 4 years ago
  • Updated over 3 years ago

Reviews

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

Repository Details

[CVPR 2021] Closed-Form Factorization of Latent Semantics in GANs

SeFa - Closed-Form Factorization of Latent Semantics in GANs

image Figure: Versatile semantics found from various types of GAN models using SeFa.

Closed-Form Factorization of Latent Semantics in GANs
Yujun Shen, Bolei Zhou
Computer Vision and Pattern Recognition (CVPR), 2021 (Oral)

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

In this repository, we propose a closed-form approach, termed as SeFa, for unsupervised latent semantic factorization in GANs. With this algorithm, we are able to discover versatile semantics from different GAN models trained on various datasets. Most importantly, the proposed method does not rely on pre-trained semantic predictors and has an extremely fast implementation (i.e., less than 1 second to interpret a model). Below show some interesting results on anime faces, cats, and cars.

NOTE: The following semantics are identified in a completely unsupervised manner, and post-annotated for reference.

Anime Faces
Pose Mouth Painting Style
image image image
Cats
Posture (Left & Right) Posture (Up & Down) Zoom
image image image
Cars
Orientation Vertical Position Shape
image image image

Semantic Discovery

It is very simple to interpret a particular model with

MODEL_NAME=stylegan_animeface512
LAYER_IDX=0-1
NUM_SAMPLES=5
NUM_SEMANTICS=5
python sefa.py ${MODEL_NAME} \
    -L ${LAYER_IDX} \
    -N ${NUM_SAMPLES} \
    -K ${NUM_SEMANTICS}

After the program finishes, there will be two visualization pages in the directory results.

NOTE: The pre-trained models are borrowed from the genforce repository.

Interface

We also provide an interface for interactive editing based on StreamLit. This interface can be locally launched with

pip install streamlit
CUDA_VISIBLE_DEVICES=0 streamlit run interface.py

After the interface is launched, users can play with it via a browser.

NOTE: We have prepared some latent codes in the directory latent_codes to ensure the synthesis quality, which is completely determined by the pre-trained generator. Users can simply skip these prepared codes by clicking the Random button.

BibTeX

@inproceedings{shen2021closedform,
  title     = {Closed-Form Factorization of Latent Semantics in GANs},
  author    = {Shen, Yujun and Zhou, Bolei},
  booktitle = {CVPR},
  year      = {2021}
}

More Repositories

1

interfacegan

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

genforce

An efficient PyTorch library for deep generative modeling.
Python
906
star
3

idinvert

[ECCV 2020] In-Domain GAN Inversion for Real Image Editing
Python
460
star
4

idinvert_pytorch

[ECCV 2020] In-Domain GAN Inversion for Real Image Editing (PyTorch code)
Python
410
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

ghfeat

[CVPR 2021] Generative Hierarchical Features from Synthesizing Images
Python
157
star
9

eqgan-sa

[CVPR 2022] Improving GAN Equilibrium by Raising Spatial Awareness
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