code: def get_norm_crop(image_path):
      im = cv2.imread(image_path)
      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)
      bbox, landmark = detector.detect(
          im, threshold=0.5, scales=[im_scale]
      )
      # print(im.shape, bbox.shape, landmark.shape)
      if bbox.shape[0] == 0:
          bbox, landmark = detector.detect(
              im,
              threshold=0.05,
              scales=[im_scale * 0.75, im_scale, im_scale * 2.0],
          )
          print("refine", im.shape, bbox.shape, landmark.shape)
      nrof_faces = bbox.shape[0]
      if nrof_faces > 0:
          det = bbox[:, 0:4]
          img_size = np.asarray(im.shape)[0:2]
          bindex = 0
          if nrof_faces > 1:
              bounding_box_size = (det[:, 2] - det[:, 0]) * (
                  det[:, 3] - det[:, 1]
              )
              img_center = img_size / 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)
              bindex = np.argmax(
                  bounding_box_size - offset_dist_squared * 2.0
              )  # some extra weight on the centering
          # _bbox = bounding_boxes[bindex, 0:4]
          _landmark = landmark[bindex]
          warped = face_align.norm_crop(
              im,
              landmark=_landmark,
              image_size=args.image_size,
              mode=args.align_mode,
          )
          return warped
      else:
          return None
  
file_path: insightface/recognition/subcenter_arcface/common/build_eval_pack.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import argparse
  import cv2
  import pickle
  import numpy
  import sys
  import os
  import face_align
  from retinaface import RetinaFace
label_desc: Use image node_id 3 for calling a global function with example usage: get_norm_crop(image_path) and returns: warped, None