class_docstr: Evaluation hook.
  
  Notes:
      If new arguments are added for EvalHook, tools/test.py,
      tools/eval_metric.py may be effected.
  
  Attributes:
      dataloader (DataLoader): A PyTorch dataloader.
      start (int, optional): Evaluation starting epoch. It enables evaluation
          before the training starts if ``start`` <= the resuming epoch.
          If None, whether to evaluate is merely decided by ``interval``.
          Default: None.
      interval (int): Evaluation interval (by epochs). Default: 1.
      save_best (str, optional): If a metric is specified, it would measure
          the best checkpoint during evaluation. The information about best
          checkpoint would be save in best.json.
          Options are the evaluation metrics to the test dataset. e.g.,
          ``bbox_mAP``, ``segm_mAP`` for bbox detection and instance
          segmentation. ``AR@100`` for proposal recall. If ``save_best`` is
          ``auto``, the first key will be used. The interval of
          ``CheckpointHook`` should device EvalHook. Default: None.
      rule (str, optional): Comparison rule for best score. If set to None,
          it will infer a reasonable rule. Keys such as 'mAP' or 'AR' will
          be inferred by 'greater' rule. Keys contain 'loss' will be inferred
           by 'less' rule. Options are 'greater', 'less'. Default: None.
      **eval_kwargs: Evaluation arguments fed into the evaluate function of
          the dataset.
class_docstr_tok: ["Evaluation","hook",".","Notes",":","If","new","arguments","are","added","for","EvalHook",",","tools\/test.py",",","tools\/eval_metric.py","may","be","effected",".","Attributes",":","dataloader","(","DataLoader",")",":","A","PyTorch","dataloader",".","start","(","int",",","optional",")",":","Evaluation","starting","epoch",".","It","enables","evaluation","before","the","training","starts","if","``","start","``","<","=","the","resuming","epoch",".","If","None",",","whether","to","evaluate","is","merely","decided","by","``","interval","``",".","Default",":","None",".","interval","(","int",")",":","Evaluation","interval","(","by","epochs",")",".","Default",":","1.","save_best","(","str",",","optional",")",":","If","a","metric","is","specified",",","it","would","measure","the","best","checkpoint","during","evaluation",".","The","information","about","best","checkpoint","would","be","save","in","best.json",".","Options","are","the","evaluation","metrics","to","the","test","dataset",".","e.g.",",","``","bbox_mAP","``",",","``","segm_mAP","``","for","bbox","detection","and","instance","segmentation",".","``","AR","@","100","``","for","proposal","recall",".","If","``","save_best","``","is","``","auto","``",",","the","first","key","will","be","used",".","The","interval","of","``","CheckpointHook","``","should","device","EvalHook",".","Default",":","None",".","rule","(","str",",","optional",")",":","Comparison","rule","for","best","score",".","If","set","to","None",",","it","will","infer","a","reasonable","rule",".","Keys","such","as","'mAP","'","or","'AR","'","will","be","inferred","by","'greater","'","rule",".","Keys","contain","'loss","'","will","be","inferred","by","'less","'","rule",".","Options","are","'greater","'",",","'less","'",".","Default",":","None",".","*","*","eval_kwargs",":","Evaluation","arguments","fed","into","the","evaluate","function","of","the","dataset","."]
code: def __init__(
      self,
      dataloader,
      start=None,
      interval=1,
      save_best=None,
      rule=None,
      **eval_kwargs,
  ):
      if not isinstance(dataloader, DataLoader):
          raise TypeError(
              "dataloader must be a pytorch DataLoader, but got"
              f" {type(dataloader)}"
          )
      if not interval > 0:
          raise ValueError(
              f"interval must be positive, but got {interval}"
          )
      if start is not None and start < 0:
          warnings.warn(
              f"The evaluation start epoch {start} is smaller than 0, "
              f"use 0 instead",
              UserWarning,
          )
          start = 0
      self.dataloader = dataloader
      self.interval = interval
      self.start = start
      assert isinstance(save_best, str) or save_best is None
      self.save_best = save_best
      self.eval_kwargs = eval_kwargs
      self.initial_epoch_flag = True
  
      self.logger = get_root_logger()
  
      if self.save_best is not None:
          self._init_rule(rule, self.save_best)
  
file_path: insightface/detection/scrfd/mmdet/core/evaluation/eval_hooks.py
imports: import os.path
  import warnings
  from math import inf
  import mmcv
  from mmcv.runner import Hook
  from torch.utils.data import DataLoader
  from mmdet.utils import get_root_logger
label_desc: Use image node_id 1 to create a new EvalHook object from inherited base classes: Hook with example: obj = EvalHook(dataloader, start, interval, save_best, rule)