code: def visualize_box_mask(
      im, results, labels=None, mask_resolution=14, threshold=0.5
  ):
      """
      Args:
          im (str/np.ndarray): path of image/np.ndarray read by cv2
          results (dict): include 'boxes': np.ndarray: shape:[N,6], N: number of box,
                          matix element:[class, score, x_min, y_min, x_max, y_max]
                          MaskRCNN's results include 'masks': np.ndarray:
                          shape:[N, class_num, mask_resolution, mask_resolution]
          labels (list): labels:['class1', ..., 'classn']
          mask_resolution (int): shape of a mask is:[mask_resolution, mask_resolution]
          threshold (float): Threshold of score.
      Returns:
          im (PIL.Image.Image): visualized image
      """
      if not labels:
          labels = [
              "background",
              "person",
              "bicycle",
              "car",
              "motorcycle",
              "airplane",
              "bus",
              "train",
              "truck",
              "boat",
              "traffic light",
              "fire",
              "hydrant",
              "stop sign",
              "parking meter",
              "bench",
              "bird",
              "cat",
              "dog",
              "horse",
              "sheep",
              "cow",
              "elephant",
              "bear",
              "zebra",
              "giraffe",
              "backpack",
              "umbrella",
              "handbag",
              "tie",
              "suitcase",
              "frisbee",
              "skis",
              "snowboard",
              "sports ball",
              "kite",
              "baseball bat",
              "baseball glove",
              "skateboard",
              "surfboard",
              "tennis racket",
              "bottle",
              "wine glass",
              "cup",
              "fork",
              "knife",
              "spoon",
              "bowl",
              "banana",
              "apple",
              "sandwich",
              "orange",
              "broccoli",
              "carrot",
              "hot dog",
              "pizza",
              "donut",
              "cake",
              "chair",
              "couch",
              "potted plant",
              "bed",
              "dining table",
              "toilet",
              "tv",
              "laptop",
              "mouse",
              "remote",
              "keyboard",
              "cell phone",
              "microwave",
              "oven",
              "toaster",
              "sink",
              "refrigerator",
              "book",
              "clock",
              "vase",
              "scissors",
              "teddy bear",
              "hair drier",
              "toothbrush",
          ]
      if isinstance(im, str):
          im = Image.open(im).convert("RGB")
      else:
          im = cv2.cvtColor(im, cv2.COLOR_BGR2RGB)
          im = Image.fromarray(im)
      if "masks" in results and "boxes" in results:
          im = draw_mask(
              im,
              results["boxes"],
              results["masks"],
              labels,
              resolution=mask_resolution,
          )
      if "boxes" in results:
          im = draw_box(im, results["boxes"], labels)
      if "segm" in results:
          im = draw_segm(
              im,
              results["segm"],
              results["label"],
              results["score"],
              labels,
              threshold=threshold,
          )
      return im
  
file_path: PaddleHub/modules/image/instance_segmentation/solov2/data_feed.py
imports: import base64
  import cv2
  import numpy
  from paddle.inference import Config
  from paddle.inference import create_predictor
  from paddle.inference import PrecisionType
  from PIL import Image
  from PIL import ImageDraw
label_desc: Use image node_id 2 for calling a global function with example usage: visualize_box_mask(im, results, labels, mask_resolution, threshold) and returns: im