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: 'trainModel()' function starts the actual model training. Once the training starts, the training instance
  creates 3 sub-folders in your dataset folder which are:
  
  - json,  where the JSON configuration file for using your trained model is stored
  - models, where your trained models are stored once they are generated after each improved experiments
  - cache , where temporary traing configuraton files are stored
  
  :return:
docstr_tok: ["'trainModel","(",")","'","function","starts","the","actual","model","training",".","Once","the","training","starts",",","the","training","instance","creates","3","sub-folders","in","your","dataset","folder","which","are",":","-","json",",","where","the","JSON","configuration","file","for","using","your","trained","model","is","stored","-","models",",","where","your","trained","models","are","stored","once","they","are","generated","after","each","improved","experiments","-","cache",",","where","temporary","traing","configuraton","files","are","stored",":","return",":"]
code: def trainModel(self):
      """
      'trainModel()' function starts the actual model training. Once the training starts, the training instance
      creates 3 sub-folders in your dataset folder which are:
  
      - json,  where the JSON configuration file for using your trained model is stored
      - models, where your trained models are stored once they are generated after each improved experiments
      - cache , where temporary traing configuraton files are stored
  
      :return:
      """
  
      (
          train_ints,
          valid_ints,
          labels,
          max_box_per_image,
      ) = self._create_training_instances(
          self.__train_annotations_folder,
          self.__train_images_folder,
          self.__train_cache_file,
          self.__validation_annotations_folder,
          self.__validation_images_folder,
          self.__validation_cache_file,
          self.__model_labels,
      )
      if self.__training_mode:
          print("Training on: \t" + str(labels) + "")
          print("Training with Batch Size: ", self.__train_batch_size)
          print("Number of Training Samples: ", len(train_ints))
          print("Number of Validation Samples: ", len(valid_ints))
          print("Number of Experiments: ", self.__train_epochs)
  
      ###############################
      #   Create the generators
      ###############################
      train_generator = BatchGenerator(
          instances=train_ints,
          anchors=self.__model_anchors,
          labels=labels,
          downsample=32,  # ratio between network input's size and network output's size, 32 for YOLOv3
          max_box_per_image=max_box_per_image,
          batch_size=self.__train_batch_size,
          min_net_size=self.__model_min_input_size,
          max_net_size=self.__model_max_input_size,
          shuffle=True,
          jitter=0.3,
          norm=normalize,
      )
  
      valid_generator = BatchGenerator(
          instances=valid_ints,
          anchors=self.__model_anchors,
          labels=labels,
          downsample=32,  # ratio between network input's size and network output's size, 32 for YOLOv3
          max_box_per_image=max_box_per_image,
          batch_size=self.__train_batch_size,
          min_net_size=self.__model_min_input_size,
          max_net_size=self.__model_max_input_size,
          shuffle=True,
          jitter=0.0,
          norm=normalize,
      )
  
      ###############################
      #   Create the model
      ###############################
      if os.path.exists(self.__pre_trained_model):
          self.__train_warmup_epochs = 0
      warmup_batches = self.__train_warmup_epochs * (
          self.__train_times * len(train_generator)
      )
  
      os.environ["CUDA_VISIBLE_DEVICES"] = self.__train_gpus
      multi_gpu = [int(gpu) for gpu in self.__train_gpus.split(",")]
  
      """train_model, infer_model = self._create_model(
              nb_class=len(labels),
              anchors=self.__model_anchors,
              max_box_per_image=max_box_per_image,
              max_grid=[self.__model_max_input_size, self.__model_max_input_size],
              batch_size=self.__train_batch_size,
              warmup_batches=warmup_batches,
              ignore_thresh=self.__train_ignore_treshold,
              multi_gpu=multi_gpu,
              lr=self.__train_learning_rate,
              grid_scales=self.__train_grid_scales,
              obj_scale=self.__train_obj_scale,
              noobj_scale=self.__train_noobj_scale,
              xywh_scale=self.__train_xywh_scale,
              class_scale=self.__train_class_scale,
          )"""
  
      train_model, infer_model = self._create_model(
          nb_class=len(labels),
          anchors=self.__model_anchors,
          max_box_per_image=max_box_per_image,
          max_grid=[
              self.__model_max_input_size,
              self.__model_max_input_size,
          ],
          batch_size=self.__train_batch_size,
          warmup_batches=warmup_batches,
          ignore_thresh=self.__train_ignore_treshold,
          multi_gpu=multi_gpu,
          lr=self.__train_learning_rate,
          grid_scales=self.__train_grid_scales,
          obj_scale=self.__train_obj_scale,
          noobj_scale=self.__train_noobj_scale,
          xywh_scale=self.__train_xywh_scale,
          class_scale=self.__train_class_scale,
      )
  
      ###############################
      #   Kick off the training
      ###############################
      callbacks = self._create_callbacks(
          self.__train_weights_name, infer_model
      )
  
      train_model.fit_generator(
          generator=train_generator,
          steps_per_epoch=len(train_generator) * self.__train_times,
          validation_data=valid_generator,
          validation_steps=len(valid_generator) * self.__train_times,
          epochs=self.__train_epochs + self.__train_warmup_epochs,
          verbose=1,
          callbacks=callbacks,
          workers=4,
          max_queue_size=8,
      )
  
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 6 for calling the DetectionModelTrainer obj's underlying member method code with example usage: obj.trainModel() without return types