code: def shape2mask(img_size, points):
      label_mask = PIL.Image.fromarray(
          np.zeros(img_size[:2], dtype=np.uint8)
      )
      image_draw = PIL.ImageDraw.Draw(label_mask)
      points_list = [tuple(point) for point in points]
      assert (
          len(points_list) > 2
      ), "Polygon must have points more than 2"
      image_draw.polygon(xy=points_list, outline=1, fill=1)
      return np.array(label_mask, dtype=bool)
  
file_path: PaddleSeg/tools/data/labelme2seg.py
imports: from __future__ import print_function
  import argparse
  import glob
  import math
  import json
  import os
  import os.path
  import shutil
  import numpy
  import PIL.Image
  import PIL.ImageDraw
  import cv2
label_desc: Use image node_id 3 for calling a global function with example usage: shape2mask(img_size, points) and returns: np