Can not able to pass audio input shape in GRPC inputs method while using tensorflow serving
Jitendradubey opened this issue · comments
Bug Report
If this is a bug report, please fill out the following form in full:
System information
- Linux Ubuntu 18.04:
- TensorFlow Serving 2.7.3:
Describe the problem
How to host below model on tensorflow serving and pass the audio input using GRPC APIs
https://tfhub.dev/google/yamnet/1
Source code / logs
import grpc
import numpy as np
import tensorflow as tf
from tensorflow_serving.apis import predict_pb2
from tensorflow_serving.apis import prediction_service_pb2_grpc
import soundfile as sf
import resampy
import yamnet_files.params as yamnet_params
GRPC_MAX_RECEIVE_MESSAGE_LENGTH = 4096 * 4096 * 3
channel = grpc.insecure_channel('xx.xxx.xxx.xx:8500', options=[('grpc.max_receive_message_length', GRPC_MAX_RECEIVE_MESSAGE_LENGTH)])
stub = prediction_service_pb2_grpc.PredictionServiceStub(channel)
grpc_request = predict_pb2.PredictRequest()
grpc_request.model_spec.name = 'saved_models'
grpc_request.model_spec.signature_name = 'serving_default'
wav_data, sr = sf.read('731.wav', dtype=np.int16)
assert wav_data.dtype == np.int16, 'Bad sample type: %r' % wav_data.dtype
waveform = wav_data / tf.int16.max # 32768.0 # Convert to [-1.0, +1.0]
waveform = waveform.astype('float32')
params = yamnet_params.Params()
grpc_request.inputs['waveform'].CopyFrom(tf.make_tensor_proto(waveform, shape =waveform.shape)
here i'm not able to pass proper input shape to return only 521 classes of my yamnet model instead of returning all values
scores = stub.Predict(grpc_request,10)
https://tfhub.dev/google/yamnet/1 link to yamnet model which i'm refering to use as tensorflow serving
Thanks in advance.
I was able to serve yamnet model on TF Serving and able to pass audio input to the model server and generate predictions using REST API. Please find attached gist and let us know if this helps. Thank you!
This issue has been marked stale because it has no recent activity since 7 days. It will be closed if no further activity occurs. Thank you.
This issue was closed due to lack of activity after being marked stale for past 7 days.