code: def preprocess(self):
      input_datas = []
  
      # 数据预处理
      for i, img in enumerate(self.datas):
          # 格式转换
          img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
  
          # 缩放图片
          h, w = img.shape[:2]
          if max(h, w) > self.max_size:
              img = (
                  cv2.resize(
                      img, (self.max_size, int(h / w * self.max_size))
                  )
                  if h < w
                  else cv2.resize(
                      img, (int(w / h * self.max_size), self.max_size)
                  )
              )
          elif min(h, w) < self.min_size:
              img = (
                  cv2.resize(
                      img, (self.min_size, int(h / w * self.min_size))
                  )
                  if h > w
                  else cv2.resize(
                      img, (int(w / h * self.min_size), self.min_size)
                  )
              )
  
          # 裁剪图片
          h, w = img.shape[:2]
          img = img[: h - (h % 32), : w - (w % 32), :]
  
          # 归一化
          img = img / 127.5 - 1.0
  
          # 新建维度
          img = np.expand_dims(img, axis=0).astype("float32")
  
          # 加入输入数据列表
          input_datas.append(img)
  
      # 数据按batch_size切分
      input_datas = np.concatenate(input_datas, 0)
      split_num = (
          len(self.datas) // self.batch_size + 1
          if len(self.datas) % self.batch_size != 0
          else len(self.datas) // self.batch_size
      )
      input_datas = np.array_split(input_datas, split_num)
  
      # 返回预处理完成的数据
      return input_datas
  
file_path: PaddleHub/modules/image/Image_gan/style_transfer/animegan_v2_paprika_97/processor.py
imports: import base64
  import os
  import time
  import cv2
  import numpy
label_desc: Use image node_id 3 for calling the Processor obj's underlying member method code with example usage: obj.preprocess() and returns: input_datas