Dockerfile updates for OpenFace + Python3 + Dlib19.2 + OpenCV3.2

This commit is contained in:
Andrew 2017-01-30 01:57:03 +00:00
parent 4825c8a266
commit ec08fc9226
2 changed files with 64 additions and 63 deletions

50
Dockerfile Normal file → Executable file
View File

@ -1,31 +1,31 @@
FROM bamos/ubuntu-opencv-dlib-torch:ubuntu_14.04-opencv_2.4.11-dlib_19.0-torch_2016.07.12
# Note from Brandon on 2015-01-13:
#
# Always push this from an OSX Docker machine.
#
# If I build this on my Arch Linux desktop it works fine locally,
# but dlib gives an `Illegal Instruction (core dumped)` error in
# dlib.get_frontal_face_detector() when running on OSX in a Docker machine.
# Building in a Docker machine on OSX fixes this issue and the built
# container successfully deploys on my Arch Linux desktop.
#
# Building and pushing:
# docker build -f opencv-dlib-torch.Dockerfile -t opencv-dlib-torch .
# docker tag -f <tag of last container> bamos/ubuntu-opencv-dlib-torch:ubuntu_latest-opencv_3.2.0-dlib_19.2-torch_2017.01.29
# docker push bamos/ubuntu-opencv-dlib-torch:ubuntu_latest-opencv_3.2.0-dlib_19.2-torch_2017.01.29
FROM bamos/ubuntu-opencv-dlib-torch:ubuntu_latest-opencv_3.2.0-dlib_19.2-torch_2017.01.29
MAINTAINER Brandon Amos <brandon.amos.cs@gmail.com>
# TODO: Should be added to opencv-dlib-torch image.
RUN ln -s /root/torch/install/bin/* /usr/local/bin
RUN apt-get update && apt-get install -y \
curl \
git \
graphicsmagick \
python-dev \
python-pip \
python-numpy \
python-nose \
python-scipy \
python-pandas \
python-protobuf\
wget \
zip \
&& apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
ADD . /root/openface
RUN cd ~/openface && \
# OpenFace
###############################################################################
RUN cd ~ && \
git clone https://github.com/qacollective/openface.git ~/openface --recursive && \
cd ~/openface && \
./models/get-models.sh && \
pip2 install -r requirements.txt && \
python2 setup.py install && \
pip2 install -r demos/web/requirements.txt && \
pip2 install -r training/requirements.txt
pip3 install -r requirements.txt && \
python3.5 setup.py install && \
pip3 install -r demos/web/requirements.txt && \
pip3 install -r training/requirements.txt
EXPOSE 8000 9000
CMD /bin/bash -l -c '/root/openface/demos/web/start-servers.sh'

View File

@ -8,41 +8,31 @@
# Building in a Docker machine on OSX fixes this issue and the built
# container successfully deploys on my Arch Linux desktop.
#
# Building this Dockerfile results in the download of approximately 450 MB of data.
#
# Building and pushing:
# docker build -f opencv-dlib-torch.Dockerfile -t opencv-dlib-torch .
# docker tag -f <tag of last container> bamos/ubuntu-opencv-dlib-torch:ubuntu_14.04-opencv_2.4.11-dlib_18.16-torch_2016.03.19
# docker push bamos/ubuntu-opencv-dlib-torch:ubuntu_14.04-opencv_2.4.11-dlib_18.16-torch_2016.03.19
# docker tag -f <tag of last container> bamos/ubuntu-opencv-dlib-torch:ubuntu_latest-opencv_3.2.0-dlib_19.2-torch_2017.01.29
# docker push bamos/ubuntu-opencv-dlib-torch:ubuntu_latest-opencv_3.2.0-dlib_19.2-torch_2017.01.29
FROM ubuntu:14.04
FROM ubuntu
MAINTAINER Brandon Amos <brandon.amos.cs@gmail.com>
RUN apt-get update && apt-get install -y \
build-essential \
cmake \
curl \
gfortran \
git \
graphicsmagick \
libgraphicsmagick1-dev \
libatlas-dev \
libavcodec-dev \
libavformat-dev \
libboost-all-dev \
libgtk2.0-dev \
libjpeg-dev \
liblapack-dev \
libswscale-dev \
pkg-config \
python-dev \
python-numpy \
python-protobuf\
software-properties-common \
zip \
&& apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
RUN apt-get update && apt-get install -y apt-utils
RUN curl -s https://raw.githubusercontent.com/torch/ezinstall/master/install-deps | bash -e
# Python 3.5
###############################################################################
RUN apt-get install -y python3.5 python3-pip python3.5-dev python3.5-numpy
RUN pip3 install --upgrade pip
# Torch
###############################################################################
RUN apt-get install -y git sudo curl luarocks libqtgui4 libqtcore4 libreadline-dev graphicsmagick libgraphicsmagick1-dev
RUN git clone https://github.com/torch/distro.git ~/torch --recursive
RUN cd ~/torch && ./install.sh && \
RUN cd ~/torch && \
bash install-deps && \
./install.sh && \
cd install/bin && \
./luarocks install nn && \
./luarocks install dpnn && \
@ -50,14 +40,20 @@ RUN cd ~/torch && ./install.sh && \
./luarocks install optim && \
./luarocks install csvigo && \
./luarocks install torchx && \
./luarocks install tds
./luarocks install tds && \
./luarocks install graphicsmagick && \
ln -s /root/torch/install/bin/* /usr/local/bin
# OpenCV 3.2
###############################################################################
RUN apt-get install -y zip cmake pkg-config
RUN cd ~ && \
mkdir -p ocv-tmp && \
cd ocv-tmp && \
curl -L https://github.com/Itseez/opencv/archive/2.4.11.zip -o ocv.zip && \
curl -L https://github.com/Itseez/opencv/archive/3.2.0.zip -o ocv.zip && \
unzip ocv.zip && \
cd opencv-2.4.11 && \
cd opencv-3.2.0 && \
mkdir release && \
cd release && \
cmake -D CMAKE_BUILD_TYPE=RELEASE \
@ -68,17 +64,22 @@ RUN cd ~ && \
make install && \
rm -rf ~/ocv-tmp
# Dlib 19.2
###############################################################################
# Note: Python 2.7 is still installed due to libboost-all-dev
RUN apt-get install -y libx11-dev libboost-all-dev
RUN cd ~ && \
mkdir -p dlib-tmp && \
cd dlib-tmp && \
curl -L \
https://github.com/davisking/dlib/archive/v19.0.tar.gz \
-o dlib.tar.bz2 && \
tar xf dlib.tar.bz2 && \
cd dlib-19.0/python_examples && \
http://dlib.net/files/dlib-19.2.zip \
-o dlib.zip && \
unzip dlib.zip && \
cd dlib-19.2/examples && \
mkdir build && \
cd build && \
cmake ../../tools/python && \
cmake .. -DUSE_SSE4_INSTRUCTIONS=ON && \
cmake --build . --config Release && \
cp dlib.so /usr/local/lib/python2.7/dist-packages && \
rm -rf ~/dlib-tmp
python3.5 ../../setup.py install --yes USE_AVX_INSTRUCTIONS && \
rm -rf ~/dlib-tmp