code: def draw_press_box_lanes(im, np_boxes, labels, threshold=0.5):
      """
      Args:
          im (PIL.Image.Image): PIL image
          np_boxes (np.ndarray): shape:[N,6], N: number of box,
                                 matix element:[class, score, x_min, y_min, x_max, y_max]
          labels (list): labels:['class1', ..., 'classn']
          threshold (float): threshold of box
      Returns:
          im (PIL.Image.Image): visualized image
      """
  
      if isinstance(im, str):
          im = Image.open(im).convert("RGB")
      elif isinstance(im, np.ndarray):
          im = Image.fromarray(im)
  
      draw_thickness = min(im.size) // 320
      draw = ImageDraw.Draw(im)
      clsid2color = {}
      color_list = get_color_map_list(len(labels))
  
      if np_boxes.shape[1] == 7:
          np_boxes = np_boxes[:, 1:]
  
      expect_boxes = (np_boxes[:, 1] > threshold) & (
          np_boxes[:, 0] > -1
      )
      np_boxes = np_boxes[expect_boxes, :]
  
      for dt in np_boxes:
          clsid, bbox, score = int(dt[0]), dt[2:], dt[1]
          if clsid not in clsid2color:
              clsid2color[clsid] = color_list[clsid]
          color = tuple(clsid2color[clsid])
  
          if len(bbox) == 4:
              xmin, ymin, xmax, ymax = bbox
              # draw bbox
              draw.line(
                  [
                      (xmin, ymin),
                      (xmin, ymax),
                      (xmax, ymax),
                      (xmax, ymin),
                      (xmin, ymin),
                  ],
                  width=draw_thickness,
                  fill=(0, 0, 255),
              )
          elif len(bbox) == 8:
              x1, y1, x2, y2, x3, y3, x4, y4 = bbox
              draw.line(
                  [(x1, y1), (x2, y2), (x3, y3), (x4, y4), (x1, y1)],
                  width=2,
                  fill=color,
              )
              xmin = min(x1, x2, x3, x4)
              ymin = min(y1, y2, y3, y4)
  
          # draw label
          text = "{}".format(labels[clsid])
          tw, th = imagedraw_textsize_c(draw, text)
          draw.rectangle(
              [(xmin + 1, ymax - th), (xmin + tw + 1, ymax)], fill=color
          )
          draw.text((xmin + 1, ymax - th), text, fill=(0, 0, 255))
      return im
  
imports: from __future__ import division
  import os
  import cv2
  import math
  import numpy
  import PIL
  from PIL import Image, ImageDraw, ImageFile
label_desc: Use image node_id 12 for calling a global function with example usage: draw_press_box_lanes(im, np_boxes, labels, threshold) and returns: im