Home

Awesome

GenDR - The Generalized Differentiable Renderer

gendr_logo

Official implementation for our CVPR 2022 Paper "GenDR: A Generalized Differentiable Renderer".

Paper @ ArXiv, Video @ Youtube.

๐Ÿ’ป Installation

gendr can be installed via pip from PyPI with

pip install gendr

โš ๏ธ Note that gendr requires CUDA, the CUDA Toolkit (for compilation), and torch>=1.9.0 (matching the CUDA version).

Alternatively, GenDR may be installed from source, e.g., in a virtual environment like

virtualenv -p python3 .env1
. .env1/bin/activate
pip install torch==1.9.0+cu111 torchvision==0.10.0+cu111 -f https://download.pytorch.org/whl/torch_stable.html
pip install .

Make sure that the CUDA version of PyTorch (e.g., cu111 for CUDA 11.1) matches the locally installed version. However, on some machines, compiling works only with specific subversions that may be unequal to the local subversion, so a potential quick fix is trying different PyTorch version and CUDA subversion combinations.

๐Ÿ‘ฉโ€๐Ÿ’ป Documentation

A differentiable renderer may be defined as follows

import gendr

diff_renderer = gendr.GenDR(
    image_size=256,
    dist_func='uniform',
    dist_scale=0.01,
    dist_squared=False,
    aggr_alpha_func='probabilistic',
    aggr_rgb_func='hard',
)

In the following, we provide the entire set of arguments of GenDR. The most important parameters are marked in bold. For the essential parameters dist_func and aggr_alpha_func, we give a set of options. For a reference, see the paper.

๐Ÿงช Experiments

๐Ÿผ Shape Optimization (opt_shape.py)

python experiments/opt_shape.py -sq --gif

๐Ÿ“ฝ Camera Pose Optimization (opt_camera.py)

python experiments/opt_camera.py -sq --gif

โœˆ๏ธ Single-View 3D Reconstruction (train_reconstruction.py)

Optimal default parameters for --dist_scale are automatically used in the script for the set of distributions and t-conorms that are benchmarked on this task in the paper.

python experiments/train_reconstruction.py --distribution uniform --t_conorm probabilistic

๐Ÿ“– Citing

@inproceedings{petersen2022gendr,
  title={{GenDR: A Generalized Differentiable Renderer}},
  author={Petersen, Felix and Goldluecke, Bastian and Borgelt, Christian and Deussen, Oliver},
  booktitle={IEEE/CVF International Conference on Computer Vision and Pattern Recognition (CVPR)},
  year={2022}
}

License

gendr is released under the MIT license. See LICENSE for additional details about it.