class_docstr: Base class of Two-stage Panoptic Segmentor.
  
  As well as the components in TwoStageDetector, Panoptic Segmentor has extra
  semantic_head and panoptic_fusion_head.
class_docstr_tok: ["Base","class","of","Two-stage","Panoptic","Segmentor",".","As","well","as","the","components","in","TwoStageDetector",",","Panoptic","Segmentor","has","extra","semantic_head","and","panoptic_fusion_head","."]
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`]: Return the packed panoptic segmentation
          results of input images. Each DetDataSample usually contains
          'pred_panoptic_seg'. And the 'pred_panoptic_seg' has a key
          ``sem_seg``, which is a tensor of 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","`","]",":","Return","the","packed","panoptic","segmentation","results","of","input","images",".","Each","DetDataSample","usually","contains","'pred_panoptic_seg","'",".","And","the","'pred_panoptic_seg","'","has","a","key","``","sem_seg","``",",","which","is","a","tensor","of","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`]: Return the packed panoptic segmentation
              results of input images. Each DetDataSample usually contains
              'pred_panoptic_seg'. And the 'pred_panoptic_seg' has a key
              ``sem_seg``, which is a tensor of shape (1, h, w).
      """
      batch_img_metas = [
          data_samples.metainfo for data_samples in batch_data_samples
      ]
  
      x = self.extract_feat(batch_inputs)
  
      # If there are no pre-defined proposals, use RPN to get proposals
      if batch_data_samples[0].get("proposals", None) is None:
          rpn_results_list = self.rpn_head.predict(
              x, batch_data_samples, rescale=False
          )
      else:
          rpn_results_list = [
              data_sample.proposals
              for data_sample in batch_data_samples
          ]
  
      results_list = self.roi_head.predict(
          x, rpn_results_list, batch_data_samples, rescale=rescale
      )
  
      seg_preds = self.semantic_head.predict(
          x, batch_img_metas, rescale
      )
  
      results_list = self.panoptic_fusion_head.predict(
          results_list, seg_preds
      )
  
      batch_data_samples = self.add_pred_to_datasample(
          batch_data_samples, results_list
      )
      return batch_data_samples
  
file_path: mmdetection/mmdet/models/detectors/panoptic_two_stage_segmentor.py
imports: import copy
  from typing import List
  import torch
  from mmengine.structures import PixelData
  from torch import Tensor
  from mmdet.registry import MODELS
  from mmdet.structures import SampleList
  from mmdet.utils import ConfigType, OptConfigType, OptMultiConfig
  from .two_stage import TwoStageDetector
label_desc: Use image node_id 5 for calling the TwoStagePanopticSegmentor obj's underlying member method code with example usage: obj.predict(batch_inputs, batch_data_samples, rescale) and returns: batch_data_samples