class_docstr: Image segmentation pipeline using any `AutoModelForXXXSegmentation`. This pipeline predicts masks of objects and
  their classes.
  
  This image segmentation pipeline can currently be loaded from [`pipeline`] using the following task identifier:
  `"image-segmentation"`.
  
  See the list of available models on
  [huggingface.co/models](https://huggingface.co/models?filter=image-segmentation).
code: def postprocess(
      self,
      model_outputs,
      subtask=None,
      threshold=0.9,
      mask_threshold=0.5,
      overlap_mask_area_threshold=0.5,
  ):
      fn = None
      if subtask in {"panoptic", None} and hasattr(
          self.feature_extractor, "post_process_panoptic_segmentation"
      ):
          fn = self.feature_extractor.post_process_panoptic_segmentation
      elif subtask in {"instance", None} and hasattr(
          self.feature_extractor, "post_process_instance_segmentation"
      ):
          fn = self.feature_extractor.post_process_instance_segmentation
  
      if fn is not None:
          outputs = fn(
              model_outputs,
              threshold=threshold,
              mask_threshold=mask_threshold,
              overlap_mask_area_threshold=overlap_mask_area_threshold,
              target_sizes=model_outputs["target_size"],
          )[0]
  
          annotation = []
          segmentation = outputs["segmentation"]
  
          for segment in outputs["segments_info"]:
              mask = (segmentation == segment["id"]) * 255
              mask = Image.fromarray(
                  mask.numpy().astype(np.uint8), mode="L"
              )
              label = self.model.config.id2label[segment["label_id"]]
              score = segment["score"]
              annotation.append(
                  {"score": score, "label": label, "mask": mask}
              )
  
      elif subtask in {"semantic", None} and hasattr(
          self.feature_extractor, "post_process_semantic_segmentation"
      ):
          outputs = (
              self.feature_extractor.post_process_semantic_segmentation(
                  model_outputs,
                  target_sizes=model_outputs["target_size"],
              )[0]
          )
  
          annotation = []
          segmentation = outputs.numpy()
          labels = np.unique(segmentation)
  
          for label in labels:
              mask = (segmentation == label) * 255
              mask = Image.fromarray(mask.astype(np.uint8), mode="L")
              label = self.model.config.id2label[label]
              annotation.append(
                  {"score": None, "label": label, "mask": mask}
              )
      else:
          raise ValueError(
              f"Subtask {subtask} is not supported for model {type(self.model)}"
          )
      return annotation
  
file_path: H2O/h2o_flexgen/benchmark/third_party/transformers/src/transformers/pipelines/image_segmentation.py
imports: from typing import Any, Dict, List, Union
  import numpy
  from ..utils import add_end_docstrings, is_torch_available, is_vision_available, logging, requires_backends
  from .base import PIPELINE_INIT_ARGS, Pipeline
label_desc: Use image node_id 6 for calling the ImageSegmentationPipeline obj's underlying member method code with example usage: obj.postprocess(model_outputs, subtask, threshold, mask_threshold, overlap_mask_area_threshold) and returns: annotation