class_docstr: Hybrid task cascade roi head including one bbox head and one mask head.
  
  https://arxiv.org/abs/1901.07518
class_docstr_tok: ["Hybrid","task","cascade","roi","head","including","one","bbox","head","and","one","mask","head",".","https",":","\/\/arxiv.org\/abs\/1901.07518"]
docstr: Test with augmentations.
  
  If rescale is False, then returned bboxes and masks will fit the scale
  of imgs[0].
docstr_tok: ["Test","with","augmentations",".","If","rescale","is","False",",","then","returned","bboxes","and","masks","will","fit","the","scale","of","imgs","[","0","]","."]
code: def aug_test(
      self, img_feats, proposal_list, img_metas, rescale=False
  ):
      """Test with augmentations.
  
      If rescale is False, then returned bboxes and masks will fit the scale
      of imgs[0].
      """
      if self.with_semantic:
          semantic_feats = [
              self.semantic_head(feat)[1] for feat in img_feats
          ]
      else:
          semantic_feats = [None] * len(img_metas)
  
      rcnn_test_cfg = self.test_cfg
      aug_bboxes = []
      aug_scores = []
      for x, img_meta, semantic in zip(
          img_feats, img_metas, semantic_feats
      ):
          # only one image in the batch
          img_shape = img_meta[0]["img_shape"]
          scale_factor = img_meta[0]["scale_factor"]
          flip = img_meta[0]["flip"]
          flip_direction = img_meta[0]["flip_direction"]
  
          proposals = bbox_mapping(
              proposal_list[0][:, :4],
              img_shape,
              scale_factor,
              flip,
              flip_direction,
          )
          # "ms" in variable names means multi-stage
          ms_scores = []
  
          rois = bbox2roi([proposals])
          for i in range(self.num_stages):
              bbox_head = self.bbox_head[i]
              bbox_results = self._bbox_forward(
                  i, x, rois, semantic_feat=semantic
              )
              ms_scores.append(bbox_results["cls_score"])
  
              if i < self.num_stages - 1:
                  bbox_label = bbox_results["cls_score"].argmax(dim=1)
                  rois = bbox_head.regress_by_class(
                      rois,
                      bbox_label,
                      bbox_results["bbox_pred"],
                      img_meta[0],
                  )
  
          cls_score = sum(ms_scores) / float(len(ms_scores))
          bboxes, scores = self.bbox_head[-1].get_bboxes(
              rois,
              cls_score,
              bbox_results["bbox_pred"],
              img_shape,
              scale_factor,
              rescale=False,
              cfg=None,
          )
          aug_bboxes.append(bboxes)
          aug_scores.append(scores)
  
      # after merging, bboxes will be rescaled to the original image size
      merged_bboxes, merged_scores = merge_aug_bboxes(
          aug_bboxes, aug_scores, img_metas, rcnn_test_cfg
      )
      det_bboxes, det_labels = multiclass_nms(
          merged_bboxes,
          merged_scores,
          rcnn_test_cfg.score_thr,
          rcnn_test_cfg.nms,
          rcnn_test_cfg.max_per_img,
      )
  
      bbox_result = bbox2result(
          det_bboxes, det_labels, self.bbox_head[-1].num_classes
      )
  
      if self.with_mask:
          if det_bboxes.shape[0] == 0:
              segm_result = [
                  [
                      []
                      for _ in range(self.mask_head[-1].num_classes - 1)
                  ]
              ]
          else:
              aug_masks = []
              aug_img_metas = []
              for x, img_meta, semantic in zip(
                  img_feats, img_metas, semantic_feats
              ):
                  img_shape = img_meta[0]["img_shape"]
                  scale_factor = img_meta[0]["scale_factor"]
                  flip = img_meta[0]["flip"]
                  flip_direction = img_meta[0]["flip_direction"]
                  _bboxes = bbox_mapping(
                      det_bboxes[:, :4],
                      img_shape,
                      scale_factor,
                      flip,
                      flip_direction,
                  )
                  mask_rois = bbox2roi([_bboxes])
                  mask_feats = self.mask_roi_extractor[-1](
                      x[
                          : len(
                              self.mask_roi_extractor[
                                  -1
                              ].featmap_strides
                          )
                      ],
                      mask_rois,
                  )
                  if self.with_semantic:
                      semantic_feat = semantic
                      mask_semantic_feat = self.semantic_roi_extractor(
                          [semantic_feat], mask_rois
                      )
                      if (
                          mask_semantic_feat.shape[-2:]
                          != mask_feats.shape[-2:]
                      ):
                          mask_semantic_feat = F.adaptive_avg_pool2d(
                              mask_semantic_feat, mask_feats.shape[-2:]
                          )
                      mask_feats += mask_semantic_feat
                  last_feat = None
                  for i in range(self.num_stages):
                      mask_head = self.mask_head[i]
                      if self.mask_info_flow:
                          mask_pred, last_feat = mask_head(
                              mask_feats, last_feat
                          )
                      else:
                          mask_pred = mask_head(mask_feats)
                      aug_masks.append(
                          mask_pred.sigmoid().cpu().numpy()
                      )
                      aug_img_metas.append(img_meta)
              merged_masks = merge_aug_masks(
                  aug_masks, aug_img_metas, self.test_cfg
              )
  
              ori_shape = img_metas[0][0]["ori_shape"]
              segm_result = self.mask_head[-1].get_seg_masks(
                  merged_masks,
                  det_bboxes,
                  det_labels,
                  rcnn_test_cfg,
                  ori_shape,
                  scale_factor=1.0,
                  rescale=False,
              )
          return [(bbox_result, segm_result)]
      else:
          return [bbox_result]
  
file_path: insightface/detection/scrfd/mmdet/models/roi_heads/htc_roi_head.py
imports: import torch
  import torch.nn.functional
  from mmdet.core import bbox2result, bbox2roi, bbox_mapping, merge_aug_bboxes, merge_aug_masks, multiclass_nms
  from ..builder import HEADS, build_head, build_roi_extractor
  from .cascade_roi_head import CascadeRoIHead
label_desc: Use image node_id 11 for calling the HybridTaskCascadeRoIHead obj's underlying member method code with example usage: obj.aug_test(img_feats, proposal_list, img_metas, rescale) and returns: list, list