code: def preprocess_input(image, net_h, net_w):
      new_h, new_w, _ = image.shape
  
      # determine the new size of the image
      if (float(net_w) / new_w) < (float(net_h) / new_h):
          new_h = (new_h * net_w) // new_w
          new_w = net_w
      else:
          new_w = (new_w * net_h) // new_h
          new_h = net_h
  
      # resize the image to the new size
      resized = cv2.resize(
          cv2.cvtColor(image, cv2.COLOR_BGR2RGB) / 255.0, (new_w, new_h)
      )
  
      # embed the image into the standard letter box
      new_image = np.ones((net_h, net_w, 3)) * 0.5
      new_image[
          (net_h - new_h) // 2 : (net_h + new_h) // 2,
          (net_w - new_w) // 2 : (net_w + new_w) // 2,
          :,
      ] = resized
      new_image = np.expand_dims(new_image, 0)
  
      return new_image
  
file_path: ImageAI/imageai_tf_deprecated/Detection/Custom/utils/utils.py
imports: import cv2
  import numpy
  import os
  from .bbox import BoundBox, bbox_iou
  from scipy.special import expit
label_desc: Use image node_id 7 for calling a global function with example usage: preprocess_input(image, net_h, net_w) and returns: new_image