code: def postprocess(
      confidences,
      boxes,
      orig_im,
      orig_im_shape,
      orig_im_path,
      output_dir,
      visualization,
      confs_threshold=0.5,
      iou_threshold=0.5,
  ):
      """
      Postprocess output of network. one image at a time.
  
      Args:
          confidences (numpy.ndarray): confidences, with shape [num, 2]
          boxes (numpy.ndaray): boxes coordinate,  with shape [num, 4]
          orig_im (numpy.ndarray): original image.
          orig_im_shape (list): shape pf original image.
          orig_im_path (list): path of riginal image.
          output_dir (str): output directory to store image.
          visualization (bool): whether to save image or not.
      """
      output = {}
      output["data"] = []
      if orig_im_path:
          output["path"] = orig_im_path
      picked_box_probs = []
      picked_labels = []
      for class_index in range(1, confidences.shape[1]):
          probs = confidences[:, class_index]
          mask = probs > confs_threshold
          probs = probs[mask]
          if probs.shape[0] == 0:
              continue
          subset_boxes = boxes[mask, :]
          box_probs = np.concatenate(
              [subset_boxes, probs.reshape(-1, 1)], axis=1
          )
          box_probs = hard_nms(
              box_probs, iou_threshold=iou_threshold, top_k=-1
          )
          picked_box_probs.append(box_probs)
          picked_labels.extend([class_index] * box_probs.shape[0])
  
      if not picked_box_probs:
          return output
  
      picked_box_probs = np.concatenate(picked_box_probs)
      picked_box_probs[:, 0] *= orig_im_shape[1]
      picked_box_probs[:, 1] *= orig_im_shape[0]
      picked_box_probs[:, 2] *= orig_im_shape[1]
      picked_box_probs[:, 3] *= orig_im_shape[0]
  
      for data in picked_box_probs:
          output["data"].append(
              {
                  "left": float(data[0]),
                  "right": float(data[2]),
                  "top": float(data[1]),
                  "bottom": float(data[3]),
                  "confidence": float(data[4]),
              }
          )
  
      picked_box_probs = picked_box_probs[:, :4].astype(np.int32)
      if visualization:
          for i in range(picked_box_probs.shape[0]):
              box = picked_box_probs[i]
              cv2.rectangle(
                  orig_im,
                  (box[0], box[1]),
                  (box[2], box[3]),
                  (255, 255, 0),
                  2,
              )
          check_dir(output_dir)
          ext = os.path.splitext(orig_im_path) if orig_im_path else ""
          ext = ext if ext else get_image_ext(orig_im)
          orig_im_path = (
              orig_im_path
              if orig_im_path
              else "ndarray_{}{}".format(time.time(), ext)
          )
          im_name = os.path.basename(orig_im_path)
          im_save_path = os.path.join(output_dir, im_name)
          output["save_path"] = im_save_path
          cv2.imwrite(im_save_path, orig_im)
      return output
  
file_path: PaddleHub/modules/image/face_detection/ultra_light_fast_generic_face_detector_1mb_640/processor.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import os
  import time
  import base64
  import cv2
  import numpy
label_desc: Use image node_id 7 for calling a global function with example usage: postprocess(confidences, boxes, orig_im, orig_im_shape, orig_im_path, output_dir, visualization, confs_threshold, iou_threshold) and returns: output, output