class_docstr: `PointRend <https://arxiv.org/abs/1912.08193>`_.
class_docstr_tok: ["`","PointRend","<","https",":","\/\/arxiv.org\/abs\/1912.08193",">","`","_","."]
docstr: Perform forward propagation of the mask 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.
      results_list (list[:obj:`InstanceData`]): Detection results of
          each image.
      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).
      - masks (Tensor): Has a shape (num_instances, H, W).
docstr_tok: ["Perform","forward","propagation","of","the","mask","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",".","results_list","(","list","[",":","obj",":","`","InstanceData","`","]",")",":","Detection","results","of","each","image",".","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",")",".","-","masks","(","Tensor",")",":","Has","a","shape","(","num_instances",",","H",",","W",")","."]
code: def predict_mask(
      self,
      x: Tuple[Tensor],
      batch_img_metas: List[dict],
      results_list: InstanceList,
      rescale: bool = False,
  ) -> InstanceList:
      """Perform forward propagation of the mask 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.
          results_list (list[:obj:`InstanceData`]): Detection results of
              each image.
          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).
          - masks (Tensor): Has a shape (num_instances, H, W).
      """
      # don't need to consider aug_test.
      bboxes = [res.bboxes for res in results_list]
      mask_rois = bbox2roi(bboxes)
      if mask_rois.shape[0] == 0:
          results_list = empty_instances(
              batch_img_metas,
              mask_rois.device,
              task_type="mask",
              instance_results=results_list,
              mask_thr_binary=self.test_cfg.mask_thr_binary,
          )
          return results_list
  
      mask_results = self._mask_forward(x, mask_rois)
      mask_preds = mask_results["mask_preds"]
      # split batch mask prediction back to each image
      num_mask_rois_per_img = [len(res) for res in results_list]
      mask_preds = mask_preds.split(num_mask_rois_per_img, 0)
  
      # refine mask_preds
      mask_rois = mask_rois.split(num_mask_rois_per_img, 0)
      mask_preds_refined = []
      for i in range(len(batch_img_metas)):
          labels = results_list[i].labels
          x_i = [xx[[i]] for xx in x]
          mask_rois_i = mask_rois[i]
          mask_rois_i[:, 0] = 0
          mask_pred_i = self._mask_point_forward_test(
              x_i, mask_rois_i, labels, mask_preds[i]
          )
          mask_preds_refined.append(mask_pred_i)
  
      # TODO: Handle the case where rescale is false
      results_list = self.mask_head.predict_by_feat(
          mask_preds=mask_preds_refined,
          results_list=results_list,
          batch_img_metas=batch_img_metas,
          rcnn_test_cfg=self.test_cfg,
          rescale=rescale,
      )
      return results_list
  
file_path: mmdetection/mmdet/models/roi_heads/point_rend_roi_head.py
imports: from typing import List, Tuple
  import torch
  import torch.nn.functional
  from mmcv.ops import point_sample, rel_roi_point_to_rel_img_point
  from torch import Tensor
  from mmdet.registry import MODELS
  from mmdet.structures.bbox import bbox2roi
  from mmdet.utils import ConfigType, InstanceList
  from ..task_modules.samplers import SamplingResult
  from ..utils import empty_instances
  from .standard_roi_head import StandardRoIHead
label_desc: Use image node_id 7 for calling the PointRendRoIHead obj's underlying member method code with example usage: obj.predict_mask(x, batch_img_metas, results_list, rescale) and returns: results_list, results_list