All Projects → cleardusk → 3ddfa_v2

cleardusk / 3ddfa_v2

Licence: mit
The official PyTorch implementation of Towards Fast, Accurate and Stable 3D Dense Face Alignment, ECCV 2020.

Programming Languages

python
139335 projects - #7 most used programming language
C++
36643 projects - #6 most used programming language
cython
566 projects
c
50402 projects - #5 most used programming language
Jupyter Notebook
11667 projects
CMake
9771 projects
shell
77523 projects

Projects that are alternatives of or similar to 3ddfa v2

3ddfa
The PyTorch improved version of TPAMI 2017 paper: Face Alignment in Full Pose Range: A 3D Total Solution.
Stars: ✭ 3,154 (+60.84%)
Mutual labels:  3d, face-alignment, 3d-face, 3dmm
Tf flame
Tensorflow framework for the FLAME 3D head model. The code demonstrates how to sample 3D heads from the model, fit the model to 2D or 3D keypoints, and how to generate textured head meshes from Images.
Stars: ✭ 193 (-90.16%)
Mutual labels:  3d, face-alignment
Eos
A lightweight 3D Morphable Face Model fitting library in modern C++14
Stars: ✭ 1,579 (-19.48%)
Mutual labels:  3d-face, 3dmm
SOLAR
PyTorch code for "SOLAR: Second-Order Loss and Attention for Image Retrieval". In ECCV 2020
Stars: ✭ 150 (-92.35%)
Mutual labels:  eccv, eccv-2020
DeepVTB
🌌 OpenVTuber-虚拟アイドル共享计划 An application of real-time face and gaze analyzation via deep nerual networks.
Stars: ✭ 32 (-98.37%)
Mutual labels:  face-alignment, eccv
Pytorch face landmark
Fast and accurate face landmark detection library using PyTorch; Support 68-point semi-frontal and 39-point profile landmark detection; Support both coordinate-based and heatmap-based inference; Up to 100 FPS landmark inference speed with SOTA face detector on CPU.
Stars: ✭ 388 (-80.21%)
Mutual labels:  onnx, face-alignment
Peppa-Facial-Landmark-PyTorch
Facial Landmark Detection based on PyTorch
Stars: ✭ 172 (-91.23%)
Mutual labels:  alignment, onnx
JSTASR-DesnowNet-ECCV-2020
This is the project page of our paper which has been published in ECCV 2020.
Stars: ✭ 17 (-99.13%)
Mutual labels:  eccv, eccv-2020
Deca
DECA: Detailed Expression Capture and Animation
Stars: ✭ 292 (-85.11%)
Mutual labels:  alignment, 3d
Mesh mesh align plus
Precisely align, move, and measure+match objects and mesh parts in your 3D scenes.
Stars: ✭ 350 (-82.15%)
Mutual labels:  alignment, 3d
Prnet
Joint 3D Face Reconstruction and Dense Alignment with Position Map Regression Network (ECCV 2018)
Stars: ✭ 4,479 (+128.4%)
Mutual labels:  alignment, 3d
Vircadia
Vircadia open source metaverse platform, based on the former High Fidelity Virtual Reality Platform.
Stars: ✭ 110 (-94.39%)
Mutual labels:  3d
Giojs
🌏 A Declarative 3D Globe Data Visualization Library built with Three.js
Stars: ✭ 1,528 (-22.08%)
Mutual labels:  3d
Uav Mapper
UAV-Mapper is a lightweight UAV Image Processing System, Visual SFM reconstruction or Aerial Triangulation, Fast Ortho-Mosaic, Plannar Mosaic, Fast Digital Surface Map (DSM) and 3d reconstruction for UAVs.
Stars: ✭ 106 (-94.59%)
Mutual labels:  3d
Ode4j
Java 3D Physics Engine & Library
Stars: ✭ 105 (-94.65%)
Mutual labels:  3d
Sortmerna
SortMeRNA: next-generation sequence filtering and alignment tool
Stars: ✭ 108 (-94.49%)
Mutual labels:  alignment
Kicad 3d Models In Freecad
kicad 3d models in freecad
Stars: ✭ 104 (-94.7%)
Mutual labels:  3d
Pose Interpreter Networks
Real-Time Object Pose Estimation with Pose Interpreter Networks (IROS 2018)
Stars: ✭ 104 (-94.7%)
Mutual labels:  3d
Websoftspheredemo
Implement and optimizate ANALYTICAL FOAM algorithm metioned in Entagma
Stars: ✭ 104 (-94.7%)
Mutual labels:  3d
Iros20 6d Pose Tracking
[IROS 2020] se(3)-TrackNet: Data-driven 6D Pose Tracking by Calibrating Image Residuals in Synthetic Domains
Stars: ✭ 113 (-94.24%)
Mutual labels:  3d

