|
| 1 | +# Copyright 2018 The TensorFlow Authors. All Rights Reserved. |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | +# #========================================================================== |
| 15 | + |
| 16 | +FROM tensorflow/tensorflow:nightly-devel |
| 17 | + |
| 18 | +# Get the tensorflow models research directory, and move it into tensorflow |
| 19 | +# source folder to match recommendation of installation |
| 20 | +RUN git clone --depth 1 https://github.com/tensorflow/models.git && \ |
| 21 | + mv models /tensorflow/models |
| 22 | + |
| 23 | + |
| 24 | +# Install gcloud and gsutil commands |
| 25 | +# https://cloud.google.com/sdk/docs/quickstart-debian-ubuntu |
| 26 | +RUN export CLOUD_SDK_REPO="cloud-sdk-$(lsb_release -c -s)" && \ |
| 27 | + echo "deb http://packages.cloud.google.com/apt $CLOUD_SDK_REPO main" | tee -a /etc/apt/sources.list.d/google-cloud-sdk.list && \ |
| 28 | + curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add - && \ |
| 29 | + apt-get update -y && apt-get install google-cloud-sdk -y |
| 30 | + |
| 31 | + |
| 32 | +# Install the Tensorflow Object Detection API from here |
| 33 | +# https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/installation.md |
| 34 | + |
| 35 | +# Install object detection api dependencies |
| 36 | +RUN apt-get install -y protobuf-compiler python-pil python-lxml python-tk && \ |
| 37 | + pip install Cython && \ |
| 38 | + pip install contextlib2 && \ |
| 39 | + pip install jupyter && \ |
| 40 | + pip install matplotlib |
| 41 | + |
| 42 | +# Install pycocoapi |
| 43 | +RUN git clone --depth 1 https://github.com/cocodataset/cocoapi.git && \ |
| 44 | + cd cocoapi/PythonAPI && \ |
| 45 | + make -j8 && \ |
| 46 | + cp -r pycocotools /tensorflow/models/research && \ |
| 47 | + cd ../../ && \ |
| 48 | + rm -rf cocoapi |
| 49 | + |
| 50 | +# Get protoc 3.0.0, rather than the old version already in the container |
| 51 | +RUN curl -OL "https://github.com/google/protobuf/releases/download/v3.0.0/protoc-3.0.0-linux-x86_64.zip" && \ |
| 52 | + unzip protoc-3.0.0-linux-x86_64.zip -d proto3 && \ |
| 53 | + mv proto3/bin/* /usr/local/bin && \ |
| 54 | + mv proto3/include/* /usr/local/include && \ |
| 55 | + rm -rf proto3 protoc-3.0.0-linux-x86_64.zip |
| 56 | + |
| 57 | +# Run protoc on the object detection repo |
| 58 | +RUN cd /tensorflow/models/research && \ |
| 59 | + protoc object_detection/protos/*.proto --python_out=. |
| 60 | + |
| 61 | +# Set the PYTHONPATH to finish installing the API |
| 62 | +ENV PYTHONPATH $PYTHONPATH:/tensorflow/models/research:/tensorflow/models/research/slim |
| 63 | + |
| 64 | + |
| 65 | +# Install wget (to make life easier below) and editors (to allow people to edit |
| 66 | +# the files inside the container) |
| 67 | +RUN apt-get install -y wget vim emacs nano |
| 68 | + |
| 69 | + |
| 70 | +# Grab various data files which are used throughout the demo: dataset, |
| 71 | +# pretrained model, and pretrained TensorFlow Lite model. Install these all in |
| 72 | +# the same directories as recommended by the blog post. |
| 73 | + |
| 74 | +# Pets example dataset |
| 75 | +RUN mkdir -p /tmp/pet_faces_tfrecord/ && \ |
| 76 | + cd /tmp/pet_faces_tfrecord && \ |
| 77 | + curl "http://download.tensorflow.org/models/object_detection/pet_faces_tfrecord.tar.gz" | tar xzf - |
| 78 | + |
| 79 | +# Pretrained model |
| 80 | +# This one doesn't need its own directory, since it comes in a folder. |
| 81 | +RUN cd /tmp && \ |
| 82 | + curl -O "http://download.tensorflow.org/models/object_detection/ssd_mobilenet_v1_0.75_depth_300x300_coco14_sync_2018_07_03.tar.gz" && \ |
| 83 | + tar xzf ssd_mobilenet_v1_0.75_depth_300x300_coco14_sync_2018_07_03.tar.gz && \ |
| 84 | + rm ssd_mobilenet_v1_0.75_depth_300x300_coco14_sync_2018_07_03.tar.gz |
| 85 | + |
| 86 | +# Trained TensorFlow Lite model. This should get replaced by one generated from |
| 87 | +# export_tflite_ssd_graph.py when that command is called. |
| 88 | +RUN cd /tmp && \ |
| 89 | + curl -L -o tflite.zip \ |
| 90 | + https://storage.googleapis.com/download.tensorflow.org/models/tflite/frozengraphs_ssd_mobilenet_v1_0.75_quant_pets_2018_06_29.zip && \ |
| 91 | + unzip tflite.zip -d tflite && \ |
| 92 | + rm tflite.zip |
| 93 | + |
| 94 | + |
| 95 | +# Install Android development tools |
| 96 | +# Inspired by the following sources: |
| 97 | +# https://github.com/bitrise-docker/android/blob/master/Dockerfile |
| 98 | +# https://github.com/reddit/docker-android-build/blob/master/Dockerfile |
| 99 | + |
| 100 | +# Set environment variables |
| 101 | +ENV ANDROID_HOME /opt/android-sdk-linux |
| 102 | +ENV ANDROID_NDK_HOME /opt/android-ndk-r14b |
| 103 | +ENV PATH ${PATH}:${ANDROID_HOME}/tools:${ANDROID_HOME}/tools/bin:${ANDROID_HOME}/platform-tools |
| 104 | + |
| 105 | +# Install SDK tools |
| 106 | +RUN cd /opt && \ |
| 107 | + curl -OL https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip && \ |
| 108 | + unzip sdk-tools-linux-4333796.zip -d ${ANDROID_HOME} && \ |
| 109 | + rm sdk-tools-linux-4333796.zip |
| 110 | + |
| 111 | +# Accept licenses before installing components, no need to echo y for each component |
| 112 | +# License is valid for all the standard components in versions installed from this file |
| 113 | +# Non-standard components: MIPS system images, preview versions, GDK (Google Glass) and Android Google TV require separate licenses, not accepted there |
| 114 | +RUN yes | sdkmanager --licenses |
| 115 | + |
| 116 | +# Install platform tools, SDK platform, and other build tools |
| 117 | +RUN yes | sdkmanager \ |
| 118 | + "tools" \ |
| 119 | + "platform-tools" \ |
| 120 | + "platforms;android-27" \ |
| 121 | + "platforms;android-23" \ |
| 122 | + "build-tools;27.0.3" \ |
| 123 | + "build-tools;23.0.3" |
| 124 | + |
| 125 | +# Install Android NDK (r14b) |
| 126 | +RUN cd /opt && \ |
| 127 | + curl -L -o android-ndk.zip http://dl.google.com/android/repository/android-ndk-r14b-linux-x86_64.zip && \ |
| 128 | + unzip -q android-ndk.zip && \ |
| 129 | + rm -f android-ndk.zip |
| 130 | + |
| 131 | +# Configure the build to use the things we just downloaded |
| 132 | +RUN cd /tensorflow && \ |
| 133 | + printf '\n\nn\ny\nn\nn\nn\ny\nn\nn\nn\nn\nn\nn\n\ny\n%s\n\n\n' ${ANDROID_HOME}|./configure |
| 134 | + |
| 135 | + |
| 136 | +WORKDIR /tensorflow |
0 commit comments