Skip to content
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

ResNet Latency test #328

Merged
merged 2 commits into from
Dec 4, 2018
Merged
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
12 changes: 12 additions & 0 deletions examples/models/resnet/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@


build_image:
s2i build -E environment_grpc . seldonio/seldon-core-s2i-python36:0.4-SNAPSHOT seldon-resnet2.4


clean:
rm -rf model
rm -rf proto/__pycache__
rm -f proto/*.py
rm -r proto/*.proto
rm -rf tensorflow
38 changes: 38 additions & 0 deletions examples/models/resnet/Resnet.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import tensorflow as tf
import numpy as np
import logging
import datetime

def get_logger(name):
logger = logging.getLogger(name)
log_formatter = logging.Formatter("%(asctime)s - %(name)s - "
"%(levelname)s - %(message)s")
logger.setLevel('DEBUG')

console_handler = logging.StreamHandler()
console_handler.setFormatter(log_formatter)
logger.addHandler(console_handler)

return logger

logger = get_logger(__name__)

class Resnet(object):
def __init__(self):
self.class_names = ["class:{}".format(str(i)) for i in range(1000)]
self.sess = tf.Session()
tf.saved_model.loader.load(self.sess, ["serve"], "model", clear_devices=True)

graph = tf.get_default_graph()
self.x = graph.get_tensor_by_name("input:0")
self.y = graph.get_tensor_by_name("resnet_v1_50/predictions/Reshape_1:0")

def predict(self,X,feature_names):
start_time = datetime.datetime.now()
predictions = self.sess.run(self.y,feed_dict={self.x:X})
end_time = datetime.datetime.now()
duration = (end_time - start_time).total_seconds() * 1000
logger.debug("Processing time: {:.2f} ms".format(duration))
return predictions.astype(np.float64)


Binary file added examples/models/resnet/dog.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions examples/models/resnet/environment_grpc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
MODEL_NAME=Resnet
API_TYPE=GRPC
SERVICE_TYPE=MODEL
PERSISTENCE=0
Empty file.
1 change: 1 addition & 0 deletions examples/models/resnet/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tensorflow
Loading