class_docstr: Export models for inference.
docstr: Converts a checkpoint and graph to a servable for TensorFlow Serving.
  Use TF's `SavedModelBuilder` to export a trained model without tensorpack dependency.
  
  Args:
      filename (str): path for export directory
      tags (tuple): tuple of user specified tags. Defaults to just "SERVING".
      signature_name (str): name of signature for prediction
  
  Note:
      This produces
  
      .. code-block:: none
  
          variables/       # output from the vanilla Saver
              variables.data-?????-of-?????
              variables.index
          saved_model.pb   # a `SavedModel` protobuf
  
      Currently, we only support a single signature, which is the general PredictSignatureDef:
      https://github.com/tensorflow/serving/blob/master/tensorflow_serving/g3doc/signature_defs.md
docstr_tok: ["Converts","a","checkpoint","and","graph","to","a","servable","for","TensorFlow","Serving",".","Use","TF","'s","`","SavedModelBuilder","`","to","export","a","trained","model","without","tensorpack","dependency",".","Args",":","filename","(","str",")",":","path","for","export","directory","tags","(","tuple",")",":","tuple","of","user","specified","tags",".","Defaults","to","just","``","SERVING","''",".","signature_name","(","str",")",":","name","of","signature","for","prediction","Note",":","This","produces","..","code-block",":",":","none","variables\/","#","output","from","the","vanilla","Saver","variables.data-","?","?","?","?","?","-of-","?","?","?","?","?","variables.index","saved_model.pb","#","a","`","SavedModel","`","protobuf","Currently",",","we","only","support","a","single","signature",",","which","is","the","general","PredictSignatureDef",":","https",":","\/\/github.com\/tensorflow\/serving\/blob\/master\/tensorflow_serving\/g3doc\/signature_defs.md"]
code: def export_serving(
      self, filename, tags=None, signature_name="prediction_pipeline"
  ):
      """
      Converts a checkpoint and graph to a servable for TensorFlow Serving.
      Use TF's `SavedModelBuilder` to export a trained model without tensorpack dependency.
  
      Args:
          filename (str): path for export directory
          tags (tuple): tuple of user specified tags. Defaults to just "SERVING".
          signature_name (str): name of signature for prediction
  
      Note:
          This produces
  
          .. code-block:: none
  
              variables/       # output from the vanilla Saver
                  variables.data-?????-of-?????
                  variables.index
              saved_model.pb   # a `SavedModel` protobuf
  
          Currently, we only support a single signature, which is the general PredictSignatureDef:
          https://github.com/tensorflow/serving/blob/master/tensorflow_serving/g3doc/signature_defs.md
      """
      if tags is None:
          tags = (
              tf.saved_model.SERVING
              if get_tf_version_tuple() >= (1, 12)
              else tf.saved_model.tag_constants.SERVING,
          )
  
      self.graph = self.config._maybe_create_graph()
      with self.graph.as_default():
          input = PlaceholderInput()
          input.setup(self.config.input_signature)
          with PredictTowerContext(""):
              self.config.tower_func(*input.get_input_tensors())
  
          input_tensors = get_tensors_by_names(self.config.input_names)
          saved_model = tfv1.saved_model.utils
          inputs_signatures = {
              t.name: saved_model.build_tensor_info(t)
              for t in input_tensors
          }
          output_tensors = get_tensors_by_names(
              self.config.output_names
          )
          outputs_signatures = {
              t.name: saved_model.build_tensor_info(t)
              for t in output_tensors
          }
  
          self.config.session_init._setup_graph()
          # we cannot use "self.config.session_creator.create_session()" here since it finalizes the graph
          sess = tfv1.Session(
              config=tfv1.ConfigProto(allow_soft_placement=True)
          )
          self.config.session_init._run_init(sess)
  
          builder = tfv1.saved_model.builder.SavedModelBuilder(filename)
  
          prediction_signature = tfv1.saved_model.signature_def_utils.build_signature_def(
              inputs=inputs_signatures,
              outputs=outputs_signatures,
              method_name=tfv1.saved_model.signature_constants.PREDICT_METHOD_NAME,
          )
  
          builder.add_meta_graph_and_variables(
              sess,
              list(tags),
              signature_def_map={signature_name: prediction_signature},
          )
          builder.save()
          logger.info("SavedModel created at {}.".format(filename))
  
file_path: tensorpack/tensorpack/tfutils/export.py
imports: import tensorflow
  from tensorflow.python.framework import graph_util
  from tensorflow.python.platform import gfile
  from tensorflow.python.tools import optimize_for_inference_lib
  from ..compat import tfv1
  from ..input_source import PlaceholderInput
  from ..tfutils.common import get_tensors_by_names, get_tf_version_tuple
  from ..tfutils.tower import PredictTowerContext
  from ..utils import logger
label_desc: Use image node_id 3 for calling the ModelExporter obj's underlying member method code with example usage: obj.export_serving(filename, tags, signature_name) without return types