class_docstr: Custom dataset for detection.
  
  The annotation format is shown as follows. The `ann` field is optional for
  testing.
  
  .. code-block:: none
  
      [
          {
              'filename': 'a.jpg',
              'width': 1280,
              'height': 720,
              'ann': {
                  'bboxes': <np.ndarray> (n, 4) in (x1, y1, x2, y2) order.
                  'labels': <np.ndarray> (n, ),
                  'bboxes_ignore': <np.ndarray> (k, 4), (optional field)
                  'labels_ignore': <np.ndarray> (k, 4) (optional field)
              }
          },
          ...
      ]
  
  Args:
      ann_file (str): Annotation file path.
      pipeline (list[dict]): Processing pipeline.
      classes (str | Sequence[str], optional): Specify classes to load.
          If is None, ``cls.CLASSES`` will be used. Default: None.
      data_root (str, optional): Data root for ``ann_file``,
          ``img_prefix``, ``seg_prefix``, ``proposal_file`` if specified.
      test_mode (bool, optional): If set True, annotation will not be loaded.
      filter_empty_gt (bool, optional): If set true, images without bounding
          boxes of the dataset's classes will be filtered out. This option
          only works when `test_mode=False`, i.e., we never filter images
          during tests.
class_docstr_tok: ["Custom","dataset","for","detection",".","The","annotation","format","is","shown","as","follows",".","The","`","ann","`","field","is","optional","for","testing",".","..","code-block",":",":","none","[","{","'filename","'",":","'","a.jpg","'",",","'width","'",":","1280",",","'height","'",":","720",",","'ann","'",":","{","'bboxes","'",":","<","np.ndarray",">","(","n",",","4",")","in","(","x1",",","y1",",","x2",",","y2",")","order",".","'labels","'",":","<","np.ndarray",">","(","n",",",")",",","'bboxes_ignore","'",":","<","np.ndarray",">","(","k",",","4",")",",","(","optional","field",")","'labels_ignore","'",":","<","np.ndarray",">","(","k",",","4",")","(","optional","field",")","}","}",",","...","]","Args",":","ann_file","(","str",")",":","Annotation","file","path",".","pipeline","(","list","[","dict","]",")",":","Processing","pipeline",".","classes","(","str","|","Sequence","[","str","]",",","optional",")",":","Specify","classes","to","load",".","If","is","None",",","``","cls.CLASSES","``","will","be","used",".","Default",":","None",".","data_root","(","str",",","optional",")",":","Data","root","for","``","ann_file","``",",","``","img_prefix","``",",","``","seg_prefix","``",",","``","proposal_file","``","if","specified",".","test_mode","(","bool",",","optional",")",":","If","set","True",",","annotation","will","not","be","loaded",".","filter_empty_gt","(","bool",",","optional",")",":","If","set","true",",","images","without","bounding","boxes","of","the","dataset","'s","classes","will","be","filtered","out",".","This","option","only","works","when","`","test_mode=False","`",",","i.e.",",","we","never","filter","images","during","tests","."]
code: def __init__(
      self,
      ann_file,
      pipeline,
      classes=None,
      data_root=None,
      img_prefix="",
      seg_prefix=None,
      proposal_file=None,
      test_mode=False,
      filter_empty_gt=True,
      support_mosaic=False,
  ):
      self.ann_file = ann_file
      self.data_root = data_root
      self.img_prefix = img_prefix
      self.seg_prefix = seg_prefix
      self.proposal_file = proposal_file
      self.test_mode = test_mode
      self.filter_empty_gt = filter_empty_gt
      self.support_mosaic = support_mosaic
      self.CLASSES = self.get_classes(classes)
  
      # join paths if data_root is specified
      if self.data_root is not None:
          if not osp.isabs(self.ann_file):
              self.ann_file = osp.join(self.data_root, self.ann_file)
          if not (
              self.img_prefix is None or osp.isabs(self.img_prefix)
          ):
              self.img_prefix = osp.join(
                  self.data_root, self.img_prefix
              )
          if not (
              self.seg_prefix is None or osp.isabs(self.seg_prefix)
          ):
              self.seg_prefix = osp.join(
                  self.data_root, self.seg_prefix
              )
          if not (
              self.proposal_file is None
              or osp.isabs(self.proposal_file)
          ):
              self.proposal_file = osp.join(
                  self.data_root, self.proposal_file
              )
      # load annotations (and proposals)
      self.data_infos = self.load_annotations(self.ann_file)
  
      if self.proposal_file is not None:
          self.proposals = self.load_proposals(self.proposal_file)
      else:
          self.proposals = None
  
      # filter images too small and containing no annotations
      if not test_mode:
          valid_inds = self._filter_imgs()
          self.data_infos = [self.data_infos[i] for i in valid_inds]
          if self.proposals is not None:
              self.proposals = [self.proposals[i] for i in valid_inds]
          # set group flag for the sampler
          self._set_group_flag()
  
      # processing pipeline
      self.pipeline = Compose(pipeline)
  
imports: import os.path
  import warnings
  from collections import OrderedDict
  import mmcv
  import numpy
  from torch.utils.data import Dataset
  from mmdet.core import eval_map, eval_recalls
  from .builder import DATASETS
  from .pipelines import Compose
label_desc: Use image node_id 1 to create a new CustomDataset object from inherited base classes: Dataset with example: obj = CustomDataset(ann_file, pipeline, classes, data_root, img_prefix, seg_prefix, proposal_file, test_mode, filter_empty_gt, support_mosaic)