code: def get_boxes(roi, pyramid):
      global imgid
      im = cv2.imread(roi["image"])
      do_flip = False
      if not pyramid:
          target_size = 1200
          max_size = 1600
          # do_flip = True
          target_size = 1504
          max_size = 2000
          target_size = 1600
          max_size = 2150
          im_shape = im.shape
          im_size_min = np.min(im_shape[0:2])
          im_size_max = np.max(im_shape[0:2])
          im_scale = float(target_size) / float(im_size_min)
          # prevent bigger axis from being more than max_size:
          if np.round(im_scale * im_size_max) > max_size:
              im_scale = float(max_size) / float(im_size_max)
          scales = [im_scale]
      else:
          do_flip = True
          # TEST_SCALES = [500, 800, 1200, 1600]
          TEST_SCALES = [500, 800, 1100, 1400, 1700]
          target_size = 800
          max_size = 1200
          im_shape = im.shape
          im_size_min = np.min(im_shape[0:2])
          im_size_max = np.max(im_shape[0:2])
          im_scale = float(target_size) / float(im_size_min)
          # prevent bigger axis from being more than max_size:
          if np.round(im_scale * im_size_max) > max_size:
              im_scale = float(max_size) / float(im_size_max)
          scales = [
              float(scale) / target_size * im_scale
              for scale in TEST_SCALES
          ]
      boxes, landmarks = detector.detect(
          im, threshold=args.thresh, scales=scales, do_flip=do_flip
      )
      # print(boxes.shape, landmarks.shape)
      if imgid >= 0 and imgid < 100:
          font = cv2.FONT_HERSHEY_SIMPLEX
          for i in range(boxes.shape[0]):
              box = boxes[i]
              ibox = box[0:4].copy().astype(np.int)
              cv2.rectangle(
                  im,
                  (ibox[0], ibox[1]),
                  (ibox[2], ibox[3]),
                  (255, 0, 0),
                  2,
              )
              # print('box', ibox)
              # if len(ibox)>5:
              #  for l in range(5):
              #    pp = (ibox[5+l*2], ibox[6+l*2])
              #    cv2.circle(im, (pp[0], pp[1]), 1, (0, 0, 255), 1)
              blur = box[5]
              k = "%.3f" % blur
              cv2.putText(
                  im,
                  k,
                  (ibox[0] + 2, ibox[1] + 14),
                  font,
                  0.6,
                  (0, 255, 0),
                  2,
              )
              # landmarks = box[6:21].reshape( (5,3) )
              if landmarks is not None:
                  for l in range(5):
                      color = (0, 255, 0)
                      landmark = landmarks[i][l]
                      pp = (int(landmark[0]), int(landmark[1]))
                      if landmark[2] - 0.5 < 0.0:
                          color = (0, 0, 255)
                      cv2.circle(im, (pp[0], pp[1]), 1, color, 2)
          filename = "./testimages/%d.jpg" % imgid
          cv2.imwrite(filename, im)
          print(filename, "wrote")
          imgid += 1
  
      return boxes
  
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 2 for calling a global function with example usage: get_boxes(roi, pyramid) and returns: boxes