Skip to content

Commit

Permalink
Add Misalignment Detection
Browse files Browse the repository at this point in the history
  - lib.align.AlignedFace - Add average_distance property (distance from mean_face)
  - tools.manual - Add misaligned Faces filter
  - tools.sort - Add sort by distance (misaligned sort)Add "Misaligned Faces" filter to manual tool
  • Loading branch information
torzdf committed Jun 8, 2021
1 parent e024189 commit eb96da0
Show file tree
Hide file tree
Showing 14 changed files with 378 additions and 179 deletions.
26 changes: 26 additions & 0 deletions lib/align/aligned_face.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,18 @@ def landmarks(self):
self._cache["landmarks"][0] = lms
return self._cache["landmarks"][0]

@property
def normalized_landmarks(self):
""" :class:`numpy.ndarray`: The 68 point facial landmarks normalized to 0.0 - 1.0 as
aligned by Umeyama. """
with self._cache["landmarks_normalized"][1]:
if self._cache["landmarks_normalized"][0] is None:
lms = np.expand_dims(self._frame_landmarks, axis=1)
lms = cv2.transform(lms, self._matrices["legacy"], lms.shape).squeeze()
logger.trace("normalized landmarks: %s", lms)
self._cache["landmarks_normalized"][0] = lms
return self._cache["landmarks_normalized"][0]

@property
def interpolators(self):
""" tuple: (`interpolator` and `reverse interpolator`) for the :attr:`adjusted matrix`. """
Expand All @@ -271,6 +283,18 @@ def interpolators(self):
self._cache["interpolators"][0] = interpolators
return self._cache["interpolators"][0]

@property
def average_distance(self):
""" float: The average distance of the core landmarks (18-67) from the mean face that was
used for aligning the image. """
with self._cache["average_distance"][1]:
if self._cache["average_distance"][0] is None:
# pylint:disable=unsubscriptable-object
average_distance = np.mean(np.abs(self.normalized_landmarks[17:] - _MEAN_FACE))
logger.trace("average_distance: %s", average_distance)
self._cache["average_distance"][0] = average_distance
return self._cache["average_distance"][0]

