Code Monkey home page Code Monkey logo

3dmm_cnn's Introduction

Python code for 3D face modeling from single image using our very deep neural network

New: Please see our follow up project for deep pose and 3D expression fitting.

This page contains end-to-end demo code that estimates the 3D facial shape and texture directly from an unconstrained 2D face image. For a given input image, it produces a standard ply file of the face shape and texture. It accompanies the deep network described in our paper [1]. We also include demo code of pose and expression fitting from landmarks in this release.

This release is part of an on-going face recognition and modeling project. Please, see this page for updates and more data.

Teaser

Features

  • End-to-End code to be used for 3D shape and texture estimation directly from image intensities
  • Designed and tested on face images in unconstrained conditions, including the challenging LFW, YTF and IJB-A benchmarks
  • The 3D face shape and texture parameters extracted using our network were shown for the first time to be descriminative and robust, providing near state of the art face recognition performance with 3DMM representations on these benchmarks
  • No expensive, iterative optimization, inner loops to regress the shape. 3DMM fitting is therefore extremely fast
  • Extra code for head pose and expression estimation from detected facial landmarks, with the use of the regressed 3D face model

Dependencies

Library requirements

The code has been tested on Linux only. On Linux you can rely on the default version of python, installing all the packages needed from the package manager or on Anaconda Python and install required packages through conda. A bit more effort is required to install caffé, dlib, and libhdf5.

Automatic Install of the Dependencies

Check this useful script on the wiki by seva100

Data requirements

Before running the code, please, make sure to have all the required data in the following specific folder:

  • Download our CNN and move the CNN model (3 files: 3dmm_cnn_resnet_101.caffemodel,deploy_network.prototxt,mean.binaryproto) into the CNN folder
  • Download the Basel Face Model and move 01_MorphableModel.mat into the 3DMM_model folder
  • Acquire 3DDFA Expression Model, run its code to generate Model_Expression.mat and move this file the 3DMM_model folder
  • Go into 3DMM_model folder. Run the script python trimBaselFace.py. This should output 2 files BaselFaceModel_mod.mat and BaselFaceModel_mod.h5.
  • Download dlib face prediction model and move the .dat file into the dlib_model folder.

