                  raise
  
              if output == "" and self.process.poll() is not None:
                  break
              if output:
                  self._process_training_stdout(output)
                  print(output.rstrip())
  
          returncode = self.process.poll()
 
</s> remove                 if ((self.command == "train" and self.capture_loss(output)) or
                        (self.command == "effmpeg" and self.capture_ffmpeg(output)) or
                        (self.command not in ("train", "effmpeg") and self.capture_tqdm(output))):
                    continue
                if self.command == "train" and self.wrapper.tk_vars.is_training.get():
                    if "[saved models]" in output.strip().lower():
                        logger.debug("Trigger GUI Training update")
                        logger.trace("tk_vars: %s",
                                     {itm: var.get()
                                      for itm, var in self.wrapper.tk_vars.__dict__.items()})
                        if not Session.is_training:
                            # Don't initialize session until after the first save as state
                            # file must exist first
                            logger.debug("Initializing curret training session")
                            Session.initialize_session(
                                self._session_info["model_folder"],
                                self._session_info["model_name"],
                                is_training=True)
                        self.wrapper.tk_vars.update_preview.set(True)
                        self.wrapper.tk_vars.refresh_graph.set(True)
                    if "[preview updated]" in output.strip().lower():
                        self.wrapper.tk_vars.update_preview.set(True)
                        continue
 </s> add                 self._process_training_stdout(output) </s> remove     def read_stdout(self):
        """ Read stdout from the subprocess. If training, pass the loss
        values to Queue """
 </s> add     def _process_progress_stdout(self, output: str) -> bool:
        """ Process stdout for any faceswap processes that update the status/progress bar(s)

        Parameters
        ----------
        output: str
            The output line read from stdout

        Returns
        -------
        bool
            ``True`` if all actions have been completed on the output line otherwise ``False``
        """
        if self.command == "train" and self.capture_loss(output):
            return True

        if self.command == "effmpeg" and self.capture_ffmpeg(output):
            return True

        if self.command not in ("train", "effmpeg") and self.capture_tqdm(output):
            return True

        return False

    def _process_training_stdout(self, output: str) -> None:
        """ Process any triggers that are required to update the GUI when Faceswap is running a
        training session.

        Parameters
        ----------
        output: str
            The output line read from stdout
        """
        if self.command != "train" or not self.wrapper.tk_vars.is_training.get():
            return

        if "[saved models]" not in output.strip().lower():
            return

        logger.debug("Trigger GUI Training update")
        logger.trace("tk_vars: %s", {itm: var.get()  # type:ignore
                                     for itm, var in self.wrapper.tk_vars.__dict__.items()})
        if not Session.is_training:
            # Don't initialize session until after the first save as state file must exist first
            logger.debug("Initializing curret training session")
            Session.initialize_session(self._session_info["model_folder"],
                                       self._session_info["model_name"],
                                       is_training=True)
        self.wrapper.tk_vars.refresh_graph.set(True)

    def read_stdout(self) -> None:
        """ Read stdout from the subprocess. """ </s> remove         logger.debug("Resizing image: (name: '%s', frame_dims: %s", name, frame_dims)
        displayimg = cast(Image.Image, self._previewtrain[name][0])
        if frame_dims:
            frameratio = float(frame_dims[0]) / float(frame_dims[1])
            imgratio = float(displayimg.size[0]) / float(displayimg.size[1])

            if frameratio <= imgratio:
                scale = frame_dims[0] / float(displayimg.size[0])
                size = (frame_dims[0], int(displayimg.size[1] * scale))
            else:
                scale = frame_dims[1] / float(displayimg.size[1])
                size = (int(displayimg.size[0] * scale), frame_dims[1])
            logger.debug("Scaling: (scale: %s, size: %s", scale, size)

            # Hacky fix to force a reload if it happens to find corrupted
            # data, probably due to reading the image whilst it is partially
            # saved. If it continues to fail, then eventually raise.
            for i in range(0, 1000):
                try:
                    displayimg = displayimg.resize(size, Image.ANTIALIAS)
                except OSError:
                    if i == 999:
                        raise
                    continue
                break
        self._previewtrain[name][1] = ImageTk.PhotoImage(displayimg)
 </s> add         logger.debug("Deleting previews")
        for item in os.listdir(self._pathpreview):
            if item.startswith(os.path.splitext(TRAININGPREVIEW)[0]) and item.endswith((".jpg",
                                                                                        ".png")):
                fullitem = os.path.join(self._pathpreview, item)
                logger.debug("Deleting: '%s'", fullitem)
                os.remove(fullitem)

        self._preview_extract.delete_previews()
        del self._preview_train
        del self._preview_extract
        self._preview_train = PreviewTrain(self._pathpreview)
        self._preview_extract = PreviewExtract(self._pathpreview) </s> remove         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))]
 </s> add         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))]
            if output and self._process_progress_stdout(output):
                continue

                  raise
  
              if output == "" and self.process.poll() is not None:
                  break
            if output and self._process_progress_stdout(output):
                continue

              if output:
                  self._process_training_stdout(output)
                  print(output.rstrip())
  
          returncode = self.process.poll()
keep keep keep add keep keep keep keep keep
 GUI - Preview updates
  - Training preview. Embed preview pop-out window
  - Bugfix - convert/extract previews 
lib/gui/wrapper.py