code: def test(args):
      print("test with", args)
      global detector
      output_folder = args.output
      if not os.path.exists(output_folder):
          os.mkdir(output_folder)
      detector = RetinaFace(
          args.prefix,
          args.epoch,
          args.gpu,
          network=args.network,
          nocrop=args.nocrop,
          vote=args.bbox_vote,
      )
      imdb = eval(args.dataset)(
          args.image_set, args.root_path, args.dataset_path
      )
      roidb = imdb.gt_roidb()
      gt_overlaps = np.zeros(0)
      overall = [0.0, 0.0]
      gt_max = np.array((0.0, 0.0))
      num_pos = 0
      print("roidb size", len(roidb))
  
      for i in range(len(roidb)):
          if i % args.parts != args.part:
              continue
          # if i%10==0:
          #  print('processing', i, file=sys.stderr)
          roi = roidb[i]
          boxes = get_boxes(roi, args.pyramid)
          if "boxes" in roi:
              gt_boxes = roi["boxes"].copy()
              gt_areas = (gt_boxes[:, 2] - gt_boxes[:, 0] + 1) * (
                  gt_boxes[:, 3] - gt_boxes[:, 1] + 1
              )
              num_pos += gt_boxes.shape[0]
  
              overlaps = bbox_overlaps(
                  boxes.astype(np.float), gt_boxes.astype(np.float)
              )
              # print(im_info, gt_boxes.shape, boxes.shape, overlaps.shape, file=sys.stderr)
  
              _gt_overlaps = np.zeros((gt_boxes.shape[0]))
  
              if boxes.shape[0] > 0:
                  _gt_overlaps = overlaps.max(axis=0)
                  # print('max_overlaps', _gt_overlaps, file=sys.stderr)
                  for j in range(len(_gt_overlaps)):
                      if _gt_overlaps[j] > 0.5:
                          continue
                      # print(j, 'failed', gt_boxes[j],  'max_overlap:', _gt_overlaps[j], file=sys.stderr)
  
                  # append recorded IoU coverage level
                  found = (_gt_overlaps > 0.5).sum()
                  recall = found / float(gt_boxes.shape[0])
                  # print('recall', _recall, gt_boxes.shape[0], boxes.shape[0], gt_areas, 'num:', i, file=sys.stderr)
                  overall[0] += found
                  overall[1] += gt_boxes.shape[0]
                  # gt_overlaps = np.hstack((gt_overlaps, _gt_overlaps))
                  # _recall = (gt_overlaps >= threshold).sum() / float(num_pos)
                  recall_all = float(overall[0]) / overall[1]
                  # print('recall_all', _recall, file=sys.stderr)
                  print(
                      "[%d]" % i,
                      "recall",
                      recall,
                      (gt_boxes.shape[0], boxes.shape[0]),
                      "all:",
                      recall_all,
                      file=sys.stderr,
                  )
          else:
              print("[%d]" % i, "detect %d faces" % boxes.shape[0])
  
          _vec = roidb[i]["image"].split("/")
          out_dir = os.path.join(output_folder, _vec[-2])
          if not os.path.exists(out_dir):
              os.mkdir(out_dir)
          out_file = os.path.join(
              out_dir, _vec[-1].replace("jpg", "txt")
          )
          with open(out_file, "w") as f:
              name = "/".join(roidb[i]["image"].split("/")[-2:])
              f.write("%s\n" % (name))
              f.write("%d\n" % (boxes.shape[0]))
              for b in range(boxes.shape[0]):
                  box = boxes[b]
                  f.write(
                      "%d %d %d %d %g \n"
                      % (
                          box[0],
                          box[1],
                          box[2] - box[0],
                          box[3] - box[1],
                          box[4],
                      )
                  )
  
file_path: insightface/detection/retinaface/test_widerface.py
imports: from __future__ import print_function
  import argparse
  import sys
  import os
  import time
  import numpy
  import mxnet
  from mxnet import ndarray
  import cv2
  from rcnn.logger import logger
  from rcnn.processing.bbox_transform import nonlinear_pred, clip_boxes, landmark_pred
  from rcnn.processing.generate_anchor import generate_anchors_fpn, anchors_plane
  from rcnn.processing.nms import gpu_nms_wrapper
  from rcnn.processing.bbox_transform import bbox_overlaps
  from rcnn.dataset import retinaface
  from retinaface import RetinaFace
label_desc: Use image node_id 3 for calling a global function with example usage: test(args) without return types