text: import sys
  import os.path as osp
  from keras import backend as K
  from keras.models import load_model
  import tensorflow as tf
  from tensorflow.python.framework import graph_util
  from tensorflow.python.framework import graph_io
  
  model_path = sys.argv[1]
  
  weight_file_path = model_path
  model_name = osp.split(model_path)[-1].split(".")[0]
  net_model = load_model(weight_file_path)
  sess = K.get_session()
  
  # ops = sess.graph.get_operations()
  # for op in ops:
  #     if op.op_def and op.op_def.name == "Variable":
  #         print(op)
  
  output_names = [out.op.name for out in net_model.outputs]
  outputs = {out.op.name: out for out in net_model.outputs}
  print("output: ", output_names)
  print(net_model.output.name)
  
  input_names = [inp.op.name for inp in net_model.inputs]
  inputs = {inp.op.name: inp for inp in net_model.inputs}
  print("input: ", input_names)
  
  # constant_graph = graph_util.convert_variables_to_constants(sess, sess.graph.as_graph_def(), output_names)
  # TODO: Save model the right way via SavedModel
  # graph_io.write_graph(constant_graph, '../models/', 'evidencedetection.pb', as_text=False)
  # print('saved the constant graph (ready for inference) at: ', osp.join('../models/', 'evidencedetection.pb'))
  
  builder = tf.saved_model.builder.SavedModelBuilder(model_name)
  builder.add_meta_graph_and_variables(
      sess,
      [tf.saved_model.tag_constants.SERVING],
      signature_def_map= {
         "magic_model": tf.saved_model.signature_def_utils.predict_signature_def(inputs, outputs)
      })
  builder.save()
  