          cmd = sys.argv
          if not self.check_display(cmd) or not self.check_tkinter_available(cmd):
              return
  
          self.arguments = None
          self.opts = self.extract_options(subparsers)
          self.utils = Utils(self.opts, calling_file=cmd[0])
          self.root = FaceswapGui(self.utils, calling_file=cmd[0])
          self.parse_arguments(description, subparser, command)
  
 
</s> remove         cmd = sys.argv
        if not self.check_display(cmd) or not self.check_tkinter_available(cmd):
 </s> add         if not self.check_display() or not self.check_tkinter_available(): </s> remove         self.parse_arguments(description, subparser, command)
 </s> add  </s> remove     def check_display(command):
 </s> add     def check_display(): </s> remove class TKGui(object):
    """ Main GUI Control """

    def __init__(self, subparser, subparsers, command, description='default'):
 </s> add class Gui(object):
    """ The GUI process. """
    def __init__(self, arguments, subparsers): </s> remove tf = None
set_session = None
def import_tensorflow_keras():
    ''' Import the TensorFlow and keras set_session modules only when they are required '''
    global tf
    global set_session
    if tf is None or set_session is None:
        import tensorflow
        import keras.backend.tensorflow_backend
        tf = tensorflow
        set_session = keras.backend.tensorflow_backend.set_session

class TrainingProcessor(object):
    arguments = None

    def __init__(self, subparser, command, description='default'):
        self.argument_list = self.get_argument_list()
        self.optional_arguments = self.get_optional_arguments()
        self.parse_arguments(description, subparser, command)
        self.lock = threading.Lock()
 </s> add import cv2
import tensorflow as tf
from keras.backend.tensorflow_backend import set_session
        cmd = sys.argv

        self.args = arguments
          cmd = sys.argv
          if not self.check_display(cmd) or not self.check_tkinter_available(cmd):
              return
  
        cmd = sys.argv

        self.args = arguments
          self.opts = self.extract_options(subparsers)
          self.utils = Utils(self.opts, calling_file=cmd[0])
          self.root = FaceswapGui(self.utils, calling_file=cmd[0])
          self.parse_arguments(description, subparser, command)
  
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