code: def reader(
      face_detector,
      shrink,
      confs_threshold,
      images,
      paths,
      use_gpu,
      use_multi_scale,
  ):
      """
      Preprocess to yield image.
  
      Args:
          face_detector (class): class to detect faces.
          shrink (float): parameter to control the resize scale in face_detector.
          confs_threshold (float): confidence threshold of face_detector.
          images (list(numpy.ndarray)): images data, shape of each is [H, W, C], color space is BGR.
          paths (list[str]): paths to images.
          use_gpu (bool): whether to use gpu in face_detector.
          use_multi_scale (bool): whether to enable multi-scale face detection.
      Yield:
          element (collections.OrderedDict): info of original image, preprocessed image, contains 3 keys:
              org_im (numpy.ndarray) : original image.
              org_im_path (str): path to original image.
              preprocessed (list[OrderedDict]):each element contains 2 keys:
                 face  (dict): face detected in the original image.
                 image (numpy.ndarray): data to be fed into neural network.
      """
      component = list()
      if paths is not None:
          assert type(paths) is list, "paths should be a list."
          for im_path in paths:
              each = OrderedDict()
              assert os.path.isfile(
                  im_path
              ), "The {} isn't a valid file path.".format(im_path)
              im = cv2.imread(im_path)
              each["org_im"] = im
              each["org_im_path"] = im_path
              component.append(each)
      if images is not None:
          assert type(images) is list, "images should be a list."
          for im in images:
              each = OrderedDict()
              each["org_im"] = im
              each["org_im_path"] = "ndarray_time={}".format(
                  round(time.time(), 6) * 1e6
              )
              component.append(each)
  
      for element in component:
          if use_multi_scale:
              scale_res = list()
              detect_faces = list()
              for scale in multi_scales:
                  _detect_res = face_detector.face_detection(
                      images=[element["org_im"]],
                      use_gpu=use_gpu,
                      visualization=False,
                      shrink=scale,
                      confs_threshold=confs_threshold,
                  )
  
                  _s = list()
                  for _face in _detect_res[0]["data"]:
                      _face_list = [
                          _face["left"],
                          _face["top"],
                          _face["right"],
                          _face["bottom"],
                          _face["confidence"],
                      ]
                      _s.append(_face_list)
  
                  if _s:
                      scale_res.append(np.array(_s))
  
              scale_res = np.row_stack(scale_res)
              scale_res = bbox_vote(scale_res)
              keep_index = np.where(scale_res[:, 4] >= confs_threshold)[
                  0
              ]
              scale_res = scale_res[keep_index, :]
              for data in scale_res:
                  face = {
                      "left": data[0],
                      "top": data[1],
                      "right": data[2],
                      "bottom": data[3],
                      "confidence": data[4],
                  }
                  detect_faces.append(face)
          else:
              _detect_res = face_detector.face_detection(
                  images=[element["org_im"]],
                  use_gpu=use_gpu,
                  visualization=False,
                  shrink=shrink,
                  confs_threshold=confs_threshold,
              )
              detect_faces = _detect_res[0]["data"]
  
          element["preprocessed"] = list()
          for face in detect_faces:
              handled = OrderedDict()
              handled["face"] = face
              handled["image"] = process_image(element["org_im"], face)
              element["preprocessed"].append(handled)
  
          yield element
  
file_path: PaddleHub/modules/image/face_detection/pyramidbox_lite_mobile_mask/data_feed.py
imports: import math
  import os
  import time
  from collections import OrderedDict
  import cv2
  import numpy
label_desc: Use image node_id 5 for calling a global function with example usage: reader(face_detector, shrink, confs_threshold, images, paths, use_gpu, use_multi_scale) without return types