How to encode binary data for prediction input in Vertex AI

Viewed 221

I have searched high and low across StackOverflow to solve this issue but either the answers are outdated (don't used TF 2.x) or are too complicated.

I have created a model as so:

import tensorflow as tf

inputs = tf.keras.layers.Input((128, 128, 3))
conv1 = tf.keras.layers.Conv2D(16, (3, 3))(inputs)
outputs = tf.keras.layers.Dense(64)(conv1)
model = tf.keras.models.Model(inputs=inputs, outputs=outputs)

I am saving the model as thus and want to host this SavedModel on Vertex AI Predictions.

tf.saved_model.save(model, 'placeholder_model')

Is there a different way I should save the model?

I want to use binary data encoded as base64 strings as prediction inputs. The official documentation from Vertex AI for online predictions says:

In your TensorFlow model code, you must name the aliases for your binary input and output tensors so that they end with '_bytes'.

My question is thus: How should export my SavedModel such that I can use base64 strings to send requests for online predictions?

0 Answers
Related