class_docstr: MaskFormer fusion head which postprocesses results for panoptic
  segmentation, instance segmentation and semantic segmentation.
class_docstr_tok: ["MaskFormer","fusion","head","which","postprocesses","results","for","panoptic","segmentation",",","instance","segmentation","and","semantic","segmentation","."]
docstr: Test segment without test-time aumengtation.
  
  Only the output of last decoder layers was used.
  
  Args:
      mask_cls_results (Tensor): Mask classification logits,
          shape (batch_size, num_queries, cls_out_channels).
          Note `cls_out_channels` should includes background.
      mask_pred_results (Tensor): Mask logits, shape
          (batch_size, num_queries, h, w).
      batch_data_samples (List[:obj:`DetDataSample`]): The Data
          Samples. It usually includes information such as
          `gt_instance`, `gt_panoptic_seg` and `gt_sem_seg`.
      rescale (bool): If True, return boxes in
          original image space. Default False.
  
  Returns:
      list[dict]: Instance segmentation                 results and panoptic segmentation results for each                 image.
  
      .. code-block:: none
  
          [
              {
                  'pan_results': PixelData,
                  'ins_results': InstanceData,
                  # semantic segmentation results are not supported yet
                  'sem_results': PixelData
              },
              ...
          ]
docstr_tok: ["Test","segment","without","test-time","aumengtation",".","Only","the","output","of","last","decoder","layers","was","used",".","Args",":","mask_cls_results","(","Tensor",")",":","Mask","classification","logits",",","shape","(","batch_size",",","num_queries",",","cls_out_channels",")",".","Note","`","cls_out_channels","`","should","includes","background",".","mask_pred_results","(","Tensor",")",":","Mask","logits",",","shape","(","batch_size",",","num_queries",",","h",",","w",")",".","batch_data_samples","(","List","[",":","obj",":","`","DetDataSample","`","]",")",":","The","Data","Samples",".","It","usually","includes","information","such","as","`","gt_instance","`",",","`","gt_panoptic_seg","`","and","`","gt_sem_seg","`",".","rescale","(","bool",")",":","If","True",",","return","boxes","in","original","image","space",".","Default","False",".","Returns",":","list","[","dict","]",":","Instance","segmentation","results","and","panoptic","segmentation","results","for","each","image",".","..","code-block",":",":","none","[","{","'pan_results","'",":","PixelData",",","'ins_results","'",":","InstanceData",",","#","semantic","segmentation","results","are","not","supported","yet","'sem_results","'",":","PixelData","}",",","...","]"]
code: def predict(
      self,
      mask_cls_results: Tensor,
      mask_pred_results: Tensor,
      batch_data_samples: SampleList,
      rescale: bool = False,
      **kwargs,
  ) -> List[dict]:
      """Test segment without test-time aumengtation.
  
          Only the output of last decoder layers was used.
  
          Args:
              mask_cls_results (Tensor): Mask classification logits,
                  shape (batch_size, num_queries, cls_out_channels).
                  Note `cls_out_channels` should includes background.
              mask_pred_results (Tensor): Mask logits, shape
                  (batch_size, num_queries, h, w).
              batch_data_samples (List[:obj:`DetDataSample`]): The Data
                  Samples. It usually includes information such as
                  `gt_instance`, `gt_panoptic_seg` and `gt_sem_seg`.
              rescale (bool): If True, return boxes in
                  original image space. Default False.
  
          Returns:
              list[dict]: Instance segmentation \
                  results and panoptic segmentation results for each \
                  image.
  
              .. code-block:: none
  
                  [
                      {
                          'pan_results': PixelData,
                          'ins_results': InstanceData,
                          # semantic segmentation results are not supported yet
                          'sem_results': PixelData
                      },
                      ...
                  ]
          """
      batch_img_metas = [
          data_sample.metainfo for data_sample in batch_data_samples
      ]
      panoptic_on = self.test_cfg.get("panoptic_on", True)
      semantic_on = self.test_cfg.get("semantic_on", False)
      instance_on = self.test_cfg.get("instance_on", False)
      assert not semantic_on, (
          "segmantic segmentation " "results are not supported yet."
      )
  
      results = []
      for mask_cls_result, mask_pred_result, meta in zip(
          mask_cls_results, mask_pred_results, batch_img_metas
      ):
          # remove padding
          img_height, img_width = meta["img_shape"][:2]
          mask_pred_result = mask_pred_result[
              :, :img_height, :img_width
          ]
  
          if rescale:
              # return result in original resolution
              ori_height, ori_width = meta["ori_shape"][:2]
              mask_pred_result = F.interpolate(
                  mask_pred_result[:, None],
                  size=(ori_height, ori_width),
                  mode="bilinear",
                  align_corners=False,
              )[:, 0]
  
          result = dict()
          if panoptic_on:
              pan_results = self.panoptic_postprocess(
                  mask_cls_result, mask_pred_result
              )
              result["pan_results"] = pan_results
  
          if instance_on:
              ins_results = self.instance_postprocess(
                  mask_cls_result, mask_pred_result
              )
              result["ins_results"] = ins_results
  
          if semantic_on:
              sem_results = self.semantic_postprocess(
                  mask_cls_result, mask_pred_result
              )
              result["sem_results"] = sem_results
  
          results.append(result)
  
      return results
  
file_path: mmdetection/mmdet/models/seg_heads/panoptic_fusion_heads/maskformer_fusion_head.py
imports: from typing import List
  import torch
  import torch.nn.functional
  from mmengine.structures import InstanceData, PixelData
  from torch import Tensor
  from mmdet.evaluation.functional import INSTANCE_OFFSET
  from mmdet.registry import MODELS
  from mmdet.structures import SampleList
  from mmdet.structures.mask import mask2bbox
  from mmdet.utils import OptConfigType, OptMultiConfig
  from .base_panoptic_fusion_head import BasePanopticFusionHead
label_desc: Use image node_id 6 for calling the MaskFormerFusionHead obj's underlying member method code with example usage: obj.predict(mask_cls_results, mask_pred_results, batch_data_samples, rescale) and returns: results