Skip to content

alessioGalatolo/GAN-2D-to-3D

Repository files navigation

Unsupervised 3D shape retrieval from pre-trained GANs

Replication of GAN2Shape. We participated with this code in the Machine Learning Reproducibility Challenge 2021 and our paper for accepted for publication at ReScience C journal, our report is also temporarily available in the OpenReview forum.

Results

Cats (Ellipsoid) Cats (Smoothed Box) Cars (Ellipsoid) Cars (Smoothed Box) Faces (Ellipsoid) Faces (Confidence)
Cat 0 - Ellipsoid Cat 0 - Smoothed Box Car 0 - Ellipsoid Car 0 - Smoothed Box Face 0 - Ellipsoid Face 0 - Confidence
Cat 1 - Ellipsoid Cat 1 - Smoothed Box Car 4 - Ellipsoid Car 4 - Smoothed Box Face 1 - Ellipsoid Face 1 - Confidence
Cat 2 - Ellipsoid Cat 2 - Smoothed Box Car 5 - Ellipsoid Car 5 - Smoothed Box Face 2 - Ellipsoid Face 2 - Confidence

The results are also available interactively at alessiogalatolo.github.io/GAN-2D-to-3D/.

Install instructions for Ubuntu 18.04.6 LTS with CUDA 10+ compatible GPU

sudo apt update
sudo apt install build-essential
# CUDA toolkit
wget https://developer.download.nvidia.com/compute/cuda/10.2/Prod/local_installers/cuda_10.2.89_440.33.01_linux.run
sudo sh cuda_10.2.89_440.33.01_linux.run
# Install Conda
curl -LO https://repo.anaconda.com/miniconda/Miniconda3-py39_4.10.3-Linux-x86_64.sh
bash Miniconda3-py39_4.10.3-Linux-x86_64.sh

Close and reopen terminal

conda create --name 3D-GAN pytorch==1.2.0 torchvision==0.4.0 cudatoolkit=10.0 -c pytorch
conda activate 3D-GAN
# Install neural renderer
git clone https://github.com/daniilidis-group/neural_renderer.git
cd neural_renderer
python setup.py install
# Install all other dependencies
conda install numpy pandas distributed ipython lmdb matplotlib Pillow scipy tqdm scikit-image
conda install PyYAML -c conda-forge
conda install wandb -c conda-forge  # optional
conda install -y -c anaconda ipykernel ipython_genutils  # only needed if running on notebook
pip install plotly  # only needed for evaluating results

Install instruction for Windows

The procedure is the same except for the installing the neural renderer that will not work out of the box on windows. Please see our guide here for a procedure that might work for installing the neural renderer on Windows.

How to run:

First you need to download the various datasets:

python download_data.py
python main.py --save-ckpts

To evaluate the results:

python evaluate_results.py

Acknowledgments

Part of this code is borrowed from Unsup3d, StyleGAN2, Semseg and BiSeNet.