Skip to content

Add Docker support #128

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions docker/DockerFile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
FROM "ubuntu"
RUN apt-get update && yes | apt-get upgrade
RUN apt-get update
RUN apt-get install -y git python-pip libsm6 libxrender-dev python-pil python-lxml protobuf-compiler
RUN mkdir -p /tensorflow/models

COPY ts-models/models /tensorflow/models
COPY edje-tutorial/TensorFlow-Object-Detection-API-Tutorial-Train-Multiple-Objects-Windows-10 /tensorflow/models/research/object_detection
COPY faster_rcnn_inception_v2_coco_2018_01_28.tar.gz /tensorflow/models/research/object_detection
COPY inference_graph /tensorflow/models/research/object_detection/inference_graph

WORKDIR /tensorflow/models/research/object_detection
RUN tar -xzf faster_rcnn_inception_v2_coco_2018_01_28.tar.gz

WORKDIR /tensorflow/models/research

RUN pip install tensorflow
RUN pip install jupyter
RUN pip install matplotlib
RUN pip install Cython
RUN pip install pandas
RUN pip install opencv-python

RUN protoc object_detection/protos/*.proto --python_out=.
RUN export PYTHONPATH=$PYTHONPATH:`pwd`:`pwd`/slim

RUN python setup.py build
RUN python setup.py install

RUN jupyter notebook --generate-config --allow-root
RUN echo "c.NotebookApp.password = u'sha1:6a3f528eec40:6e896b6e4828f525a6e20e5411cd1c8075d68619'" >> /root/.jupyter/jupyter_notebook_config.py
EXPOSE 8888

CMD ["jupyter", "notebook", "--allow-root", "--notebook-dir=/tensorflow/models/research/object_detection", "--ip='*'", "--port=8888", "--no-browser"]
37 changes: 37 additions & 0 deletions docker/readme.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# This work build upon the Docker container created in this example:
# https://towardsdatascience.com/tensorflow-object-detection-with-docker-from-scratch-5e015b639b0b

1. Manual download dependencies needed for the container
# Download TensorFlow models and examples
git clone https://github.com/tensorflow/models.git

# Download EdjeElectronics tutorial
git clone https://github.com/EdjeElectronics/TensorFlow-Object-Detection-API-#Tutorial-Train-Multiple-Objects-Windows-10.git

# Download (and unzip) inference_graph into folder inference_graph
https://www.dropbox.com/s/va9ob6wcucusse1/inference_graph.zip?dl=0

Your directory should now look like this:

+ edje-tutorial
+ inference_graph
+ ts_models (contains models/research/... folders)
DockerFile
faster_rcnn_inception_v2_coco_2018_01_28.tar.gz
readme.txt

2. Build and run the docker container
Download and install Docker if yoiu havent already, make sure your Docker is set to "Linux Containers"
Now open up a command line and navigate to this directory

docker build -t ts-api .
< = Should finish without any major errors

Now start the container:
docker run -it --name ts-api -p 8888:8888 ts-api /bin/bash
If you donw want interactive container, simply run
docker run --name ts-api -p 8888:8888 ts-api

If everything is ok, you should be able to browse http://localhost:8888 and see the Jupyter login prompt