  import cv2
  import numpy
  import time
  
  import threading 
  from lib.utils import get_image_paths, get_folder
  from lib.cli import FullPaths, argparse, os, sys
  from plugins.PluginLoader import PluginLoader
 
</s> remove import threading 
from lib.utils import get_image_paths, get_folder
from lib.cli import FullPaths, argparse, os, sys
from plugins.PluginLoader import PluginLoader
 </s> add import os
import sys
import threading </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 </s> remove from lib.cli import DirectoryProcessor, rotate_image
from lib.utils import get_folder
 </s> add  </s> remove import os
import numpy as np
 </s> add  </s> remove from lib.cli import DirectoryProcessor, FullPaths
from lib.utils import BackgroundGenerator, get_folder, get_image_paths, rotate_image
 </s> add from scripts.fsmedia import Alignments, Images, Faces, Utils
from scripts.extract import Extract
from lib.utils import BackgroundGenerator, get_folder, get_image_paths
#!/usr/bin python3
""" The script to run the training process of faceswap """
#!/usr/bin python3
""" The script to run the training process of faceswap """
#!/usr/bin python3
""" The script to run the training process of faceswap """
#!/usr/bin python3
""" The script to run the training process of faceswap """
  
  import threading 
  from lib.utils import get_image_paths, get_folder
  from lib.cli import FullPaths, argparse, os, sys
  from plugins.PluginLoader import PluginLoader
replace replace 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/train.py