Towards Fast, Accurate and Stable 3D Dense Face Alignment

License GitHub repo size CodeFactor

By Jianzhu Guo, Xiangyu Zhu, Yang Yang, Fan Yang, Zhen Lei and Stan Z. Li. The code repo is owned and maintained by Jianzhu Guo.

demo

[Updates]

  • 2021.7.10: Run 3DDFA_V2 online on Gradio.
  • 2021.1.15: Borrow the implementation of Dense-Head-Pose-Estimation for the faster mesh rendering (speedup about 3x, 15ms -> 4ms), see utils/render_ctypes.py for details.
  • 2020.10.7: Add the latency evaluation of the full pipeline in latency.py, just run by python3 latency.py --onnx, see Latency evaluation for details.
  • 2020.10.6: Add onnxruntime support for FaceBoxes to reduce the face detection latency, just append the --onnx action to activate it, see FaceBoxes_ONNX.py for details.
  • 2020.10.2: Add onnxruntime support to greatly reduce the 3dmm parameters inference latency, just append the --onnx action when running demo.py, see TDDFA_ONNX.py for details.
  • 2020.9.20: Add features including pose estimation and serializations to .ply and .obj, see pose, ply, obj options in demo.py.
  • 2020.9.19: Add PNCC (Projected Normalized Coordinate Code), uv texture mapping features, see pncc, uv_tex options in demo.py.

Introduction

This work extends 3DDFA, named 3DDFA_V2, titled Towards Fast, Accurate and Stable 3D Dense Face Alignment, accepted by ECCV 2020. The supplementary material is here. The gif above shows a webcam demo of the tracking result, in the scenario of my lab. This repo is the official implementation of 3DDFA_V2.

Compared to 3DDFA, 3DDFA_V2 achieves better performance and stability. Besides, 3DDFA_V2 incorporates the fast face detector FaceBoxes instead of Dlib. A simple 3D render written by c++ and cython is also included. This repo supports the onnxruntime, and the latency of regressing 3DMM parameters using the default backbone is about 1.35ms/image on CPU with a single image as input. If you are interested in this repo, just try it on this google colab! Welcome for valuable issues, PRs and discussions 😄

Getting started

Requirements

See requirements.txt, tested on macOS and Linux platforms. The Windows users may refer to FQA for building issues. Note that this repo uses Python3. The major dependencies are PyTorch, numpy, opencv-python and onnxruntime, etc. If you run the demos with --onnx flag to do acceleration, you may need to install libomp first, i.e., brew install libomp on macOS.

Usage

  1. Clone this repo
git clone https://github.com/cleardusk/3DDFA_V2.git
cd 3DDFA_V2
  1. Build the cython version of NMS, Sim3DR, and the faster mesh render
sh ./build.sh
  1. Run demos
# 1. running on still image, the options include: 2d_sparse, 2d_dense, 3d, depth, pncc, pose, uv_tex, ply, obj
python3 demo.py -f examples/inputs/emma.jpg --onnx # -o [2d_sparse, 2d_dense, 3d, depth, pncc, pose, uv_tex, ply, obj]

# 2. running on videos
python3 demo_video.py -f examples/inputs/videos/214.avi --onnx

# 3. running on videos smoothly by looking ahead by `n_next` frames
python3 demo_video_smooth.py -f examples/inputs/videos/214.avi --onnx

