GithubHelp home page GithubHelp logo

chen990627 / gan2shape Goto Github PK

View Code? Open in Web Editor NEW

This project forked from xingangpan/gan2shape

0.0 0.0 0.0 22.33 MB

Code for GAN2Shape (ICLR2021 oral)

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

License: MIT License

Shell 1.55% C++ 0.87% Python 90.53% Cuda 7.06%

gan2shape's Introduction

Do 2D GANs Know 3D Shape? Unsupervised 3D Shape Reconstruction from 2D Image GANs

Figure: Recovered 3D shape and rotation&relighting effects using GAN2Shape.

Do 2D GANs Know 3D Shape? Unsupervised 3D Shape Reconstruction from 2D Image GANs
Xingang Pan, Bo Dai, Ziwei Liu, Chen Change Loy, Ping Luo
ICLR2021 (Oral)

[Paper] [Project Page]

In this repository, we present GAN2Shape, which reconstructs the 3D shape of an image using off-the-shelf 2D image GANs in an unsupervised manner. Our method does not rely on mannual annotations or external 3D models, yet it achieves high-quality 3D reconstruction, object rotation, and relighting effects.

Requirements

  • python>=3.6
  • pytorch=1.1 or 1.2
  • neural_renderer
    pip install neural_renderer_pytorch  # or follow the guidance at https://github.com/elliottwu/unsup3d
  • mmcv
    pip install mmcv
  • other dependencies
    conda install -c conda-forge scikit-image matplotlib opencv pyyaml tensorboardX

Dataset and pre-trained weights

To download dataset and pre-trained weights, simply run:

sh scripts/download.sh

Training

Before training, you may optionally compile StyleGAN2 operations, which would be faster:

cd gan2shape/stylegan/stylegan2-pytorch/op
python setup.py install
cd ../../../..

Example1: training on car images:

sh scripts/run_car.sh

This would run on 4 GPUs by default. You can view the results at results/car/images or Tensorboard.

Example2: training on Celeba images:

sh scripts/run_celeba.sh

This by default uses our provided pre-trained weights. You can also perform joint pre-training via:

sh scripts/run_celeba-pre.sh

Example3: evaluating on synface (BFM) dataset:

sh scripts/run_synface.sh

This by default uses our provided pre-trained weights. You can also perform joint pre-training via:

sh scripts/run_synface-pre.sh

If you want to train on new StyleGAN2 samples, simply run the following script to generate new samples:

sh scripts/run_sample.sh

Note:
- For human and cat faces, we perform joint training before instance-specific training, which produces better results.
- For car and church, the quality of StyleGAN2 samples vary a lot, thus our approach may not produce good result on every sample. The downloaded dataset contains examples of good samples.

Acknowledgement

Part of the code is borrowed from Unsup3d and StyleGAN2.
Colab demo reproduced by ucalyptus: Link

BibTeX

@inproceedings{pan2020gan2shape,
  title   = {Do 2D GANs Know 3D Shape? Unsupervised 3D Shape Reconstruction from 2D Image GANs},
  author  =  {Pan, Xingang and Dai, Bo and Liu, Ziwei and Loy, Chen Change and Luo, Ping},
  booktitle = {International Conference on Learning Representations},
  year    = {2021}
}

gan2shape's People

Contributors

xingangpan avatar sheldontsui 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.