code: def _main():
      parser = argparse.ArgumentParser()
  
      parser.add_argument(
          "-n",
          "--network",
          type=_text_type,
          help="Model Type",
          required=True,
          choices=input_layer_map.keys(),
      )
  
      parser.add_argument(
          "-i", "--image", type=_text_type, help="Test Image Path"
      )
  
      parser.add_argument(
          "-ckpt",
          "--checkpoint",
          type=_text_type,
          help="Tensorflow Checkpoint file name",
          required=True,
      )
  
      args = parser.parse_args()
  
      num_classes = (
          1000
          if args.network in ("vgg16", "vgg19", "resnet_v1_101")
          else 1001
      )
  
      with slim.arg_scope(arg_scopes_map[args.network]()):
          data_input = input_layer_map[args.network]()
          logits, endpoints = networks_map[args.network]()(
              data_input, num_classes=num_classes, is_training=False
          )
          labels = tf.squeeze(logits)
  
      init = tf.global_variables_initializer()
  
      with tf.Session() as sess:
          writer = tf.summary.FileWriter("./graphs", sess.graph)
          writer.close()
          sess.run(init)
          saver = tf.train.Saver()
          saver.restore(sess, args.checkpoint)
          save_path = saver.save(
              sess, "./imagenet_{}.ckpt".format(args.network)
          )
          print("Model saved in file: %s" % save_path)
  
          if args.image:
              import numpy as np
  
              func = TestKit.preprocess_func["tensorflow"][args.network]
              img = func(args.image)
              img = np.expand_dims(img, axis=0)
              predict = sess.run(logits, feed_dict={data_input: img})
              predict = np.squeeze(predict)
              top_indices = predict.argsort()[-5:][::-1]
              result = [(i, predict[i]) for i in top_indices]
              print(result)
  
file_path: MMdnn/mmdnn/conversion/examples/tensorflow/extract_model.py
imports: import argparse
  from six import text_type
  import tensorflow
  from tensorflow.contrib.slim.python.slim.nets import vgg
  from tensorflow.contrib.slim.python.slim.nets import inception
  from tensorflow.contrib.slim.python.slim.nets import resnet_v1
  from tensorflow.contrib.slim.python.slim.nets import resnet_v2
  from mmdnn.conversion.examples.imagenet_test import TestKit
label_desc: Use image node_id 1 for calling a global function with example usage: _main() without return types