GithubHelp home page GithubHelp logo

neka-nat / stylegan2-distillation Goto Github PK

View Code? Open in Web Editor NEW

This project forked from evgenykashin/stylegan2-distillation

0.0 0.0 0.0 45.38 MB

Home Page: https://arxiv.org/abs/2003.03581

License: Other

Shell 0.61% Python 91.67% Cuda 4.48% HTML 0.34% Jupyter Notebook 2.83% Dockerfile 0.07%

stylegan2-distillation's Introduction

StyleGAN2 Distillation for Feed-forward Image Manipulation

Title image

Paper: https://arxiv.org/abs/2003.03581

TL;DR: Paired image-to-image translation, trained on synthetic data generated by StyleGAN2 outperforms existing approaches in image manipulation.

StyleGAN2 Distillation for Feed-forward Image Manipulation
Yuri Viazovetskyi*1, Vladimir Ivashkin*1,2, and Evgeny Kashin*1
[1]Yandex, [2]Moscow Institute of Physics and Technology (* indicates equal contribution).
Abstract: StyleGAN2 is a state-of-the-art network in generating realistic images. Besides, it was explicitly trained to have disentangled directions in latent space, which allows efficient image manipulation by varying latent factors. Editing existing images requires embedding a given image into the latent space of StyleGAN2. Latent code optimization via backpropagation is commonly used for qualitative embedding of real world images, although it is prohibitively slow for many applications. We propose a way to distill a particular image manipulation of StyleGAN2 into image-to-image network trained in paired way. The resulting pipeline is an alternative to existing GANs, trained on unpaired data. We provide results of human faces’ transformation: gender swap, aging/rejuvenation, style transfer and image morphing. We show that the quality of generation using our method is comparable to StyleGAN2 backpropagation and current state-of-the-art methods in these particular tasks.

Additional materials

Results

Gender swap

Gender swap
Full-size

Aging

Aging
Full-size

Style mixing

Style mixing
Full-size

Usage

Based on stylegan2 and pix2pixHD repos. To use it, you must install their requirements.

Inference notebook

Open In Colab

Search for directions

In stylegan2 directory.

  • Generate random images and save source dlatents vectors:
python run_generator.py generate-images-custom --network=gdrive:networks/stylegan2-ffhq-config-f.pk
 --truncation-psi=0.7 --num 5000 --result-dir /mnt/generated_faces
  • Predict attributes for each image with some pretrained classifier (we used internal)
  • Use Learn_direction_in_latent_space.ipynb to find a direction in dlatents
  • Alternatively, you can use publicly available vectors https://twitter.com/robertluxemburg/status/1207087801344372736 (stylegan2directions folder in root)

Creating paired dataset

  • Generate the dataset using a vector:
python run_generator.py generate-images-custom --network=gdrive:networks/stylegan2-ffhq-config-f.pkl
 --truncation-psi=0.7 --num 50000 --result-dir /mnt/generated_ffhq_smile
 --direction_path ../stylegan2directions/smile.npy --coeff 1.5
  • Our filtered gender dataset as an example
  • Use Dataset_preprocessing.ipynb to transform data in pix2pixHD format TODO: make a script

Fitting transform

In pix2pixHD directory.

Training command:

python train.py --name r512_smile_pos --label_nc 0
 --dataroot /mnt/generated_ffhq_smile --tf_log --no_instance
 --loadSize 512  --gpu_ids 0,1 --batchSize 8

Testing command:

python test.py --name r512_smile_pos --label_nc 0
 --dataroot /mnt/datasets/ffhq_69000 --no_instance --loadSize 512
 --gpu_ids 0,1 --batchSize 32 --how_many 100

Style mixing:

For style mixing you need to generate mixing examples and create a third folder C for the pixp2pixHD model. It turns out that in folder A and C there will be two different people, who have to mix, and in folder B the result. For the learning script, you only need to add --input_nc 6 parameter.

License

The source code, pretrained models, and dataset will be available under Creative Commons BY-NC 4.0 license by Yandex LLC. You can use, copy, tranform and build upon the material for non-commercial purposes as long as you give appropriate credit by citing our paper, and indicate if changes were made.

Citation

@inproceedings{DBLP:conf/eccv/ViazovetskyiIK20,
  author    = {Yuri Viazovetskyi and
               Vladimir Ivashkin and
               Evgeny Kashin},
  title     = {StyleGAN2 Distillation for Feed-Forward Image Manipulation},
  booktitle = {ECCV},
  year      = {2020}
}

stylegan2-distillation's People

Contributors

evgenykashin avatar metropass avatar vlivashkin 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.