@classmethod
def _set_cache(cls):
""" Set the cache items.
Expand All @@ -286,6 +310,8 @@ def _set_cache(cls):
return dict(pose=[None, Lock()],
original_roi=[None, Lock()],
landmarks=[None, Lock()],
landmarks_normalized=[None, Lock()],
average_distance=[None, Lock()],
adjusted_matrix=[None, Lock()],
interpolators=[None, Lock()],
head_size=[dict(), Lock()],
Expand Down
Binary file modified locales/es/LC_MESSAGES/tools.manual.mo
Binary file not shown.
98 changes: 53 additions & 45 deletions locales/es/LC_MESSAGES/tools.manual.po
Original file line number Diff line number Diff line change
Expand Up @@ -5,64 +5,64 @@
msgid ""
msgstr ""
"Project-Id-Version: faceswap.spanish\n"
"POT-Creation-Date: 2021-03-22 18:31+0000\n"
"POT-Creation-Date: 2021-06-08 19:24+0100\n"
"PO-Revision-Date: \n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 2.4.2\n"
"X-Generator: Poedit 2.4.3\n"

#: tools/manual/cli.py:13
#: tools/manual\cli.py:13
msgid ""
"This command lets you perform various actions on frames, faces and "
"alignments files using visual tools."
msgstr ""
"Este comando le permite realizar varias acciones en los archivos de "
"fotogramas, caras y alineaciones utilizando herramientas visuales."

#: tools/manual/cli.py:23
#: tools/manual\cli.py:23
msgid ""
"A tool to perform various actions on frames, faces and alignments files "
"using visual tools"
msgstr ""
"Una herramienta que permite realizar diversas acciones en archivos de "
"fotogramas, caras y alineaciones mediante herramientas visuales"

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

#: tools/manual/cli.py:37
#: tools/manual\cli.py:37
msgid ""
"Path to the alignments file for the input, if not at the default location"
msgstr ""
"Ruta del archivo de alineaciones para la entrada, si no está en la ubicación "
"por defecto"

#: tools/manual/cli.py:44
#: tools/manual\cli.py:44
msgid ""
"Video file or directory containing source frames that faces were extracted "
"from."
msgstr ""
"Archivo o directorio de vídeo que contiene los fotogramas de origen de los "
"que se extrajeron las caras."

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

#: tools/manual/cli.py:52
#: tools/manual\cli.py:52
msgid ""
"Force regeneration of the low resolution jpg thumbnails in the alignments "
"file."
msgstr ""
"Forzar la regeneración de las miniaturas jpg de baja resolución en el "
"archivo de alineaciones."

#: tools/manual/cli.py:60
#: 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 "
Expand All @@ -74,26 +74,26 @@ msgstr ""
"extracción se cuelgue. Si esto sucede, entonces configure esta opción para "
"generar las miniaturas en un solo hilo más lento, pero más estable."

#: tools/manual/faceviewer\frame.py:163
#: tools/manual\faceviewer\frame.py:163
msgid "Display the landmarks mesh"
msgstr "Mostrar la malla de puntos de referencia"

#: tools/manual/faceviewer\frame.py:164
#: tools/manual\faceviewer\frame.py:164
msgid "Display the mask"
msgstr "Mostrar la máscara"

#: tools/manual/frameviewer\editor\_base.py:627
#: tools/manual/frameviewer\editor\landmarks.py:44
#: tools/manual/frameviewer\editor\mask.py:75
#: tools/manual\frameviewer\editor\_base.py:628
#: tools/manual\frameviewer\editor\landmarks.py:44
#: tools/manual\frameviewer\editor\mask.py:75
msgid "Magnify/Demagnify the View"
msgstr "Ampliar/Reducir la vista"

#: tools/manual/frameviewer\editor\bounding_box.py:33
#: tools/manual/frameviewer\editor\extract_box.py:32
#: tools/manual\frameviewer\editor\bounding_box.py:33
#: tools/manual\frameviewer\editor\extract_box.py:32
msgid "Delete Face"
msgstr "Borrar cara"

#: tools/manual/frameviewer\editor\bounding_box.py:36
#: tools/manual\frameviewer\editor\bounding_box.py:36
msgid ""
"Bounding Box Editor\n"
"Edit the bounding box being fed into the aligner to recalculate the "
Expand All @@ -115,7 +115,7 @@ msgstr ""
" - Haga clic con el botón derecho del ratón en un cuadro delimitador para "
"eliminar una cara."

#: tools/manual/frameviewer\editor\bounding_box.py:70
#: tools/manual\frameviewer\editor\bounding_box.py:70
msgid ""
"Aligner to use. FAN will obtain better alignments, but cv2-dnn can be useful "
"if FAN cannot get decent alignments and you want to set a base to edit from."
Expand All @@ -124,7 +124,7 @@ msgstr ""
"ser útil si FAN no puede obtener alineaciones decentes y quiere tener una "
"base inicial que luego se vaya a editar."

#: tools/manual/frameviewer\editor\bounding_box.py:83
#: tools/manual\frameviewer\editor\bounding_box.py:83
msgid ""
"Normalization method to use for feeding faces to the aligner. This can help "
"the aligner better align faces with difficult lighting conditions. Different "
Expand All @@ -147,7 +147,7 @@ msgstr ""
"\thist: Iguala los histogramas en los canales RGB.\n"
"\tmean: Normaliza los colores de la cara a la media."

#: tools/manual/frameviewer\editor\extract_box.py:35
#: tools/manual\frameviewer\editor\extract_box.py:35
msgid ""
"Extract Box Editor\n"
"Move the extract box that has been generated by the aligner. Click and "
Expand All @@ -166,7 +166,7 @@ msgstr ""
"referencia.\n"
" - Fuera de las esquinas para girar los puntos de referencia."

#: tools/manual/frameviewer\editor\landmarks.py:27
#: tools/manual\frameviewer\editor\landmarks.py:27
msgid ""
"Landmark Point Editor\n"
"Edit the individual landmark points.\n"
Expand All @@ -180,7 +180,7 @@ msgstr ""
" - Haga clic y arrastre los puntos individuales para reubicarlos.\n"
" - Dibuje un cuadro para seleccionar varios puntos para reubicarlos."

#: tools/manual/frameviewer\editor\mask.py:33
#: tools/manual\frameviewer\editor\mask.py:33
msgid ""
"Mask Editor\n"
"Edit the mask.\n"
Expand All @@ -197,90 +197,98 @@ msgstr ""
"Cualquier cambio en los puntos de referencia después de editar la máscara "
"anulará sus ediciones manuales."

#: tools/manual/frameviewer\editor\mask.py:77
#: tools/manual\frameviewer\editor\mask.py:77
msgid "Draw Tool"
msgstr "Herramienta de dibujo"

#: tools/manual/frameviewer\editor\mask.py:78
#: tools/manual\frameviewer\editor\mask.py:78
msgid "Erase Tool"
msgstr "Herramienta de borrado"

#: tools/manual/frameviewer\editor\mask.py:97
#: tools/manual\frameviewer\editor\mask.py:97
msgid "Select which mask to edit"
msgstr "Seleccionar máscara a editar"

#: tools/manual/frameviewer\editor\mask.py:104
#: tools/manual\frameviewer\editor\mask.py:104
msgid "Set the brush size. ([ - decrease, ] - increase)"
msgstr "Seleccionar el tamaño del pincel ([ - disminuir, ] - aumentar)"

#: tools/manual/frameviewer\editor\mask.py:111
#: tools/manual\frameviewer\editor\mask.py:111
msgid "Select the brush cursor color."
msgstr "Seleccionar el color del pincel."

#: tools/manual/frameviewer\frame.py:77
#: tools/manual\frameviewer\frame.py:78
msgid "Play/Pause (SPACE)"
msgstr "Reproducir/Pausa (BARRA DE ESPACIO)"

#: tools/manual/frameviewer\frame.py:78
#: tools/manual\frameviewer\frame.py:79
msgid "Go to First Frame (HOME)"
msgstr "Ir al primer cuadro (INICIO)"

#: tools/manual/frameviewer\frame.py:79
#: tools/manual\frameviewer\frame.py:80
msgid "Go to Previous Frame (Z)"
msgstr "Ir al cuadro anterior (Z)"

#: tools/manual/frameviewer\frame.py:80
#: tools/manual\frameviewer\frame.py:81
msgid "Go to Next Frame (X)"
msgstr "Ir al siguiente cuadro (X)"

#: tools/manual/frameviewer\frame.py:81
#: tools/manual\frameviewer\frame.py:82
msgid "Go to Last Frame (END)"
msgstr "Ir al último cuadro (FIN)"

#: tools/manual/frameviewer\frame.py:82
#: tools/manual\frameviewer\frame.py:83
msgid "Extract the faces to a folder... (Ctrl+E)"
msgstr "Extraer las caras a una carpeta... (Ctrl+E)"

#: tools/manual/frameviewer\frame.py:83
#: tools/manual\frameviewer\frame.py:84
msgid "Save the Alignments file (Ctrl+S)"
msgstr "Guardar el fichero de alineamientos (Ctrl+S)"

#: tools/manual/frameviewer\frame.py:84
#: tools/manual\frameviewer\frame.py:85
msgid "Filter Frames to only those Containing the Selected Item (F)"
msgstr "Mostrar cuadros que contenga únicamente el elemento seleccionado (F)"

#: tools/manual/frameviewer\frame.py:318
#: tools/manual\frameviewer\frame.py:86
msgid ""
"Set the distance from an 'average face' to be considered misaligned. Higher "
"distances are more restrictive"
msgstr ""
"Establezca la distancia desde una 'cara promedio' para que se considere "
"desalineada. Las distancias más altas son más restrictivas"

#: tools/manual\frameviewer\frame.py:391
msgid "View alignments"
msgstr "Ver alineamientos"

#: tools/manual/frameviewer\frame.py:319
#: tools/manual\frameviewer\frame.py:392
msgid "Bounding box editor"
msgstr "Editor de cuadro delimitador"

#: tools/manual/frameviewer\frame.py:320
#: tools/manual\frameviewer\frame.py:393
msgid "Location editor"
msgstr "Editor de ubicación"

#: tools/manual/frameviewer\frame.py:321
#: tools/manual\frameviewer\frame.py:394
msgid "Mask editor"
msgstr "Editor de máscara"

#: tools/manual/frameviewer\frame.py:322
#: tools/manual\frameviewer\frame.py:395
msgid "Landmark point editor"
msgstr "Editor de puntos de referencia"

#: tools/manual/frameviewer\frame.py:397
#: tools/manual\frameviewer\frame.py:470
msgid "Next"
msgstr "Siguiente"

#: tools/manual/frameviewer\frame.py:397
#: tools/manual\frameviewer\frame.py:470
msgid "Previous"
msgstr "Anterior"

#: tools/manual/frameviewer\frame.py:408
#: tools/manual\frameviewer\frame.py:481
msgid "Revert to saved Alignments ({})"
msgstr "Volver a los alineamientos guardados ({})"

#: tools/manual/frameviewer\frame.py:414
#: tools/manual\frameviewer\frame.py:487
msgid "Copy {} Alignments ({})"
msgstr "Copiar los alineamientos del cuadro {} ({})"
Binary file modified locales/es/LC_MESSAGES/tools.sort.cli.mo
Binary file not shown.
Loading

0 comments on commit eb96da0

Please sign in to comment.