class_docstr: Implementation of `Grid RoI Head <https://arxiv.org/abs/1811.12030>`_
  
  Args:
      grid_roi_extractor (:obj:`ConfigDict` or dict): Config of
          roi extractor.
      grid_head (:obj:`ConfigDict` or dict): Config of grid head
class_docstr_tok: ["Implementation","of","`","Grid","RoI","Head","<","https",":","\/\/arxiv.org\/abs\/1811.12030",">","`","_","Args",":","grid_roi_extractor","(",":","obj",":","`","ConfigDict","`","or","dict",")",":","Config","of","roi","extractor",".","grid_head","(",":","obj",":","`","ConfigDict","`","or","dict",")",":","Config","of","grid","head"]
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).
          """
      results_list = super().predict_bbox(
          x,
          batch_img_metas=batch_img_metas,
          rpn_results_list=rpn_results_list,
          rcnn_test_cfg=rcnn_test_cfg,
          rescale=False,
      )
  
      grid_rois = bbox2roi([res.bboxes for res in results_list])
      if grid_rois.shape[0] != 0:
          grid_feats = self.grid_roi_extractor(
              x[: len(self.grid_roi_extractor.featmap_strides)],
              grid_rois,
          )
          if self.with_shared_head:
              grid_feats = self.shared_head(grid_feats)
          self.grid_head.test_mode = True
          grid_preds = self.grid_head(grid_feats)
          results_list = self.grid_head.predict_by_feat(
              grid_preds=grid_preds,
              results_list=results_list,
              batch_img_metas=batch_img_metas,
              rescale=rescale,
          )
  
      return results_list
  
file_path: mmdetection/mmdet/models/roi_heads/grid_roi_head.py
imports: from typing import List, Optional, Tuple
  import torch
  from torch import Tensor
  from mmdet.registry import MODELS
  from mmdet.structures import SampleList
  from mmdet.structures.bbox import bbox2roi
  from mmdet.utils import ConfigType, InstanceList
  from ..task_modules.samplers import SamplingResult
  from ..utils.misc import unpack_gt_instances
  from .standard_roi_head import StandardRoIHead
label_desc: Use image node_id 6 for calling the GridRoIHead 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: results_list