          return sum(scores) / len(scores)
  
  
  def bad_args(args):
      parser.print_help()
      exit(0)
  
  
  if __name__ == "__main__":
      __warning_string = "Important: face-cnn method will cause an error when "
 
</s> remove     parser.print_help()
 </s> add     """ Print help on bad arguments """
    PARSER.print_help() </s> remove         import_face_recognition()
 </s> add  </s> remove     @staticmethod
    def get_argument_list():
        log_filetypes = [["Serializers", ['json', 'yaml']],
                         ["JSON", ["json"]],
                         ["YAML", ["yaml"]]]
        log_filetypes = FileFullPaths.prep_filetypes(log_filetypes)

        arguments_list = list()
        arguments_list.append({"opts": ('-i', '--input'),
                               "action": DirFullPaths,
                               "dest": "input_dir",
                               "default": "input_dir",
                               "help": "Input directory of aligned faces.",
                               "required": True})

        arguments_list.append({"opts": ('-o', '--output'),
                               "action": DirFullPaths,
                               "dest": "output_dir",
                               "default": "_output_dir",
                               "help": "Output directory for sorted aligned "
                                       "faces."})

        arguments_list.append({"opts": ('-fp', '--final-process'),
                               "type": str,
                               "choices": ("folders", "rename"),
                               "dest": 'final_process',
                               "default": "rename",
                               "help": "'folders': files are sorted using the "
                                       "-s/--sort-by method, then they are "
                                       "organized into folders using the "
                                       "-g/--group-by grouping method. "
                                       "'rename': files are sorted using the "
                                       "-s/--sort-by then they are renamed. "
                                       "Default: rename"})

        arguments_list.append({"opts": ('-k', '--keep'),
                               "action": 'store_true',
                               "dest": 'keep_original',
                               "default": False,
                               "help": "Keeps the original files in the input "
                                       "directory. Be careful when using this "
                                       "with rename grouping and no specified "
                                       "output directory as this would keep "
                                       "the original and renamed files in the "
                                       "same directory."})

        arguments_list.append({"opts": ('-s', '--sort-by'),
                               "type": str,
                               "choices": ("blur", "face", "face-cnn",
                                           "face-cnn-dissim", "face-dissim",
                                           "face-yaw", "hist",
                                           "hist-dissim"),
                               "dest": 'sort_method',
                               "default": "hist",
                               "help": "Sort by method. "
                                       "Choose how images are sorted. "
                                       "Default: hist"})

        arguments_list.append({"opts": ('-g', '--group-by'),
                               "type": str,
                               "choices": ("blur", "face", "face-cnn",
                                           "face-yaw", "hist"),
                               "dest": 'group_method',
                               "default": "hist",
                               "help": "Group by method. "
                                       "When -fp/--final-processing by "
                                       "folders choose the how the images are "
                                       "grouped after sorting. "
                                       "Default: hist"})

        arguments_list.append({"opts": ('-t', '--ref_threshold'),
                               "type": float,
                               "dest": 'min_threshold',
                               "default": -1.0,
                               "help": "Float value. "
                                       "Minimum threshold to use for grouping "
                                       "comparison with 'face' and 'hist' "
                                       "methods. The lower the value the more "
                                       "discriminating the grouping is. "
                                       "Leaving -1.0 will make the program "
                                       "set the default value automatically. "
                                       "For face 0.6 should be enough, with "
                                       "0.5 being very discriminating. "
                                       "For face-cnn 7.2 should be enough, "
                                       "with 4 being very discriminating. "
                                       "For hist 0.3 should be enough, with "
                                       "0.2 being very discriminating. "
                                       "Be careful setting a value that's too "
                                       "low in a directory with many images, "
                                       "as this could result in a lot of "
                                       "directories being created. "
                                       "Defaults: face 0.6, face-cnn 7.2, "
                                       "hist 0.3"})

        arguments_list.append({"opts": ('-b', '--bins'),
                               "type": int,
                               "dest": 'num_bins',
                               "default": 5,
                               "help": "Integer value. "
                                       "Number of folders that will be used "
                                       "to group by blur and face-yaw. "
                                       "For blur folder 0 will be the least "
                                       "blurry, while the last folder will be "
                                       "the blurriest. "
                                       "For face-yaw the number of bins is by "
                                       "how much 180 degrees is divided. So "
                                       "if you use 18, then each folder will "
                                       "be a 10 degree increment. Folder 0 "
                                       "will contain faces looking the most "
                                       "to the left whereas the last folder "
                                       "will contain the faces looking the "
                                       "most to the right. "
                                       "If the number of images doesn't "
                                       "divide evenly into the number of "
                                       "bins, the remaining images get put in "
                                       "the last bin."
                                       "Default value: 5"})

        arguments_list.append({"opts": ('-l', '--log-changes'),
                               "action": 'store_true',
                               "dest": 'log_changes',
                               "default": False,
                               "help": "Logs file renaming changes if "
                                       "grouping by renaming, or it logs the "
                                       "file copying/movement if grouping by "
                                       "folders. If no log file is specified "
                                       "with '--log-file', then a "
                                       "'sort_log.json' file will be created "
                                       "in the input directory."})

        arguments_list.append({"opts": ('-lf', '--log-file'),
                               "action": FileFullPaths,
                               "filetypes": log_filetypes,
                               "dest": 'log_file_path',
                               "default": 'sort_log.json',
                               "help": "Specify a log file to use for saving "
                                       "the renaming or grouping information. "
                                       "If specified extension isn't 'json' "
                                       "or 'yaml', then json will be used as "
                                       "the serializer, with the supplied "
                                       "filename. "
                                       "Default: sort_log.json"})

        return arguments_list

    @staticmethod
    def get_optional_arguments():
        """
        Put the arguments in a list so that they are accessible from both
        argparse and gui.
        """
        # Override this for custom arguments
        argument_list = []
        return argument_list

    def parse_arguments(self, description, subparser, command):
        parser = subparser.add_parser(
                command,
                help="This command lets you sort images using various "
                     "methods.",
                description=description,
                epilog="Questions and feedback: \
                        https://github.com/deepfakes/faceswap-playground"
        )

        for option in self.argument_list:
            args = option['opts']
            kwargs = {key: option[key] for key in option.keys() if key != 'opts'}
            parser.add_argument(*args, **kwargs)

        parser = self.add_optional_arguments(parser)
        parser.set_defaults(func=self.process_arguments)

    def add_optional_arguments(self, parser):
        for option in self.optional_arguments:
            args = option['opts']
            kwargs = {key: option[key] for key in option.keys() if key != 'opts'}
            parser.add_argument(*args, **kwargs)
        return parser

    def process_arguments(self, arguments):
        self.args = arguments
 </s> add     def process(self): </s> remove     parser = argparse.ArgumentParser()
    subparser = parser.add_subparsers()
    sort = Effmpeg(
            subparser, "effmpeg", "Wrapper for various common ffmpeg commands.")
 </s> add     PARSER = FullHelpArgumentParser()
    SUBPARSER = PARSER.add_subparsers()
    EFFMPEG = cli.EffmpegArgs(
        SUBPARSER, "effmpeg", "Wrapper for various common ffmpeg commands.")
    PARSER.set_defaults(func=bad_args)
    ARGUMENTS = PARSER.parse_args()
    ARGUMENTS.func(ARGUMENTS)
    """ Print help on bad arguments """
    PARSER.print_help()
          return sum(scores) / len(scores)
  
  
  def bad_args(args):
    """ Print help on bad arguments """
    PARSER.print_help()
      exit(0)
  
  
  if __name__ == "__main__":
      __warning_string = "Important: face-cnn method will cause an error when "
