  
  _IMAGES: Optional["Images"] = None
  _PREVIEW_TRIGGER: Optional["PreviewTrigger"] = None
  
  
  def initialize_images() -> None:
      """ Initialize the :class:`Images` handler  and add to global constant.
  
 
</s> remove         logger.trace("Displaying preview")  # type:ignore
        sortednames = sorted(list(get_images().previewtrain.keys()))
        existing = self.subnotebook_get_titles_ids()
        should_update = self.update_preview.get()

        for name in sortednames:
            if name not in existing:
                self.add_child(name)
            elif should_update:
                tab_id = existing[name]
                self.update_child(tab_id, name)

        if should_update:
            self.update_preview.set(False)

    def add_child(self, name: str) -> None:
        """ Add the preview canvas child

        Parameters
        ----------
        name: str
            The name of the notebook tab to add
        """
        logger.debug("Adding child")
        preview = PreviewTrainCanvas(self.subnotebook, name)
        preview = self.subnotebook_add_page(name, widget=preview)
        Tooltip(preview, text=self.helptext, wrap_length=200)
        self.vars["modified"].set(get_images().previewtrain[name][2])

    def update_child(self, tab_id: int, name: str) -> None:
        """ Update the preview canvas
 </s> add         if self.subnotebook.children:
            return </s> remove     def __init__(self) -> None:
        logger.debug("Initializing %s", self.__class__.__name__)
        self._pathpreview = os.path.join(PATHCACHE, "preview")
        self._pathoutput: Optional[str] = None
        self._batch_mode = False
        self._previewoutput: Optional[Tuple[Image.Image, ImageTk.PhotoImage]] = None
        self._previewtrain: Dict[str, List[Union[Image.Image,
                                                 ImageTk.PhotoImage,
                                                 None,
                                                 float]]] = {}
        self._previewcache: Dict[str, Union[None, float, np.ndarray, List[str]]] = dict(
            modified=None,  # cache for extract and convert
            images=None,
            filenames=[],
            placeholder=None)
        self._errcount = 0
        self._icons = self._load_icons()
 </s> add     logger.debug("Getting images: '%s'", image_path)
    if not os.path.isdir(image_path):
        logger.debug("Folder does not exist")
        return []
    files = [os.path.join(image_path, f)
             for f in os.listdir(image_path) if f.lower().endswith((".png", ".jpg"))]
    logger.debug("Image files: %s", files)
    return files


class PreviewTrain():
    """ Handles the loading of the training preview image(s) and adding to the display buffer

    Parameters
    ----------
    cache_path: str
        Full path to the cache folder that contains the preview images
    """
    def __init__(self, cache_path: str) -> None:
        logger.debug("Initializing %s: (cache_path: '%s')", self.__class__.__name__, cache_path)
        self._buffer = PreviewBuffer()
        self._cache_path = cache_path
        self._modified: float = 0.0
        self._error_count: int = 0 </s> remove         self.update_preview = get_config().tk_vars.update_preview
 </s> add         logger.debug("Initializing %s (args: %s, kwargs: %s)",
                     self.__class__.__name__, args, kwargs)
        self._preview = get_images().preview_train
        self._display: Optional[PreviewTk] = None
TRAININGPREVIEW = ".gui_training_preview.png"
  
  _IMAGES: Optional["Images"] = None
  _PREVIEW_TRIGGER: Optional["PreviewTrigger"] = None
TRAININGPREVIEW = ".gui_training_preview.png"
  
  
  def initialize_images() -> None:
      """ Initialize the :class:`Images` handler  and add to global constant.
  
keep keep add keep keep keep keep keep
 GUI - Preview updates
  - Training preview. Embed preview pop-out window
  - Bugfix - convert/extract previews 
lib/gui/utils/image.py