Skip to content

Commit

Permalink
Add Locale support for cli arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
torzdf committed Feb 18, 2021
1 parent a5e666f commit 1f3e1b0
Show file tree
Hide file tree
Showing 23 changed files with 2,778 additions and 823 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@
!*.inf
!*.keep
!*.md
!*.mo
!*.nsi
!*.png
!*.po
!*.pot
!*.py
!*.rst
!*.sh
Expand All @@ -21,6 +24,9 @@
!docs/full
!docs/_static
!config/
!locales/
!locales/*
!locales/*/LC_MESSAGES
!lib/
!lib/*
!lib/gui
Expand Down
25 changes: 16 additions & 9 deletions faceswap.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,29 @@
#!/usr/bin/env python3
""" The master faceswap.py script """
import gettext
import sys

from lib.cli import args
from lib.cli import args as cli_args
from lib.config import generate_configs


# LOCALES
_LANG = gettext.translation("faceswap", localedir="locales", fallback=True)
_ = _LANG.gettext


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


_PARSER = args.FullHelpArgumentParser()
_PARSER = cli_args.FullHelpArgumentParser()


def _bad_args(*args): # pylint:disable=unused-argument
""" Print help to console when bad arguments are provided. """
print(args)
print(cli_args)
_PARSER.print_help()
sys.exit(0)

Expand All @@ -33,12 +40,12 @@ def _main():
generate_configs()

subparser = _PARSER.add_subparsers()
args.ExtractArgs(subparser, "extract", "Extract the faces from pictures")
args.TrainArgs(subparser, "train", "This command trains the model for the two faces A and B")
args.ConvertArgs(subparser,
"convert",
"Convert a source image to a new one with the face swapped")
args.GuiArgs(subparser, "gui", "Launch the Faceswap Graphical User Interface")
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"))
_PARSER.set_defaults(func=_bad_args)
arguments = _PARSER.parse_args()
arguments.func(arguments)
Expand Down
718 changes: 362 additions & 356 deletions lib/cli/args.py

Large diffs are not rendered by default.

Binary file added locales/es/LC_MESSAGES/lib.cli.args.mo
Binary file not shown.
894 changes: 894 additions & 0 deletions locales/es/LC_MESSAGES/lib.cli.args.po

Large diffs are not rendered by default.

33 changes: 33 additions & 0 deletions locales/faceswap.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR ORGANIZATION
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2021-02-18 23:48-0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=cp1252\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: pygettext.py 1.5\n"


#: faceswap.py:43
msgid "Extract the faces from pictures or a video"
msgstr ""

#: faceswap.py:44
msgid "Train a model for the two faces A and B"
msgstr ""

#: faceswap.py:47
msgid "Convert source pictures or video to a new one with the face swapped"
msgstr ""

#: faceswap.py:48
msgid "Launch the Faceswap Graphical User Interface"
msgstr ""

404 changes: 404 additions & 0 deletions locales/lib.cli.args.pot

Large diffs are not rendered by default.

108 changes: 108 additions & 0 deletions locales/tools.alignments.cli.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR ORGANIZATION
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2021-02-18 23:43-0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=cp1252\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: pygettext.py 1.5\n"


#: tools/alignments/cli.py:14
msgid "This command lets you perform various tasks pertaining to an alignments file."
msgstr ""

#: tools/alignments/cli.py:23
msgid ""
"Alignments tool\n"
"This tool allows you to perform numerous actions on or using an alignments file against its corresponding faceset/frame source."
msgstr ""

#: tools/alignments/cli.py:27
msgid " Must Pass in a frames folder/source video file (-fr)."
msgstr ""

#: tools/alignments/cli.py:28
msgid " Must Pass in a faces folder (-fc)."
msgstr ""

#: tools/alignments/cli.py:29
msgid " Must Pass in either a frames folder/source video file OR afaces folder (-fr or -fc)."
msgstr ""

#: tools/alignments/cli.py:31
msgid " Must Pass in a frames folder/source video file AND a faces folder (-fr and -fc)."
msgstr ""

#: tools/alignments/cli.py:33
msgid " Use the output option (-o) to process results."
msgstr ""

#: tools/alignments/cli.py:42
msgid ""
"R|Choose which action you want to perform. NB: All actions require an alignments file (-a) to be passed in.\n"
"L|'draw': Draw landmarks on frames in the selected folder/video. A subfolder will be created within the frames folder to hold the output.{0}\n"
"L|'extract': Re-extract faces from the source frames/video based on alignment data. This is a lot quicker than re-detecting faces. Can pass in the '-een' (--extract-every-n) parameter to only extract every nth frame.{1}\n"
"L|'missing-alignments': Identify frames that do not exist in the alignments file.{2}{0}\n"
"L|'missing-frames': Identify frames in the alignments file that do not appear within the frames folder/video.{2}{0}\n"
"L|'multi-faces': Identify where multiple faces exist within the alignments file.{2}{4}\n"
"L|'no-faces': Identify frames that exist within the alignment file but no faces were detected.{2}{0}\n"
"L|'remove-faces': Remove deleted faces from an alignments file. The original alignments file will be backed up.{3}\n"
"L|'rename' - Rename faces to correspond with their parent frame and position index in the alignments file (i.e. how they are named after running extract).{3}\n"
"L|'sort': Re-index the alignments from left to right. For alignments with multiple faces this will ensure that the left-most face is at index 0.\n"
"L|'spatial': Perform spatial and temporal filtering to smooth alignments (EXPERIMENTAL!)"
msgstr ""

#: tools/alignments/cli.py:72 tools/alignments/cli.py:81
#: tools/alignments/cli.py:88
msgid "data"
msgstr ""

#: tools/alignments/cli.py:75
msgid "Full path to the alignments file to be processed. If merging alignments, then multiple files can be selected, space separated"
msgstr ""

#: tools/alignments/cli.py:82
msgid "Directory containing extracted faces."
msgstr ""

#: tools/alignments/cli.py:89
msgid "Directory containing source frames that faces were extracted from."
msgstr ""

#: tools/alignments/cli.py:95
msgid "processing"
msgstr ""

#: tools/alignments/cli.py:97
msgid ""
"R|How to output discovered items ('faces' and 'frames' only):\n"
"L|'console': Print the list of frames to the screen. (DEFAULT)\n"
"L|'file': Output the list of frames to a text file (stored within the source directory).\n"
"L|'move': Move the discovered items to a sub-folder within the source directory."
msgstr ""

#: tools/alignments/cli.py:111 tools/alignments/cli.py:121
#: tools/alignments/cli.py:127
msgid "extract"
msgstr ""

#: tools/alignments/cli.py:112
msgid "[Extract only] Extract every 'nth' frame. This option will skip frames when extracting faces. For example a value of 1 will extract faces from every frame, a value of 10 will extract faces from every 10th frame."
msgstr ""

#: tools/alignments/cli.py:123
msgid "[Extract only] The output size of extracted faces."
msgstr ""

#: tools/alignments/cli.py:129
msgid "[Extract only] Only extract faces that have not been upscaled to the required size (`-sz`, `--size). Useful for excluding low-res images from a training set."
msgstr ""

115 changes: 115 additions & 0 deletions locales/tools.effmpeg.cli.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR ORGANIZATION
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2021-02-18 23:34-0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=cp1252\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: pygettext.py 1.5\n"


#: tools/effmpeg/cli.py:15
msgid "This command allows you to easily execute common ffmpeg tasks."
msgstr ""

#: tools/effmpeg/cli.py:24
msgid "A wrapper for ffmpeg for performing image <> video converting."
msgstr ""

#: tools/effmpeg/cli.py:51
msgid ""
"R|Choose which action you want ffmpeg ffmpeg to do.\n"
"L|'extract': turns videos into images \n"
"L|'gen-vid': turns images into videos \n"
"L|'get-fps' returns the chosen video's fps.\n"
"L|'get-info' returns information about a video.\n"
"L|'mux-audio' add audio from one video to another.\n"
"L|'rescale' resize video.\n"
"L|'rotate' rotate video.\n"
"L|'slice' cuts a portion of the video into a separate video file."
msgstr ""

#: tools/effmpeg/cli.py:65
msgid "Input file."
msgstr ""

#: tools/effmpeg/cli.py:66 tools/effmpeg/cli.py:73 tools/effmpeg/cli.py:87
msgid "data"
msgstr ""

#: tools/effmpeg/cli.py:76
msgid "Output file. If no output is specified then: if the output is meant to be a video then a video called 'out.mkv' will be created in the input directory; if the output is meant to be a directory then a directory called 'out' will be created inside the input directory. Note: the chosen output file extension will determine the file encoding."
msgstr ""

#: tools/effmpeg/cli.py:89
msgid "Path to reference video if 'input' was not a video."
msgstr ""

#: tools/effmpeg/cli.py:95 tools/effmpeg/cli.py:105 tools/effmpeg/cli.py:142
#: tools/effmpeg/cli.py:171
msgid "output"
msgstr ""

#: tools/effmpeg/cli.py:97
msgid "Provide video fps. Can be an integer, float or fraction. Negative values will will make the program try to get the fps from the input or reference videos."
msgstr ""

#: tools/effmpeg/cli.py:107
msgid "Image format that extracted images should be saved as. '.bmp' will offer the fastest extraction speed, but will take the most storage space. '.png' will be slower but will take less storage."
msgstr ""

#: tools/effmpeg/cli.py:114 tools/effmpeg/cli.py:123 tools/effmpeg/cli.py:132
msgid "clip"
msgstr ""

#: tools/effmpeg/cli.py:116
msgid "Enter the start time from which an action is to be applied. Default: 00:00:00, in HH:MM:SS format. You can also enter the time with or without the colons, e.g. 00:0000 or 026010."
msgstr ""

#: tools/effmpeg/cli.py:125
msgid "Enter the end time to which an action is to be applied. If both an end time and duration are set, then the end time will be used and the duration will be ignored. Default: 00:00:00, in HH:MM:SS."
msgstr ""

#: tools/effmpeg/cli.py:134
msgid "Enter the duration of the chosen action, for example if you enter 00:00:10 for slice, then the first 10 seconds after and including the start time will be cut out into a new video. Default: 00:00:00, in HH:MM:SS format. You can also enter the time with or without the colons, e.g. 00:0000 or 026010."
msgstr ""

#: tools/effmpeg/cli.py:144
msgid "Mux the audio from the reference video into the input video. This option is only used for the 'gen-vid' action. 'mux-audio' action has this turned on implicitly."
msgstr ""

#: tools/effmpeg/cli.py:155 tools/effmpeg/cli.py:165
msgid "rotate"
msgstr ""

#: tools/effmpeg/cli.py:157
msgid "Transpose the video. If transpose is set, then degrees will be ignored. For cli you can enter either the number or the long command name, e.g. to use (1, 90Clockwise) -tr 1 or -tr 90Clockwise"
msgstr ""

#: tools/effmpeg/cli.py:166
msgid "Rotate the video clockwise by the given number of degrees."
msgstr ""

#: tools/effmpeg/cli.py:173
msgid "Set the new resolution scale if the chosen action is 'rescale'."
msgstr ""

#: tools/effmpeg/cli.py:178 tools/effmpeg/cli.py:186
msgid "settings"
msgstr ""

#: tools/effmpeg/cli.py:180
msgid "Reduces output verbosity so that only serious errors are printed. If both quiet and verbose are set, verbose will override quiet."
msgstr ""

#: tools/effmpeg/cli.py:188
msgid "Increases output verbosity. If both quiet and verbose are set, verbose will override quiet."
msgstr ""

49 changes: 49 additions & 0 deletions locales/tools.manual.cli.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR ORGANIZATION
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2021-02-18 23:17-0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=cp1252\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: pygettext.py 1.5\n"


#: tools/manual/cli.py:13
msgid "This command lets you perform various actions on frames, faces and alignments files using visual tools."
msgstr ""

#: tools/manual/cli.py:23
msgid "A tool to perform various actions on frames, faces and alignments files using visual tools"
msgstr ""

#: tools/manual/cli.py:35 tools/manual/cli.py:43
msgid "data"
msgstr ""

#: tools/manual/cli.py:37
msgid "Path to the alignments file for the input, if not at the default location"
msgstr ""

#: tools/manual/cli.py:44
msgid "Video file or directory containing source frames that faces were extracted from."
msgstr ""

#: tools/manual/cli.py:51 tools/manual/cli.py:59
msgid "options"
msgstr ""

#: tools/manual/cli.py:52
msgid "Force regeneration of the low resolution jpg thumbnails in the alignments file."
msgstr ""

#: tools/manual/cli.py:60
msgid "The process attempts to speed up generation of thumbnails by extracting from the video in parallel threads. For some videos, this causes the caching process to hang. If this happens, then set this option to generate the thumbnails in a slower, but more stable single thread."
msgstr ""

Loading

0 comments on commit 1f3e1b0

Please sign in to comment.