mirror of
https://gitcode.com/gh_mirrors/ope/OpenFace.git
synced 2025-12-30 04:52:29 +00:00
Updating OpenFace to version 2.2.0 (#741)
Change log: Moving to C++17. This means that the code can only be build using C++17 compilers (e.g. g++ >8 and Visual Studio 2017, clang > 5), fixing related bugs - (#698, #629, #641) Removing an explicit dependency on boost (all the filesystem operations are performed using std::filesystem or boost::filesysteme). If boost is available it will used boost:filesystem, otherwise std::filesystem (this requires C++17) Visual Studio 2017 is now the main version for Visual Studio builds, VS 2015 is no longer supported Updating OpenCV to 4.1 version (#511) Fixing a bug with output images when using GUI (#694) Updating RAWImage - #609, so it can be initialized from System.Drawing.Bitmap directly Fixing overlap detection for multi face tracking (#693)
This commit is contained in:
committed by
GitHub
parent
f023667fee
commit
e4a57e11d2
110
docker/Dockerfile
Normal file
110
docker/Dockerfile
Normal file
@@ -0,0 +1,110 @@
|
||||
# ==================== Building Model Layer ===========================
|
||||
# This is a little trick to improve caching and minimize rebuild time
|
||||
# and bandwidth. Note that RUN commands only cache-miss if the prior layers
|
||||
# miss, or the dockerfile changes prior to this step.
|
||||
# To update these patch files, be sure to run build with --no-cache
|
||||
FROM alpine as model_data
|
||||
RUN apk --no-cache --update-cache add wget
|
||||
WORKDIR /data/patch_experts
|
||||
|
||||
RUN wget -q https://www.dropbox.com/s/7na5qsjzz8yfoer/cen_patches_0.25_of.dat &&\
|
||||
wget -q https://www.dropbox.com/s/k7bj804cyiu474t/cen_patches_0.35_of.dat &&\
|
||||
wget -q https://www.dropbox.com/s/ixt4vkbmxgab1iu/cen_patches_0.50_of.dat &&\
|
||||
wget -q https://www.dropbox.com/s/2t5t1sdpshzfhpj/cen_patches_1.00_of.dat
|
||||
|
||||
## ==================== Install Ubuntu Base libs ===========================
|
||||
## This will be our base image for OpenFace, and also the base for the compiler
|
||||
## image. We only need packages which are linked
|
||||
|
||||
FROM ubuntu:18.04 as ubuntu_base
|
||||
|
||||
LABEL maintainer="Michael McDermott <mikemcdermott23@gmail.com>"
|
||||
|
||||
ARG DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
# todo: minimize this even more
|
||||
RUN apt-get update -qq &&\
|
||||
apt-get install -qq curl &&\
|
||||
apt-get install -qq --no-install-recommends \
|
||||
libopenblas-dev liblapack-dev \
|
||||
libavcodec-dev libavformat-dev libswscale-dev \
|
||||
libtbb2 libtbb-dev libjpeg-dev \
|
||||
libpng-dev libtiff-dev &&\
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
## ==================== Build-time dependency libs ======================
|
||||
## This will build and install opencv and dlib into an additional dummy
|
||||
## directory, /root/diff, so we can later copy in these artifacts,
|
||||
## minimizing docker layer size
|
||||
## Protip: ninja is faster than `make -j` and less likely to lock up system
|
||||
FROM ubuntu_base as cv_deps
|
||||
|
||||
WORKDIR /root/build-dep
|
||||
ARG DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
RUN apt-get update -qq && apt-get install -qq -y \
|
||||
cmake ninja-build pkg-config build-essential checkinstall\
|
||||
g++-8 &&\
|
||||
rm -rf /var/lib/apt/lists/* &&\
|
||||
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 800 --slave /usr/bin/g++ g++ /usr/bin/g++-8
|
||||
|
||||
## llvm clang-3.7 libc++-dev libc++abi-dev \
|
||||
## ==================== Building dlib ===========================
|
||||
|
||||
RUN curl http://dlib.net/files/dlib-19.13.tar.bz2 -LO &&\
|
||||
tar xf dlib-19.13.tar.bz2 && \
|
||||
rm dlib-19.13.tar.bz2 &&\
|
||||
mv dlib-19.13 dlib &&\
|
||||
mkdir -p dlib/build &&\
|
||||
cd dlib/build &&\
|
||||
cmake -DCMAKE_BUILD_TYPE=Release -G Ninja .. &&\
|
||||
ninja && \
|
||||
ninja install && \
|
||||
DESTDIR=/root/diff ninja install &&\
|
||||
ldconfig
|
||||
|
||||
## ==================== Building OpenCV ======================
|
||||
ENV OPENCV_VERSION=4.1.0
|
||||
|
||||
RUN curl https://github.com/opencv/opencv/archive/${OPENCV_VERSION}.tar.gz -LO &&\
|
||||
tar xf ${OPENCV_VERSION}.tar.gz && \
|
||||
rm ${OPENCV_VERSION}.tar.gz &&\
|
||||
mv opencv-${OPENCV_VERSION} opencv && \
|
||||
mkdir -p opencv/build && \
|
||||
cd opencv/build && \
|
||||
cmake -D CMAKE_BUILD_TYPE=RELEASE \
|
||||
-D CMAKE_INSTALL_PREFIX=/usr/local \
|
||||
-D WITH_TBB=ON -D WITH_CUDA=OFF \
|
||||
-DWITH_QT=OFF -DWITH_GTK=OFF\
|
||||
-G Ninja .. && \
|
||||
ninja && \
|
||||
ninja install &&\
|
||||
DESTDIR=/root/diff ninja install
|
||||
|
||||
## ==================== Building OpenFace ===========================
|
||||
FROM cv_deps as openface
|
||||
WORKDIR /root/openface
|
||||
|
||||
COPY ./ ./
|
||||
|
||||
COPY --from=model_data /data/patch_experts/* \
|
||||
/root/openface/lib/local/LandmarkDetector/model/patch_experts/
|
||||
|
||||
RUN mkdir -p build && cd build && \
|
||||
cmake -D CMAKE_BUILD_TYPE=RELEASE -G Ninja .. && \
|
||||
ninja &&\
|
||||
DESTDIR=/root/diff ninja install
|
||||
|
||||
|
||||
## ==================== Streamline container ===========================
|
||||
## Clean up - start fresh and only copy in necessary stuff
|
||||
## This shrinks the image from ~8 GB to ~1.6 GB
|
||||
FROM ubuntu_base as final
|
||||
|
||||
WORKDIR /root
|
||||
|
||||
# Copy in only necessary libraries
|
||||
COPY --from=openface /root/diff /
|
||||
|
||||
# Since we "imported" the build artifacts, we need to reconfigure ld
|
||||
RUN ldconfig
|
||||
57
docker/README.md
Normal file
57
docker/README.md
Normal file
@@ -0,0 +1,57 @@
|
||||
# Docker building instructions
|
||||
|
||||
This image can be build with just `docker`, but it is highly recommend to use
|
||||
`docker-compose` as this greatly simplifies and improves the process.
|
||||
|
||||
## Quick start
|
||||
|
||||
To start with the container hosted by the repo maintainer, run
|
||||
|
||||
`docker run -it --rm --name openface algebr/openface:latest`
|
||||
|
||||
This will drop you into a shell with binaries such as FaceLandmarkImg. For example,
|
||||
try this code (in the container):
|
||||
|
||||
```bash
|
||||
curl -o tesla.jpg https://upload.wikimedia.org/wikipedia/commons/thumb/b/b7/Nicola_Tesla_LCCN2014684845.jpg/559px-Nicola_Tesla_LCCN2014684845.jpg
|
||||
FaceLandmarkImg -f tesla.jpg
|
||||
```
|
||||
|
||||
Then, copy the output to the host system (from host terminal):
|
||||
|
||||
```bash
|
||||
docker cp openface:/root/processed /tmp/
|
||||
cd /tmp/processed
|
||||
```
|
||||
|
||||
Tip: On Ubuntu and other *nixes with X running, you can open a file directly
|
||||
like this:
|
||||
```bash
|
||||
xdg-open /tmp/processed/tesla.jpg
|
||||
```
|
||||
|
||||
## Building
|
||||
|
||||
In repo root, run `docker-compose build` to automatically build and tag.
|
||||
There are two variables which can be used to modify the tag, `$DOCKERUSER` and
|
||||
`$DOCKERTAG`. DC will automatically tag image as
|
||||
`${DOCKERUSER}/openface:${DOCKERTAG}`
|
||||
|
||||
## OpenFace service (in progress)
|
||||
|
||||
To run OpenFace like a service, you can start the container with bind mounts
|
||||
in order to pass data into and out of the container easily.
|
||||
`$DATA_MOUNT` by default is set to `/tmp/openface`. This can be overridden by
|
||||
modifying `.env` file, setting it in your shell environment, or passing in
|
||||
before `docker-compose` at runtime. Note: output will be `root` owner.
|
||||
|
||||
```bash
|
||||
export DATA_MOUNT=/tmp/openface
|
||||
mkdir -p $DATA_MOUNT/tesla # this is just to ensure this is writable by user
|
||||
docker-compose up -d openface && sync # sync is to wait till service starts
|
||||
curl -o $DATA_MOUNT/tesla.jpg \
|
||||
https://upload.wikimedia.org/wikipedia/commons/thumb/b/b7/Nicola_Tesla_LCCN2014684845.jpg/559px-Nicola_Tesla_LCCN2014684845.jpg
|
||||
docker exec -it openface FaceLandmarkImg -f $DATA_MOUNT/tesla.jpg -out_dir $DATA_MOUNT/tesla
|
||||
docker exec -it openface chown -R $UID:$UID $DATA_MOUNT # chown to current user
|
||||
docker-compose down # stop service if you wish
|
||||
```
|
||||
Reference in New Issue
Block a user