class_docstr: This is the Detection Model training class, which allows you to train object detection models
  on image datasets that are in YOLO 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 input dataset must be in the YOLO format. 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 TXT 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 (except the extension) of their corresponding annotation TXT 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.txt
                  >> annotations  >> img_2.txt
                  >> annotations  >> img_3.txt
      >> validation   >> images       >> img_151.jpg
                      >> images       >> img_152.jpg
                      >> images       >> img_153.jpg
                      >> annotations  >> img_151.txt
                      >> annotations  >> img_152.txt
                      >> annotations  >> img_153.txt
  :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","input","dataset","must","be","in","the","YOLO","format",".","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","TXT","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","(","except","the","extension",")","of","their","corresponding","annotation","TXT","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.txt",">",">","annotations",">",">","img_2.txt",">",">","annotations",">",">","img_3.txt",">",">","validation",">",">","images",">",">","img_151.jpg",">",">","images",">",">","img_152.jpg",">",">","images",">",">","img_153.jpg",">",">","annotations",">",">","img_151.txt",">",">","annotations",">",">","img_152.txt",">",">","annotations",">",">","img_153.txt",":","param","data_directory",":",":","return",":"]
code: def setDataDirectory(self, data_directory: str):
      """
      'setDataDirectory()' is required to set the path to which the data/dataset to be used for training is kept. The input dataset must be in the YOLO format. 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 TXT 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 (except the extension) of their corresponding annotation TXT 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.txt
                      >> annotations  >> img_2.txt
                      >> annotations  >> img_3.txt
          >> validation   >> images       >> img_151.jpg
                          >> images       >> img_152.jpg
                          >> images       >> img_153.jpg
                          >> annotations  >> img_151.txt
                          >> annotations  >> img_152.txt
                          >> annotations  >> img_153.txt
      :param data_directory:
      :return:
      """
      if os.path.isdir(data_directory):
          self.__data_dir = data_directory
      else:
          raise ValueError(
              "The parameter passed should point to a valid directory"
          )
  
imports: import os
  import time
  import math
  import json
  import warnings
  from typing import List, Union, Tuple, Dict
  from collections import defaultdict
  import numpy
  from PIL import Image
  import cv2
  import torch
  from torch.cuda import amp
  from torch.utils.data import DataLoader
  from torch.optim import SGD, lr_scheduler
  from tqdm import tqdm
  from .yolo.dataset import LoadImagesAndLabels
  from .yolo.custom_anchors import generate_anchors
  from .yolo.compute_loss import compute_loss
  from .yolo import validate
  from ...yolov3.tiny_yolov3 import YoloV3Tiny
  from ...yolov3.yolov3 import YoloV3
  from ...yolov3.utils import draw_bbox_and_label, get_predictions, prepare_image
  from ...backend_check.model_extension import extension_check
label_desc: Use image node_id 7 for calling the DetectionModelTrainer obj's underlying member method code with example usage: obj.setDataDirectory(data_directory) without return types