Installation (pose & expression fitting code)

  • Install cmake:
	apt-get install cmake
  • Install opencv (2.4.6 or higher is recommended):
	(http://docs.opencv.org/doc/tutorials/introduction/linux_install/linux_install.html)
  • Install libboost (1.5 or higher is recommended):
	apt-get install libboost-all-dev
  • Install OpenGL, freeglut, and glew
	sudo apt-get install freeglut3-dev
	sudo apt-get install libglew-dev
  • Install libhdf5-dev library
	sudo apt-get install libhdf5-dev
  • Install Dlib C++ library. Dlib should be compiled to shared objects. Check the comments in its CMakeList.txt.
	(http://dlib.net/)
  • Update Dlib directory paths (DLIB_INCLUDE_DIR and DLIB_LIB_DIR) in CMakeLists.txt
  • Make build directory (temporary). Make & install to bin folder
	mkdir build
	cd build
	cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=../bin ..
	make
	make install

This code should generate TestVisualization in bin folder

Usage

3DMM fitting on a set of input images

  • Go into demoCode folder. The demo script can be used from the command line with the following syntax:
$ Usage: python testBatchModel.py <inputList> <outputDir> <needCrop> <useLM>

where the parameters are the following:

  • <inputList> is a text file containing the paths to each of the input images, one in each line.
  • <outputDir> is the path to the output directory, where ply files are stored.
  • <needCrop> tells the demo if the images need cropping (1) or not (0). Default 1. If your input image size is equal (square) and has a CASIA-like [2] bounding box, you can set <needCrop> as 0. Otherwise, you have to set it as 1.
  • <useLM> is an option to refine the bounding box using detected landmarks (1) or not (0). Default 1.

Example for <inputList>:

data/1.jpg
data/2.jpg
....
  • The demo code should produce an output similar to this:
user@system:~/Desktop/3dmm_release$ python testBatchModel.py input.txt out/
> Prepare image data/1.jpg:
>     Number of faces detected: 1
> Prepare image data/2.jpg:
>     Number of faces detected: 1
> CNN Model loaded to regress 3D Shape and Texture!
> Loaded the Basel Face Model to write the 3D output!
> Processing image:  tmp_ims/2.png   2.png   1/2
> Writing 3D file in:  out//2.ply
> Processing image:  tmp_ims/1.png   1.png   2/2
> Writing 3D file in:  out//1.ply

The final 3D shape and texture can be displayed using standard off-the-shelf 3D (ply file) visualization software such as MeshLab. Using MeshLab, the output may be displayed as follows:

user@system:~/Desktop/3dmm_release$ meshlab out/1.ply

user@system:~/Desktop/3dmm_release$ meshlab out/2.ply

which should produce something similar to:

Teaser

3D Face modeling + pose & expression estimation on a single input image

  • Go into demoCode folder. The demo script can be used from the command line with the following syntax:
$ Usage: python testModel_PoseExpr.py <outputDir> <save3D>

where the parameters are the following:

  • <outputDir> is the path to the output directory, where 3DMM (and ply) files are stored.
  • <save3D> is an option to save the ply file (1) or not (0). Default 1.
  • The program will pop up a dialog to select an input image. Then it will estimate 3DMM paramters (with the CNN model), estimate pose+expression and visualize the result (with C++ program)

Example:

user@system:~/Desktop/3dmm_release$ python testModel_PoseExpr.py out/
(Select `Anders_Fogh_Rasmussen_0004.jpg`)
> Prepare image /home/anh/Downloads/PoseExprFromLM-master/demoCode/data/Anders_Fogh_Rasmussen_0004.jpg:
    Number of faces detected: 1
> CNN Model loaded to regress 3D Shape and Texture!
> Loaded the Basel Face Model to write the 3D output!
*****************************************
** Caffe loading    : 1.007 s
** Image cropping   : 0.069 s
** 3D Modeling      : 1.145 s
*****************************************
> Writing 3D file in:  out/Anders_Fogh_Rasmussen_0004.ply
> Pose & expression estimation
load ../3DMM_model/BaselFaceModel_mod.h5
** Pose+expr fitting: 0.153 s
** Visualization    : 0.052 s
*****************************************

The pop up window should look similar to: Teaser

Citation

If you find this work useful, please cite our paper [1] with the following bibtex:

@inproceedings{tran2017regressing,
  title={Regressing Robust and Discriminative 3D Morphable Models with a very Deep Neural Network},
  author={Tran, Anh Tuan and Hassner, Tal and Masi, Iacopo and Medioni, Gerard},
  booktitle={Computer Vision and Pattern Recognition (CVPR)},
  year={2017}
}

Troubleshooting

Problem: Old Caffe Engine

"F0210 10:49:17.604714 24046 net.cpp:797] Check failed:
target_blobs.size() == source_layer.blobs_size() (5 vs. 3) Incompatible
number of blobs for layer bn_conv1"

Solution: install caffe 1.0.0-rc3 or above.

For more info on caffe verson please see https://github.com/BVLC/caffe/releases

To check your caffe version from python:

In [3]: import caffe
In [4]: caffe.__version__
Out[4]: '1.0.0-rc3'

References

[1] A. Tran, T. Hassner, I. Masi, G. Medioni, "Regressing Robust and Discriminative 3D Morphable Models with a very Deep Neural Network", arxiv pre-print 2016

[2] Dong Yi, Zhen Lei, Shengcai Liao and Stan Z. Li, "Learning Face Representation from Scratch". arXiv preprint arXiv:1411.7923. 2014.

Changelog

  • Jan 2017, First Release

License and Disclaimer

Please, see the LICENSE here

Contacts

If you have any questions, drop an email to [email protected] , [email protected] and [email protected] or leave a message below with GitHub (log-in is needed).

3dmm_cnn's People

Contributors

anhttran avatar iacopomasi avatar talhassner avatar tangshi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

3dmm_cnn's Issues

compile error:undefined reference to symbol 'dgesdd_'

/usr/bin/ld: ../modules/PoseExpr/libPoseExprLib.a(DlibWrapper.cpp.o): undefined reference to symbol 'dgesdd_'
//usr/lib/libopenblas.so.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
config/CMakeFiles/TestVisualization.dir/build.make:132: recipe for target 'bin/TestVisualization' failed
make[2]: *** [bin/TestVisualization] Error 1
CMakeFiles/Makefile2:196: recipe for target 'config/CMakeFiles/TestVisualization.dir/all' failed
make[1]: *** [config/CMakeFiles/TestVisualization.dir/all] Error 2
Makefile:127: recipe for target 'all' failed
make: *** [all] Error 2

Error in load BFM mat file

How to solve this error ?

CNN Model loaded to regress 3D Shape and Texture!
/usr/lib/python2.7/dist-packages/scipy/sparse/compressed.py:130: VisibleDeprecationWarning: rank is deprecated; use the ndim attribute or function instead. To find the rank of a matrix see numpy.linalg.matrix_rank.
if np.rank(self.data) != 1 or np.rank(self.indices) != 1 or np.rank(self.indptr) != 1:
Traceback (most recent call last):
File "demo.py", line 153, in
model = model["BFM"]
KeyError: 'BFM'

The install.sh may exist errors

I followed the install tutorial, but the caffe can't be installed on my ubuntu. Could you please check the install script of caffe and lib for c++, and give more details about it.

OpenCV linking error

I'm trying to run cmake and make but I get the following error

  Found OpenCV Windows Pack but it has not binaries compatible with your
  configuration.

  You should manually point CMake variable OpenCV_DIR to your build of OpenCV
  library.
Call Stack (most recent call first):
  CMakeLists.txt:15 (find_package)


CMake Error at CMakeLists.txt:15 (find_package):
  Found package configuration file:

    /home/savvycom/OpenCV/cmake/OpenCVConfig.cmake

  but it set OpenCV_FOUND to FALSE so package "OpenCV" is considered to be
  NOT FOUND.


-- Configuring incomplete, errors occurred!

My OpenCV version is 2.4.9 (installed from source) and my dlib version is 19.6.

I've tried to add set (OPENCV_DIR "~/OpenCV/build/") to CMakeLists.txt and remove find_package( OpenCV REQUIRED ). I ran cmake successfully and make with 100% then failed with this error:

../modules/CvGl/libCvGl.a(FBRender.cpp.o): In function `FBRender::checkClip(double, double, double)':
FBRender.cpp:(.text+0x120c): undefined reference to `cvCreateMat'
FBRender.cpp:(.text+0x1334): undefined reference to `cvCreateMat'
FBRender.cpp:(.text+0x1456): undefined reference to `cvCreateMat'
FBRender.cpp:(.text+0x14b7): undefined reference to `cvCreateMat'
FBRender.cpp:(.text+0x14df): undefined reference to `cvGEMM'
FBRender.cpp:(.text+0x14f0): undefined reference to `cvCopy'
FBRender.cpp:(.text+0x1515): undefined reference to `cvGEMM'
FBRender.cpp:(.text+0x1696): undefined reference to `cvReleaseMat'
FBRender.cpp:(.text+0x16a0): undefined reference to `cvReleaseMat'
FBRender.cpp:(.text+0x16aa): undefined reference to `cvReleaseMat'
FBRender.cpp:(.text+0x16b4): undefined reference to `cvReleaseMat'
collect2: error: ld returned 1 exit status
config/CMakeFiles/TestVisualization.dir/build.make:103: recipe for target 'bin/TestVisualization' failed
make[2]: *** [bin/TestVisualization] Error 1
CMakeFiles/Makefile2:196: recipe for target 'config/CMakeFiles/TestVisualization.dir/all' failed
make[1]: *** [config/CMakeFiles/TestVisualization.dir/all] Error 2
Makefile:127: recipe for target 'all' failed
make: *** [all] Error 2

Can anyone help me fix this ?

dlib::serialization_error

Hello,

I tried to run testModel_PoseExpr.py.
But it throws an exception with it.

terminate called after throwing an instance of 'dlib::serialization_error'
what(): An error occurred while trying to read the first object from the file ../3DMM_model/BaselFaceModel_mod.h5.
ERROR: Error deserializing object of type int

Any suggestions for it?

"H5Cpp.h: No such file or directory" error once.

hi,
i have already set "export CPATH=/usr/include/hdf5/serial/**:$CPATH" , but still wrong.

===================
/home/demo/3dmm_cnn/modules/PoseExpr/src/BaselFace.cpp:19:19: fatal error: H5Cpp.h: No such file or directory
compilation terminated.
modules/PoseExpr/CMakeFiles/PoseExprLib.dir/build.make:110: recipe for target 'modules/PoseExpr/CMakeFiles/PoseExprLib.dir/src/BaselFace.cpp.o' failed
make[2]: *** [modules/PoseExpr/CMakeFiles/PoseExprLib.dir/src/BaselFace.cpp.o] Error 1
CMakeFiles/Makefile2:140: recipe for target 'modules/PoseExpr/CMakeFiles/PoseExprLib.dir/all' failed
make[1]: *** [modules/PoseExpr/CMakeFiles/PoseExprLib.dir/all] Error 2
Makefile:127: recipe for target 'all' failed
make: *** [all] Error 2

can not download ResNet-101 for 3DMM Regression

After i submitted my information, i got the following instruction:
"""
You can access the download page from this link
https://goo.gl/RwU7Nz
Thank you!
"""
But when i clicked the link above, it told me that:
""
Redirecting you to https://goo.gl/RwU7Nz
"""
the link doesn't send any data.

I also see that the same issue occurred for somebody, but i don't know how to solve it.

Could you tell me what should i do to get access to the code? thanks

Getting hdf5 related error while linking

I am getting following error while linking

../modules/PoseExpr/libPoseExprLib.a(BaselFace.cpp.o): In function readH5Dataset(H5::H5File const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)': BaselFace.cpp:(.text+0x8e): undefined reference to H5::CommonFG::openDataSet(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&) const'
../modules/PoseExpr/libPoseExprLib.a(BaselFace.cpp.o): In function BaselFace::load(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)': BaselFace.cpp:(.text+0x279e): undefined reference to H5::Exception::getDetailMsgabi:cxx11 const'
collect2: error: ld returned 1 exit status
config/CMakeFiles/TestVisualization.dir/build.make:128: recipe for target 'bin/TestVisualization' failed
make[2]: *** [bin/TestVisualization] Error 1
CMakeFiles/Makefile2:196: recipe for target 'config/CMakeFiles/TestVisualization.dir/all' failed
make[1]: *** [config/CMakeFiles/TestVisualization.dir/all] Error 2
Makefile:127: recipe for target 'all' failed
make: *** [all] Error 2

I am building on ubuntu 16.04.

error: ‘Rodrigues’ is not a member of ‘cv’

After

mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=../bin ..

When I try to “make”
it shows :

   **/3dmm_cnn/modules/PoseExpr/src/BaselFaceEstimator.cpp: In member function ‘void BaselFaceEstimator::estimatePose3D(cv::Mat, cv::Mat, cv::Mat, cv::Mat&, cv::Mat&)’:
   /3dmm_cnn/modules/PoseExpr/src/BaselFaceEstimator.cpp:207:2: error: ‘Rodrigues’ is not a member of ‘cv’
    cv::Rodrigues(rMatP, rVec);**
     ^

HI

Hi, can u support the training code and data for study

caffe error..!

Hii,
I am new to python when i am trying to install caffe i am getting error when running make all,make pycaffe.The error is
CXX .build_release/src/caffe/proto/caffe.pb.cc
In file included from .build_release/src/caffe/proto/caffe.pb.cc:5:0:
.build_release/src/caffe/proto/caffe.pb.h:12:2: error: #error This file was generated by a newer version of protoc which is
#error This file was generated by a newer version of protoc which is
^
.build_release/src/caffe/proto/caffe.pb.h:13:2: error: #error incompatible with your Protocol Buffer headers. Please update
#error incompatible with your Protocol Buffer headers. Please update
^
.build_release/src/caffe/proto/caffe.pb.h:14:2: error: #error your headers.
#error your headers.
^
In file included from .build_release/src/caffe/proto/caffe.pb.cc:5:0:
.build_release/src/caffe/proto/caffe.pb.h:23:35: fatal error: google/protobuf/arena.h: No such file or directory
compilation terminated.
Makefile:588: recipe for target '.build_release/src/caffe/proto/caffe.pb.o' failed
make: *** [.build_release/src/caffe/proto/caffe.pb.o] Error 1

Please any one can help
Thanks in advance

what is /home/anh anyway?

make[2]: *** No rule to make target '/home/anh/Downloads/dlib-19.4/shared_build/dlib/libdlib.so', needed by 'bin/TestVisualization'。 停止。
CMakeFiles/Makefile2:196: recipe for target 'config/CMakeFiles/TestVisualization.dir/all' failed
make[1]: *** [config/CMakeFiles/TestVisualization.dir/all] Error 2

[Question] How to run code in 3DDFA

Hello. Thanks for sharing this nice project.

I am having trouble to run 3DDFA.exe.
I am using ubuntu. Do I need a software like WINE to execute the file?
Thank you.

[Qustion] Usage of TestVisualization

Hello Thanks for sharing this nice project.

I have a question for c++ build result, "TestVisualization".
I checked the main.cpp.

printf("Usage: Visualize3D <input 3D alpha> <BaselFace.dat path> []\n");

: path to directory which contains image files?
<input 3D alpha>: totally no idea.
<BaselFace.dat path>: path to "01_MorphableModel.mat"?
path to "shape_predictor_68_face_landmarks.dat"?

I need some help to test it. :-)

H5Cpp.h

I like your paper very much.
but....
Can you tell me why?

fatal error: H5Cpp.h: No such file or directory
compilation terminated.
modules/PoseExpr/CMakeFiles/PoseExprLib.dir/build.make:110: recipe for target 'modules/PoseExpr/CMakeFiles/PoseExprLib.dir/src/BaselFace.cpp.o' failed
make[2]: *** [modules/PoseExpr/CMakeFiles/PoseExprLib.dir/src/BaselFace.cpp.o] Error 1
CMakeFiles/Makefile2:140: recipe for target 'modules/PoseExpr/CMakeFiles/PoseExprLib.dir/all' failed
make[1]: *** [modules/PoseExpr/CMakeFiles/PoseExprLib.dir/all] Error 2
Makefile:127: recipe for target 'all' failed
make: *** [all] Error 2

I use ubuntu 16.04, and have installed libhdf5-dev and libhdf5-serial-dev
thank you

undefined reference to symbol 'dgesdd_'

/usr/bin/ld: ../modules/PoseExpr/libPoseExprLib.a(DlibWrapper.cpp.o): undefined reference to symbol 'dgesdd_'
/opt/intel/mkl/lib/intel64//libmkl_rt.so: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
config/CMakeFiles/TestVisualization.dir/build.make:122: recipe for target 'bin/TestVisualization' failed
make[2]: *** [bin/TestVisualization] Error 1
CMakeFiles/Makefile2:196: recipe for target 'config/CMakeFiles/TestVisualization.dir/all' failed
make[1]: *** [config/CMakeFiles/TestVisualization.dir/all] Error 2
Makefile:127: recipe for target 'all' failed
make: *** [all] Error 2

Full head model

how to create full head model for training dataset( same like BFM, but full head)
output will be full head 3d model only mesh, no color or texture

cropped image 3d translation issue

In pose estimation cpp project, estimation is based on cropped image created by 2d-landmark positions, then in visualization we must use cropped image to project 3d model and rasterize it.
If I use full image then translation and scale is false. I have fixed the scale problem by multiplying 3d model with scale calculated in getCroppedIm method, but translation is not fixed.
What is the solution for full image visualization?
Thank you.

HDF5 object not found

Congratulations, nice work
I am trying to run your code on windows, everything works fine on python side, trimBaselFace.py successfully create modified baselface models, and testModel_PoseExpr.py works prefect.
But I am getting following error when I want to run your cpp pose find example using visual stdio.
It seems modified baselface model created by python can not be read in cpp hdf5.
It seems hdf5 is searching for object name that is not in ascii form (line #4) :

HDF5-DIAG: Error detected in HDF5 (1.8.19) thread 0:
#000: C:\Users\buildbot\Buildbot\hdf518-StdRelease-code-vs14\build\hdfsrc\src
H5D.c line 356 in H5Dopen2(): not found
major: Dataset
minor: Object not found
#1: C:\Users\buildbot\Buildbot\hdf518-StdRelease-code-vs14\build\hdfsrc\src\H5Gloc.c line 428 in H5G_loc_find(): can't find object
major: Symbol table
minor: Object not found
#2: C:\Users\buildbot\Buildbot\hdf518-StdRelease-code-vs14\build\hdfsrc\src\H5Gtraverse.c line 859 in H5G_traverse(): internal path traversal failed
major: Symbol table
minor: Object not found
#3: C:\Users\buildbot\Buildbot\hdf518-StdRelease-code-vs14\build\hdfsrc\src\H5Gtraverse.c line 639 in H5G_traverse_real(): traversal operator failed
major: Symbol table
minor: Callback failed
#4: C:\Users\buildbot\Buildbot\hdf518-StdRelease-code-vs14\build\hdfsrc\src\H5Gloc.c line 383 in H5G_loc_find_cb(): object '@>┐⌠↔' doesn't exist
major: Symbol table
minor: Object not found

/usr/bin/ld: cannot find -lhdf5

Dear all,
Please help me with this issue.
++++++++++++++++++++
92%] Building CXX object modules/PoseExpr/CMakeFiles/PoseExprLib.dir/src/RenderModel.cpp.o
[ 92%] Building CXX object modules/PoseExpr/CMakeFiles/PoseExprLib.dir/src/FaceServices2.cpp.o
[ 92%] Building CXX object modules/PoseExpr/CMakeFiles/PoseExprLib.dir/src/DlibWrapper.cpp.o
[ 92%] Linking CXX static library libPoseExprLib.a
[ 92%] Built target PoseExprLib
[ 92%] Building CXX object config/CMakeFiles/TestVisualization.dir/__/main.cpp.o
[ 92%] Linking CXX executable ../bin/TestVisualization
/usr/bin/ld: cannot find -lhdf5
collect2: error: ld returned 1 exit status
config/CMakeFiles/TestVisualization.dir/build.make:111: recipe for target 'bin/TestVisualization' failed
make[2]: *** [bin/TestVisualization] Error 1
CMakeFiles/Makefile2:201: recipe for target 'config/CMakeFiles/TestVisualization.dir/all' failed
make[1]: *** [config/CMakeFiles/TestVisualization.dir/all] Error 2
Makefile:129: recipe for target 'all' failed
make: *** [all] Error 2
++++++++++++++++++++
I am facing with this issue when running "make" for building this project.
Thank you,
Khanh

when Cmake, 92% processing, occuring a problem

*** No rule to make target '/home/pp/dlib-19.4/dlib/libdlib.so', needed by 'bin/TestVisualization'。
So how to solve the problem?
I use the dlib-19.4,and opencv=2.4.9,other included libraries have been installed.
Thanks for your reply.

Unable to download the file in the link

Hello, dear anhttran, iacopomasi and tangshi
I am about to start my undergraduate design and interested in 3D reconstruction. I read some papers and fortunately find your project. I want to try the effect that you said in the paper, but when I download the file in the link, I encountered some trouble. The process of acquiring 3DDFA Expression Model will always be terminated when the file is downloaded 33.64%. So I sincerely hope whether you can send me this file through email. Thank you very much.

About ground truth 3d face shape

It's very kind of you to share the model, I'am inspired by your work.
I'am a new guy to 3d face construction and I want to reproduce your paper.
I found your paper generate ground truth 3d face shape by paper: "Estimating 3D Shape and Texture Using Pixel Intensity, Edges, Specular Highlights, Texture Constraints and a Prior". Are you implement the method? Or where can i found this code to generate ground truth 3d face shape?
Thanks!!

Could you please explain why there are two sets of landmarks, innerLandmarkIndex and outerLandmarkIndex

Hi, @anhttran
I really want to learn all your work. :). And of course there will be many questions for you. :(

In the file "BaselFaceEstimator.cpp", there is the code snippet as below. I couldn't figure out why there are two sets of landmarks, and why the yaw angle could affect the selection of landmark index?
Any explanation from anyone would be appreciated. Thanks in advance..

// Get 3D landmarks points (68x3), given 3D shape (Vx3) and yaw angle
cv::Mat BaselFaceEstimator::getLM(cv::Mat shape, float yaw){
	cv::Mat lm(bf.lmInd.rows,3,CV_32F);
	for (int i=0;i<lm.rows;i++){
		int ind;
		if (yaw > 0 && yaw < M_PI/9 && i < 8) ind = bf.lmInd.at<int>(i,0)-1;
		else if (yaw < 0 && yaw > -M_PI/9 && i > 8 && i < 17) ind = bf.lmInd.at<int>(i,0)-1;
		else
		ind = bf.lmInd2.at<int>(i)-1;
		for (int j=0;j<3;j++){
			lm.at<float>(i,j) = shape.at<float>(ind,j);
		}
	}
	return lm;
}

The input of multi images for one face model

I am looking a method to generate one face model by feeding multi-images of one person. does your code support that? Hope for your replying.
PS: I see that you use multi-images of one man to train the network, so I wonder the similar input to get one model.

dlib/image_processing/frontal_face_detector.h: No such file or directory

download dlib-19.4 and python setup.py install. 'import dlib' in python is all ok

and then i update Dlib directory paths (DLIB_INCLUDE_DIR and DLIB_LIB_DIR) in CMakeLists.txt.
set (DLIB_INCLUDE_DIR "/home/xiaoyun/soft/dlib-19.4.0")
But there's no folder named "/...../dlib-19.4/shared_build/dlib", my path is ""/...../dlib-19.4.0/build"".

and then Make build directory (temporary) and Make

the error is :
/data/yun/speech2video/3dmm_cnn/modules/PoseExpr/include/DlibWrapper.h:7:57: fatal error: dlib/image_processing/frontal_face_detector.h: No such file or directory
#include <dlib/image_processing/frontal_face_detector.h>
^
compilation terminated.
make[2]: *** [modules/PoseExpr/CMakeFiles/PoseExprLib.dir/src/DlibWrapper.cpp.o] Error 1
make[1]: *** [modules/PoseExpr/CMakeFiles/PoseExprLib.dir/all] Error 2
make: *** [all] Error 2

but i can find 'dlib/image_processing/frontal_face_detector.h'.

I wonder how to solve the problem

Asians look alike

I test some photos of Chinese. But it seems that everyone looks alike. Shapes between different people are not as discriminative as your examples.

Script for fast installation on clean ubuntu 16.04

@anhttran, huge thanks for open-sourcing this.
I would like to share the installation script for all dependencies of this repository, which I prepared for convenient installation on a clean Ubuntu 16.04, Cuda 9.2 with Conda.
This is not an issue, rather an improvement which someone might find helpful, as I hope.

Installation instructions:

  1. Download the repository and recreate additional files, as described on the repository home page
  2. Download and install CUDA for Ubuntu 16.04 (9.2 is the current latest version):
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/cuda-repo-ubuntu1604_9.2.88-1_amd64.deb
sudo dpkg -i cuda-repo-ubuntu1604_9.2.88-1_amd64.deb
sudo apt-key adv --fetch-keys http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/7fa2af80.pub
sudo apt-get update
sudo apt-get install cuda
  1. Download latest Anaconda or Miniconda
  2. Do
conda create -n=3dmm_cnn python=2.7.*
source activate 3dmm_cnn
  1. Download install.sh to the project folder, where all the files from repository are contained.
  2. Then
    bash install.sh

The script installs everything in a conda virtual environment 3dmm_cnn.

Provision of ground truths

Hi!
Could you provide the ground truths that you generated to train your model?
It will be of great help to us.

Creating caffe model

how to create my own caffe model using full head model. i have unique 50 full head model with input picture (PNG image) for creating model.
i am new for caffe network model, can you please guide me to create caffe model which is support your CNN system.

Sample model:
head

"freeglut (c): ERROR: Internal error <FBConfig with necessary capabilities not found> in function fgOpenWindow" when running the testModel_PoseExpr.py demo.

> Prepare image ~/3dmm_cnn/demoCode/data/1.jpg:
    Number of faces detected: 1
> CNN Model loaded to regress 3D Shape and Texture!
*****************************************
** Caffe loading    : 1.468 s
** Image cropping   : 2.259 s
** 3D Modeling      : 1.975 s
*****************************************
> Pose & expression estimation
load ../3DMM_model/BaselFaceModel_mod.h5
freeglut (c):  ERROR:  Internal error <FBConfig with necessary capabilities not found> in function fgOpenWindow

I found the same issue on google, but cannot work. Is there a trouble shooting about it?

Boost.Python.ArgumentError

Go into demoCode folder and use the code:
python testBatchModel.py input.txt out/ 1 1

But I get an error:

raceback (most recent call last):
File "testBatchModel.py", line 76, in
predictor = dlib.shape_predictor(predictor_path)
Boost.Python.ArgumentError: Python argument types in
shape_predictor.init(shape_predictor, str)
did not match C++ signature:
init(boost::python::api::object, std::string)
init(_object*)

link error

Hi,
Thank you for your work.
And finally I compiled all files succeed. But there is a link error can not solve.
Can you check the issue? I am not sure if it caused by version of dlib, or openblas.

$ make
[ 7%] Building CXX object modules/CvGl/CMakeFiles/CvGl.dir/FBRender.cpp.o
[ 14%] Linking CXX static library libCvGl.a
[ 14%] Built target CvGl
[ 21%] Building CXX object modules/PoseExpr/CMakeFiles/PoseExprLib.dir/src/utility.cpp.o
[ 28%] Building CXX object modules/PoseExpr/CMakeFiles/PoseExprLib.dir/src/epnp.cpp.o
[ 35%] Building CXX object modules/PoseExpr/CMakeFiles/PoseExprLib.dir/src/BaselFace.cpp.o
[ 42%] Building CXX object modules/PoseExpr/CMakeFiles/PoseExprLib.dir/src/BaselFaceEstimator.cpp.o
[ 50%] Building CXX object modules/PoseExpr/CMakeFiles/PoseExprLib.dir/src/FTModel.cpp.o
[ 57%] Building CXX object modules/PoseExpr/CMakeFiles/PoseExprLib.dir/src/FImRenderer.cpp.o
[ 64%] Building CXX object modules/PoseExpr/CMakeFiles/PoseExprLib.dir/src/RenderModel.cpp.o
[ 71%] Building CXX object modules/PoseExpr/CMakeFiles/PoseExprLib.dir/src/FaceServices2.cpp.o
[ 78%] Building CXX object modules/PoseExpr/CMakeFiles/PoseExprLib.dir/src/DlibWrapper.cpp.o
[ 85%] Linking CXX static library libPoseExprLib.a
[ 85%] Built target PoseExprLib
[ 92%] Building CXX object config/CMakeFiles/TestVisualization.dir/__/main.cpp.o
[100%] Linking CXX executable ../bin/TestVisualization
/usr/bin/ld: ../modules/PoseExpr/libPoseExprLib.a(DlibWrapper.cpp.o): undefined reference to symbol 'dgesdd_'
//usr/lib/libopenblas.so.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status

config/CMakeFiles/TestVisualization.dir/build.make:131: recipe for target 'bin/TestVisualization' failed
make[2]: *** [bin/TestVisualization] Error 1
CMakeFiles/Makefile2:196: recipe for target 'config/CMakeFiles/TestVisualization.dir/all' failed
make[1]: *** [config/CMakeFiles/TestVisualization.dir/all] Error 2
Makefile:127: recipe for target 'all' failed
make: *** [all] Error 2

Can't download ResNet-101 for 3DMM Regression

After i submitted my information,then i got the following instruction:
"""
You can access the download page from this link

Thank you!
"""
But when i clicked the link above, it told me that:
"""Redirecting you to"""
And:
"""
gist.github.com doesn't send any data.
ERR_EMPTY_RESPONSE
"""
Could anyone tell me what should i do to get access to the code? Thank you very much.

error: ‘Rodrigues’ is not a member of ‘cv’

when i use "make" to compile this project, i have a mistake as follows:

/home/zhangyao/zyao/3dmm_cnn/modules/PoseExpr/src/BaselFaceEstimator.cpp: In member function ‘void BaselFaceEstimator::estimatePose3D(cv::Mat, cv::Mat, cv::Mat, cv::Mat&, cv::Mat&)’:
/home/zhangyao/zyao/3dmm_cnn/modules/PoseExpr/src/BaselFaceEstimator.cpp:207:2:
error: ‘Rodrigues’ is not a member of ‘cv’
cv::Rodrigues(rMatP, rVec);
^
modules/PoseExpr/CMakeFiles/PoseExprLib.dir/build.make:134: recipe for target 'modules/PoseExpr/CMakeFiles/PoseExprLib.dir/src/BaselFaceEstimator.cpp.o' failed
make[2]: *** [modules/PoseExpr/CMakeFiles/PoseExprLib.dir/src/BaselFaceEstimator.cpp.o] Error 1
CMakeFiles/Makefile2:140: recipe for target 'modules/PoseExpr/CMakeFiles/PoseExprLib.dir/all' failed
make[1]: *** [modules/PoseExpr/CMakeFiles/PoseExprLib.dir/all] Error 2
Makefile:127: recipe for target 'all' failed
make: *** [all] Error 2

i installed opencv 2.4.13 .

fatal error: mkl_dfti.h: No such file or directory

install dlib-19.4.0 and Update Dlib directory paths (DLIB_INCLUDE_DIR and DLIB_LIB_DIR) in CMakeLists.txt

set (DLIB_INCLUDE_DIR "/home/xiaoyun/soft/dlib-19.4.0")
set (DLIB_LIB_DIR "/home/xiaoyun/soft/dlib-19.4.0/dlib/build")

and then Make build directory (temporary) and Make
a error:

[100%] Building CXX object config/CMakeFiles/TestVisualization.dir//main.cpp.o
In file included from /usr/local/include/dlib/matrix.h:15:0,
from /usr/local/include/dlib/geometry/point_transforms.h:9,
from /usr/local/include/dlib/geometry.h:10,
from /usr/local/include/dlib/image_processing/object_detector.h:7,
from /usr/local/include/dlib/image_processing/frontal_face_detector.h:7,
from /data/yun/speech2video/3dmm_cnn/config/../modules/PoseExpr/include/DlibWrapper.h:7,
from /data/yun/speech2video/3dmm_cnn/main.cpp:10:
/usr/local/include/dlib/matrix/matrix_fft.h:12:22: fatal error: mkl_dfti.h: No such file or directory
#include <mkl_dfti.h>
^
compilation terminated.
make[2]: *** [config/CMakeFiles/TestVisualization.dir/
/main.cpp.o] Error 1
make[1]: *** [config/CMakeFiles/TestVisualization.dir/all] Error 2
make: *** [all] Error 2

I wonder how to solve the problem, thanks a lot

TestVisualization: error while loading shared libraries: libdlib.so

I've compiled everything successfully and got testBatchModel.py running. However, when I try testModel_PoseExpr.py, I get the following output

Prepare image /home/vaheta/builds/3dmm_cnn/demoCode/data/1.jpg:
Number of faces detected: 1
CNN Model loaded to regress 3D Shape and Texture!
Loaded the Basel Face Model to write the 3D output!
/usr/local/lib/python2.7/dist-packages/skimage/transform/_warps.py:84: UserWarning: The default mode, 'constant', will be changed to 'reflect' in skimage 0.15.
warn("The default mode, 'constant', will be changed to 'reflect' in "
** Caffe loading : 0.351 s
** Image cropping : 0.253 s
** 3D Modeling : 0.741 s
Writing 3D file in: out//1.ply
Pose & expression estimation
./TestVisualization: error while loading shared libraries: libdlib.so.19.10.0: cannot open shared object file: No such file or directory

although dlib was successfully compiled and I put the path to it in CMakeLists.txt. What am I doing wrong?
Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.