class_docstr: `PointRend <https://arxiv.org/abs/1912.08193>`_.
class_docstr_tok: ["`","PointRend","<","https",":","\/\/arxiv.org\/abs\/1912.08193",">","`","_","."]
docstr: Obtain mask prediction without augmentation.
docstr_tok: ["Obtain","mask","prediction","without","augmentation","."]
code: def simple_test_mask(
      self, x, img_metas, det_bboxes, det_labels, rescale=False
  ):
      """Obtain mask prediction without augmentation."""
      ori_shapes = tuple(meta["ori_shape"] for meta in img_metas)
      scale_factors = tuple(meta["scale_factor"] for meta in img_metas)
      num_imgs = len(det_bboxes)
      if all(det_bbox.shape[0] == 0 for det_bbox in det_bboxes):
          segm_results = [
              [[] for _ in range(self.mask_head.num_classes)]
              for _ in range(num_imgs)
          ]
      else:
          # if det_bboxes is rescaled to the original image size, we need to
          # rescale it back to the testing scale to obtain RoIs.
          if rescale and not isinstance(scale_factors[0], float):
              scale_factors = [
                  torch.from_numpy(scale_factor).to(
                      det_bboxes[0].device
                  )
                  for scale_factor in scale_factors
              ]
          _bboxes = [
              det_bboxes[i][:, :4] * scale_factors[i]
              if rescale
              else det_bboxes[i][:, :4]
              for i in range(len(det_bboxes))
          ]
          mask_rois = bbox2roi(_bboxes)
          mask_results = self._mask_forward(x, mask_rois)
          # split batch mask prediction back to each image
          mask_pred = mask_results["mask_pred"]
          num_mask_roi_per_img = [
              len(det_bbox) for det_bbox in det_bboxes
          ]
          mask_preds = mask_pred.split(num_mask_roi_per_img, 0)
          mask_rois = mask_rois.split(num_mask_roi_per_img, 0)
  
          # apply mask post-processing to each image individually
          segm_results = []
          for i in range(num_imgs):
              if det_bboxes[i].shape[0] == 0:
                  segm_results.append(
                      [[] for _ in range(self.mask_head.num_classes)]
                  )
              else:
                  x_i = [xx[[i]] for xx in x]
                  mask_rois_i = mask_rois[i]
                  mask_rois_i[:, 0] = 0  # TODO: remove this hack
                  mask_pred_i = self._mask_point_forward_test(
                      x_i,
                      mask_rois_i,
                      det_labels[i],
                      mask_preds[i],
                      [img_metas],
                  )
                  segm_result = self.mask_head.get_seg_masks(
                      mask_pred_i,
                      _bboxes[i],
                      det_labels[i],
                      self.test_cfg,
                      ori_shapes[i],
                      scale_factors[i],
                      rescale,
                  )
                  segm_results.append(segm_result)
      return segm_results
  
file_path: insightface/detection/scrfd/mmdet/models/roi_heads/point_rend_roi_head.py
imports: import torch
  import torch.nn.functional
  from mmcv.ops import point_sample, rel_roi_point_to_rel_img_point
  from mmdet.core import bbox2roi, bbox_mapping, merge_aug_masks
  from ..None import builder
  from ..builder import HEADS
  from .standard_roi_head import StandardRoIHead
label_desc: Use image node_id 8 for calling the PointRendRoIHead obj's underlying member method code with example usage: obj.simple_test_mask(x, img_metas, det_bboxes, det_labels, rescale) and returns: segm_results