keep keep keep keep replace keep keep keep keep keep
 Gui v3.0b (#436)

* GUI version 3 (#411)

GUI version 3.0a

* Required for Shaonlu mode (#416)

Added two modes - Original and Shaonlu.
The later requires this file to function.

* model update (#417)

New, functional Original 128 model

* OriginalHighRes 128 model update (#418)

Required for OriginalHighRes Model to function

* Add OriginalHighRes 128 update to gui branch (#421)

* Required for Shaonlu mode (#416)

Added two modes - Original and Shaonlu.
The later requires this file to function.

* model update (#417)

New, functional Original 128 model

* OriginalHighRes 128 model update (#418)

Required for OriginalHighRes Model to function

* Dev gui (#420)

* reduce singletons

* Fix tooltips and screen boundaries on popup

* Remove dpi fix. Fix context filebrowsers

* fix tools.py execution and context filebrowser bugs

* Bugfixes (#422)

* Bump matplotlib requirement. Fix polyfit. Fix TQDM on sort

* Fixed memory usage at 6GB cards. (#423)

- Switched default encoder to ORIGINAL
- Fixed memory consumption. Tested with geforce gtx 9800 ti with 6Gb; batch_size 8 no OOM or memory warnings now.

* Staging (#426)

* altered trainer (#425)

altered trainer to accommodate with model change

* Update Model.py (#424)

- Added saving state (currently only saved epoch number, to be extended in future)
- Changed saving to ThreadPoolExecutor

* Add DPI Scaling (#428)

* Add dpi scaling

* Hotfix for effmpeg. (#429)

effmpeg fixed so it works both in cli and gui.
Initial work done to add previewing feature to effmpeg (currently does nothing).
Some small spacing changes in other files to improve PEP8 conformity.

* PEP8 Linting (#430)

* pep8 linting

* Requirements version bump (#432)

* altered trainer (#425)

altered trainer to accommodate with model change

* Update Model.py (#424)

- Added saving state (currently only saved epoch number, to be extended in future)
- Changed saving to ThreadPoolExecutor

* Requirements version bump (#431)

This bumps the versions of:

    scandir
    h5py
    Keras
    opencv-python

to their latest vesions.

Virtual Environment will need to be setup again to make use of these.

* High DPI Fixes (#433)

* dpi scaling

* DPI Fixes

* Fix and improve context manager. (#434)

effmpeg tool:
Context manager for GUI fixed.

Context manager in general:
Functionality extended to allow configuring the context with both:
  command -> action
  command -> variable (cli argument) -> action

* Change epoch option to iterations

* Change epochs to iterations 
tools/sort.py