Commit 3cb2d93a authored by Richard Torenvliet's avatar Richard Torenvliet

Move to using Docker

parent 6867bcfd
FROM smvanveen/computer-vision:20160120173546
RUN pip install dlib
WORKDIR /src
#COPY requirements.txt /tmp
#RUN python --version
...@@ -6,9 +6,19 @@ $ source bin/activate ...@@ -6,9 +6,19 @@ $ source bin/activate
$ make show_reconstruction $ make show_reconstruction
~~~~ ~~~~
Will get the data needed for this tool.
# Imm dataset
Will get the data needed for this tool. # IBUG + dlib
For the IBUG dataset we use dlib to detect landmarks. You will need the train
file for that. http://dlib.net/files/shape_predictor_68_face_landmarks.dat.bz2
~~~bash
$ wget http://dlib.net/files/shape_predictor_68_face_landmarks.dat.bz2 -P data/
$ cd data/
$ bzip2 -d shape_predictor_68_face_landmarks.dat.bz2
~~~
## References ## References
1. [imm_dataset](http://www.imm.dtu.dk/~aam/datasets/datasets.html, "Imm dataset") 1. [imm_dataset](http://www.imm.dtu.dk/~aam/datasets/datasets.html, "Imm dataset")
TARGETS += data/pca_shape_train_model.npy TARGETS += data/pca_shape_train_model.npy
.PHONY := train_model show_pca test_model show_reconstruction .PHONY := train_model show_pca test_model show_reconstruction
DEBUG_LEVEL=*
data/imm_face_db: data/imm_face_db.tar.gz data/imm_face_db: data/imm_face_db.tar.gz
(cd data; mkdir -p imm_face_db; \ (cd data; mkdir -p imm_face_db; \
...@@ -13,38 +14,44 @@ train_shape: data/pca_imm_shape_model.npy data/pca_ibug_shape_model.npy ...@@ -13,38 +14,44 @@ train_shape: data/pca_imm_shape_model.npy data/pca_ibug_shape_model.npy
data/imm_face_db.tar.gz: data/imm_face_db.tar.gz:
(cd data; wget http://www.imm.dtu.dk/~aam/datasets/imm_face_db.tar.gz) (cd data; wget http://www.imm.dtu.dk/~aam/datasets/imm_face_db.tar.gz)
runnit:
$(BASE_DOCKER_CMD) python main.py
compile_texture: src/reconstruction/texture.pyx
$(BASE_DOCKER_CMD) /bin/bash -c '(cd reconstruction; python setup.py build_ext --inplace)'
data/pca_imm_shape_model.npy: data/pca_imm_shape_model.npy:
python src/main.py \ $(BASE_DOCKER_CMD) python main.py \
--save_pca_shape \ --save_pca_shape \
--files `./scripts/imm_train_set.sh` \ --files `./scripts/imm_train_set.sh` \
--model_shape_file data/pca_imm_shape_model \ --model_shape_file /data/pca_imm_shape_model \
--shape_type imm --shape_type imm
data/pca_ibug_shape_model.npy: data/pca_ibug_shape_model.npy:
python src/main.py \ $(BASE_DOCKER_CMD) python main.py \
--save_pca_shape \ --save_pca_shape \
--files `./scripts/ibug_train_set.sh` \ --files `./scripts/ibug_train_set.sh` \
--model_shape_file data/pca_ibug_shape_model \ --model_shape_file /data/pca_ibug_shape_model \
--shape_type ibug --shape_type ibug
data/pca_ibug_texture_model.npy: data/pca_ibug_texture_model.npy:
python src/main.py \ $(BASE_DOCKER_CMD) python main.py \
--save_pca_texture \ --save_pca_texture \
--files `./scripts/ibug_train_set.sh` \ --files `./scripts/ibug_train_set.sh` \
--model_texture_file data/pca_ibug_texture_model \ --model_texture_file /data/pca_ibug_texture_model \
--model_shape_file data/pca_ibug_shape_model.npy \ --model_shape_file /data/pca_ibug_shape_model.npy \
--shape_type ibug --shape_type ibug
data/pca_imm_texture_model.npy: data/pca_imm_texture_model.npy:
python src/main.py \ $(BASE_DOCKER_CMD) python main.py \
--save_pca_texture \ --save_pca_texture \
--files `./scripts/imm_train_set.sh` \ --files `./scripts/imm_train_set.sh` \
--model_texture_file data/pca_imm_texture_model \ --model_texture_file /data/pca_imm_texture_model \
--model_shape_file data/pca_imm_shape_model.npy \ --model_shape_file /data/pca_imm_shape_model.npy \
--shape_type imm --shape_type imm
test_model: test_model:
python src/main.py \ $(BASE_DOCKER_CMD) python main.py \
--reconstruct \ --reconstruct \
--files `./scripts/imm_test_set.sh` \ --files `./scripts/imm_test_set.sh` \
--model_texture_file data/pca_imm_texture_model \ --model_texture_file data/pca_imm_texture_model \
...@@ -52,11 +59,11 @@ test_model: ...@@ -52,11 +59,11 @@ test_model:
--n_components 6 --n_components 6
show_reconstruction: show_reconstruction:
python src/main.py \ $(BASE_DOCKER_CMD) python main.py \
--reconstruct \ --reconstruct \
--files data/imm_face_db/*.asf \ --files data/imm_face_db/*.asf \
--model_texture_file data/pca_imm_texture_model.npy \ --model_texture_file /data/pca_imm_texture_model.npy \
--model_shape_file data/pca_imm_shape_model.npy \ --model_shape_file /data/pca_imm_shape_model.npy \
--shape_type imm \ --shape_type imm \
--n_components 6 --n_components 6
...@@ -98,7 +105,7 @@ test: ...@@ -98,7 +105,7 @@ test:
.PHONY:= server .PHONY:= server
server: server:
(cd src/; python -m tornado.autoreload server.py) #(cd src/; python -m tornado.autoreload server.py)
.PHONY:= ember .PHONY:= ember
ember: ember:
......
VIRTUALENV := venv #VIRTUALENV := venv
PYTHON := python2.7 #PYTHON := python2.7
PYTHON_BIN_PATH := /usr/local/bin/$(PYTHON) #PYTHON_BIN_PATH := /usr/local/bin/$(PYTHON)
SITE_PACKAGES := $(VIRTUALENV)/lib/$(PYTHON)/site-packages #SITE_PACKAGES := $(VIRTUALENV)/lib/$(PYTHON)/site-packages
#OPENCV := $(SITE_PACKAGES)/cv.py $(SITE_PACKAGES)/cv2.so
OPENCV := $(SITE_PACKAGES)/cv.py $(SITE_PACKAGES)/cv2.so #TARGETS := $(OPENCV) $(VIRTUALENV) data reconstruction
TARGETS := $(OPENCV) $(VIRTUALENV) data reconstruction VERSION:=v0.1
IMAGE_TAG:= icyrizard/face-reconstruction.git:$(VERSION)
include build.mk DEBUG:=1
BASE_DOCKER_CMD:= docker run \
all: $(TARGETS) --rm \
--volume /Users/richard/Documents/sighthub/face-reconstruction/data:/data \
--volume /Users/richard/Documents/sighthub/face-reconstruction/src:/src \
-e "DEBUG=$(DEBUG)" \
$(IMAGE_TAG)
include actions.mk include actions.mk
include src/reconstruction/build.mk include src/reconstruction/build.mk
all: $(TARGETS)
data: data/imm_face_db data: data/imm_face_db
reconstruction: texture.so reconstruction: texture.so
OS := $(shell uname) OS := $(shell uname)
build: requirements.txt build: requirements.txt
@(source $(VIRTUALENV)/bin/activate; \ docker build -t $(IMAGE_TAG) .
pip install -r requirements.txt; \
); #@(source $(VIRTUALENV)/bin/activate; \
# pip install -r requirements.txt; \
#);
run-bash:
$(BASE_DOCKER_CMD) --interactive --tty $(IMAGE_TAG) /bin/bash
$(VIRTUALENV): $(VIRTUALENV):
virtualenv -p $(PYTHON_BIN_PATH) venv virtualenv -p $(PYTHON_BIN_PATH) venv
...@@ -30,3 +41,5 @@ $(VIRTUALENV): ...@@ -30,3 +41,5 @@ $(VIRTUALENV):
$(SITE_PACKAGES)/cv%: $(SITE_PACKAGES)/cv%:
@/bin/ln -s `scripts/get_site_package_location.sh`/$(shell basename $@) $@ @/bin/ln -s `scripts/get_site_package_location.sh`/$(shell basename $@) $@
@ls $@ @ls $@
cycler==0.10.0 cycler==0.10.0
Cython==0.24 matplotlib==1.5.3
matplotlib==1.5.1
numpy==1.11.0
pyparsing==2.1.2 pyparsing==2.1.2
python-dateutil==2.5.3 python-dateutil==2.5.3
pytz==2016.4 pytz==2016.4
requests==2.10.0 requests==2.10.0
six==1.10.0 six==1.10.0
tornado==4.4.2
files=`ls data/imm_face_db/ | grep -E "^[0-3][0-9].*.jpg"` files=`ls data/imm_face_db/ | grep -E "^[0-3][0-9].*.jpg"`
for f in $files; do for f in $files; do
echo "data/imm_face_db/$f" echo "/data/imm_face_db/$f"
done done
files=`ls data/imm_face_db/ | grep -E "^[4][0-9].*.asf"` files=`ls data/imm_face_db/ | grep -E "^[4][0-9].*.asf"`
for f in $files; do for f in $files; do
echo "data/imm_face_db/$f" echo "/data/imm_face_db/$f"
done done
files=`ls data/imm_face_db/ | grep -E "^[0-3][0-9].*.asf"` files=`ls data/imm_face_db/ | grep -E "^[0-3][0-9].*.asf"`
for f in $files; do for f in $files; do
echo "data/imm_face_db/$f" echo "/data/imm_face_db/$f"
done done
...@@ -5,9 +5,9 @@ ...@@ -5,9 +5,9 @@
""" """
import cv2
import numpy as np import numpy as np
from matplotlib.tri import Triangulation from matplotlib.tri import Triangulation
import cv2
# local imports # local imports
import pca import pca
......
...@@ -133,7 +133,7 @@ def pca(data, mean_values, variance_percentage=90): ...@@ -133,7 +133,7 @@ def pca(data, mean_values, variance_percentage=90):
i += 1 i += 1
n_components = i n_components = i
logger.debug('%s components form %s% of the variance', n_components, variance_percentage) logger.debug('%s components form %s percent of the variance', n_components, variance_percentage)
return U, s, Vt, n_components return U, s, Vt, n_components
......
...@@ -3,8 +3,8 @@ from distutils.core import setup ...@@ -3,8 +3,8 @@ from distutils.core import setup
from distutils.extension import Extension from distutils.extension import Extension
import os import os
os.environ["CXX"] = "clang++" os.environ["CXX"] = "g++"
os.environ["CC"] = "clang++" os.environ["CC"] = "g++"
from Cython.Build import cythonize from Cython.Build import cythonize
...@@ -16,18 +16,18 @@ extensions = [ ...@@ -16,18 +16,18 @@ extensions = [
'texture', 'texture',
['texture.pyx'], ['texture.pyx'],
include_dirs=[np.get_include()], ), include_dirs=[np.get_include()], ),
Extension( #Extension(
'halide', # 'halide',
['texture_halide.cpp'], # ['texture_halide.cpp'],
language="c++", # language="c++",
include_dirs=[ # include_dirs=[
'../../vendor/halide/include', # '../../vendor/halide/include',
'../../vendor/halide' # '../../vendor/halide'
], # ],
library_dirs=['../../vendor/halide/bin'], # library_dirs=['../../vendor/halide/bin'],
libraries=['Halide'], # libraries=['Halide'],
extra_compile_args=['-std=c++11'], # extra_compile_args=['-std=c++11'],
) #)
] ]
setup( setup(
......
...@@ -8,9 +8,7 @@ import logging ...@@ -8,9 +8,7 @@ import logging
import logging.config import logging.config
import os import os
LANDMARK_DETECTOR_PATH = '/data/shape_predictor_68_face_landmarks.dat'
dir_path = os.path.dirname(os.path.realpath(__file__))
LANDMARK_DETECTOR_PATH = dir_path + '/../data/shape_predictor_68_face_landmarks.dat'
#logging.basicConfig(level=logging.INFO, #logging.basicConfig(level=logging.INFO,
# format='%(asctime)s %(levelname)s %(name)s: %(message)s') # format='%(asctime)s %(levelname)s %(name)s: %(message)s')
......
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