class_docstr: Generate data for a custom CSV dataset.
  
  See https://github.com/fizyr/keras-retinanet#csv-datasets for more information.
class_docstr_tok: ["Generate","data","for","a","custom","CSV","dataset",".","See","https",":","\/\/github.com\/fizyr\/keras-retinanet","#","csv-datasets","for","more","information","."]
docstr: Initialize a CSV data generator.
  
  Args
      csv_data_file: Path to the CSV annotations file.
      csv_class_file: Path to the CSV classes file.
      base_dir: Directory w.r.t. where the files are to be searched (defaults to the directory containing the csv_data_file).
docstr_tok: ["Initialize","a","CSV","data","generator",".","Args","csv_data_file",":","Path","to","the","CSV","annotations","file",".","csv_class_file",":","Path","to","the","CSV","classes","file",".","base_dir",":","Directory","w.r.t",".","where","the","files","are","to","be","searched","(","defaults","to","the","directory","containing","the","csv_data_file",")","."]
code: def __init__(
      self, csv_data_file, csv_class_file, base_dir=None, **kwargs
  ):
      """Initialize a CSV data generator.
  
      Args
          csv_data_file: Path to the CSV annotations file.
          csv_class_file: Path to the CSV classes file.
          base_dir: Directory w.r.t. where the files are to be searched (defaults to the directory containing the csv_data_file).
      """
      self.image_names = []
      self.image_data = {}
      self.base_dir = base_dir
  
      # Take base_dir from annotations file if not explicitly specified.
      if self.base_dir is None:
          self.base_dir = os.path.dirname(csv_data_file)
  
      # parse the provided class file
      try:
          with _open_for_csv(csv_class_file) as file:
              self.classes = _read_classes(
                  csv.reader(file, delimiter=",")
              )
      except ValueError as e:
          raise_from(
              ValueError(
                  "invalid CSV class file: {}: {}".format(
                      csv_class_file, e
                  )
              ),
              None,
          )
  
      self.labels = {}
      for key, value in self.classes.items():
          self.labels[value] = key
  
      # csv with img_path, x1, y1, x2, y2, class_name
      try:
          with _open_for_csv(csv_data_file) as file:
              self.image_data = _read_annotations(
                  csv.reader(file, delimiter=","), self.classes
              )
      except ValueError as e:
          raise_from(
              ValueError(
                  "invalid CSV annotations file: {}: {}".format(
                      csv_data_file, e
                  )
              ),
              None,
          )
      self.image_names = list(self.image_data.keys())
  
      super(CSVGenerator, self).__init__(**kwargs)
  
imports: from .generator import Generator
  from ..utils.image import read_image_bgr
  import numpy
  from PIL import Image
  from six import raise_from
  import csv
  import sys
  import os.path
  from collections import OrderedDict
label_desc: Use image node_id 1 to create a new CSVGenerator object from inherited base classes: Generator with example: obj = CSVGenerator(csv_data_file, csv_class_file, base_dir)