Skip to content

Commit

Permalink
Merge pull request #2 from TheWebMonks/segmentation
Browse files Browse the repository at this point in the history
Segmentation
  • Loading branch information
lukin0110 authored Oct 26, 2017
2 parents 7c47dfd + affc20e commit f3e31d9
Show file tree
Hide file tree
Showing 5 changed files with 123 additions and 5 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,8 @@ input/*_body.pkl_vis.png
input/*_body_*.png
input/*_pose.npz
input/*_pose.npz_vis.png
input/*_pose.npz_vis.png_body.pkl_working
input/work_lock

# TODO
TODO*
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ RUN cd /models \
&& mkdir -p ${BASE}/pose/training/model/pose/ \
&& unzip p91.zip -d ${BASE}/pose/training/model/pose/ \
&& unzip SMPL_python_v.1.0.0.zip \
&& mv -v smpl/* /usr/lib/python2.7/dist-packages/
&& mv -v smpl/* /usr/lib/python2.7/dist-packages/ \
&& rm *.zip

# Add the entrypoint.sh
COPY deployment/docker-entrypoint.sh /usr/local/bin/
Expand Down
95 changes: 95 additions & 0 deletions Dockerfile.deeplabv2
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
FROM nvidia/cuda:7.5-cudnn5-devel-ubuntu14.04
MAINTAINER caffe-maint@googlegroups.com

ENV DEBIAN_FRONTEND=noninteractive
ENV BASE=/code/up-master

RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
cmake \
git \
wget \
libatlas-base-dev \
libboost-all-dev \
libgflags-dev \
libgoogle-glog-dev \
libhdf5-serial-dev \
libleveldb-dev \
liblmdb-dev \
libopencv-dev \
libprotobuf-dev \
libsnappy-dev \
protobuf-compiler \
python-dev \
python-numpy \
python-pip \
python-scipy \
realpath unzip && \
rm -rf /var/lib/apt/lists/*

WORKDIR /opt

# MATIO
RUN wget http://jaist.dl.sourceforge.net/project/matio/matio/1.5.2/matio-1.5.2.tar.gz && \
tar -xvzf matio-1.5.2.tar.gz && \
rm matio-1.5.2.tar.gz

WORKDIR /opt/matio-1.5.2

RUN ./configure && make -j8 && make install -j8

ENV CAFFE_ROOT=/opt/caffe
WORKDIR $CAFFE_ROOT

ENV INCLUDE_DIRS=/opt/matio-1.5.2/src/:$INCLUDE_DIRS
ENV LIBRARY_DIRS=/opt/matio-1.5.2/src/:$LIBRARY_DIRS

# FIXME: clone a specific git tag and use ARG instead of ENV once DockerHub supports this.
ENV CLONE_TAG=master

RUN git clone -b ${CLONE_TAG} --depth 1 https://bitbucket.org/aquariusjay/deeplab-public-ver2.git . && \
for req in $(cat python/requirements.txt) pydot; do pip install $req; done && \
cp Makefile.config.example Makefile.config && \
make all -j8 && \
make pycaffe -j8

ENV PYCAFFE_ROOT $CAFFE_ROOT/python
ENV PYTHONPATH $PYCAFFE_ROOT:$PYTHONPATH
ENV PATH $CAFFE_ROOT/build/tools:$PYCAFFE_ROOT:$PATH
RUN echo "$CAFFE_ROOT/build/lib" >> /etc/ld.so.conf.d/caffe.conf && ldconfig

# Create code dir an download UP
# https://github.com/classner/up
RUN mkdir /code
WORKDIR /code
COPY deployment/requirements.txt .
RUN apt-get install realpath \
&& wget https://github.com/classner/up/archive/master.zip \
&& unzip master.zip \
&& rm master.zip
WORKDIR ${BASE}

# Install python packages
RUN pip install -r ${BASE}/requirements.txt

# Applying some hacks to the segmentation.py script
# Allow bigger resolution
# Changing the logging level
RUN sed -i 's/_MAXSIZE = 513/_MAXSIZE = 1000/g' segmentation/segmentation.py \
&& sed -i 's/_logging.basicConfig(level=_logging.INFO)/_logging.basicConfig(level=_logging.DEBUG)/g' segmentation/segmentation.py

# Adding models: caffe & smpl
COPY models /models/
RUN cd /models \
&& mkdir -p ${BASE}/segmentation/training/model/segmentation/ \
&& unzip s31.zip -d ${BASE}/segmentation/training/model/segmentation/ \
&& unzip SMPL_python_v.1.0.0.zip \
&& mv -v smpl/* /usr/lib/python2.7/dist-packages/ \
&& rm *.zip

# Add the entrypoint.sh
COPY deployment/docker-entrypoint.sh /usr/local/bin/
RUN chmod ugo+x /usr/local/bin/docker-entrypoint.sh
ENTRYPOINT ["/bin/bash", "/usr/local/bin/docker-entrypoint.sh"]

CMD ["bash"]
19 changes: 15 additions & 4 deletions deployment/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,35 @@ function format_file() {
echo $file
}

# TODO: version stuff
# nvcc --version

# Run
case "$1" in
bash)
python ${BASE}/setup.py develop > /dev/null 2>&1
python ${BASE}/setup.py develop > /dev/null 2>&1 || true
/bin/bash "${@:2}"
;;
pose)
python ${BASE}/setup.py develop > /dev/null 2>&1
python ${BASE}/setup.py develop > /dev/null 2>&1 || true
python pose/pose.py --use_cpu $(format_file ${@:2})
;;
bodyfit)
python ${BASE}/setup.py develop > /dev/null 2>&1
python ${BASE}/setup.py develop > /dev/null 2>&1 || true
python 3dfit/bodyfit.py $(format_file ${@:2})
;;
render)
python ${BASE}/setup.py develop > /dev/null 2>&1
python ${BASE}/setup.py develop > /dev/null 2>&1 || true
python 3dfit/render.py $(format_file ${@:2})
;;
segmentation)
#python ${BASE}/setup.py develop > /dev/null 2>&1 || true
python segmentation/segmentation.py $(format_file ${@:2}) --part
;;
version)
nvcc --version
# TODO: uname? lsb_release, python
;;
*)
show_help
;;
Expand Down
7 changes: 7 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,10 @@ services:
build: .
volumes:
- ./input:/input

dl:
build:
context: .
dockerfile: Dockerfile.deeplabv2
volumes:
- ./input:/input

0 comments on commit f3e31d9

Please sign in to comment.