class_docstr: CSVReader supports reading annotations out of a CSV file.
  
  The reader requires the following directory structure within `data_dir`:
  * Annotation data (bounding boxes) per split, under the name `{split}.csv`
    on the root directory.
  * Dataset images per split, under the `{split}/` directory on the root
    directory.
  
  Thus, a CSV dataset directory structure may look as follows::
  
      .
      ├── train
      │   ├── image_1.jpg
      │   ├── image_2.jpg
      │   └── image_3.jpg
      ├── val
      │   ├── image_4.jpg
      │   ├── image_5.jpg
      │   └── image_6.jpg
      ├── train.csv
      └── val.csv
  
  The CSV file itself must have the following format::
  
      image_id,xmin,ymin,xmax,ymax,label
      image_1.jpg,26,594,86,617,cat
      image_1.jpg,599,528,612,541,car
      image_2.jpg,393,477,430,552,dog
  
  You can skip the header by overriding the `headers` parameter, in which
  case the `columns` option will be used (specified as either a string or a
  comma-separated list of fields). If this is done, the above six columns
  *must* be present. Extra columns will be ignored.
class_docstr_tok: ["CSVReader","supports","reading","annotations","out","of","a","CSV","file",".","The","reader","requires","the","following","directory","structure","within","`","data_dir","`",":","*","Annotation","data","(","bounding","boxes",")","per","split",",","under","the","name","`","{","split","}",".csv","`","on","the","root","directory",".","*","Dataset","images","per","split",",","under","the","`","{","split","}","\/","`","directory","on","the","root","directory",".","Thus",",","a","CSV","dataset","directory","structure","may","look","as","follows",":",":",".","\u251c\u2500\u2500","train","\u2502","\u251c\u2500\u2500","image_1.jpg","\u2502","\u251c\u2500\u2500","image_2.jpg","\u2502","\u2514\u2500\u2500","image_3.jpg","\u251c\u2500\u2500","val","\u2502","\u251c\u2500\u2500","image_4.jpg","\u2502","\u251c\u2500\u2500","image_5.jpg","\u2502","\u2514\u2500\u2500","image_6.jpg","\u251c\u2500\u2500","train.csv","\u2514\u2500\u2500","val.csv","The","CSV","file","itself","must","have","the","following","format",":",":","image_id",",","xmin",",","ymin",",","xmax",",","ymax",",","label","image_1.jpg,26,594,86,617",",","cat","image_1.jpg,599,528,612,541",",","car","image_2.jpg,393,477,430,552",",","dog","You","can","skip","the","header","by","overriding","the","`","headers","`","parameter",",","in","which","case","the","`","columns","`","option","will","be","used","(","specified","as","either","a","string","or","a","comma-separated","list","of","fields",")",".","If","this","is","done",",","the","above","six","columns","*","must","*","be","present",".","Extra","columns","will","be","ignored","."]
docstr: Initializes the reader, allowing to override internal settings.
  
  Arguments:
      data_dir: Path to base directory where all the files are
          located. See class docstring for a description on the expected
          structure.
      split: Split to read. Possible values depend on the dataset itself.
      headers (boolean): Whether the CSV file has headers indicating
          field names, in which case those will be considered.
      columns (list or str): Column names for when `headers` is `False`
          (i.e. the CSV file has no headers). Will be ignored if
          `headers` is `True`.
docstr_tok: ["Initializes","the","reader",",","allowing","to","override","internal","settings",".","Arguments",":","data_dir",":","Path","to","base","directory","where","all","the","files","are","located",".","See","class","docstring","for","a","description","on","the","expected","structure",".","split",":","Split","to","read",".","Possible","values","depend","on","the","dataset","itself",".","headers","(","boolean",")",":","Whether","the","CSV","file","has","headers","indicating","field","names",",","in","which","case","those","will","be","considered",".","columns","(","list","or","str",")",":","Column","names","for","when","`","headers","`","is","`","False","`","(","i.e",".","the","CSV","file","has","no","headers",")",".","Will","be","ignored","if","`","headers","`","is","`","True","`","."]
code: def __init__(
      self, data_dir, split, headers=True, columns=None, **kwargs
  ):
      """Initializes the reader, allowing to override internal settings.
  
      Arguments:
          data_dir: Path to base directory where all the files are
              located. See class docstring for a description on the expected
              structure.
          split: Split to read. Possible values depend on the dataset itself.
          headers (boolean): Whether the CSV file has headers indicating
              field names, in which case those will be considered.
          columns (list or str): Column names for when `headers` is `False`
              (i.e. the CSV file has no headers). Will be ignored if
              `headers` is `True`.
      """
      super(CSVReader, self).__init__(**kwargs)
  
      self._data_dir = data_dir
      self._split = split
  
      self._annotations_path = os.path.join(
          self._data_dir, "{}.csv".format(self._split)
      )
      if not tf.gfile.Exists(self._annotations_path):
          raise InvalidDataDirectory(
              "CSV annotation file not found. Should be located at "
              "`{}`".format(self._annotations_path)
          )
  
      self._images_dir = os.path.join(self._data_dir, self._split)
      if not tf.gfile.Exists(self._images_dir):
          raise InvalidDataDirectory(
              "Image directory not found. Should be located at "
              "`{}`".format(self._images_dir)
          )
  
      if columns is not None:
          if is_basestring(columns):
              columns = columns.split(",")
      else:
          columns = self.DEFAULT_COLUMNS
      self._columns = columns
      self._column_names = set(self._columns)
  
      self._has_headers = headers
  
      # Cache for the records.
      # TODO: Don't read it all upfront.
      self._records = None
  
      # Whether the structure of the CSV file has been checked already.
      self._csv_checked = False
  
      self.errors = 0
      self.yielded_records = 0
  
file_path: luminoth/luminoth/tools/dataset/readers/object_detection/csv_reader.py
imports: import csv
  import os
  import six
  import tensorflow
  from PIL import Image
  from luminoth.tools.dataset.readers import InvalidDataDirectory
  from luminoth.tools.dataset.readers.object_detection import ObjectDetectionReader
  from luminoth.utils.config import is_basestring
  from luminoth.utils.dataset import read_image
label_desc: Use image node_id 1 to create a new CSVReader object from inherited base classes: ObjectDetectionReader with example: obj = CSVReader(data_dir, split, headers, columns)