From ea63f1e64a206157b61eaff1329324f03b3a4bd3 Mon Sep 17 00:00:00 2001 From: torzdf <36920800+torzdf@users.noreply.github.com> Date: Fri, 28 Jun 2024 13:50:14 +0100 Subject: [PATCH] Mask tool. Add ability to output custom imported masks --- locales/es/LC_MESSAGES/tools.mask.cli.mo | Bin 14916 -> 15278 bytes locales/es/LC_MESSAGES/tools.mask.cli.po | 41 +++++++++++++---------- locales/kr/LC_MESSAGES/tools.mask.cli.mo | Bin 14151 -> 14531 bytes locales/kr/LC_MESSAGES/tools.mask.cli.po | 40 ++++++++++++---------- locales/ru/LC_MESSAGES/tools.mask.cli.mo | Bin 18221 -> 18726 bytes locales/ru/LC_MESSAGES/tools.mask.cli.po | 41 +++++++++++++---------- locales/tools.mask.cli.pot | 28 +++++++++------- tools/mask/cli.py | 8 +++-- tools/mask/mask_output.py | 4 +++ 9 files changed, 92 insertions(+), 70 deletions(-) diff --git a/locales/es/LC_MESSAGES/tools.mask.cli.mo b/locales/es/LC_MESSAGES/tools.mask.cli.mo index 2b153b9c56767340632a1725fdbfdb9220ba1b4f..ad86f74687970000a91cee1fd14ce3bb86455225 100644 GIT binary patch delta 868 zcmY*WOKTHR7(HoiQ>&HM`sl;QXHfgFO`lk87g7YljTMCY0EIDgZAK?^)0qh+-K0vz zZ8hpnLR*5kwRzF8u+bpo@BDl1Mwuox?rf_nmX@on`;!%z|0?Rs}qc z1JA30LOpP&2I$@bX!5U{fk|TT4&V)d`4-?N@pvn6f%uNNfw;d7s3mrlv7bmuj1Vuz zfMdk-#0TxbCGx*_QIq@0-6-HEiTORiP7?XOzzyzi3ou9AwhtI5e~&oFfS(h<7#+_Y z1g_HIZa1*PfU5&Q2lg$kkAM6>Hzf3j;3;2tLKW*9438@2d(YGg#Ei5c7WaYh?uTIZ7@7Fo+IoB(9#@5P&6#)A#V9N`r ztbJv`7`a^z+yKZ_@Q*z80TX0HC6GfV$y{#GF+G+UdVl*77o zzdEd7(QKi&vpv)+WH~H%w8^r0R`n}|t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{BF} zWu0sdm|^~13GW%7lpuj)3hXlATSoXC_({S0a^Q+=ssMg7uU7)+9PGA=#*U{U>N)K9 zdSHmLd#r2gnNP)1&N0KZr#?+xH3FUcTzL-IMEcCv8+onR+GJ-9IPX_>=* zD3EhP5*_mA03~F zPR29Y@ei@FnC$Y@sCmz}Lv6bMI8-RN*XwJnYiQ9;v(;>_HBGe|^b66TcC^)#F`v2UTGoSUbd4~+D_`$k+o;fT6@+P>%dOhv+{@WQ5>r7 R7c)+^QGMrBCyo6@{{bA>Z=nDH diff --git a/locales/ru/LC_MESSAGES/tools.mask.cli.po b/locales/ru/LC_MESSAGES/tools.mask.cli.po index 1f63fe42ff..6cabf81c53 100644 --- a/locales/ru/LC_MESSAGES/tools.mask.cli.po +++ b/locales/ru/LC_MESSAGES/tools.mask.cli.po @@ -7,8 +7,8 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-28 23:51+0000\n" -"PO-Revision-Date: 2024-03-29 00:07+0000\n" +"POT-Creation-Date: 2024-06-28 13:45+0100\n" +"PO-Revision-Date: 2024-06-28 13:48+0100\n" "Last-Translator: \n" "Language-Team: \n" "Language: ru\n" @@ -17,7 +17,7 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && " "n%10<=4 && (n%100<12 || n%100>14) ? 1 : 2);\n" -"X-Generator: Poedit 3.4.2\n" +"X-Generator: Poedit 3.4.4\n" #: tools/mask/cli.py:15 msgid "" @@ -175,7 +175,7 @@ msgstr "" "de alineaciones. Nota: 'custom' debe ser el 'masker' seleccionado y las " "máscaras deben tener el mismo formato que el 'input-type' (frames o faces)" -#: tools/mask/cli.py:135 tools/mask/cli.py:154 tools/mask/cli.py:174 +#: tools/mask/cli.py:135 tools/mask/cli.py:154 tools/mask/cli.py:176 msgid "import" msgstr "Импортировать" @@ -208,9 +208,11 @@ msgstr "" #: tools/mask/cli.py:156 msgid "" -"R|Import only. The centering to use when importing masks. Note: For any job " -"other than 'import' this option is ignored as mask centering is handled " -"internally.\n" +"R|Import/Output only. When importing masks, this is the centering to use. " +"For output this is only used for outputting custom imported masks, and " +"should correspond to the centering used when importing the mask. Note: For " +"any job other than 'import' and 'output' this option is ignored as mask " +"centering is handled internally.\n" "L|face: Centers the mask on the center of the face, adjusting for pitch and " "yaw. Outside of requirements for full head masking/training, this is likely " "to be the best choice.\n" @@ -222,9 +224,12 @@ msgid "" "the nose with and crops closely to the face. Can result in the edges of the " "mask appearing outside of the training area." msgstr "" -"R|Только импорт. Центрирование, используемое при импорте масок. Примечание. " -"Для любого задания, кроме «импорта», этот параметр игнорируется, поскольку " -"центрирование маски обрабатывается внутри.\n" +"R|Только импорт/вывод. При импорте масок это центрирование для " +"использования. Для вывода это используется только для вывода " +"пользовательских импортированных масок и должно соответствовать " +"центрированию, используемому при импорте маски. Примечание: для любого " +"задания, кроме «импорта» и «вывода», эта опция игнорируется, поскольку " +"центрирование маски обрабатывается внутренне.\n" "L|face: центрирует маску по центру лица с регулировкой угла наклона и " "отклонения от курса. Помимо требований к полной маскировке/тренировке " "головы, это, вероятно, будет лучшим выбором.\n" @@ -236,7 +241,7 @@ msgstr "" "приближает ее к лицу. Это может привести к тому, что края маски окажутся за " "пределами тренировочной зоны." -#: tools/mask/cli.py:179 +#: tools/mask/cli.py:181 msgid "" "Import only. The size, in pixels to internally store the mask at.\n" "The default is 128 which is fine for nearly all usecases. Larger sizes will " @@ -247,12 +252,12 @@ msgstr "" "использования. Большие размеры приведут к увеличению размера файлов " "выравниваний и более длительной обработке." -#: tools/mask/cli.py:187 tools/mask/cli.py:195 tools/mask/cli.py:209 -#: tools/mask/cli.py:223 tools/mask/cli.py:233 +#: tools/mask/cli.py:189 tools/mask/cli.py:197 tools/mask/cli.py:211 +#: tools/mask/cli.py:225 tools/mask/cli.py:235 msgid "output" msgstr "вывод" -#: tools/mask/cli.py:189 +#: tools/mask/cli.py:191 msgid "" "Optional output location. If provided, a preview of the masks created will " "be output in the given folder." @@ -260,7 +265,7 @@ msgstr "" "Необязательное местоположение вывода. Если указано, предварительный просмотр " "созданных масок будет выведен в указанную папку." -#: tools/mask/cli.py:200 +#: tools/mask/cli.py:202 msgid "" "Apply gaussian blur to the mask output. Has the effect of smoothing the " "edges of the mask giving less of a hard edge. the size is in pixels. This " @@ -273,7 +278,7 @@ msgstr "" "Примечание: влияет только на предварительный просмотр. Установите значение 0 " "для выключения" -#: tools/mask/cli.py:214 +#: tools/mask/cli.py:216 msgid "" "Helps reduce 'blotchiness' on some masks by making light shades white and " "dark shades black. Higher values will impact more of the mask. NB: Only " @@ -284,7 +289,7 @@ msgstr "" "часть маски. Примечание: влияет только на предварительный просмотр. " "Установите значение 0 для выключения" -#: tools/mask/cli.py:225 +#: tools/mask/cli.py:227 msgid "" "R|How to format the output when processing is set to 'output'.\n" "L|combined: The image contains the face/frame, face mask and masked face.\n" @@ -297,7 +302,7 @@ msgstr "" "L|masked: Вывести лицо/кадр как изображение rgba с маскированным лицом.\n" "L|mask: Выводить только маску как одноканальное изображение." -#: tools/mask/cli.py:235 +#: tools/mask/cli.py:237 msgid "" "R|Whether to output the whole frame or only the face box when using output " "processing. Only has an effect when using frames as input." diff --git a/locales/tools.mask.cli.pot b/locales/tools.mask.cli.pot index 54563a8620..f8024c88ee 100644 --- a/locales/tools.mask.cli.pot +++ b/locales/tools.mask.cli.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-28 23:51+0000\n" +"POT-Creation-Date: 2024-06-28 13:45+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -114,7 +114,7 @@ msgid "" "must be in the same format as the 'input-type' (frames or faces)" msgstr "" -#: tools/mask/cli.py:135 tools/mask/cli.py:154 tools/mask/cli.py:174 +#: tools/mask/cli.py:135 tools/mask/cli.py:154 tools/mask/cli.py:176 msgid "import" msgstr "" @@ -135,9 +135,11 @@ msgstr "" #: tools/mask/cli.py:156 msgid "" -"R|Import only. The centering to use when importing masks. Note: For any job " -"other than 'import' this option is ignored as mask centering is handled " -"internally.\n" +"R|Import/Output only. When importing masks, this is the centering to use. " +"For output this is only used for outputting custom imported masks, and " +"should correspond to the centering used when importing the mask. Note: For " +"any job other than 'import' and 'output' this option is ignored as mask " +"centering is handled internally.\n" "L|face: Centers the mask on the center of the face, adjusting for pitch and " "yaw. Outside of requirements for full head masking/training, this is likely " "to be the best choice.\n" @@ -150,25 +152,25 @@ msgid "" "mask appearing outside of the training area." msgstr "" -#: tools/mask/cli.py:179 +#: tools/mask/cli.py:181 msgid "" "Import only. The size, in pixels to internally store the mask at.\n" "The default is 128 which is fine for nearly all usecases. Larger sizes will " "result in larger alignments files and longer processing." msgstr "" -#: tools/mask/cli.py:187 tools/mask/cli.py:195 tools/mask/cli.py:209 -#: tools/mask/cli.py:223 tools/mask/cli.py:233 +#: tools/mask/cli.py:189 tools/mask/cli.py:197 tools/mask/cli.py:211 +#: tools/mask/cli.py:225 tools/mask/cli.py:235 msgid "output" msgstr "" -#: tools/mask/cli.py:189 +#: tools/mask/cli.py:191 msgid "" "Optional output location. If provided, a preview of the masks created will " "be output in the given folder." msgstr "" -#: tools/mask/cli.py:200 +#: tools/mask/cli.py:202 msgid "" "Apply gaussian blur to the mask output. Has the effect of smoothing the " "edges of the mask giving less of a hard edge. the size is in pixels. This " @@ -176,14 +178,14 @@ msgid "" "to the next odd number. NB: Only effects the output preview. Set to 0 for off" msgstr "" -#: tools/mask/cli.py:214 +#: tools/mask/cli.py:216 msgid "" "Helps reduce 'blotchiness' on some masks by making light shades white and " "dark shades black. Higher values will impact more of the mask. NB: Only " "effects the output preview. Set to 0 for off" msgstr "" -#: tools/mask/cli.py:225 +#: tools/mask/cli.py:227 msgid "" "R|How to format the output when processing is set to 'output'.\n" "L|combined: The image contains the face/frame, face mask and masked face.\n" @@ -191,7 +193,7 @@ msgid "" "L|mask: Only output the mask as a single channel image." msgstr "" -#: tools/mask/cli.py:235 +#: tools/mask/cli.py:237 msgid "" "R|Whether to output the whole frame or only the face box when using output " "processing. Only has an effect when using frames as input." diff --git a/tools/mask/cli.py b/tools/mask/cli.py index 4ec06e9ed3..cc14bb1b9d 100644 --- a/tools/mask/cli.py +++ b/tools/mask/cli.py @@ -153,9 +153,11 @@ def get_argument_list(): "default": "face", "group": _("import"), "help": _( - "R|Import only. The centering to use when importing masks. Note: For any job " - "other than 'import' this option is ignored as mask centering is handled " - "internally." + "R|Import/Output only. When importing masks, this is the centering to use. For " + "output this is only used for outputting custom imported masks, and should " + "correspond to the centering used when importing the mask. Note: For any job " + "other than 'import' and 'output' this option is ignored as mask centering is " + "handled internally." "\nL|face: Centers the mask on the center of the face, adjusting for " "pitch and yaw. Outside of requirements for full head masking/training, this " "is likely to be the best choice." diff --git a/tools/mask/mask_output.py b/tools/mask/mask_output.py index 344332a9b3..79ffb809e3 100644 --- a/tools/mask/mask_output.py +++ b/tools/mask/mask_output.py @@ -49,6 +49,7 @@ def __init__(self, arguments: Namespace, self._type: T.Literal["combined", "masked", "mask"] = arguments.output_type self._full_frame: bool = arguments.full_frame self._mask_type = arguments.masker + self._centering: CenteringType = arguments.centering self._input_is_faces = arguments.input_type == "faces" self._saver = self._set_saver(arguments.output, arguments.processing) @@ -445,6 +446,9 @@ def _get_mask_types(self, else: mask_types = [self._mask_type] + if self._mask_type == "custom": + mask_types.append(f"{self._mask_type}_{self._centering}") + final_masks = set() for idx in reversed(range(len(detected_faces))): face_idx, detected_face = detected_faces[idx]