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: Add predictions to `DetDataSample`.
  
  Args:
      data_samples (list[:obj:`DetDataSample`], optional): A batch of
          data samples that contain annotations and predictions.
      results_list (List[dict]): Instance segmentation, segmantic
          segmentation and panoptic segmentation results.
  
  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: ["Add","predictions","to","`","DetDataSample","`",".","Args",":","data_samples","(","list","[",":","obj",":","`","DetDataSample","`","]",",","optional",")",":","A","batch","of","data","samples","that","contain","annotations","and","predictions",".","results_list","(","List","[","dict","]",")",":","Instance","segmentation",",","segmantic","segmentation","and","panoptic","segmentation","results",".","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 add_pred_to_datasample(
      self, data_samples: SampleList, results_list: List[dict]
  ) -> SampleList:
      """Add predictions to `DetDataSample`.
  
      Args:
          data_samples (list[:obj:`DetDataSample`], optional): A batch of
              data samples that contain annotations and predictions.
          results_list (List[dict]): Instance segmentation, segmantic
              segmentation and panoptic segmentation results.
  
      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).
      """
      for data_sample, pred_results in zip(data_samples, results_list):
          if "pan_results" in pred_results:
              data_sample.pred_panoptic_seg = pred_results[
                  "pan_results"
              ]
  
          if "ins_results" in pred_results:
              data_sample.pred_instances = pred_results["ins_results"]
  
          assert "sem_results" not in pred_results, (
              "segmantic " "segmentation results are not supported yet."
          )
  
      return data_samples
  
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 4 for calling the MaskFormer obj's underlying member method code with example usage: obj.add_pred_to_datasample(data_samples, results_list) and returns: data_samples