| 17 | |
| 18 | |
| 19 | def optimize_graph(input_path, output_path, input_nodes, output_nodes): |
| 20 | graph = tf.Graph() |
| 21 | with tf.Session(graph=graph) as sess: |
| 22 | tf.saved_model.loader.load(sess, [tf.saved_model.tag_constants.SERVING], input_path) |
| 23 | |
| 24 | gdef = strip_unused_lib.strip_unused( |
| 25 | input_graph_def=graph.as_graph_def(), |
| 26 | input_node_names=input_nodes, |
| 27 | output_node_names=output_nodes, |
| 28 | placeholder_type_enum=dtypes.float32.as_datatype_enum) |
| 29 | with gfile.GFile(output_path, 'wb') as f: |
| 30 | f.write(gdef.SerializeToString()) |
| 31 | return graph |
| 32 | |
| 33 | |
| 34 | def convert_ssd(exported_graph_path, model_structure, output_path): |