class_docstr: Implements a text detection dataset
  
  >>> from doctr.datasets import DetectionDataset
  >>> train_set = DetectionDataset(img_folder="/path/to/images",
  >>>                              label_path="/path/to/labels.json")
  >>> img, target = train_set[0]
  
  Args:
  ----
      img_folder: folder with all the images of the dataset
      label_path: path to the annotations of each image
      use_polygons: whether polygons should be considered as rotated bounding box (instead of straight ones)
      **kwargs: keyword arguments from `AbstractDataset`.
code: def __init__(
      self,
      img_folder: str,
      label_path: str,
      use_polygons: bool = False,
      **kwargs: Any,
  ) -> None:
      super().__init__(
          img_folder,
          pre_transforms=pre_transform_multiclass,
          **kwargs,
      )
  
      # File existence check
      self._class_names: List = []
      if not os.path.exists(label_path):
          raise FileNotFoundError(f"unable to locate {label_path}")
      with open(label_path, "rb") as f:
          labels = json.load(f)
  
      self.data: List[Tuple[str, Tuple[np.ndarray, List[str]]]] = []
      np_dtype = np.float32
      for img_name, label in labels.items():
          # File existence check
          if not os.path.exists(os.path.join(self.root, img_name)):
              raise FileNotFoundError(
                  f"unable to locate {os.path.join(self.root, img_name)}"
              )
  
          geoms, polygons_classes = self.format_polygons(
              label["polygons"], use_polygons, np_dtype
          )
  
          self.data.append(
              (
                  img_name,
                  (np.asarray(geoms, dtype=np_dtype), polygons_classes),
              )
          )
  
file_path: doctr/doctr/datasets/detection.py
imports: import json
  import os
  from typing import Any, Dict, List, Tuple, Type, Union
  import numpy
  from doctr.file_utils import CLASS_NAME
  from .datasets import AbstractDataset
  from .utils import pre_transform_multiclass
label_desc: Use image node_id 1 to create a new DetectionDataset object from inherited base classes: AbstractDataset with example: obj = DetectionDataset(img_folder, label_path, use_polygons)