code: def main(args):
      print(args)
      gpuid = args.gpu
      ctx = mx.gpu(gpuid)
      nets = []
      image_shape = [int(x) for x in args.image_size.split(",")]
      for model in args.model.split("|"):
          vec = model.split(",")
          assert len(vec) > 1
          prefix = vec[0]
          epoch = int(vec[1])
          print("loading", prefix, epoch)
          net = edict()
          net.ctx = ctx
          (
              net.sym,
              net.arg_params,
              net.aux_params,
          ) = mx.model.load_checkpoint(prefix, epoch)
          all_layers = net.sym.get_internals()
          net.sym = all_layers["fc1_output"]
          net.model = mx.mod.Module(
              symbol=net.sym, context=net.ctx, label_names=None
          )
          net.model.bind(
              data_shapes=[
                  ("data", (1, 3, image_shape[1], image_shape[2]))
              ]
          )
          net.model.set_params(net.arg_params, net.aux_params)
          nets.append(net)
  
      facescrub_out = os.path.join(args.output, "facescrub")
      megaface_out = os.path.join(args.output, "megaface")
  
      i = 0
      succ = 0
      buffer = []
      for line in open(args.facescrub_lst, "r"):
          if i % 1000 == 0:
              print("writing fs", i, succ)
          i += 1
          image_path = line.strip()
          _path = image_path.split("/")
          a, b = _path[-2], _path[-1]
          out_dir = os.path.join(facescrub_out, a)
          if not os.path.exists(out_dir):
              os.makedirs(out_dir)
          image_path = os.path.join(args.facescrub_root, image_path)
          img = read_img(image_path)
          if img is None:
              print("read error:", image_path)
              continue
          out_path = os.path.join(out_dir, b + "_%s.bin" % (args.algo))
          item = (img, out_path)
          buffer.append(item)
          if len(buffer) == args.batch_size:
              get_and_write(buffer, nets)
              buffer = []
          succ += 1
      if len(buffer) > 0:
          get_and_write(buffer, nets)
          buffer = []
      print("fs stat", i, succ)
  
      i = 0
      succ = 0
      buffer = []
      for line in open(args.megaface_lst, "r"):
          if i % 1000 == 0:
              print("writing mf", i, succ)
          i += 1
          image_path = line.strip()
          _path = image_path.split("/")
          a1, a2, b = _path[-3], _path[-2], _path[-1]
          out_dir = os.path.join(megaface_out, a1, a2)
          if not os.path.exists(out_dir):
              os.makedirs(out_dir)
              # continue
          # print(landmark)
          image_path = os.path.join(args.megaface_root, image_path)
          img = read_img(image_path)
          if img is None:
              print("read error:", image_path)
              continue
          out_path = os.path.join(out_dir, b + "_%s.bin" % (args.algo))
          item = (img, out_path)
          buffer.append(item)
          if len(buffer) == args.batch_size:
              get_and_write(buffer, nets)
              buffer = []
          succ += 1
      if len(buffer) > 0:
          get_and_write(buffer, nets)
          buffer = []
      print("mf stat", i, succ)
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import os
  from easydict import EasyDict
  import time
  import sys
  import numpy
  import argparse
  import struct
  import cv2
  import sklearn
  from sklearn.preprocessing import normalize
  import mxnet
  from mxnet import ndarray
label_desc: Use image node_id 5 for calling a global function with example usage: main(args) without return types