              return False
          return True
  
      @staticmethod
      def check_tkinter_available(command):
          """ Check whether TkInter is installed on user's machine """
          tkinter_vars = [tk, ttk, filedialog, messagebox, TclError]
          if any(var is None for var in tkinter_vars):
              if "gui" in command:
                  print(
 
</s> remove             if "gui" in command:
                print(
                    "It looks like TkInter isn't installed for your OS, so "
                    "the GUI has been "
                    "disabled. To enable the GUI please install the TkInter "
                    "application.\n"
                    "You can try:\n"
                    "  Windows/macOS:      Install ActiveTcl Community "
                    "Edition from "
                    "www.activestate.com\n"
                    "  Ubuntu/Mint/Debian: sudo apt install python3-tk\n"
                    "  Arch:               sudo pacman -S tk\n"
                    "  CentOS/Redhat:      sudo yum install tkinter\n"
                    "  Fedora:             sudo dnf install python3-tkinter\n",
                    file=sys.stderr)
 </s> add             print(
                "It looks like TkInter isn't installed for your OS, so "
                "the GUI has been "
                "disabled. To enable the GUI please install the TkInter "
                "application.\n"
                "You can try:\n"
                "  Windows/macOS:      Install ActiveTcl Community "
                "Edition from "
                "www.activestate.com\n"
                "  Ubuntu/Mint/Debian: sudo apt install python3-tk\n"
                "  Arch:               sudo pacman -S tk\n"
                "  CentOS/Redhat:      sudo yum install tkinter\n"
                "  Fedora:             sudo dnf install python3-tkinter\n",
                file=sys.stderr) </s> remove             if 'gui' in command:
                print('Could not detect a display. The GUI has been disabled.')
                if os.name == 'posix':
                    print('macOS users need to install XQuartz. '
                          'See https://support.apple.com/en-gb/HT201341')
 </s> add             if os.name == 'posix':
                print('macOS users need to install XQuartz. '
                      'See https://support.apple.com/en-gb/HT201341') </s> remove     def check_display(command):
 </s> add     def check_display(): </s> remove         self.parse_arguments(description, subparser, command)
 </s> add  </s> remove                 trainer.train_one_step(epoch, self.show if (save_iteration or self.save_now) else None)
 </s> add             self.run_training_cycle(model, trainer)
        except KeyboardInterrupt:
            try:
                model.save_weights()
            except KeyboardInterrupt:
                print("Saving model weights has been cancelled!")
            exit(0)
        except Exception as err:
            raise err

    def load_model(self):
        """ Load the model requested for training """
        model_dir = get_folder(self.args.model_dir)
        model = PluginLoader.get_model(self.trainer_name)(model_dir, self.args.gpus)

        model.load(swapped=False)
        return model

    def load_trainer(self, model):
        """ Load the trainer requested for traning """
        images_a, images_b = self.images

        trainer = PluginLoader.get_trainer(self.trainer_name)
        trainer = trainer(model,
                          images_a,
                          images_b,
                          self.args.batch_size,
                          self.args.perceptual_loss)
        return trainer

    def run_training_cycle(self, model, trainer):
        """ Perform the training cycle """
        for epoch in range(0, self.args.epochs):
            save_iteration = epoch % self.args.save_interval == 0
            viewer = self.show if save_iteration or self.save_now else None
            trainer.train_one_step(epoch, viewer)
            if self.stop:
                break
            elif save_iteration:
                model.save_weights()
            elif self.save_now:
                model.save_weights()
                self.save_now = False
        model.save_weights()
        self.stop = True
    def check_tkinter_available():
              return False
          return True
  
      @staticmethod
    def check_tkinter_available():
          """ Check whether TkInter is installed on user's machine """
          tkinter_vars = [tk, ttk, filedialog, messagebox, TclError]
          if any(var is None for var in tkinter_vars):
              if "gui" in command:
                  print(
keep keep keep keep replace keep keep keep keep keep
 cli/scripts Refactor (#367)

* Refactor for PEP 8 and split process function

* Remove backwards compatibility for skip frames

* Split optional functions into own class. Make functions more modular

* Conform scripts folder to PEP 8

* train.py - Fix write image bug. Make more modular

* extract.py - Make more modular, Put optional actions into own class

* cli.py - start PEP 8

* cli,py - Pep 8. Refactor and make modular. Bugfixes

* 1st round refactor. Completely untested and probably broken.

* convert.py: Extract alignments from frames if they don't exist

* BugFix: SkipExisting broken since face name refactor

* Extract.py tested

* Minor formatting

* convert.py + train.py amended not tested

* train.py - Semi-fix for hang on reaching target iteration. Now quits on preview mode
Make tensorflow / system warning less verbose

* 2nd pass refactor. Semi tested

bugfixes

* Remove obsolete code. imread/write to Utils

* rename inout.py to fsmedia.py

* Final bugfixes 
scripts/gui.py