code: def resize_image(self, srcimg, keep_ratio=False):
      top, left, newh, neww = (
          0,
          0,
          self.input_shape[0],
          self.input_shape[1],
      )
      origin_shape = srcimg.shape[:2]
      im_scale_y = newh / float(origin_shape[0])
      im_scale_x = neww / float(origin_shape[1])
      img_shape = np.array(
          [[float(self.input_shape[0]), float(self.input_shape[1])]]
      ).astype("float32")
      scale_factor = np.array([[im_scale_y, im_scale_x]]).astype(
          "float32"
      )
  
      if keep_ratio and srcimg.shape[0] != srcimg.shape[1]:
          hw_scale = srcimg.shape[0] / srcimg.shape[1]
          if hw_scale > 1:
              newh, neww = self.input_shape[0], int(
                  self.input_shape[1] / hw_scale
              )
              img = cv2.resize(
                  srcimg, (neww, newh), interpolation=cv2.INTER_AREA
              )
              left = int((self.input_shape[1] - neww) * 0.5)
              img = cv2.copyMakeBorder(
                  img,
                  0,
                  0,
                  left,
                  self.input_shape[1] - neww - left,
                  cv2.BORDER_CONSTANT,
                  value=0,
              )  # add border
          else:
              newh, neww = (
                  int(self.input_shape[0] * hw_scale),
                  self.input_shape[1],
              )
              img = cv2.resize(
                  srcimg, (neww, newh), interpolation=cv2.INTER_AREA
              )
              top = int((self.input_shape[0] - newh) * 0.5)
              img = cv2.copyMakeBorder(
                  img,
                  top,
                  self.input_shape[0] - newh - top,
                  0,
                  0,
                  cv2.BORDER_CONSTANT,
                  value=0,
              )
      else:
          img = cv2.resize(
              srcimg, self.input_shape, interpolation=cv2.INTER_LINEAR
          )
  
      return img, img_shape, scale_factor
  
file_path: PaddleDetection/deploy/third_engine/demo_onnxruntime/infer_demo.py
imports: import cv2
  import numpy
  import argparse
  import onnxruntime
  from pathlib import Path
  from tqdm import tqdm
label_desc: Use image node_id 3 for calling the PicoDet obj's underlying member method code with example usage: obj.resize_image(srcimg, keep_ratio) and returns: img,  img_shape,  scale_factor