Skip to content
Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
36 lines (29 sloc) 1.18 KB
# -*- coding: utf-8 -*-
import numpy as np
import pandas as pd
import tensorflow as tf
from tensorflow_serving.apis import classification_pb2
from tensorflow_serving.apis import regression_pb2
from tensorflow_serving.apis import predict_pb2
from tensorflow_serving.apis import prediction_service_pb2
from grpc.beta import implementations
import common
channel = implementations.insecure_channel('', 9000)
stub = prediction_service_pb2.beta_create_PredictionService_stub(channel)
inputs = common.get_test_inputs()
examples = []
for index, row in inputs.iterrows():
example = tf.train.Example()
for col, value in row.iteritems():
request = classification_pb2.ClassificationRequest() = 'default'
response = stub.Classify(request, 10.0)
outputs = inputs.copy()
for index, row in outputs.iterrows():
max_class = max(response.result.classifications[index].classes, key=lambda c: c.score)
outputs.loc[index, 'ClassId'] = max_class.label
outputs.loc[index, 'Probability'] = max_class.score
You can’t perform that action at this time.