              The most recently modified folder within the parent output folder. If no folders have
              been created, returns the parent output folder
  
          """
          assert self._pathoutput is not None
          folders = [] if not os.path.exists(self._pathoutput) else [
              os.path.join(self._pathoutput, folder)
              for folder in os.listdir(self._pathoutput)
              if os.path.isdir(os.path.join(self._pathoutput, folder))]
  
          folders.sort(key=os.path.getmtime)
          retval = folders[-1] if folders else self._pathoutput
          logger.debug("sorted folders: %s, return value: %s", folders, retval)
          return retval
 
</s> remove         self._pathoutput = location
 </s> add         self._output_path = location </s> remove     def previewoutput(self) -> Tuple[Image.Image, ImageTk.PhotoImage]:
        """ Tuple: First item in the tuple is the extract or convert preview image
        (:class:`PIL.Image`), the second item is the image in a format that tkinter can display
        (:class:`PIL.ImageTK.PhotoImage`).
 </s> add     def buffer(self) -> PreviewBuffer:
        """ :class:`~lib.training.PreviewBuffer` The preview buffer for the training preview
        image. """
        return self._buffer

    def load(self) -> bool:
        """ Load the latest training preview image(s) from disk and add to :attr:`buffer` """
        logger.trace("Loading Training preview images")  # type:ignore
        image_files = _get_previews(self._cache_path)
        filename = next((fname for fname in image_files
                         if os.path.basename(fname) == TRAININGPREVIEW), "")
        if not filename:
            logger.trace("No preview to display")  # type:ignore
            return False
        try:
            modified = os.path.getmtime(filename)
            if modified <= self._modified:
                logger.trace("preview '%s' not updated. Current timestamp: %s, "  # type:ignore
                             "existing timestamp: %s", filename, modified, self._modified)
                return False

            logger.debug("Loading preview: '%s'", filename)
            img = cv2.imread(filename, cv2.IMREAD_UNCHANGED)
            self._modified = modified
            self._buffer.add_image(os.path.basename(filename), img)
            self._error_count = 0
        except ValueError:
            # This is probably an error reading the file whilst it's being saved so ignore it
            # for now and only pick up if there have been multiple consecutive fails
            logger.warning("Unable to display preview: (image: '%s', attempt: %s)",
                           img, self._error_count)
            if self._error_count < 10:
                self._error_count += 1
            else:
                logger.error("Error reading the preview file for '%s'", filename)
            return False </s> remove         # TODO skip when loading in GUI?
        logger.debug("Obtaining screen geometry")
 </s> add         if not self._is_standalone:
            root = self._root.winfo_toplevel()  # Get dims of whole GUI
            retval = root.winfo_width(), root.winfo_height()
            logger.debug("Obtained frame geometry: %s", retval)
            return retval
 </s> remove         self._initialized = not self._is_standalone
 </s> add         self._initialized = False </s> remove         self._taskbar = _Taskbar(self._master_frame, self._is_standalone)
 </s> add         self._taskbar = _Taskbar(self._master_frame, taskbar)
        folders = [] if not os.path.exists(self._output_path) else [
            os.path.join(self._output_path, folder)
            for folder in os.listdir(self._output_path)
            if os.path.isdir(os.path.join(self._output_path, folder))]
              The most recently modified folder within the parent output folder. If no folders have
              been created, returns the parent output folder
  
          """
        folders = [] if not os.path.exists(self._output_path) else [
            os.path.join(self._output_path, folder)
            for folder in os.listdir(self._output_path)
            if os.path.isdir(os.path.join(self._output_path, folder))]
        folders = [] if not os.path.exists(self._output_path) else [
            os.path.join(self._output_path, folder)
            for folder in os.listdir(self._output_path)
            if os.path.isdir(os.path.join(self._output_path, folder))]
        folders = [] if not os.path.exists(self._output_path) else [
            os.path.join(self._output_path, folder)
            for folder in os.listdir(self._output_path)
            if os.path.isdir(os.path.join(self._output_path, folder))]
        folders = [] if not os.path.exists(self._output_path) else [
            os.path.join(self._output_path, folder)
            for folder in os.listdir(self._output_path)
            if os.path.isdir(os.path.join(self._output_path, folder))]
        folders = [] if not os.path.exists(self._output_path) else [
            os.path.join(self._output_path, folder)
            for folder in os.listdir(self._output_path)
            if os.path.isdir(os.path.join(self._output_path, folder))]
  
          folders.sort(key=os.path.getmtime)
          retval = folders[-1] if folders else self._pathoutput
          logger.debug("sorted folders: %s, return value: %s", folders, retval)
          return retval
keep keep keep keep replace replace replace replace replace keep keep keep keep keep
 GUI - Preview updates
  - Training preview. Embed preview pop-out window
  - Bugfix - convert/extract previews 
lib/gui/utils/image.py