Giter Site home page Giter Site logo

batermj / mganprior Goto Github PK

View Code? Open in Web Editor NEW

This project forked from genforce/mganprior

0.0 1.0 0.0 34.32 MB

CVPR'20 paper `Image Processing Using Multi-Code GAN Prior`

Home Page: https://genforce.github.io/mganprior/

Python 97.75% Dockerfile 0.03% Cuda 2.22%

mganprior's Introduction

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}
}

mganprior's People

Contributors

shenyujun avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.