docstr: Tests center head generating and decoding the heatmap.
docstr_tok: ["Tests","center","head","generating","and","decoding","the","heatmap","."]
code: def test_centernet_head_get_results(self):
      """Tests center head generating and decoding the heatmap."""
      s = 256
      img_metas = [
          {
              "img_shape": (s, s, 3),
              "batch_input_shape": (s, s),
              "border": (0, 0, 0, 0),
          }
      ]
      test_cfg = ConfigDict(
          dict(
              topk=100,
              local_maximum_kernel=3,
              max_per_img=100,
              nms=dict(type="nms", iou_threshold=0.5),
          )
      )
      gt_bboxes = [
          torch.Tensor(
              [
                  [10, 20, 200, 240],
                  [40, 50, 100, 200],
                  [10, 20, 100, 240],
              ]
          )
      ]
      gt_labels = [torch.LongTensor([1, 1, 2])]
  
      centernet_head = CenterNetHead(
          num_classes=4,
          in_channels=1,
          feat_channels=4,
          test_cfg=test_cfg,
      )
      self.feat_shape = (1, 1, s // 4, s // 4)
      targets, _ = centernet_head.get_targets(
          gt_bboxes,
          gt_labels,
          self.feat_shape,
          img_metas[0]["img_shape"],
      )
      center_target = targets["center_heatmap_target"]
      wh_target = targets["wh_target"]
      offset_target = targets["offset_target"]
      # make sure get_bboxes is right
      detections = centernet_head.predict_by_feat(
          [center_target],
          [wh_target],
          [offset_target],
          img_metas,
          rescale=True,
          with_nms=False,
      )
  
      pred_instances = detections[0]
      out_bboxes = pred_instances.bboxes[:3]
      out_clses = pred_instances.labels[:3]
      for bbox, cls in zip(out_bboxes, out_clses):
          flag = False
          for gt_bbox, gt_cls in zip(gt_bboxes[0], gt_labels[0]):
              if (bbox[:4] == gt_bbox[:4]).all():
                  flag = True
          assert flag, "get_bboxes is wrong"
  
      detections = centernet_head.predict_by_feat(
          [center_target],
          [wh_target],
          [offset_target],
          img_metas,
          rescale=True,
          with_nms=True,
      )
  
      pred_instances = detections[0]
      out_bboxes = pred_instances.bboxes[:3]
      out_clses = pred_instances.labels[:3]
      for bbox, cls in zip(out_bboxes, out_clses):
          flag = False
          for gt_bbox, gt_cls in zip(gt_bboxes[0], gt_labels[0]):
              if (bbox[:4] == gt_bbox[:4]).all():
                  flag = True
      assert flag, "get_bboxes is wrong"
  
file_path: mmdetection/tests/test_models/test_dense_heads/test_centernet_head.py
imports: from unittest import TestCase
  import torch
  from mmengine.config import ConfigDict
  from mmengine.structures import InstanceData
  from mmdet.models.dense_heads import CenterNetHead
label_desc: Use image node_id 3 for calling the TestCenterNetHead obj's underlying member method code with example usage: obj.test_centernet_head_get_results() without return types