-
Notifications
You must be signed in to change notification settings - Fork 5
/
InceptionVideoRestDockerfile
108 lines (91 loc) · 3.81 KB
/
InceptionVideoRestDockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
FROM uscdatascience/tf-tika-base
MAINTAINER Apache Tika Team
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
cmake \
libavcodec-dev \
libavformat-dev \
libswscale-dev \
libv4l-dev \
libavutil-dev \
pkg-config \
&& \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Download OpenCV + OpenCV_Contrib
WORKDIR /usr/local/src
RUN \
wget -O opencv.zip https://github.com/opencv/opencv/archive/3.2.0.zip && \
unzip opencv.zip && \
wget -O opencv_contrib.zip https://github.com/opencv/opencv_contrib/archive/3.2.0.zip && \
unzip opencv_contrib.zip
# Build + Install OpenCV
RUN mkdir -p opencv-3.2.0/build
WORKDIR /usr/local/src/opencv-3.2.0/build
RUN cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-3.2.0/modules \
-D BUILD_PYTHON_SUPPORT=ON \
-D BUILD_EXAMPLES=OFF \
-D PYTHON_DEFAULT_EXECUTABLE=/usr/bin/python3 \
-D BUILD_opencv_python3=OFF \
-D BUILD_opencv_python2=ON \
-D WITH_IPP=OFF \
-D WITH_FFMPEG=ON \
-D WITH_V4L=ON ..
RUN make -j$(nproc) && make install
# Download the pretrained inception v4 checkpoint & other meta files
WORKDIR /usr/share/apache-tika/models/dl/image-video/recognition/
RUN curl -O http://download.tensorflow.org/models/inception_v4_2016_09_09.tar.gz && \
tar -xzvf inception_v4_2016_09_09.tar.gz && rm -rf inception_v4_2016_09_09.tar.gz && \
curl -O https://raw.githubusercontent.com/tensorflow/models/master/research/inception/inception/data/imagenet_lsvrc_2015_synsets.txt && \
curl -O https://raw.githubusercontent.com/tensorflow/models/master/research/inception/inception/data/imagenet_metadata.txt
# Download server related source files
WORKDIR /usr/share/apache-tika/src/dl/image-video/recognition/
RUN curl -O https://raw.githubusercontent.com/apache/tika/master/tika-parsers/src/main/resources/org/apache/tika/parser/recognition/tf/inceptionapi.py && \
curl -O https://raw.githubusercontent.com/apache/tika/master/tika-parsers/src/main/resources/org/apache/tika/parser/recognition/tf/inception_v4.py && \
curl -O https://raw.githubusercontent.com/apache/tika/master/tika-parsers/src/main/resources/org/apache/tika/parser/recognition/tf/video_util.py && \
chmod +x inceptionapi.py
WORKDIR /
# Remove unnecessary packages comes with base
RUN apt-get -y remove \
apt-utils \
curl \
git \
software-properties-common \
unzip \
wget
# Remove unnecessary packages
RUN apt-get -y remove \
apt-utils \
build-essential \
cmake \
libavcodec-dev \
libavformat-dev \
libswscale-dev \
libv4l-dev \
libavutil-dev \
pkg-config
# Delete OpenCV source files
RUN rm -rf /usr/local/src
# Add symbolic link to inceptionapi.py
RUN ln -s /usr/share/apache-tika/src/dl/image-video/recognition/inceptionapi.py /usr/bin/inceptionapi
# Expose API port, this is the default port
EXPOSE 8764
CMD inceptionapi