class_docstr: Data structure for evaluation of CrowdHuman.
  
  Note:
      This implementation is modified from https://github.com/Purkialo/
      CrowdDet/blob/master/lib/evaluate/APMRToolkits/image.py
  
  Args:
      mode (int): Select the mode of evaluate. Valid mode include
          0(just body box), 1(just head box) and 2(both of them).
          Defaults to 0.
docstr: Loading information for evaluation.
  
  Args:
      record (dict): Label information or test results.
          The format might look something like this:
          {
              'ID': '273271,c9db000d5146c15',
              'gtboxes': [
                  {'fbox': [72, 202, 163, 503], 'tag': 'person', ...},
                  {'fbox': [199, 180, 144, 499], 'tag': 'person', ...},
                  ...
              ]
          }
          or:
          {
              'ID': '273271,c9db000d5146c15',
              'width': 800,
              'height': 1067,
              'dtboxes': [
                  {
                      'box': [306.22, 205.95, 164.05, 394.04],
                      'score': 0.99,
                      'tag': 1
                  },
                  {
                      'box': [403.60, 178.66, 157.15, 421.33],
                      'score': 0.99,
                      'tag': 1
                  },
                  ...
              ]
          }
      body_key (str, None): key of detection body box.
          Valid when loading detection results and self.eval_mode!=1.
      head_key (str, None): key of detection head box.
          Valid when loading detection results and self.eval_mode!=0.
      class_names (list[str]):class names of data set.
          Defaults to ['background', 'person'].
      gt_flag (bool): Indicate whether record is ground truth
          or predicting the outcome.
code: def load(self, record, body_key, head_key, class_names, gt_flag):
      """Loading information for evaluation.
  
      Args:
          record (dict): Label information or test results.
              The format might look something like this:
              {
                  'ID': '273271,c9db000d5146c15',
                  'gtboxes': [
                      {'fbox': [72, 202, 163, 503], 'tag': 'person', ...},
                      {'fbox': [199, 180, 144, 499], 'tag': 'person', ...},
                      ...
                  ]
              }
              or:
              {
                  'ID': '273271,c9db000d5146c15',
                  'width': 800,
                  'height': 1067,
                  'dtboxes': [
                      {
                          'box': [306.22, 205.95, 164.05, 394.04],
                          'score': 0.99,
                          'tag': 1
                      },
                      {
                          'box': [403.60, 178.66, 157.15, 421.33],
                          'score': 0.99,
                          'tag': 1
                      },
                      ...
                  ]
              }
          body_key (str, None): key of detection body box.
              Valid when loading detection results and self.eval_mode!=1.
          head_key (str, None): key of detection head box.
              Valid when loading detection results and self.eval_mode!=0.
          class_names (list[str]):class names of data set.
              Defaults to ['background', 'person'].
          gt_flag (bool): Indicate whether record is ground truth
              or predicting the outcome.
      """
      if "ID" in record and self.ID is None:
          self.ID = record["ID"]
      if "width" in record and self.width is None:
          self.width = record["width"]
      if "height" in record and self.height is None:
          self.height = record["height"]
      if gt_flag:
          self.gt_num = len(record["gtboxes"])
          body_bbox, head_bbox = self.load_gt_boxes(
              record, "gtboxes", class_names
          )
          if self.eval_mode == 0:
              self.gt_boxes = body_bbox
              self.ign_num = (body_bbox[:, -1] == -1).sum()
          elif self.eval_mode == 1:
              self.gt_boxes = head_bbox
              self.ign_num = (head_bbox[:, -1] == -1).sum()
          else:
              gt_tag = np.array(
                  [
                      body_bbox[i, -1] != -1 and head_bbox[i, -1] != -1
                      for i in range(len(body_bbox))
                  ]
              )
              self.ign_num = (gt_tag == 0).sum()
              self.gt_boxes = np.hstack(
                  (
                      body_bbox[:, :-1],
                      head_bbox[:, :-1],
                      gt_tag.reshape(-1, 1),
                  )
              )
  
      if not gt_flag:
          self.dt_num = len(record["dtboxes"])
          if self.eval_mode == 0:
              self.dt_boxes = self.load_det_boxes(
                  record, "dtboxes", body_key, "score"
              )
          elif self.eval_mode == 1:
              self.dt_boxes = self.load_det_boxes(
                  record, "dtboxes", head_key, "score"
              )
          else:
              body_dtboxes = self.load_det_boxes(
                  record, "dtboxes", body_key, "score"
              )
              head_dtboxes = self.load_det_boxes(
                  record, "dtboxes", head_key, "score"
              )
              self.dt_boxes = np.hstack((body_dtboxes, head_dtboxes))
  
imports: import copy
  import json
  import os.path
  import tempfile
  from collections import OrderedDict
  from multiprocessing import Process, Queue
  from typing import Dict, List, Optional, Sequence, Union
  import numpy
  from mmengine.evaluator import BaseMetric
  from mmengine.fileio import dump, get_text, load
  from mmengine.logging import MMLogger
  from scipy.sparse import csr_matrix
  from scipy.sparse.csgraph import maximum_bipartite_matching
  from mmdet.evaluation.functional.bbox_overlaps import bbox_overlaps
  from mmdet.registry import METRICS
label_desc: Use image node_id 2 for calling the Image obj's underlying member method code with example usage: obj.load(record, body_key, head_key, class_names, gt_flag) without return types