class_docstr: The roi head for Multi-instance prediction.
class_docstr_tok: ["The","roi","head","for","Multi-instance","prediction","."]
docstr: Perform forward propagation of the bbox head and predict detection
  results on the features of the upstream network.
  
  Args:
      x (tuple[Tensor]): Feature maps of all scale level.
      batch_img_metas (list[dict]): List of image information.
      rpn_results_list (list[:obj:`InstanceData`]): List of region
          proposals.
      rcnn_test_cfg (obj:`ConfigDict`): `test_cfg` of R-CNN.
      rescale (bool): If True, return boxes in original image space.
          Defaults to False.
  
  Returns:
      list[:obj:`InstanceData`]: Detection results of each image
      after the post process.
      Each item 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).
docstr_tok: ["Perform","forward","propagation","of","the","bbox","head","and","predict","detection","results","on","the","features","of","the","upstream","network",".","Args",":","x","(","tuple","[","Tensor","]",")",":","Feature","maps","of","all","scale","level",".","batch_img_metas","(","list","[","dict","]",")",":","List","of","image","information",".","rpn_results_list","(","list","[",":","obj",":","`","InstanceData","`","]",")",":","List","of","region","proposals",".","rcnn_test_cfg","(","obj",":","`","ConfigDict","`",")",":","`","test_cfg","`","of","R-CNN",".","rescale","(","bool",")",":","If","True",",","return","boxes","in","original","image","space",".","Defaults","to","False",".","Returns",":","list","[",":","obj",":","`","InstanceData","`","]",":","Detection","results","of","each","image","after","the","post","process",".","Each","item","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",")","."]
code: def predict_bbox(
      self,
      x: Tuple[Tensor],
      batch_img_metas: List[dict],
      rpn_results_list: InstanceList,
      rcnn_test_cfg: ConfigType,
      rescale: bool = False,
  ) -> InstanceList:
      """Perform forward propagation of the bbox head and predict detection
      results on the features of the upstream network.
  
      Args:
          x (tuple[Tensor]): Feature maps of all scale level.
          batch_img_metas (list[dict]): List of image information.
          rpn_results_list (list[:obj:`InstanceData`]): List of region
              proposals.
          rcnn_test_cfg (obj:`ConfigDict`): `test_cfg` of R-CNN.
          rescale (bool): If True, return boxes in original image space.
              Defaults to False.
  
      Returns:
          list[:obj:`InstanceData`]: Detection results of each image
          after the post process.
          Each item 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).
      """
      proposals = [res.bboxes for res in rpn_results_list]
      rois = bbox2roi(proposals)
  
      if rois.shape[0] == 0:
          return empty_instances(
              batch_img_metas, rois.device, task_type="bbox"
          )
  
      bbox_results = self._bbox_forward(x, rois)
  
      # split batch bbox prediction back to each image
      if "cls_score_ref" in bbox_results:
          cls_scores = bbox_results["cls_score_ref"]
          bbox_preds = bbox_results["bbox_pred_ref"]
      else:
          cls_scores = bbox_results["cls_score"]
          bbox_preds = bbox_results["bbox_pred"]
      num_proposals_per_img = tuple(len(p) for p in proposals)
      rois = rois.split(num_proposals_per_img, 0)
      cls_scores = cls_scores.split(num_proposals_per_img, 0)
  
      if bbox_preds is not None:
          bbox_preds = bbox_preds.split(num_proposals_per_img, 0)
      else:
          bbox_preds = (None,) * len(proposals)
  
      result_list = self.bbox_head.predict_by_feat(
          rois=rois,
          cls_scores=cls_scores,
          bbox_preds=bbox_preds,
          batch_img_metas=batch_img_metas,
          rcnn_test_cfg=rcnn_test_cfg,
          rescale=rescale,
      )
      return result_list
  
file_path: mmdetection/mmdet/models/roi_heads/multi_instance_roi_head.py
imports: from typing import List, Tuple
  from torch import Tensor
  from mmdet.registry import MODELS
  from mmdet.structures import DetDataSample
  from mmdet.structures.bbox import bbox2roi
  from mmdet.utils import ConfigType, InstanceList
  from ..task_modules.samplers import SamplingResult
  from ..utils import empty_instances, unpack_gt_instances
  from .standard_roi_head import StandardRoIHead
label_desc: Use image node_id 6 for calling the MultiInstanceRoIHead obj's underlying member method code with example usage: obj.predict_bbox(x, batch_img_metas, rpn_results_list, rcnn_test_cfg, rescale) and returns: result_list, empty_instances