Skip to content

Commit 629de7d

Browse files
Add Dockerfile
1 parent 894ca9c commit 629de7d

File tree

3 files changed

+53
-0
lines changed

3 files changed

+53
-0
lines changed

.gitignore

+6
Original file line numberDiff line numberDiff line change
@@ -127,3 +127,9 @@ dmypy.json
127127

128128
# Pyre type checker
129129
.pyre/
130+
commands.md
131+
static/IMG-20191002-WA0006.png
132+
static/IMG_20190426_163741~2.png
133+
static/images.jfif
134+
static/demo-image.png
135+
static/d41586-020-01443-0_17985512.jpg

Dockerfile

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
ARG TF_SERVING_VERSION=latest
2+
ARG TF_SERVING_BUILD_IMAGE=tensorflow/serving:${TF_SERVING_VERSION}-devel
3+
4+
FROM ${TF_SERVING_BUILD_IMAGE} as build_image
5+
FROM ubuntu:18.04
6+
7+
ARG TF_SERVING_VERSION_GIT_BRANCH=master
8+
ARG TF_SERVING_VERSION_GIT_COMMIT=head
9+
10+
LABEL maintainer="swapnanildutta2000@gmail.com"
11+
LABEL tensorflow_serving_github_branchtag=${TF_SERVING_VERSION_GIT_BRANCH}
12+
LABEL tensorflow_serving_github_commit=${TF_SERVING_VERSION_GIT_COMMIT}
13+
14+
RUN apt-get update && apt-get install -y --no-install-recommends \
15+
ca-certificates \
16+
&& \
17+
apt-get clean && \
18+
rm -rf /var/lib/apt/lists/*
19+
20+
# Install TF Serving pkg
21+
COPY --from=build_image /usr/local/bin/tensorflow_model_server /usr/bin/tensorflow_model_server
22+
23+
# Expose ports
24+
# gRPC
25+
EXPOSE 8500
26+
27+
# REST
28+
EXPOSE 8501
29+
30+
# Set where models should be stored in the container
31+
ENV MODEL_BASE_PATH=/models
32+
RUN mkdir -p ${MODEL_BASE_PATH}
33+
34+
# The only required piece is the model name in order to differentiate endpoints
35+
ENV MODEL_NAME=saved_model
36+
37+
COPY models models
38+
# Create a script that runs the model server so we can use environment variables
39+
# while also passing in arguments from the docker command line
40+
RUN echo '#!/bin/bash \n\n\
41+
tensorflow_model_server --rest_api_port=$PORT \
42+
--model_name=${MODEL_NAME} --model_base_path=${MODEL_BASE_PATH}/${MODEL_NAME} \
43+
"$@"' > /usr/bin/tf_serving_entrypoint.sh \
44+
&& chmod +x /usr/bin/tf_serving_entrypoint.sh
45+
46+
CMD ["/usr/bin/tf_serving_entrypoint.sh"]

inference.py

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import requests
55

66
SIZE=128
7+
#Local Host
78
MODEL_URI="http://localhost:8501/v1/models/pets:predict"
89
CLASSES=['Cat','Dog']
910

0 commit comments

Comments
 (0)