code: def get_affine_transform(
      center,
      scale,
      rot,
      output_size,
      shift=np.array([0, 0], dtype=np.float32),
      inv=0,
  ):
      if not isinstance(scale, np.ndarray) and not isinstance(
          scale, list
      ):
          print(scale)
          scale = np.array([scale, scale])
  
      scale_tmp = scale
  
      src_w = scale_tmp[0]
      dst_w = output_size[1]
      dst_h = output_size[0]
  
      rot_rad = np.pi * rot / 180
      src_dir = get_dir([0, src_w * -0.5], rot_rad)
      dst_dir = np.array([0, dst_w * -0.5], np.float32)
  
      src = np.zeros((3, 2), dtype=np.float32)
      dst = np.zeros((3, 2), dtype=np.float32)
      src[0, :] = center + scale_tmp * shift
      src[1, :] = center + src_dir + scale_tmp * shift
      dst[0, :] = [dst_w * 0.5, dst_h * 0.5]
      dst[1, :] = np.array([dst_w * 0.5, dst_h * 0.5]) + dst_dir
  
      src[2:, :] = get_3rd_point(src[0, :], src[1, :])
      dst[2:, :] = get_3rd_point(dst[0, :], dst[1, :])
  
      if inv:
          trans = cv2.getAffineTransform(
              np.float32(dst), np.float32(src)
          )
      else:
          trans = cv2.getAffineTransform(
              np.float32(src), np.float32(dst)
          )
  
      return trans
  
file_path: insightface/parsing/dml_csr/utils/transforms.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import numpy
  import cv2
label_desc: Use image node_id 3 for calling a global function with example usage: get_affine_transform(center, scale, rot, output_size, shift, inv) and returns: trans