class_docstr: Mask IoU Head.
  
  This head predicts the IoU of predicted masks and corresponding gt masks.
docstr: Compute area ratio of the gt mask inside the proposal and the gt
  mask of the corresponding instance.
docstr_tok: ["Compute","area","ratio","of","the","gt","mask","inside","the","proposal","and","the","gt","mask","of","the","corresponding","instance","."]
code: def _get_area_ratio(
      self, pos_proposals, pos_assigned_gt_inds, gt_masks
  ):
      """Compute area ratio of the gt mask inside the proposal and the gt
      mask of the corresponding instance."""
      num_pos = pos_proposals.size(0)
      if num_pos > 0:
          area_ratios = []
          proposals_np = pos_proposals.cpu().numpy()
          pos_assigned_gt_inds = pos_assigned_gt_inds.cpu().numpy()
          # compute mask areas of gt instances (batch processing for speedup)
          gt_instance_mask_area = gt_masks.areas
          for i in range(num_pos):
              gt_mask = gt_masks[pos_assigned_gt_inds[i]]
  
              # crop the gt mask inside the proposal
              bbox = proposals_np[i, :].astype(np.int32)
              gt_mask_in_proposal = gt_mask.crop(bbox)
  
              ratio = gt_mask_in_proposal.areas[0] / (
                  gt_instance_mask_area[pos_assigned_gt_inds[i]] + 1e-7
              )
              area_ratios.append(ratio)
          area_ratios = (
              torch.from_numpy(np.stack(area_ratios))
              .float()
              .to(pos_proposals.device)
          )
      else:
          area_ratios = pos_proposals.new_zeros((0,))
      return area_ratios
  
file_path: insightface/detection/scrfd/mmdet/models/roi_heads/mask_heads/maskiou_head.py
imports: import numpy
  import torch
  import torch.nn
  from mmcv.cnn import Conv2d, Linear, MaxPool2d, kaiming_init, normal_init
  from mmcv.runner import force_fp32
  from torch.nn.modules.utils import _pair
  from mmdet.models.builder import HEADS, build_loss
label_desc: Use image node_id 6 for calling the MaskIoUHead obj's underlying member method code with example usage: obj._get_area_ratio(pos_proposals, pos_assigned_gt_inds, gt_masks) and returns: area_ratios