class_docstr: This is the Detection Model training class, which allows you to train object detection models
  on image datasets that are in Pascal VOC annotation format, using the YOLOv3.
docstr: 'setDataDirectory()' is required to set the path to which the data/dataset to be used for
           training is kept. The directory can have any name, but it must have 'train' and 'validation'
           sub-directory. In the 'train' and 'validation' sub-directories, there must be 'images' and 'annotations'
           sub-directories respectively. The 'images' folder will contain the pictures for the dataset and the
           'annotations' folder will contain the XML files with details of the annotations for each image in the
           'images folder'.
  
           N.B: Strictly take note that the filenames (without the extension) of the pictures in the 'images folder'
            must be the same as the filenames (without the extension) of their corresponding annotation XML files in
            the 'annotations' folder.
  
           The structure of the 'train' and 'validation' folder must be as follows:
  
          >> train    >> images       >> img_1.jpg
                      >> images       >> img_2.jpg
                      >> images       >> img_3.jpg
                      >> annotations  >> img_1.xml
                      >> annotations  >> img_2.xml
                      >> annotations  >> img_3.xml
  
  
          >> validation   >> images       >> img_151.jpg
                          >> images       >> img_152.jpg
                          >> images       >> img_153.jpg
                          >> annotations  >> img_151.xml
                          >> annotations  >> img_152.xml
                          >> annotations  >> img_153.xml
  
  :param data_directory:
  :return:
docstr_tok: ["'setDataDirectory","(",")","'","is","required","to","set","the","path","to","which","the","data\/dataset","to","be","used","for","training","is","kept",".","The","directory","can","have","any","name",",","but","it","must","have","'train","'","and","'validation'","sub-directory",".","In","the","'train","'","and","'validation","'","sub-directories",",","there","must","be","'images","'","and","'annotations'","sub-directories","respectively",".","The","'images","'","folder","will","contain","the","pictures","for","the","dataset","and","the","'annotations","'","folder","will","contain","the","XML","files","with","details","of","the","annotations","for","each","image","in","the","'images","folder","'",".","N.B",":","Strictly","take","note","that","the","filenames","(","without","the","extension",")","of","the","pictures","in","the","'images","folder'","must","be","the","same","as","the","filenames","(","without","the","extension",")","of","their","corresponding","annotation","XML","files","in","the","'annotations","'","folder",".","The","structure","of","the","'train","'","and","'validation","'","folder","must","be","as","follows",":",">",">","train",">",">","images",">",">","img_1.jpg",">",">","images",">",">","img_2.jpg",">",">","images",">",">","img_3.jpg",">",">","annotations",">",">","img_1.xml",">",">","annotations",">",">","img_2.xml",">",">","annotations",">",">","img_3.xml",">",">","validation",">",">","images",">",">","img_151.jpg",">",">","images",">",">","img_152.jpg",">",">","images",">",">","img_153.jpg",">",">","annotations",">",">","img_151.xml",">",">","annotations",">",">","img_152.xml",">",">","annotations",">",">","img_153.xml",":","param","data_directory",":",":","return",":"]
code: def setDataDirectory(self, data_directory):
      """
  
      'setDataDirectory()' is required to set the path to which the data/dataset to be used for
               training is kept. The directory can have any name, but it must have 'train' and 'validation'
               sub-directory. In the 'train' and 'validation' sub-directories, there must be 'images' and 'annotations'
               sub-directories respectively. The 'images' folder will contain the pictures for the dataset and the
               'annotations' folder will contain the XML files with details of the annotations for each image in the
               'images folder'.
  
               N.B: Strictly take note that the filenames (without the extension) of the pictures in the 'images folder'
                must be the same as the filenames (without the extension) of their corresponding annotation XML files in
                the 'annotations' folder.
  
               The structure of the 'train' and 'validation' folder must be as follows:
  
              >> train    >> images       >> img_1.jpg
                          >> images       >> img_2.jpg
                          >> images       >> img_3.jpg
                          >> annotations  >> img_1.xml
                          >> annotations  >> img_2.xml
                          >> annotations  >> img_3.xml
  
  
              >> validation   >> images       >> img_151.jpg
                              >> images       >> img_152.jpg
                              >> images       >> img_153.jpg
                              >> annotations  >> img_151.xml
                              >> annotations  >> img_152.xml
                              >> annotations  >> img_153.xml
  
      :param data_directory:
      :return:
      """
  
      self.__train_images_folder = os.path.join(
          data_directory, "train", "images"
      )
      self.__train_annotations_folder = os.path.join(
          data_directory, "train", "annotations"
      )
      self.__validation_images_folder = os.path.join(
          data_directory, "validation", "images"
      )
      self.__validation_annotations_folder = os.path.join(
          data_directory, "validation", "annotations"
      )
  
      os.makedirs(os.path.join(data_directory, "cache"), exist_ok=True)
      self.__train_cache_file = os.path.join(
          data_directory, "cache", "detection_train_data.pkl"
      )
      self.__validation_cache_file = os.path.join(
          data_directory, "cache", "detection_test_data.pkl"
      )
  
      os.makedirs(os.path.join(data_directory, "models"), exist_ok=True)
  
      os.makedirs(os.path.join(data_directory, "json"), exist_ok=True)
  
      os.makedirs(os.path.join(data_directory, "logs"), exist_ok=True)
  
      self.__model_directory = os.path.join(data_directory, "models")
      self.__train_weights_name = os.path.join(
          self.__model_directory, "detection_model-"
      )
      self.__json_directory = os.path.join(data_directory, "json")
      self.__logs_directory = os.path.join(data_directory, "logs")
  
imports: import os
  import re
  import numpy
  import json
  from imageai.Detection.Custom.voc import parse_voc_annotation
  from imageai.Detection.YOLO.yolov3 import yolov3_main, yolov3_train, dummy_loss
  from imageai.Detection.Custom.generator import BatchGenerator
  from imageai.Detection.Custom.utils.utils import normalize, evaluate, makedirs
  from tensorflow.keras.callbacks import ReduceLROnPlateau
  from tensorflow.keras.optimizers import Adam
  from imageai.Detection.Custom.callbacks import CustomModelCheckpoint
  from imageai.Detection.Custom.utils.multi_gpu_model import multi_gpu_model
  from imageai.Detection.Custom.gen_anchors import generateAnchors
  import tensorflow
  from tensorflow.keras.models import load_model
  from tensorflow.keras import Input
  from tensorflow.keras.callbacks import TensorBoard
  import tensorflow.keras.backend
  import cv2
label_desc: Use image node_id 3 for calling the DetectionModelTrainer obj's underlying member method code with example usage: obj.setDataDirectory(data_directory) without return types