serving icon indicating copy to clipboard operation
serving copied to clipboard

Can not able to pass audio input shape in GRPC inputs method while using tensorflow serving

Open Jitendradubey opened this issue 3 years ago • 0 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 yamnet_error

Thanks in advance.

Jitendradubey avatar Aug 16 '22 08:08 Jitendradubey