Beispiel #1
0
    def get_avg_score_faces_cnn(fl1, references):
        """ Return the average CNN similarity score
            between a face and reference image """
        scores = []
        for fl2 in references:
            score = np.sum(np.absolute((fl2 - fl1).flatten()))
            scores.append(score)
        return sum(scores) / len(scores)


def bad_args(args):  # pylint: disable=unused-argument
    """ Print help on bad arguments """
    PARSER.print_help()
    exit(0)


if __name__ == "__main__":
    __WARNING_STRING = "Important: face-cnn method will cause an error when "
    __WARNING_STRING += "this tool is called directly instead of through the "
    __WARNING_STRING += "tools.py command script."
    print(__WARNING_STRING)
    print("Images sort tool.\n")

    PARSER = FullHelpArgumentParser()
    SUBPARSER = PARSER.add_subparsers()
    SORT = cli.SortArgs(SUBPARSER, "sort",
                        "Sort images using various methods.")
    PARSER.set_defaults(func=bad_args)
    ARGUMENTS = PARSER.parse_args()
    ARGUMENTS.func(ARGUMENTS)
Beispiel #2
0
if sys.version_info[0] == 3 and sys.version_info[1] < 2:
    raise Exception("This program requires at least python3.2")


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


if __name__ == "__main__":
    _tools_warning = "Please backup your data and/or test the tool you want "
    _tools_warning += "to use with a smaller data set to make sure you "
    _tools_warning += "understand how it works."
    print(_tools_warning)

    PARSER = FullHelpArgumentParser()
    SUBPARSER = PARSER.add_subparsers()
    EFFMPEG = cli.EffmpegArgs(SUBPARSER,
                              "effmpeg",
                              "This command allows you to easily execute common ffmpeg tasks.")
    SORT = cli.SortArgs(SUBPARSER,
                        "sort",
                        "This command lets you sort images using various methods.")
    GUI = GuiArgs(SUBPARSER,
                  "gui",
                  "Launch the Faceswap Tools Graphical User Interface.")
    PARSER.set_defaults(func=bad_args)
    ARGUMENTS = PARSER.parse_args()
    ARGUMENTS.func(ARGUMENTS)
Beispiel #3
0
    raise Exception("This program requires at least python3.2")
if sys.version_info[0] == 3 and sys.version_info[1] < 2:
    raise Exception("This program requires at least python3.2")

from lib.cli import FullHelpArgumentParser

from scripts.extract import ExtractTrainingData
from scripts.train import TrainingProcessor
from scripts.convert import ConvertImage


def bad_args(args):
    parser.print_help()
    exit(0)


if __name__ == "__main__":
    parser = FullHelpArgumentParser()
    subparser = parser.add_subparsers()
    extract = ExtractTrainingData(subparser, "extract",
                                  "Extract the faces from a pictures.")
    train = TrainingProcessor(
        subparser, "train",
        "This command trains the model for the two faces A and B.")
    convert = ConvertImage(
        subparser, "convert",
        "Convert a source image to a new one with the face swapped.")
    parser.set_defaults(func=bad_args)
    arguments = parser.parse_args()
    arguments.func(arguments)