Simple question, but it took me many hours of digging into the code to figure out :-(. Someone should have added a document or something.
# XXX: this only works for tf 0.11, for 0.12 or 1.0 the api may be different ...
import tensorflow as tf
from tensorflow.core.protobuf import meta_graph_pb2
from tensorflow.contrib.session_bundle import manifest_pb2
with tf.Session() as sess:
new_saver = tf.train.import_meta_graph(meta_file)
graph = tf.get_default_graph()
pb = graph.get_collection("serving_signatures")
signatures = manifest_pb2.Signatures()
Basically, just import the meta graph, then unpack the protobuf object from serving_signatures collection. I really don’t understand why it is not added to signature def. Anyway, later you can just call read_serving_signature(path/to/export.meta) to retrieve the exported signatures. It will be very helpful if you want to implement a generic serving interface for tensorflow.
I also made a gist here for reference.