コード例 #1
0
def _main():
    """ The main entry point into Faceswap.

    - Generates the config files, if they don't pre-exist.
    - Compiles the :class:`~lib.cli.args.FullHelpArgumentParser` objects for each section of
      Faceswap.
    - Sets the default values and launches the relevant script.
    - Outputs help if invalid parameters are provided.
    """
    generate_configs()

    subparser = _PARSER.add_subparsers()
    cli_args.ExtractArgs(subparser, "extract",
                         _("Extract the faces from pictures or a video"))
    cli_args.TrainArgs(subparser, "train",
                       _("Train a model for the two faces A and B"))
    cli_args.ConvertArgs(
        subparser, "convert",
        _("Convert source pictures or video to a new one with the face swapped"
          ))
    cli_args.GuiArgs(subparser, "gui",
                     _("Launch the Faceswap Graphical User Interface"))
    cli_args.InsertArgs(
        subparser, "insert",
        _("Convert source pictures or video to a new one using pre-defined faces"
          ))

    _PARSER.set_defaults(func=_bad_args)
    arguments = _PARSER.parse_args()
    arguments.func(arguments)
コード例 #2
0
from lib.config import generate_configs

if sys.version_info[0] < 3:
    raise Exception("This program requires at least python3.6")
if sys.version_info[0] == 3 and sys.version_info[1] < 6:
    raise Exception("This program requires at least python3.6")


def bad_args(args):
    """ Print help on bad arguments """
    PARSER.print_help()
    sys.exit(0)


if __name__ == "__main__":
    generate_configs()
    PARSER = cli.FullHelpArgumentParser()
    SUBPARSER = PARSER.add_subparsers()
    EXTRACT = cli.ExtractArgs(SUBPARSER,
                              "extract",
                              "Extract the faces from pictures")
    TRAIN = cli.TrainArgs(SUBPARSER,
                          "train",
                          "This command trains the model for the two faces A and B")
    CONVERT = cli.ConvertArgs(SUBPARSER,
                              "convert",
                              "Convert a source image to a new one with the face swapped")
    GUI = cli.GuiArgs(SUBPARSER,
                      "gui",
                      "Launch the Faceswap Graphical User Interface")
    PARSER.set_defaults(func=bad_args)