# 4. running on webcam
python3 demo_webcam_smooth.py --onnx

The implementation of tracking is simply by alignment. If the head pose > 90° or the motion is too fast, the alignment may fail. A threshold is used to trickly check the tracking state, but it is unstable.

You can refer to demo.ipynb or google colab for the step-by-step tutorial of running on the still image.

For example, running python3 demo.py -f examples/inputs/emma.jpg -o 3d will give the result below:

demo

Another example:

demo

Running on a video will give:

demo

More results or demos to see: Hathaway.

Features (up to now)

2D sparse 2D dense 3D
2d sparse 2d dense 3d
Depth PNCC UV texture
depth pncc uv_tex
Pose Serialization to .ply Serialization to .obj
pose ply obj

Configs

The default backbone is MobileNet_V1 with input size 120x120 and the default pre-trained weight is weights/mb1_120x120.pth, shown in configs/mb1_120x120.yml. This repo provides another config in configs/mb05_120x120.yml, with the widen factor 0.5, being smaller and faster. You can specify the config by -c or --config option. The released models are shown in the below table. Note that the inference time on CPU in the paper is evaluated using TensorFlow.

Model Input #Params #Macs Inference (TF)
MobileNet 120x120 3.27M 183.5M ~6.2ms
MobileNet x0.5 120x120 0.85M 49.5M ~2.9ms

Surprisingly, the latency of onnxruntime is much smaller. The inference time on CPU with different threads is shown below. The results are tested on my MBP (i5-8259U CPU @ 2.30GHz on 13-inch MacBook Pro), with the 1.5.1 version of onnxruntime. The thread number is set by os.environ["OMP_NUM_THREADS"], see speed_cpu.py for more details.

Model THREAD=1 THREAD=2 THREAD=4
MobileNet 4.4ms 2.25ms 1.35ms
MobileNet x0.5 1.37ms 0.7ms 0.5ms

Latency

The onnx option greatly reduces the overall CPU latency, but face detection still takes up most of the latency time, e.g., 15ms for a 720p image. 3DMM parameters regression takes about 1~2ms for one face, and the dense reconstruction (more than 30,000 points, i.e. 38,365) is about 1ms for one face. Tracking applications may benefit from the fast 3DMM regression speed, since detection is not needed for every frame. The latency is tested using my 13-inch MacBook Pro (i5-8259U CPU @ 2.30GHz).

The default OMP_NUM_THREADS is set 4, you can specify it by setting os.environ['OMP_NUM_THREADS'] = '$NUM' or inserting export OMP_NUM_THREADS=$NUM before running the python script.

demo

FQA

  1. What is the training data?

    We use 300W-LP for training. You can refer to our paper for more details about the training. Since few images are closed-eyes in the training data 300W-LP, the landmarks of eyes are not accurate when closing. The eyes part of the webcam demo are also not good.

  2. Running on Windows.

    You can refer to this comment for building NMS on Windows.

Acknowledgement

  • The FaceBoxes module is modified from FaceBoxes.PyTorch.
  • A list of previous works on 3D dense face alignment or reconstruction: 3DDFA, face3d, PRNet.
  • Thank AK391 for hosting the Gradio web app.

Other implementations or applications

Citation

If your work or research benefits from this repo, please cite two bibs below : ) and 🌟 this repo.

@inproceedings{guo2020towards,
    title =        {Towards Fast, Accurate and Stable 3D Dense Face Alignment},
    author =       {Guo, Jianzhu and Zhu, Xiangyu and Yang, Yang and Yang, Fan and Lei, Zhen and Li, Stan Z},
    booktitle =    {Proceedings of the European Conference on Computer Vision (ECCV)},
    year =         {2020}
}

@misc{3ddfa_cleardusk,
    author =       {Guo, Jianzhu and Zhu, Xiangyu and Lei, Zhen},
    title =        {3DDFA},
    howpublished = {\url{https://github.com/cleardusk/3DDFA}},
    year =         {2018}
}

Contact

Jianzhu Guo (郭建珠) [Homepage, Google Scholar]: [email protected] or [email protected] or [email protected] (this email will be invalid soon).

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].