Tuesday, April 9, 2019

Tensorflow Object Detection API - Containerize the web service




1. Structure the directory inside container
docker build initial transfer
Base container image is ubuntu:16.04. When you execute command "docker build", all the files in the same directory and subdirectory of "Dockerfile" are transferred to Docker Daemon so you can copy those files to the base container image.
The figure below is an initial process when you execute the command above.



Create working directory
After installing all dependency, the docker container creates a new directory named "/app"
The figure below is when you execute the command above


Clone Tensorflow object detection from Github
Then you clone Tensorflow object detection from Github to "/app/models"
The figure below is when you execute the command above



Copy the necessary files and folders
Finally, copy the python file that generates web service app "object_detection_app_test1_docker.py"and directory "test1"

The figure below is when you execute the command above


2. PORT setting
In the Dockerfile, you point out the port number 80 so the container communicate with outside network with the command below.
When you run the docker container, you point out the port number 5000 of the host PC, which runs the docker container, with the command below
Then the docker container can be accessed by http request like below