You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

136 lines
5.6 KiB

6 years ago
  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. FROM tensorflow/tensorflow:nightly-devel
  16. # Get the tensorflow models research directory, and move it into tensorflow
  17. # source folder to match recommendation of installation
  18. RUN git clone --depth 1 https://github.com/tensorflow/models.git && \
  19. mv models /tensorflow/models
  20. # Install gcloud and gsutil commands
  21. # https://cloud.google.com/sdk/docs/quickstart-debian-ubuntu
  22. RUN export CLOUD_SDK_REPO="cloud-sdk-$(lsb_release -c -s)" && \
  23. echo "deb http://packages.cloud.google.com/apt $CLOUD_SDK_REPO main" | tee -a /etc/apt/sources.list.d/google-cloud-sdk.list && \
  24. curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add - && \
  25. apt-get update -y && apt-get install google-cloud-sdk -y
  26. # Install the Tensorflow Object Detection API from here
  27. # https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/installation.md
  28. # Install object detection api dependencies
  29. RUN apt-get install -y protobuf-compiler python-pil python-lxml python-tk && \
  30. pip install Cython && \
  31. pip install contextlib2 && \
  32. pip install jupyter && \
  33. pip install matplotlib
  34. # Install pycocoapi
  35. RUN git clone --depth 1 https://github.com/cocodataset/cocoapi.git && \
  36. cd cocoapi/PythonAPI && \
  37. make -j8 && \
  38. cp -r pycocotools /tensorflow/models/research && \
  39. cd ../../ && \
  40. rm -rf cocoapi
  41. # Get protoc 3.0.0, rather than the old version already in the container
  42. RUN curl -OL "https://github.com/google/protobuf/releases/download/v3.0.0/protoc-3.0.0-linux-x86_64.zip" && \
  43. unzip protoc-3.0.0-linux-x86_64.zip -d proto3 && \
  44. mv proto3/bin/* /usr/local/bin && \
  45. mv proto3/include/* /usr/local/include && \
  46. rm -rf proto3 protoc-3.0.0-linux-x86_64.zip
  47. # Run protoc on the object detection repo
  48. RUN cd /tensorflow/models/research && \
  49. protoc object_detection/protos/*.proto --python_out=.
  50. # Set the PYTHONPATH to finish installing the API
  51. ENV PYTHONPATH $PYTHONPATH:/tensorflow/models/research:/tensorflow/models/research/slim
  52. # Install wget (to make life easier below) and editors (to allow people to edit
  53. # the files inside the container)
  54. RUN apt-get install -y wget vim emacs nano
  55. # Grab various data files which are used throughout the demo: dataset,
  56. # pretrained model, and pretrained TensorFlow Lite model. Install these all in
  57. # the same directories as recommended by the blog post.
  58. # Pets example dataset
  59. RUN mkdir -p /tmp/pet_faces_tfrecord/ && \
  60. cd /tmp/pet_faces_tfrecord && \
  61. curl "http://download.tensorflow.org/models/object_detection/pet_faces_tfrecord.tar.gz" | tar xzf -
  62. # Pretrained model
  63. # This one doesn't need its own directory, since it comes in a folder.
  64. RUN cd /tmp && \
  65. curl -O "http://download.tensorflow.org/models/object_detection/ssd_mobilenet_v1_0.75_depth_300x300_coco14_sync_2018_07_03.tar.gz" && \
  66. tar xzf ssd_mobilenet_v1_0.75_depth_300x300_coco14_sync_2018_07_03.tar.gz && \
  67. rm ssd_mobilenet_v1_0.75_depth_300x300_coco14_sync_2018_07_03.tar.gz
  68. # Trained TensorFlow Lite model. This should get replaced by one generated from
  69. # export_tflite_ssd_graph.py when that command is called.
  70. RUN cd /tmp && \
  71. curl -L -o tflite.zip \
  72. https://storage.googleapis.com/download.tensorflow.org/models/tflite/frozengraphs_ssd_mobilenet_v1_0.75_quant_pets_2018_06_29.zip && \
  73. unzip tflite.zip -d tflite && \
  74. rm tflite.zip
  75. # Install Android development tools
  76. # Inspired by the following sources:
  77. # https://github.com/bitrise-docker/android/blob/master/Dockerfile
  78. # https://github.com/reddit/docker-android-build/blob/master/Dockerfile
  79. # Set environment variables
  80. ENV ANDROID_HOME /opt/android-sdk-linux
  81. ENV ANDROID_NDK_HOME /opt/android-ndk-r14b
  82. ENV PATH ${PATH}:${ANDROID_HOME}/tools:${ANDROID_HOME}/tools/bin:${ANDROID_HOME}/platform-tools
  83. # Install SDK tools
  84. RUN cd /opt && \
  85. curl -OL https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip && \
  86. unzip sdk-tools-linux-4333796.zip -d ${ANDROID_HOME} && \
  87. rm sdk-tools-linux-4333796.zip
  88. # Accept licenses before installing components, no need to echo y for each component
  89. # License is valid for all the standard components in versions installed from this file
  90. # Non-standard components: MIPS system images, preview versions, GDK (Google Glass) and Android Google TV require separate licenses, not accepted there
  91. RUN yes | sdkmanager --licenses
  92. # Install platform tools, SDK platform, and other build tools
  93. RUN yes | sdkmanager \
  94. "tools" \
  95. "platform-tools" \
  96. "platforms;android-27" \
  97. "platforms;android-23" \
  98. "build-tools;27.0.3" \
  99. "build-tools;23.0.3"
  100. # Install Android NDK (r14b)
  101. RUN cd /opt && \
  102. curl -L -o android-ndk.zip http://dl.google.com/android/repository/android-ndk-r14b-linux-x86_64.zip && \
  103. unzip -q android-ndk.zip && \
  104. rm -f android-ndk.zip
  105. # Configure the build to use the things we just downloaded
  106. RUN cd /tensorflow && \
  107. printf '\n\nn\ny\nn\nn\nn\ny\nn\nn\nn\nn\nn\nn\n\ny\n%s\n\n\n' ${ANDROID_HOME}|./configure
  108. WORKDIR /tensorflow