Skip to content

Instantly share code, notes, and snippets.

View alexcpn's full-sized avatar

Alex Punnen alexcpn

View GitHub Profile
@alexcpn
alexcpn / Dockerfile
Created August 9, 2018 05:26
For running GRPC gateway
FROM envoyproxy/envoy:latest
RUN apt-get update
COPY envoy.yaml /etc/envoy.yaml
CMD /usr/local/bin/envoy -c /etc/envoy.yaml
@alexcpn
alexcpn / Dockerfile
Created August 9, 2018 05:26
For running GRPC gateway
FROM envoyproxy/envoy:latest
RUN apt-get update
COPY envoy.yaml /etc/envoy.yaml
CMD /usr/local/bin/envoy -c /etc/envoy.yaml
@alexcpn
alexcpn / index.html
Last active April 5, 2019 10:53
GRPC- Web JS client
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="shortcut icon" href="#" />
<title>Echo Example</title>
<script src="https://code.jquery.com/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="compiled.js"></script>
<script type="text/javascript">
# Simple TFServing example; Based on
# https://github.com/tensorflow/serving/blob/master/tensorflow_serving/example/mnist_client.py
# Added simpler mnist loading parts and removed some complexity
#!/usr/bin/env python2.7
"""A client that talks to tensorflow_model_server loaded with mnist model.
The client downloads test images of mnist data set, queries the service with
such test images to get predictions, and calculates the inference error rate.
Typical usage example:
@alexcpn
alexcpn / python_grpc.py
Created February 5, 2019 10:23
Python Protobuffer GRPC assign to nested type and assign to repeated types
obj1 = proto.Object.Detection()
obj1.classname= classname
bbox = proto.BoundingBox()
bbox.X1 =1
# Use CopyFrom to assign to nested element
obj1.boundingbox.CopyFrom(bbox)
obj1.object_id = random.randint(1, 6)
callback = proto.Object()
# use Extend to add to repeated elements
import grpc
import numpy
import tensorflow as tf
from tensorflow_serving.apis import predict_pb2
from tensorflow_serving.apis import prediction_service_pb2_grpc
from keras.preprocessing import image
from keras_retinanet.utils.image import read_image_bgr, preprocess_image, resize_image
import time
import cv2
import grpc
import numpy
import tensorflow as tf
from tensorflow_serving.apis import predict_pb2
from tensorflow_serving.apis import prediction_service_pb2_grpc
import time
import cv2
import numpy as np
@alexcpn
alexcpn / README.md
Created March 29, 2019 06:09
Different types of image pre-processing for neural networks

#Server docker run --net=host --runtime=nvidia -it --rm -p 8900:8500 -p 8901:8501 -v /home/alex/coding/IPython_neuralnet/models:/models -e MODEL_NAME=retinanet tensorflow/serving:latest-gpu --rest_api_port=0 --enable_batching=true --model_config_file=/models/model_configs/retinanet.json

#Client

docker run -it --runtime=nvidia --net=host -v /home/alex/coding/IPython_neuralnet:/coding --rm alexcpn/tfserving-keras-retinanet-dev-gpu To run TF Client unset http_proxy unset https_proxy root@drone-OMEN:/coding/tfserving_client#python retinanet_client.py -num_tests=1 -server=127.0.0.1:8500 -batch_size=1 -img_path='../examples/google1.jpg'

@alexcpn
alexcpn / image_preprocessor_tf_client.py
Last active April 3, 2019 19:24
Image preprocessor for TF Serving Client
################################################################################
# Helper functions for image preoricessing #
################################################################################
__author__ = "Alex Punnen"
__date__ = "March 2019"
from timeit import default_timer as timer
import numpy as np
import cv2
""" GRPC Client for SSD TF Serving Model"""
from __future__ import division
__author__ = "Alex Punnen"
__date__ = "March 2019"
import grpc
import numpy
import tensorflow as tf
import time