code: def detect(self, img, input_size=None, max_num=0, metric="default"):
      assert input_size is not None or self.input_size is not None
      input_size = self.input_size if input_size is None else input_size
  
      im_ratio = float(img.shape[0]) / img.shape[1]
      model_ratio = float(input_size[1]) / input_size[0]
      if im_ratio > model_ratio:
          new_height = input_size[1]
          new_width = int(new_height / im_ratio)
      else:
          new_width = input_size[0]
          new_height = int(new_width * im_ratio)
      det_scale = float(new_height) / img.shape[0]
      resized_img = cv2.resize(img, (new_width, new_height))
      det_img = np.zeros(
          (input_size[1], input_size[0], 3), dtype=np.uint8
      )
      det_img[:new_height, :new_width, :] = resized_img
  
      scores_list, bboxes_list, kpss_list = self.forward(
          det_img, self.det_thresh
      )
  
      scores = np.vstack(scores_list)
      scores_ravel = scores.ravel()
      order = scores_ravel.argsort()[::-1]
      bboxes = np.vstack(bboxes_list) / det_scale
      if self.use_kps:
          kpss = np.vstack(kpss_list) / det_scale
      pre_det = np.hstack((bboxes, scores)).astype(
          np.float32, copy=False
      )
      pre_det = pre_det[order, :]
      keep = self.nms(pre_det)
      det = pre_det[keep, :]
      if self.use_kps:
          kpss = kpss[order, :, :]
          kpss = kpss[keep, :, :]
      else:
          kpss = None
      if max_num > 0 and det.shape[0] > max_num:
          area = (det[:, 2] - det[:, 0]) * (det[:, 3] - det[:, 1])
          img_center = img.shape[0] // 2, img.shape[1] // 2
          offsets = np.vstack(
              [
                  (det[:, 0] + det[:, 2]) / 2 - img_center[1],
                  (det[:, 1] + det[:, 3]) / 2 - img_center[0],
              ]
          )
          offset_dist_squared = np.sum(np.power(offsets, 2.0), 0)
          if metric == "max":
              values = area
          else:
              values = (
                  area - offset_dist_squared * 2.0
              )  # some extra weight on the centering
          bindex = np.argsort(values)[
              ::-1
          ]  # some extra weight on the centering
          bindex = bindex[0:max_num]
          det = det[bindex, :]
          if kpss is not None:
              kpss = kpss[bindex, :]
      return det, kpss
  
file_path: insightface/python-package/insightface/model_zoo/retinaface.py
imports: from __future__ import division
  import datetime
  import numpy
  import onnx
  import onnxruntime
  import os
  import os.path
  import cv2
  import sys
label_desc: Use image node_id 5 for calling the RetinaFace obj's underlying member method code with example usage: obj.detect(img, input_size, max_num, metric) and returns: det,  kpss