class_docstr: A text detector using the CRAFT architecture.
  
  Args:
      weights: The weights to use for the model. Currently, only `clovaai_general`
          is supported.
      load_from_torch: Whether to load the weights from the original PyTorch weights.
      optimizer: The optimizer to use for training the model.
      backbone_name: The backbone to use. Currently, only 'vgg' is supported.
class_docstr_tok: ["A","text","detector","using","the","CRAFT","architecture",".","Args",":","weights",":","The","weights","to","use","for","the","model",".","Currently",",","only","`","clovaai_general","`","is","supported",".","load_from_torch",":","Whether","to","load","the","weights","from","the","original","PyTorch","weights",".","optimizer",":","The","optimizer","to","use","for","training","the","model",".","backbone_name",":","The","backbone","to","use",".","Currently",",","only","'vgg","'","is","supported","."]
docstr: Get a generator of X, y batches to train the detector.
  
  Args:
      image_generator: A generator with the same signature as
          keras_ocr.tools.get_image_generator. Optionally, a third
          entry in the tuple (beyond image and lines) can be provided
          which will be interpreted as the sample weight.
      batch_size: The size of batches to generate.
      heatmap_size: The size of the heatmap to pass to get_gaussian_heatmap
      heatmap_distance_ratio: The distance ratio to pass to
          get_gaussian_heatmap. The larger the value, the more tightly
          concentrated the heatmap becomes.
docstr_tok: ["Get","a","generator","of","X",",","y","batches","to","train","the","detector",".","Args",":","image_generator",":","A","generator","with","the","same","signature","as","keras_ocr.tools.get_image_generator",".","Optionally",",","a","third","entry","in","the","tuple","(","beyond","image","and","lines",")","can","be","provided","which","will","be","interpreted","as","the","sample","weight",".","batch_size",":","The","size","of","batches","to","generate",".","heatmap_size",":","The","size","of","the","heatmap","to","pass","to","get_gaussian_heatmap","heatmap_distance_ratio",":","The","distance","ratio","to","pass","to","get_gaussian_heatmap",".","The","larger","the","value",",","the","more","tightly","concentrated","the","heatmap","becomes","."]
code: def get_batch_generator(
      self,
      image_generator,
      batch_size=8,
      heatmap_size=512,
      heatmap_distance_ratio=1.5,
  ):
      """Get a generator of X, y batches to train the detector.
  
      Args:
          image_generator: A generator with the same signature as
              keras_ocr.tools.get_image_generator. Optionally, a third
              entry in the tuple (beyond image and lines) can be provided
              which will be interpreted as the sample weight.
          batch_size: The size of batches to generate.
          heatmap_size: The size of the heatmap to pass to get_gaussian_heatmap
          heatmap_distance_ratio: The distance ratio to pass to
              get_gaussian_heatmap. The larger the value, the more tightly
              concentrated the heatmap becomes.
      """
      heatmap = get_gaussian_heatmap(
          size=heatmap_size, distanceRatio=heatmap_distance_ratio
      )
      while True:
          batch = [next(image_generator) for n in range(batch_size)]
          images = np.array([entry[0] for entry in batch])
          line_groups = [entry[1] for entry in batch]
          X = compute_input(images)
          # pylint: disable=unsubscriptable-object
          y = np.array(
              [
                  compute_maps(
                      heatmap=heatmap,
                      image_height=images.shape[1],
                      image_width=images.shape[2],
                      lines=lines,
                  )
                  for lines in line_groups
              ]
          )
          # pylint: enable=unsubscriptable-object
          if len(batch[0]) == 3:
              sample_weights = np.array([sample[2] for sample in batch])
              yield X, y, sample_weights
          else:
              yield X, y
  
imports: import typing
  import cv2
  import numpy
  import tensorflow
  import efficientnet.tfkeras
  from tensorflow import keras
  from .None import tools
label_desc: Use image node_id 2 for calling the Detector obj's underlying member method code with example usage: obj.get_batch_generator(image_generator, batch_size, heatmap_size, heatmap_distance_ratio) without return types