class_docstr: Implementation of `Per-Pixel Classification is
  NOT All You Need for Semantic Segmentation
  <https://arxiv.org/pdf/2107.06278>`_.
class_docstr_tok: ["Implementation","of","`","Per-Pixel","Classification","is","NOT","All","You","Need","for","Semantic","Segmentation","<","https",":","\/\/arxiv.org\/pdf\/2107.06278",">","`","_","."]
docstr: Predict results from a batch of inputs and data samples with post-
  processing.
  
  Args:
      batch_inputs (Tensor): Inputs with shape (N, C, 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): Whether to rescale the results.
          Defaults to True.
  
  Returns:
      list[:obj:`DetDataSample`]: Detection results of the
      input images. Each DetDataSample usually contain
      'pred_instances' and `pred_panoptic_seg`. And the
      ``pred_instances`` usually contains following keys.
  
          - scores (Tensor): Classification scores, has a shape
              (num_instance, )
          - labels (Tensor): Labels of bboxes, has a shape
              (num_instances, ).
          - bboxes (Tensor): Has a shape (num_instances, 4),
              the last dimension 4 arrange as (x1, y1, x2, y2).
          - masks (Tensor): Has a shape (num_instances, H, W).
  
      And the ``pred_panoptic_seg`` contains the following key
  
          - sem_seg (Tensor): panoptic segmentation mask, has a
              shape (1, h, w).
docstr_tok: ["Predict","results","from","a","batch","of","inputs","and","data","samples","with","post-","processing",".","Args",":","batch_inputs","(","Tensor",")",":","Inputs","with","shape","(","N",",","C",",","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",")",":","Whether","to","rescale","the","results",".","Defaults","to","True",".","Returns",":","list","[",":","obj",":","`","DetDataSample","`","]",":","Detection","results","of","the","input","images",".","Each","DetDataSample","usually","contain","'pred_instances","'","and","`","pred_panoptic_seg","`",".","And","the","``","pred_instances","``","usually","contains","following","keys",".","-","scores","(","Tensor",")",":","Classification","scores",",","has","a","shape","(","num_instance",",",")","-","labels","(","Tensor",")",":","Labels","of","bboxes",",","has","a","shape","(","num_instances",",",")",".","-","bboxes","(","Tensor",")",":","Has","a","shape","(","num_instances",",","4",")",",","the","last","dimension","4","arrange","as","(","x1",",","y1",",","x2",",","y2",")",".","-","masks","(","Tensor",")",":","Has","a","shape","(","num_instances",",","H",",","W",")",".","And","the","``","pred_panoptic_seg","``","contains","the","following","key","-","sem_seg","(","Tensor",")",":","panoptic","segmentation","mask",",","has","a","shape","(","1",",","h",",","w",")","."]
code: def predict(
      self,
      batch_inputs: Tensor,
      batch_data_samples: SampleList,
      rescale: bool = True,
  ) -> SampleList:
      """Predict results from a batch of inputs and data samples with post-
      processing.
  
      Args:
          batch_inputs (Tensor): Inputs with shape (N, C, 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): Whether to rescale the results.
              Defaults to True.
  
      Returns:
          list[:obj:`DetDataSample`]: Detection results of the
          input images. Each DetDataSample usually contain
          'pred_instances' and `pred_panoptic_seg`. And the
          ``pred_instances`` usually contains following keys.
  
              - scores (Tensor): Classification scores, has a shape
                  (num_instance, )
              - labels (Tensor): Labels of bboxes, has a shape
                  (num_instances, ).
              - bboxes (Tensor): Has a shape (num_instances, 4),
                  the last dimension 4 arrange as (x1, y1, x2, y2).
              - masks (Tensor): Has a shape (num_instances, H, W).
  
          And the ``pred_panoptic_seg`` contains the following key
  
              - sem_seg (Tensor): panoptic segmentation mask, has a
                  shape (1, h, w).
      """
      feats = self.extract_feat(batch_inputs)
      mask_cls_results, mask_pred_results = self.panoptic_head.predict(
          feats, batch_data_samples
      )
      results_list = self.panoptic_fusion_head.predict(
          mask_cls_results,
          mask_pred_results,
          batch_data_samples,
          rescale=rescale,
      )
      results = self.add_pred_to_datasample(
          batch_data_samples, results_list
      )
  
      return results
  
file_path: mmdetection/mmdet/models/detectors/maskformer.py
imports: from typing import Dict, List, Tuple
  from torch import Tensor
  from mmdet.registry import MODELS
  from mmdet.structures import SampleList
  from mmdet.utils import ConfigType, OptConfigType, OptMultiConfig
  from .single_stage import SingleStageDetector
label_desc: Use image node_id 3 for calling the MaskFormer obj's underlying member method code with example usage: obj.predict(batch_inputs, batch_data_samples, rescale) and returns: results