I have a bunch of custom defined model instances inheriting from tf.keras.layers.Layer
that I save. I would like to serve them with TFX Serving, which requires me to have a model_config
file.
I am wondering how to create this according to the book. Right now I have the following code which I believe is more about my own bricolage than what I am supposed to do...
model_server_config = model_server_config_pb2.ModelServerConfig()
#Create a config to add to the list of served models
config_list = model_server_config_pb2.ModelConfigList()
for i in range(0,len(trainable_unit_name)): # add models one by one to the model config.
model_name = name[i]
base_path = "/models/{}".format(name[i])
one_config = config_list.config.add()
one_config.name = model_name
one_config.base_path = base_path
one_config.model_platform ="tensorflow"
model_server_config.model_config_list.MergeFrom(config_list)
with open(C.CONF_FILEPATH, 'w+') as f:
f.write("model_config_list {" + config_list.__str__() + "}") #manually wrap it around "model_config_list { .." because this is the required format by TFX Serving.