class_docstr: Phrase Grounding Metric.
class_docstr_tok: ["Phrase","Grounding","Metric","."]
docstr: Compute the metrics from processed results.
  
  Args:
      results (list): The processed results of each batch.
  Returns:
      Dict[str, float]: The computed metrics. The keys are the names of
      the metrics, and the values are corresponding results.
docstr_tok: ["Compute","the","metrics","from","processed","results",".","Args",":","results","(","list",")",":","The","processed","results","of","each","batch",".","Returns",":","Dict","[","str",",","float","]",":","The","computed","metrics",".","The","keys","are","the","names","of","the","metrics",",","and","the","values","are","corresponding","results","."]
code: def compute_metrics(self, results: list) -> Dict[str, float]:
      """Compute the metrics from processed results.
  
      Args:
          results (list): The processed results of each batch.
      Returns:
          Dict[str, float]: The computed metrics. The keys are the names of
          the metrics, and the values are corresponding results.
      """
      logger: MMLogger = MMLogger.get_current_instance()
  
      pred_list, gt_list, gt_label_list, phrase_list = zip(*results)
  
      recall_tracker = RecallTracker(self.topk)
  
      for pred, gt_boxes, gt_labels, phrases in zip(
          pred_list, gt_list, gt_label_list, phrase_list
      ):
          pred_boxes = pred["bboxes"].cpu().numpy()
          pred_labels = pred["labels"].cpu().numpy()
          for i, phrase in enumerate(phrases):
              cur_index = pred_labels == i
              cur_boxes = pred_boxes[cur_index]
              tar_index = [
                  index
                  for index, value in enumerate(gt_labels)
                  if value == i
              ]
              tar_boxes = gt_boxes[tar_index]
              if self.merge:
                  tar_boxes = self.merge_boxes(tar_boxes)
              if len(cur_boxes) == 0:
                  cur_boxes = [[0.0, 0.0, 0.0, 0.0]]
              ious = bbox_overlaps(
                  np.asarray(cur_boxes), np.asarray(tar_boxes)
              )
              for k in self.topk:
                  if k == -1:
                      maxi = ious.max()
                  else:
                      assert k > 0
                      maxi = ious[:k].max()
                  if maxi >= self.iou_thrs:
                      recall_tracker.add_positive(k, "all")
                      # TODO: do not support class-wise evaluation yet
                      # for phrase_type in phrase['phrase_type']:
                      #     recall_tracker.add_positive(k, phrase_type)
                  else:
                      recall_tracker.add_negative(k, "all")
                      # for phrase_type in phrase['phrase_type']:
                      #     recall_tracker.add_negative(k, phrase_type)
  
      results = recall_tracker.report()
      logger.info(results)
      return results
  
file_path: mmdetection/mmdet/evaluation/metrics/flickr30k_metric.py
imports: from collections import defaultdict
  from typing import Dict, List, Optional, Sequence
  import numpy
  from mmengine.evaluator import BaseMetric
  from mmengine.logging import MMLogger
  from mmdet.registry import METRICS
  from ..functional import bbox_overlaps
label_desc: Use image node_id 4 for calling the Flickr30kMetric obj's underlying member method code with example usage: obj.compute_metrics(results) and returns: results