code: def resize_norm_img(img, image_shape, padding=True):
      imgC, imgH, imgW = image_shape
      h = img.shape[0]
      w = img.shape[1]
      if not padding:
          resized_image = cv2.resize(
              img, (imgW, imgH), interpolation=cv2.INTER_LINEAR
          )
          resized_w = imgW
      else:
          ratio = w / float(h)
          if math.ceil(imgH * ratio) > imgW:
              resized_w = imgW
          else:
              resized_w = int(math.ceil(imgH * ratio))
          resized_image = cv2.resize(img, (resized_w, imgH))
      resized_image = resized_image.astype("float32")
      if image_shape[0] == 1:
          resized_image = resized_image / 255
          resized_image = resized_image[np.newaxis, :]
      else:
          resized_image = resized_image.transpose((2, 0, 1)) / 255
      resized_image -= 0.5
      resized_image /= 0.5
      padding_im = np.zeros((imgC, imgH, imgW), dtype=np.float32)
      padding_im[:, :, 0:resized_w] = resized_image
      return padding_im
  
file_path: PaddleOCR/deploy/avh/convert_image.py
imports: import os
  import pathlib
  import re
  import sys
  import cv2
  import math
  from PIL import Image
  import numpy
label_desc: Use image node_id 1 for calling a global function with example usage: resize_norm_img(img, image_shape, padding) and returns: padding_im