(outputs, frozen_graph_pb_path, sess, graph=None)
Freeze graph to a pb file.
Freeze graph to a pb file.
Freeze graph to a pb file .
def frozen_graph_to_pb(outputs, frozen_graph_pb_path, sess, graph=None):
  """Freeze graph to a pb file."""
  if not isinstance(outputs, (list)):
    raise ValueError("Frozen graph: outputs must be list of output node name")

  if graph is None:
    graph = tf.get_default_graph()

  input_graph_def = graph.as_graph_def()
  logging.info("Frozen graph: len of input graph nodes: {}".format(
      len(input_graph_def.node)))

  # We use a built-in TF helper to export variables to constant
  output_graph_def = graph_util.convert_variables_to_constants(
      sess,
      input_graph_def,
      outputs,
  )

  logging.info("Frozen graph: len of output graph nodes: {}".format(
      len(output_graph_def.node)))  # pylint: disable=no-member

  with tf.gfile.GFile(frozen_graph_pb_path, "wb") as in_f:
    in_f.write(output_graph_def.SerializeToString())
def frozen_graph_to_pb ( outputs , frozen_graph_pb_path , sess , graph = None ) : if not isinstance ( outputs , ( list ) ) : raise ValueError ( "Frozen graph: outputs must be list of output node name" ) if graph is None : graph = tf . get_default_graph ( ) input_graph_def = graph . as_graph_def ( ) logging . info ( "Frozen graph: len of input graph nodes: {}" . format ( len ( input_graph_def . node ) ) ) # We use a built-in TF helper to export variables to constant output_graph_def = graph_util . convert_variables_to_constants ( sess , input_graph_def , outputs , ) logging . info ( "Frozen graph: len of output graph nodes: {}" . format ( len ( output_graph_def . node ) ) ) # pylint: disable=no-member with tf . gfile . GFile ( frozen_graph_pb_path , "wb" ) as in_f : in_f . write ( output_graph_def . SerializeToString ( ) )