code: def test_reader(paths=None, images=None):
      """
      data generator
  
      Args:
          paths (list[str]): paths to images.
          images (list(numpy.ndarray)): data of images, shape of each is [H, W, C]
  
      Yield:
          res (dict): key contains 'image', 'im_info', 'im_shape', the corresponding values is:
              image (numpy.ndarray): the image to be fed into network
              im_info (numpy.ndarray): the info about the preprocessed.
              im_shape (numpy.ndarray): the shape of image.
      """
      img_list = list()
      if paths:
          for img_path in paths:
              assert os.path.isfile(
                  img_path
              ), "The {} isn't a valid file path.".format(img_path)
              img = cv2.imread(img_path).astype("float32")
              img_list.append(img)
      if images is not None:
          for img in images:
              img_list.append(img)
  
      for im in img_list:
          im = cv2.cvtColor(im, cv2.COLOR_BGR2RGB)
          im = im.astype(np.float32, copy=False)
          mean = [0.485, 0.456, 0.406]
          std = [0.229, 0.224, 0.225]
          mean = np.array(mean)[np.newaxis, np.newaxis, :]
          std = np.array(std)[np.newaxis, np.newaxis, :]
          im = im / 255.0
          im -= mean
          im /= std
  
          target_size = 800
          max_size = 1333
  
          shape = im.shape
          # im_shape holds the original shape of image.
          im_shape = np.array([shape[0], shape[1], 1.0]).astype(
              "float32"
          )
          im_size_min = np.min(shape[0:2])
          im_size_max = np.max(shape[0:2])
          im_scale = float(target_size) / float(im_size_min)
          if np.round(im_scale * im_size_max) > max_size:
              im_scale = float(max_size) / float(im_size_max)
  
          resize_w = np.round(im_scale * float(shape[1]))
          resize_h = np.round(im_scale * float(shape[0]))
          # im_info holds the resize info of image.
          im_info = np.array([resize_h, resize_w, im_scale]).astype(
              "float32"
          )
  
          im = cv2.resize(
              im,
              None,
              None,
              fx=im_scale,
              fy=im_scale,
              interpolation=cv2.INTER_LINEAR,
          )
  
          # HWC --> CHW
          im = np.swapaxes(im, 1, 2)
          im = np.swapaxes(im, 1, 0)
          yield {"image": im, "im_info": im_info, "im_shape": im_shape}
  
file_path: PaddleHub/modules/image/object_detection/faster_rcnn_resnet50_fpn_venus/data_feed.py
imports: from __future__ import absolute_import
  from __future__ import print_function
  from __future__ import division
  import os
  from collections import OrderedDict
  import cv2
  import numpy
  from PIL import Image, ImageEnhance
  from paddle import fluid
label_desc: Use image node_id 1 for calling a global function with example usage: test_reader(paths, images) without return types