This is an official python implementation of PRN. The training code will be released(about two months later).
PRN is a method to jointly regress dense alignment and 3D face shape in an end-to-end manner. More examples on Multi-PIE and 300VW can be seen in YouTube .
The main features are:
-
End-to-End our method can directly regress the 3D facial structure and dense alignment from a single image bypassing 3DMM fitting.
-
Multi-task By regressing position map, the 3D geometry along with semantic meaning can be obtained. Thus, we can effortlessly complete the tasks of dense alignment, monocular 3D face reconstruction, pose estimation, etc.
-
Faster than real-time The method can run at over 100fps(with GTX 1080) to regress a position map.
-
Robust Tested on facial images in unconstrained conditions. Our method is robust to poses, illuminations and occlusions.
Dense alignment of both visible and non-visible points(including 68 key points).
And the visibility of points(1 for visible and 0 for non-visible).
Get the 3D vertices and corresponding colours from a single image. Save the result as mesh data(.obj), which can be opened with Meshlab or Microsoft 3D Builder. Notice that, the texture of non-visible area is distorted due to self-occlusion.
New:
- you can choose to output mesh with its original pose(default) or with front view(which means all output meshes are aligned)
- obj file can now also written with texture map, and you can set non-visible texture to 0.
-
Rather than only use 68 key points to calculate the camera matrix(easily effected by expression and poses), we use all vertices(more than 40K) to calculate a more accurate pose.
-
Python 2.7 (numpy, skimage, scipy)
-
TensorFlow >= 1.4
Optional:
-
dlib (for detecting face. You do not have to install if you can provide bounding box information. )
-
opencv2 (for showing results)
GPU is highly recommended. The run time is ~0.01s with GPU(GeForce GTX 1080) and ~0.2s with CPU(Intel(R) Xeon(R) CPU E5-2640 v4 @ 2.40GHz).
- Clone the repository
git clone https://github.com/YadiraF/PRNet
cd PRNet
-
Download the PRN trained model at BaiduDrive or GoogleDrive, and put it into
Data/net-data
-
Run the test code.(test AFLW2000 images)
python run_basics.py #Can run only with python and tensorflow
-
Run with your own images
python demo.py -i <inputDir> -o <outputDir> --isDlib True
run
python demo.py --help
for more details. -
For Texture Editing Apps:
python demo_texture.py -i image_path_1 -r image_path_2 -o output_path
run
python demo_texture.py --help
for more details.
- 2018/5/10 add texture editing examples(for data augmentation, face swapping)
- 2018/4/28 add visibility of vertices, output obj file with texture map, depth image
- 2018/4/26 can output mesh with front view
- 2018/3/28 add pose estimation
- 2018/3/12 first release(3d reconstruction and dense alignment)
Please contact fengyao@sjtu.edu.cn or open an issue for any questions or suggestions(like, push me to add more applications).
Thanks! (●'◡'●)
- Thanks BFM team, Xiangyu Zhu, and Anil Bas for sharing 3D data.
- Thanks Patrik Huber for sharing his work eos, which helps me a lot in studying 3D Face Reconstruction.
- Thanks the authors of 3DMMasSTN, DenseReg, 3dmm_cnn, vrn, pix2vertex, face-alignment for making their excellent works publicly available.