Commit 292bf39b authored by Richard Torenvliet's avatar Richard Torenvliet

Made changes to support eos, made Python bindings to call it from python

parent 579f7adc
FROM smvanveen/computer-vision:20161109143812
RUN git clone https://github.com/davisking/dlib.git
RUN (cd dlib; python setup.py install --yes USE_AVX_INSTRUCTIONS)
RUN apt-get install graphviz -y
# install python requirements
COPY requirements.txt /tmp
RUN pip install -r /tmp/requirements.txt
# extra packages:
# graphviz: for cProfiling using pycallgraph.
# libeigen3-dev: for eos: 3D morphable face model fitting library.
RUN apt-get install -y \
graphviz \
libeigen3-dev
WORKDIR /libs
# install dlib
RUN git clone https://github.com/davisking/dlib.git
RUN (cd dlib; python setup.py install --yes USE_AVX_INSTRUCTIONS)
# install eos (face-recosntruction, (3D Morphable Face Model fitting library)
RUN git clone --recursive https://github.com/patrikhuber/eos.git
# remove dependency on opencv 2.4.3, opencv 3.0 works fine
WORKDIR /libs/eos
RUN sed -i 's/2.4.3//g' CMakeLists.txt
RUN mkdir build
WORKDIR /libs/eos/build
RUN cmake ../ \
-DCMAKE_INSTALL_PREFIX=/usr/local/eos \
-DGENERATE_PYTHON_BINDINGS=on \
-DBUILD_UTILS=on \
-DPYTHON_EXECUTABLE=/usr/bin/python
RUN make && make install
ENV PYTHONPATH=/usr/local/eos/bin/:$PYTHONPATH
WORKDIR /src
......@@ -17,9 +17,6 @@ runnit:
$(BASE_DOCKER_CMD) python main.py
src/reconstruction/texture.so: src/reconstruction/texture.pyx
$(BASE_DOCKER_CMD) /bin/bash -c '(cd reconstruction; python setup.py build_ext --inplace)'
## IMM Dataset
data/pca_imm_shape_model.npy:
$(BASE_DOCKER_CMD) python main.py \
......
......@@ -15,6 +15,7 @@ $(info $(TARGETS))
DEPENDENCIES:= data/imm_face_db
TARGETS:= data/shape_predictor_68_face_landmarks.dat\
src/reconstruction/texture.so \
src/reconstruction/fit.so \
data/pca_ibug_shape_model.npy \
data/pca_ibug_texture_model.npy
......@@ -43,3 +44,5 @@ $(SITE_PACKAGES)/cv%:
@ls $@
src/reconstruction/fit.so: src/reconstruction/fit-model.cpp
$(BASE_DOCKER_CMD) /bin/bash -c '(cd reconstruction; python setup.py build_ext --inplace)'
This diff is collapsed.
......@@ -3,7 +3,6 @@ import numpy as np
import pca
import aam
from utility import import_dataset_module
def draw_shape(image, points, triangles, multiply=True):
......
......@@ -16,6 +16,29 @@ extensions = [
'texture',
['texture.pyx'],
include_dirs=[np.get_include()], ),
Extension(
'fit',
['fit-model.cpp'],
language="c++",
include_dirs=[
'/usr/local/eos/include/', # path need to be changed in future
'/usr/local/eos/3rdparty/glm/',
'/usr/local/eos/3rdparty/cereal-1.1.1/include/',
'/usr/local/include/opencv2/',
'/usr/include/boost/'
],
library_dirs=[
'/usr/local/eos/bin',
'/usr/lib/x86_64-linux-gnu/',
'/usr/local/lib/'
],
libraries=[
'boost_program_options',
'boost_filesystem',
'opencv_world'
],
extra_compile_args=['-std=c++14'], )
#include_dirs=[np.get_include()], ),
#Extension(
# 'halide',
# ['texture_halide.cpp'],
......
......@@ -3,24 +3,28 @@ import cv2
import pca as pca
from settings import logger
from reconstruction import reconstruction
from utility import import_dataset_module
#model_texture_file = '/data/pca_ibug_texture_model.npy'
#model_shape_file = '/data/pca_ibug_shape_model.npy'
model_texture_file = '/data/pca_ibug_texture_model.npy'
model_shape_file = '/data/pca_ibug_shape_model.npy'
model_texture_file = '/data/pca_imm_texture_model.npy'
model_shape_file = '/data/pca_imm_shape_model.npy'
#model_texture_file = '/data/pca_imm_texture_model.npy'
#model_shape_file = '/data/pca_imm_shape_model.npy'
def main():
def shape():
shape_components = 58
shape_model = pca.PCAModel(model_shape_file)
texture_model = pca.PCAModel(model_texture_file)
logger.info('using %s shape_components', shape_components)
image_filename = '/data/imm_face_db/01-1m.asf'
image_filename = '/data/imm_face_db/01-1m.jpg'
dataset_module = import_dataset_module('ibug')
dst_image = reconstruction.reconstruct_shape_texture(
'imm',
dataset_module,
shape_model,
texture_model,
image_filename,
......@@ -30,5 +34,23 @@ def main():
cv2.imwrite('/data/reconstructed.png', dst_image)
def fit_model():
from reconstruction import fit
shape_components = 58
shape_model = pca.PCAModel(model_shape_file)
texture_model = pca.PCAModel(model_texture_file)
logger.info('using %s shape_components', shape_components)
image_filename = '/data/imm_face_db/01-1m.jpg'
dataset_module = import_dataset_module('ibug')
input_points = dataset_module.factory(filename=image_filename)
input_image = input_points.get_image()
fit.fit_model(image)
if __name__ == '__main__':
main()
#fit_model()
shape()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment