class_docstr: Anchor-free head used in `FCOS <https://arxiv.org/abs/1904.01355>`_.
  
  The FCOS head does not use anchor boxes. Instead bounding boxes are
  predicted at each pixel and a centerness measure is used to supress
  low-quality predictions.
  Here norm_on_bbox, centerness_on_reg, dcn_on_last_conv are training
  tricks used in official repo, which will bring remarkable mAP gains
  of up to 4.9. Please see https://github.com/tianzhi0549/FCOS for
  more detail.
  
  Args:
      num_classes (int): Number of categories excluding the background
          category.
      in_channels (int): Number of channels in the input feature map.
      strides (list[int] | list[tuple[int, int]]): Strides of points
          in multiple feature levels. Default: (4, 8, 16, 32, 64).
      regress_ranges (tuple[tuple[int, int]]): Regress range of multiple
          level points.
      center_sampling (bool): If true, use center sampling. Default: False.
      center_sample_radius (float): Radius of center sampling. Default: 1.5.
      norm_on_bbox (bool): If true, normalize the regression targets
          with FPN strides. Default: False.
      centerness_on_reg (bool): If true, position centerness on the
          regress branch. Please refer to https://github.com/tianzhi0549/FCOS/issues/89#issuecomment-516877042.
          Default: False.
      conv_bias (bool | str): If specified as `auto`, it will be decided by the
          norm_cfg. Bias of conv will be set as True if `norm_cfg` is None, otherwise
          False. Default: "auto".
      loss_cls (dict): Config of classification loss.
      loss_bbox (dict): Config of localization loss.
      loss_centerness (dict): Config of centerness loss.
      norm_cfg (dict): dictionary to construct and config norm layer.
          Default: norm_cfg=dict(type='GN', num_groups=32, requires_grad=True).
  
  Example:
      >>> self = FCOSHead(11, 7)
      >>> feats = [torch.rand(1, 7, s, s) for s in [4, 8, 16, 32, 64]]
      >>> cls_score, bbox_pred, centerness = self.forward(feats)
      >>> assert len(cls_score) == len(self.scales)
class_docstr_tok: ["Anchor-free","head","used","in","`","FCOS","<","https",":","\/\/arxiv.org\/abs\/1904.01355",">","`","_",".","The","FCOS","head","does","not","use","anchor","boxes",".","Instead","bounding","boxes","are","predicted","at","each","pixel","and","a","centerness","measure","is","used","to","supress","low-quality","predictions",".","Here","norm_on_bbox",",","centerness_on_reg",",","dcn_on_last_conv","are","training","tricks","used","in","official","repo",",","which","will","bring","remarkable","mAP","gains","of","up","to","4.9",".","Please","see","https",":","\/\/github.com\/tianzhi0549\/FCOS","for","more","detail",".","Args",":","num_classes","(","int",")",":","Number","of","categories","excluding","the","background","category",".","in_channels","(","int",")",":","Number","of","channels","in","the","input","feature","map",".","strides","(","list","[","int","]","|","list","[","tuple","[","int",",","int","]","]",")",":","Strides","of","points","in","multiple","feature","levels",".","Default",":","(","4",",","8",",","16",",","32",",","64",")",".","regress_ranges","(","tuple","[","tuple","[","int",",","int","]","]",")",":","Regress","range","of","multiple","level","points",".","center_sampling","(","bool",")",":","If","true",",","use","center","sampling",".","Default",":","False",".","center_sample_radius","(","float",")",":","Radius","of","center","sampling",".","Default",":","1.5.","norm_on_bbox","(","bool",")",":","If","true",",","normalize","the","regression","targets","with","FPN","strides",".","Default",":","False",".","centerness_on_reg","(","bool",")",":","If","true",",","position","centerness","on","the","regress","branch",".","Please","refer","to","https",":","\/\/github.com\/tianzhi0549\/FCOS\/issues\/89","#","issuecomment-516877042",".","Default",":","False",".","conv_bias","(","bool","|","str",")",":","If","specified","as","`","auto","`",",","it","will","be","decided","by","the","norm_cfg",".","Bias","of","conv","will","be","set","as","True","if","`","norm_cfg","`","is","None",",","otherwise","False",".","Default",":","``","auto","''",".","loss_cls","(","dict",")",":","Config","of","classification","loss",".","loss_bbox","(","dict",")",":","Config","of","localization","loss",".","loss_centerness","(","dict",")",":","Config","of","centerness","loss",".","norm_cfg","(","dict",")",":","dictionary","to","construct","and","config","norm","layer",".","Default",":","norm_cfg=dict","(","type='GN","'",",","num_groups=32",",","requires_grad=True",")",".","Example",":",">",">",">","self","=","FCOSHead","(","11",",","7",")",">",">",">","feats","=","[","torch.rand","(","1",",","7",",","s",",","s",")","for","s","in","[","4",",","8",",","16",",","32",",","64","]","]",">",">",">","cls_score",",","bbox_pred",",","centerness","=","self.forward","(","feats",")",">",">",">","assert","len","(","cls_score",")","==","len","(","self.scales",")"]
docstr: Transform network output for a batch into bbox predictions.
  
  Args:
      cls_scores (list[Tensor]): Box scores for each scale level
          with shape (N, num_points * num_classes, H, W).
      bbox_preds (list[Tensor]): Box energies / deltas for each scale
          level with shape (N, num_points * 4, H, W).
      centernesses (list[Tensor]): Centerness for each scale level with
          shape (N, num_points * 1, H, W).
      img_metas (list[dict]): Meta information of each image, e.g.,
          image size, scaling factor, etc.
      cfg (mmcv.Config | None): Test / postprocessing configuration,
          if None, test_cfg would be used. Default: None.
      rescale (bool): If True, return boxes in original image space.
          Default: False.
      with_nms (bool): If True, do nms before return boxes.
          Default: True.
  
  Returns:
      list[tuple[Tensor, Tensor]]: Each item in result_list is 2-tuple.
          The first item is an (n, 5) tensor, where the first 4 columns
          are bounding box positions (tl_x, tl_y, br_x, br_y) and the
          5-th column is a score between 0 and 1. The second item is a
          (n,) tensor where each item is the predicted class label of the
          corresponding box.
