code: def postprocess(self, pred, img_data):
      result = []
      class_list = np.unique(pred)
      for cls_id in class_list:
          if cls_id == 0:
              continue  # skip background
          class_map = np.equal(pred, cls_id).astype(np.uint8)
          y_indices, x_indices = np.nonzero(class_map)
          y_min = int(y_indices.min())
          y_max = int(y_indices.max())
          x_min = int(x_indices.min())
          x_max = int(x_indices.max())
  
          contours, _ = cv2.findContours(
              class_map, cv2.RETR_LIST, cv2.CHAIN_APPROX_SIMPLE
          )
          polygon = []
          for j in range(len(contours)):
              if len(contours[j]) <= 4:
                  continue
              polygon.append(contours[j].flatten().tolist())
  
          result.append(
              {
                  "image_path": img_data,
                  "category_id": int(cls_id),
                  "bbox": [x_min, y_min, x_max - x_min, y_max - y_min],
                  #'mask': class_map,
                  "polygon": polygon,
                  "area": int(np.sum(class_map > 0)),
                  "isNG": 1,
              }
          )
  
      return result
  
file_path: PaddleSeg/contrib/QualityInspector/qinspector/seg/engine/predictor.py
imports: import numpy
  import cv2
  import paddle
  from paddleseg import utils
  from paddleseg.core import infer
  from paddleseg.core.predict import partition_list
  from paddleseg.transforms import Compose
  from paddleseg.utils import progbar
  from qinspector.utils.logger import setup_logger
label_desc: Use image node_id 2 for calling the SegPredictor obj's underlying member method code with example usage: obj.postprocess(pred, img_data) and returns: result