code: def get_detector_image_generator(
      labels,
      width,
      height,
      augmenter=None,
      area_threshold=0.5,
      focused=False,
      min_area=None,
      shuffle=True,
  ):
      """Generated augmented (image, lines) tuples from a list
      of (filepath, lines, confidence) tuples. Confidence is
      not used right now but is included for a future release
      that uses semi-supervised data.
  
      Args:
          labels: A list of (image, lines, confience) tuples.
          augmenter: An augmenter to apply to the images.
          width: The width to use for output images
          height: The height to use for output images
          area_threshold: The area threshold to use to keep
              characters in augmented images.
          min_area: The minimum area for a character to be
              included.
          focused: Whether to pre-crop images to width/height containing
              a region containing text.
          shuffle: Whether to shuffle the data on each iteration.
      """
      labels = labels.copy()
      for index in itertools.cycle(range(len(labels))):
          if index == 0 and shuffle:
              random.shuffle(labels)
          image_filepath, lines, confidence = labels[index]
          image = tools.read(image_filepath)
          if augmenter is not None:
              image, lines = tools.augment(
                  boxes=lines,
                  boxes_format="lines",
                  image=image,
                  area_threshold=area_threshold,
                  min_area=min_area,
                  augmenter=augmenter,
              )
          if focused:
              boxes = [tools.combine_line(line)[0] for line in lines]
              if boxes:
                  selected = np.array(
                      boxes[np.random.choice(len(boxes))]
                  )
                  left, top = (
                      selected.min(axis=0).clip(0, np.inf).astype("int")
                  )
                  if left > 0:
                      left -= np.random.randint(0, min(left, width / 2))
                  if top > 0:
                      top -= np.random.randint(0, min(top, height / 2))
                  image, lines = tools.augment(
                      boxes=lines,
                      augmenter=imgaug.augmenters.Sequential(
                          [
                              imgaug.augmenters.Crop(
                                  px=(int(top), 0, 0, int(left))
                              ),
                              imgaug.augmenters.CropToFixedSize(
                                  width=width,
                                  height=height,
                                  position="right-bottom",
                              ),
                          ]
                      ),
                      boxes_format="lines",
                      image=image,
                      min_area=min_area,
                      area_threshold=area_threshold,
                  )
          image, scale = tools.fit(
              image,
              width=width,
              height=height,
              mode="letterbox",
              return_scale=True,
          )
          lines = tools.adjust_boxes(
              boxes=lines, boxes_format="lines", scale=scale
          )
          yield image, lines, confidence
  
imports: import concurrent.futures
  import itertools
  import warnings
  import typing
  import zipfile
  import random
  import glob
  import json
  import os
  import tqdm
  import imgaug
  import PIL.Image
  import numpy
  from .None import tools
label_desc: Use image node_id 7 for calling a global function with example usage: get_detector_image_generator(labels, width, height, augmenter, area_threshold, focused, min_area, shuffle) without return types