The project's aim is to compare the results obtained with the pretrained Extreme 3D Faces CNN (https://github.com/anhttran/extreme_3d_faces) [1] and a ground truth using a well-known dataset (http://kunzhou.net/zjugaps/facewarehouse/) [2] to measure the similarity between the two models and, hence, estimate the performance of the net. The aligment phase is realized with cpd rigid algorithm [3].
To build and run the files, you will need the following libraries:
- scikit-learn 0.21.2
- matplotlib 3.1.1
- pycpd 1.0.5
- numpy 1.16.2
- open3d-python 0.7.0.0
- scipy 1.3.0
- h5py 2.9.0
To run the whole project, you are required to follow some steps. The parameters of each function will be explained in the next subsection.
- Download the Extreme 3D Faces
and follow the instructions to make it work correctly. Otherwise, you will need
some 3D models from another CNN in a
.ply
format (in this case, you will also need to adapt the next steps). - Save the
.ply
files of the network in thefilePlyRete
folder. - Get the FaceWarehouse dataset
- Copy the data of the dataset in a
faceWarehouse
folder. - Run the
plyTotxt()
function inplyConverter.py
choosing the right values of the parameters. This will convert the.ply
files in a bunch of.txt
(stored in thedata
folder) files in order to make the next steps easier. - Run the
MatTotxt()
function in thematConverter.py
file. This will convert the dataset's.mat
3D models in a.txt
format and store them in agroudtruth
folder. - Run
distancesTest()
intest.py
to find out how much the two models are similar. If you want an overview of the accuracy of the different poses, you can also runposesPrecision()
. - To build a heatmap of the alignment, you can run the
open3Dheatmap()
function in theheatmap.py
file.
plyTotxt()
:directory
stands for the directory where you can find the.ply
files. If you follow the steps above, this should be set to'filePlyRete/'
;compressionLevel
stands for the sampling parameterK
of the KNNSearch algorithm: since a single model has over 170.000 points, you will probably need to sample the model (depending on your hardware). If you have a single-node cluster, we recommend you to leave this parameter to its default value;radius
stands for the maximum distance (from the nose tip) of the useful points: the CNN we've used reconstructs the ears, while the ground truth models have not also those points so, to achieve a better alignment, we've focused just on the face setting this parameter properly.MatTotxt()
: same asplyTotxt()
, but with ground truth Matlab files.distancesTest()
: the FaceWarehouse dataset is structured this way: there are 150 candidates and 20 poses for each candidate. This means we can choose a subset of the candidates and also a subset of poses to run the test.testers
andposes
are two lists in which you just need to put the number of the testers and the poses you want to test.posesPrecision()
: same asdistancesTest()
open3Dheatmap()
:target
stands for the ground truth.txt
model file path, whilesource
stands for the CNN.txt
model file path.
[1] A. Tran, T. Hassner, I. Masi, E. Paz, Y. Nirkin, G. Medioni, Extreme 3D Face Reconstruction: Seeing Through Occlusions, IEEE Conf. on Computer Vision and Pattern Recognition (CVPR), 2018.
[2] Cao Chen, Yanlin Weng, Shun Zhou, Yiying Tong, Kun Zhou: "FaceWarehouse: a 3D Facial Expression Database for Visual Computing", IEEE Transactions on Visualization and Computer Graphics, 20(3): 413-425, 2014.
[3] Andriy Myronenko and Xubo Song, Point Set Registration: Coherent Point Drift, IEEE Trans. on Pattern Analysis and Machine Intelligence, vol. 32, issue 12, pp. 2262-2275, 2009.