code: def draw_objs(
      image: Image,
      boxes: np.ndarray = None,
      classes: np.ndarray = None,
      scores: np.ndarray = None,
      masks: np.ndarray = None,
      category_index: dict = None,
      box_thresh: float = 0.1,
      mask_thresh: float = 0.5,
      line_thickness: int = 8,
      font: str = "arial.ttf",
      font_size: int = 24,
      draw_boxes_on_image: bool = True,
      draw_masks_on_image: bool = False,
  ):
      """
      将目标边界框信息，类别信息，mask信息绘制在图片上
      Args:
          image: 需要绘制的图片
          boxes: 目标边界框信息
          classes: 目标类别信息
          scores: 目标概率信息
          masks: 目标mask信息
          category_index: 类别与名称字典
          box_thresh: 过滤的概率阈值
          mask_thresh:
          line_thickness: 边界框宽度
          font: 字体类型
          font_size: 字体大小
          draw_boxes_on_image:
          draw_masks_on_image:
  
      Returns:
  
      """
  
      # 过滤掉低概率的目标
      idxs = np.greater(scores, box_thresh)
      boxes = boxes[idxs]
      classes = classes[idxs]
      scores = scores[idxs]
      if masks is not None:
          masks = masks[idxs]
      if len(boxes) == 0:
          return image
  
      colors = [
          ImageColor.getrgb(STANDARD_COLORS[cls % len(STANDARD_COLORS)])
          for cls in classes
      ]
  
      if draw_boxes_on_image:
          # Draw all boxes onto image.
          draw = ImageDraw.Draw(image)
          for box, cls, score, color in zip(
              boxes, classes, scores, colors
          ):
              left, top, right, bottom = box
              # 绘制目标边界框
              draw.line(
                  [
                      (left, top),
                      (left, bottom),
                      (right, bottom),
                      (right, top),
                      (left, top),
                  ],
                  width=line_thickness,
                  fill=color,
              )
              # 绘制类别和概率信息
              draw_text(
                  draw,
                  box.tolist(),
                  int(cls),
                  float(score),
                  category_index,
                  color,
                  font,
                  font_size,
              )
  
      if draw_masks_on_image and (masks is not None):
          # Draw all mask onto image.
          image = draw_masks(image, masks, colors, mask_thresh)
  
      return image
  
file_path: deep-learning-for-image-processing/pytorch_object_detection/faster_rcnn/draw_box_utils.py
imports: from PIL.Image import Image, fromarray
  import PIL.ImageDraw
  import PIL.ImageFont
  from PIL import ImageColor
  import numpy
label_desc: Use image node_id 3 for calling a global function with example usage: draw_objs(image, boxes, classes, scores, masks, category_index, box_thresh, mask_thresh, line_thickness, font, font_size, draw_boxes_on_image, draw_masks_on_image) and returns: image, image