Skip to content

Instantly share code, notes, and snippets.

View bombdiggity's full-sized avatar

bombdiggity

  • San Francisco Bay Area
View GitHub Profile
from grpc.beta import implementations
import tensorflow as tf
from tensorflow_serving.apis import predict_pb2
from tensorflow_serving.apis import prediction_service_pb2
from PIL import Image
import numpy as np
tf.app.flags.DEFINE_string('server', 'localhost:9000',
@bombdiggity
bombdiggity / keras_model_export.py
Last active August 17, 2020 11:40
Code to export Keras model to ProtoBuf format
from keras import backend as K
from keras.models import load_model
from tensorflow.python.saved_model import builder as saved_model_builder
from tensorflow.python.saved_model.signature_def_utils import predict_signature_def
from tensorflow.python.saved_model import tag_constants
# Function to export Keras model to Protocol Buffer format
# Inputs:
# path_to_h5: Path to Keras h5 model
# export_path: Path to store Protocol Buffer model