All Projects → HavenFeng → photometric_optimization

HavenFeng / photometric_optimization

Licence: MIT license
Photometric optimization code for creating the FLAME texture space and other applications

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to photometric optimization

Alae
[CVPR2020] Adversarial Latent Autoencoders
Stars: ✭ 3,178 (+1072.69%)
Mutual labels:  pytorch-implementation, ffhq
heron-language
A pure functional type-inferred language based on JavaScript
Stars: ✭ 53 (-80.44%)
Mutual labels:  3d-graphics
gzweb
Web client for Gazebo classic simulation
Stars: ✭ 36 (-86.72%)
Mutual labels:  3d-graphics
Teg
A differentiable programming language with an integration primitive that soundly handles interactions among the derivative, integral, and discontinuities.
Stars: ✭ 25 (-90.77%)
Mutual labels:  optimization
tensorflow-riemopt
A library for optimization on Riemannian manifolds
Stars: ✭ 72 (-73.43%)
Mutual labels:  optimization
tutorials-hg1
These tutorials demonstrate the usage of the Harfang API
Stars: ✭ 12 (-95.57%)
Mutual labels:  3d-graphics
NumDiff
Modern Fortran Numerical Differentiation Library
Stars: ✭ 48 (-82.29%)
Mutual labels:  optimization
Relation-Network-PyTorch
Implementation of Relation Network and Recurrent Relational Network using PyTorch v1.3. Original papers: (RN) https://arxiv.org/abs/1706.01427 (RRN): https://arxiv.org/abs/1711.08028
Stars: ✭ 17 (-93.73%)
Mutual labels:  pytorch-implementation
utf8
Fast UTF-8 validation with range algorithm (NEON+SSE4+AVX2)
Stars: ✭ 60 (-77.86%)
Mutual labels:  optimization
PointcloudVoxelizer
A python based tool for converting point cloud into voxel grid.
Stars: ✭ 52 (-80.81%)
Mutual labels:  3d-graphics
PyOptSamples
Optimization sample codes on Python
Stars: ✭ 20 (-92.62%)
Mutual labels:  optimization
Walk-Transformer
From Random Walks to Transformer for Learning Node Embeddings (ECML-PKDD 2020) (In Pytorch and Tensorflow)
Stars: ✭ 26 (-90.41%)
Mutual labels:  pytorch-implementation
pikaia
Modern Fortran Edition of the Pikaia Genetic Algorithm
Stars: ✭ 29 (-89.3%)
Mutual labels:  optimization
REopt Lite API
The model for the REopt API, which is used as the back-end for the REopt Webtool (reopt.nrel.gov/tool), and can be accessed directly via the NREL Developer Network (https://developer.nrel.gov/docs/energy-optimization/reopt/v1)
Stars: ✭ 53 (-80.44%)
Mutual labels:  optimization
kafka-assignment-optimizer
Kafka Partitions Assignment Optimizer
Stars: ✭ 16 (-94.1%)
Mutual labels:  optimization
web-performance-optimization
Web 性能优化
Stars: ✭ 23 (-91.51%)
Mutual labels:  optimization
falcon
A WordPress cleanup and performance optimization plugin.
Stars: ✭ 17 (-93.73%)
Mutual labels:  optimization
Coluna.jl
Branch-and-Price-and-Cut in Julia
Stars: ✭ 128 (-52.77%)
Mutual labels:  optimization
nuxt-prune-html
🔌⚡ Nuxt module to prune html before sending it to the browser (it removes elements matching CSS selector(s)), useful for boosting performance showing a different HTML for bots/audits by removing all the scripts with dynamic rendering
Stars: ✭ 69 (-74.54%)
Mutual labels:  optimization
windows10-debloat
Collection of various scripts and apps to debloat Windows 10 for better privacy, performance and optimization.
Stars: ✭ 52 (-80.81%)
Mutual labels:  optimization

Photometric FLAME Fitting

This repository provides an analysis-by-synthesis framework to fit a textured FLAME model to an image. FLAME is a lightweight generic 3D head model learned from over 33,000 head scans, but it does not come with an appearance space (see the scientific publication for details).

Variations of the texture space for the first five principal components. Each column shows the variation for ±2 standard deviations along one axis.

This repository

  1. describes how to build a texture space for FLAME from in-the-wild images, and provides
  2. code to fit a textured FLAME model to in-the-wild images, optimizing for FLAME's parameters, appearance, and lighting, and
  3. code to optimize for the FLAME texture to match an in-the-wild image.

The FLAME model and the texture space can be downloaded from the FLAME project website. You need to sign up and agree to the license for access.

The demos will be released soon.

Build FLAME texture space from in-the-wild images

The goal is to build a texture space from in-the-wild images in order to cover large range of ethnicities, age groups, etc. We therefore randomly select 1500 images from the FFHQ dataset in order to build a texture space. This is done in following steps

1. Initialization

Building a texture space from in-the-wild images is a chicken-and-egg problem. Given a texture space, it can be used in an analysis-by-synthesis fashion to fit the 3D model to images, where these fits then can be used to build a texture space. To get an initial texture space, we fit FLAME to the Basel Face Model (BFM) template, and project the BFM vertex colors onto the FLAME mesh, to get an initial texture basis.

2. Model fitting

We then fit FLAME to the FFHQ images, optimizing for the FLAME shape, pose, and expression parameters, the parameters of the initial texture space, the parameters for Spherical Harmonics (SH) lighting (we optimize for 9 SH coefficient only, shared across all three color channels), and a texture offset to capture texture details deviating from the initial texture space. The fitting minimizes a landmark loss, a photometric loss, and diverse regularizers for shape, pose, expression, appearance, and the texture offset.

The landmark loss minimizes the difference between the landmarks projected from the face model's surface, and predicted 2D landmarks (predicted using the FAN landmark predictor). The photometric loss is optimized for the skin region only (provided by the face segmentation network) to gain robustness to partial occlusions. See the provided code for details how to fit a textured FLAME model to an image.

3. Texture completion

After fitting, the computed texture offsets capture for each image the facial appearance of the non-occluded skin region. To complete the texture maps, we train an inpainting network adapted from GMCNN (across all texture maps) supervisely by adding random strokes (i.e. strokes of random size and location) in the visible face region(visibility obtained from the fitted reconstruction) and learning to inpaint these strokes. Once trained, we inpaint all missing regions with the resulting inpainting network.

4. Texture space computation

After completing these 1500 texture maps, we use principal component analysis (PCA) to compute a texture space.

Demos

The single image photometric fitting demo is implemented and tested in a conda environment with PyTorch 1.5 and PyTorch3D 0.2 in Python 3.8.3. For better CUDA supports, we recommend you to install PyTorch3D 0.2 via conda,

conda create -n pytorch3d python=3.8
conda activate pytorch3d
conda install -c pytorch pytorch=1.5.0 torchvision cudatoolkit=10.2
conda install -c conda-forge -c fvcore fvcore
conda install pytorch3d -c pytorch3d

ATTENTION: The pip and conda packages of PyTorch3D have different dependencies, please follow their installation guide.

Run this demo with specified FFHQ image name and computing device,

python photometric_fitting.py 00000 cuda

Another simple demo to sample the texture space can be found here.

License

The code is available for non-commercial scientific research purposes. The texture model is available under Creative Commons BY-NC-SA 4.0 license. For details see the Texture license.

Notes

We use the FLAME.py from FLAME_PyTorch and the renderer.py from DECA.

Citation

When using this code or the texture model in a scientific publication, please cite this GitHub repository and the FFHQ dataset. When using the FLAME geometry model, please cite the model (you find the up-to-date bibtex here).

Contact

For questions regarding the provided fitting code please contact [email protected], for FLAME related questions please contact [email protected].

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].