code: def getPolygonFromMask(mask):
      m_shape = mask.shape
      polygon = []
      umm = np.unique(mask)
      if len(umm) == 2 and max(umm) == 255:
          mask = np.clip(mask, 0, 1)
      for i_clas in umm:
          if i_clas == 0:
              continue
          tmp_mask = (mask == i_clas).astype("uint8") * 255
          polygon.append(
              {
                  "label": i_clas,
                  "points": get_polygon(tmp_mask, img_size=m_shape),
              }
          )
      return polygon
  
file_path: PaddleSeg/EISeg/eiseg/util/masktococo.py
imports: import os
  import os.path
  from PIL import Image
  import json
  import numpy
  from eiseg.util import get_polygon, COCO, colorMap
  from eiseg.util.jsencoder import JSEncoder
label_desc: Use image node_id 1 for calling a global function with example usage: getPolygonFromMask(mask) and returns: polygon