I'm trying to convert this model to a tensorflow.js format so I can perform in-browser client-side inference of the model. To do this, the model needs to be in the SavedModel format as specified here.
By using a simple python script to restore the model and save it in this SavedModel format, I've managed to obtain a .pb file as expected:
import tensorflow as tf
trained_checkpoint_prefix = 'models/snap-0'
export_dir = os.path.join('export_dir', '0')
graph = tf.Graph()
with tf.compat.v1.Session(graph=graph) as sess:
# Restore from checkpoint
loader = tf.compat.v1.train.import_meta_graph(trained_checkpoint_prefix + '.meta')
loader.restore(sess, trained_checkpoint_prefix)
# Export checkpoint to SavedModel
builder = tf.compat.v1.saved_model.builder.SavedModelBuilder(export_dir)
builder.add_meta_graph_and_variables(sess, [tf.saved_model.SERVING], strip_default_attrs=True)
builder.save()
However, when I try to then convert this SavedModel format with tfjs converter, it seems that it expects some SignatureDefs to be saved, which have been lost in the conversion process so I get these error messages:
RuntimeError: MetaGraphDef associated with tags 'serve' could not be found in SavedModel.ValueError: Signature 'serving_default' does not exist. The following signatures are available: KeysView(_SignatureMap({}))MetaGraphDef with tag-set: 'serve' contains the following SignatureDefs: #no output
It seems I need to provide some sort of signature for the inputs and outputs of the network, although I'm really unfamiliar with this process so am unsure how I would do so.
Does anybody have an insight into how I could solve this?
I'm trying to convert this model to a tensorflow.js format so I can perform in-browser client-side inference of the model. To do this, the model needs to be in the SavedModel format as specified here.
By using a simple python script to restore the model and save it in this SavedModel format, I've managed to obtain a .pb file as expected:
However, when I try to then convert this SavedModel format with tfjs converter, it seems that it expects some SignatureDefs to be saved, which have been lost in the conversion process so I get these error messages:
RuntimeError: MetaGraphDef associated with tags 'serve' could not be found in SavedModel.
ValueError: Signature 'serving_default' does not exist. The following signatures are available: KeysView(_SignatureMap({}))
MetaGraphDef with tag-set: 'serve' contains the following SignatureDefs: #no output
It seems I need to provide some sort of signature for the inputs and outputs of the network, although I'm really unfamiliar with this process so am unsure how I would do so.
Does anybody have an insight into how I could solve this?