docstr_tok: ["Transform","network","output","for","a","batch","into","bbox","predictions",".","Args",":","cls_scores","(","list","[","Tensor","]",")",":","Box","scores","for","each","scale","level","with","shape","(","N",",","num_points","*","num_classes",",","H",",","W",")",".","bbox_preds","(","list","[","Tensor","]",")",":","Box","energies","\/","deltas","for","each","scale","level","with","shape","(","N",",","num_points","*","4",",","H",",","W",")",".","centernesses","(","list","[","Tensor","]",")",":","Centerness","for","each","scale","level","with","shape","(","N",",","num_points","*","1",",","H",",","W",")",".","img_metas","(","list","[","dict","]",")",":","Meta","information","of","each","image",",","e.g.",",","image","size",",","scaling","factor",",","etc",".","cfg","(","mmcv.Config","|","None",")",":","Test","\/","postprocessing","configuration",",","if","None",",","test_cfg","would","be","used",".","Default",":","None",".","rescale","(","bool",")",":","If","True",",","return","boxes","in","original","image","space",".","Default",":","False",".","with_nms","(","bool",")",":","If","True",",","do","nms","before","return","boxes",".","Default",":","True",".","Returns",":","list","[","tuple","[","Tensor",",","Tensor","]","]",":","Each","item","in","result_list","is","2-tuple",".","The","first","item","is","an","(","n",",","5",")","tensor",",","where","the","first","4","columns","are","bounding","box","positions","(","tl_x",",","tl_y",",","br_x",",","br_y",")","and","the","5-th","column","is","a","score","between","0","and","1",".","The","second","item","is","a","(","n",",",")","tensor","where","each","item","is","the","predicted","class","label","of","the","corresponding","box","."]
code: def get_bboxes(
      self,
      cls_scores,
      bbox_preds,
      centernesses,
      img_metas,
      cfg=None,
      rescale=False,
      with_nms=True,
  ):
      """Transform network output for a batch into bbox predictions.
  
      Args:
          cls_scores (list[Tensor]): Box scores for each scale level
              with shape (N, num_points * num_classes, H, W).
          bbox_preds (list[Tensor]): Box energies / deltas for each scale
              level with shape (N, num_points * 4, H, W).
          centernesses (list[Tensor]): Centerness for each scale level with
              shape (N, num_points * 1, H, W).
          img_metas (list[dict]): Meta information of each image, e.g.,
              image size, scaling factor, etc.
          cfg (mmcv.Config | None): Test / postprocessing configuration,
              if None, test_cfg would be used. Default: None.
          rescale (bool): If True, return boxes in original image space.
              Default: False.
          with_nms (bool): If True, do nms before return boxes.
              Default: True.
  
      Returns:
          list[tuple[Tensor, Tensor]]: Each item in result_list is 2-tuple.
              The first item is an (n, 5) tensor, where the first 4 columns
              are bounding box positions (tl_x, tl_y, br_x, br_y) and the
              5-th column is a score between 0 and 1. The second item is a
              (n,) tensor where each item is the predicted class label of the
              corresponding box.
      """
      assert len(cls_scores) == len(bbox_preds)
      num_levels = len(cls_scores)
  
      featmap_sizes = [featmap.size()[-2:] for featmap in cls_scores]
      mlvl_points = self.get_points(
          featmap_sizes, bbox_preds[0].dtype, bbox_preds[0].device
      )
      result_list = []
      for img_id in range(len(img_metas)):
          cls_score_list = [
              cls_scores[i][img_id].detach() for i in range(num_levels)
          ]
          bbox_pred_list = [
              bbox_preds[i][img_id].detach() for i in range(num_levels)
          ]
          centerness_pred_list = [
              centernesses[i][img_id].detach()
              for i in range(num_levels)
          ]
          img_shape = img_metas[img_id]["img_shape"]
          scale_factor = img_metas[img_id]["scale_factor"]
          det_bboxes = self._get_bboxes_single(
              cls_score_list,
              bbox_pred_list,
              centerness_pred_list,
              mlvl_points,
              img_shape,
              scale_factor,
              cfg,
              rescale,
              with_nms,
          )
          result_list.append(det_bboxes)
      return result_list
  
imports: import torch
  import torch.nn
  import torch.nn.functional
  from mmcv.cnn import Scale, normal_init
  from mmcv.runner import force_fp32
  from mmdet.core import distance2bbox, multi_apply, multiclass_nms
  from ..builder import HEADS, build_loss
  from .anchor_free_head import AnchorFreeHead
label_desc: Use image node_id 7 for calling the FCOSHead obj's underlying member method code with example usage: obj.get_bboxes(cls_scores, bbox_preds, centernesses, img_metas, cfg, rescale, with_nms) and returns: result_list