              The (width (`int`), height (`int`)) of the display panel that will display the preview
          """
          logger.debug("Loading preview image: (thumbnail_size: %s, frame_dims: %s)",
                       thumbnail_size, frame_dims)
          image_files = self._get_images(self._pathoutput)
          gui_preview = os.path.join(self._pathoutput, ".gui_preview.jpg")
          if not image_files or (len(image_files) == 1 and gui_preview not in image_files):
              logger.debug("No preview to display")
              return
          # Filter to just the gui_preview if it exists in folder output
 
</s> remove         displayimg = self._previewtrain[name][0]
 </s> add         displayimg = cast(Image.Image, self._previewtrain[name][0]) </s> remove                       if os.path.getmtime(fname) > self._previewcache["modified"]]
 </s> add                       if os.path.getmtime(fname) > cast(float, self._previewcache["modified"])] </s> remove     def load_latest_preview(self, thumbnail_size, frame_dims):
 </s> add     def load_latest_preview(self, thumbnail_size: int, frame_dims: Tuple[int, int]) -> None: </s> remove             if img.size[0] != img.size[1]:
                # Pad to square
                new_img = Image.new("RGB", (thumbnail_size, thumbnail_size))
                new_img.paste(img, ((thumbnail_size - img.size[0])//2,
                                    (thumbnail_size - img.size[1])//2))
                img = new_img
            draw = ImageDraw.Draw(img)
            draw.rectangle(((0, 0), (thumbnail_size, thumbnail_size)), outline="#E5E5E5", width=1)
            samples.append(np.array(img))

        samples = np.array(samples)
        if not np.any(samples):
 </s> add             samples.append(self._pad_and_border(img, thumbnail_size))

        return self._process_samples(samples,
                                     [fname for fname in show_files if fname not in dropped_files],
                                     num_images)

    def _pad_and_border(self, image: Image.Image, size: int) -> np.ndarray:
        """ Pad rectangle images to a square and draw borders

        Parameters
        ----------
        image: :class:`PIL.Image`
            The image to process
        size: int
            The size of the image as it should be displayed

        Returns
        -------
        :class:`PIL.Image`:
            The processed image
        """
        if image.size[0] != image.size[1]:
            # Pad to square
            new_img = Image.new("RGB", (size, size))
            new_img.paste(image, ((size - image.size[0]) // 2, (size - image.size[1]) // 2))
            image = new_img
        draw = ImageDraw.Draw(image)
        draw.rectangle(((0, 0), (size, size)), outline="#E5E5E5", width=1)
        retval = np.array(image)
        logger.trace("image shape: %s", retval.shape)  # type: ignore
        return retval

    def _process_samples(self,
                         samples: List[np.ndarray],
                         filenames: List[str],
                         num_images: int) -> bool:
        """ Process the latest sample images into a displayable image.

        Parameters
        ----------
        samples: list
            The list of extract/convert preview images to display
        filenames: list
            The full path to the filenames corresponding to the images
        num_images: int
            The number of images that should be displayed

        Returns
        -------
        bool
            ``True`` if samples succesfully compiled otherwise ``False``
        """
        asamples = np.array(samples)
        if not np.any(asamples): </s> remove     def _load_images_to_cache(self, image_files, frame_dims, thumbnail_size):
 </s> add     def _load_images_to_cache(self,
                              image_files: List[str],
                              frame_dims: Tuple[int, int],
                              thumbnail_size: int) -> bool:
        assert self._pathoutput is not None
        image_path = self._get_newest_folder() if self._batch_mode else self._pathoutput
        image_files = self._get_images(image_path)
              The (width (`int`), height (`int`)) of the display panel that will display the preview
          """
          logger.debug("Loading preview image: (thumbnail_size: %s, frame_dims: %s)",
                       thumbnail_size, frame_dims)
        assert self._pathoutput is not None
        image_path = self._get_newest_folder() if self._batch_mode else self._pathoutput
        image_files = self._get_images(image_path)
          gui_preview = os.path.join(self._pathoutput, ".gui_preview.jpg")
          if not image_files or (len(image_files) == 1 and gui_preview not in image_files):
              logger.debug("No preview to display")
              return
          # Filter to just the gui_preview if it exists in folder output
keep keep keep keep replace keep keep keep keep keep
 Bugfix: Preview for extract in batch mode 
lib/gui/utils.py