1
0
Fork 0
mirror of https://github.com/deepfakes/faceswap synced 2025-06-07 10:43:27 -04:00

linting + typing

This commit is contained in:
torzdf 2024-04-03 15:30:46 +01:00
parent 70c064ca7d
commit ab8199e243
12 changed files with 21 additions and 21 deletions

View file

@ -18,7 +18,7 @@ from .jobs_frames import Draw, Extract # noqa pylint: disable=unused-import
logger = logging.getLogger(__name__)
class Alignments(): # pylint:disable=too-few-public-methods
class Alignments():
""" The main entry point for Faceswap's Alignments Tool. This tool is part of the Faceswap
Tools suite and should be called from the ``python tools.py alignments`` command.
@ -239,7 +239,7 @@ class Alignments(): # pylint:disable=too-few-public-methods
self._run_process(args)
class _Alignments(): # pylint:disable=too-few-public-methods
class _Alignments():
""" The main entry point for Faceswap's Alignments Tool. This tool is part of the Faceswap
Tools suite and should be called from the ``python tools.py alignments`` command.

View file

@ -418,7 +418,7 @@ class Sort():
return reindexed
class Spatial(): # pylint:disable=too-few-public-methods
class Spatial():
""" Apply spatial temporal filtering to landmarks
Parameters

View file

@ -25,7 +25,7 @@ if T.TYPE_CHECKING:
logger = logging.getLogger(__name__)
class FromFaces(): # pylint:disable=too-few-public-methods
class FromFaces():
""" Scan a folder of Faceswap Extracted Faces and re-create the associated alignments file(s)
Parameters
@ -222,7 +222,7 @@ class FromFaces(): # pylint:disable=too-few-public-methods
aln.save()
class Rename(): # pylint:disable=too-few-public-methods
class Rename():
""" Rename faces in a folder to match their filename as stored in an alignments file.
Parameters
@ -319,7 +319,7 @@ class Rename(): # pylint:disable=too-few-public-methods
return rename_count
class RemoveFaces(): # pylint:disable=too-few-public-methods
class RemoveFaces():
""" Remove items from alignments file.
Parameters
@ -407,7 +407,7 @@ class RemoveFaces(): # pylint:disable=too-few-public-methods
logger.info("%s Extracted face(s) had their header information updated", len(to_update))
class FaceToFile(): # pylint:disable=too-few-public-methods
class FaceToFile():
""" Updates any optional/missing keys in the alignments file with any data that has been
populated in a PNGHeader. Includes masks and identity fields.

View file

@ -25,7 +25,7 @@ if T.TYPE_CHECKING:
logger = logging.getLogger(__name__)
class Draw(): # pylint:disable=too-few-public-methods
class Draw():
""" Draws annotations onto original frames and saves into a sub-folder next to the original
frames.
@ -171,7 +171,7 @@ class Draw(): # pylint:disable=too-few-public-methods
cv2.line(image, tuple(center), tuple(points[2]), (0, 0, 255), 2)
class Extract(): # pylint:disable=too-few-public-methods
class Extract():
""" Re-extract faces from source frames based on Alignment data
Parameters

View file

@ -245,8 +245,8 @@ class MediaLoader():
output_file = os.path.splitext(output_file)[0] + ".png"
logger.trace("Saving image: '%s'", output_file) # type: ignore
if metadata:
encoded_image = cv2.imencode(".png", image)[1]
encoded_image = png_write_meta(encoded_image.tobytes(), metadata)
encoded = cv2.imencode(".png", image)[1]
encoded_image = png_write_meta(encoded.tobytes(), metadata)
with open(output_file, "wb") as out_file:
out_file.write(encoded_image)
else:

View file

@ -248,7 +248,7 @@ class DetectedFaces():
return retval
class _DiskIO(): # pylint:disable=too-few-public-methods
class _DiskIO():
""" Handles the loading of :class:`~lib.align.DetectedFaces` from the alignments file
into :class:`DetectedFaces` and the saving of this data (in the opposite direction) to an
alignments file.

View file

@ -636,7 +636,7 @@ class VisibleObjects():
return True
class HoverBox(): # pylint:disable=too-few-public-methods
class HoverBox():
""" Handle the current mouse location when over the :class:`Viewport`.
Highlights the face currently underneath the cursor and handles actions when clicking

View file

@ -157,7 +157,7 @@ class Navigation():
self._globals.tk_transport_index.set(frame_count - 1)
class BackgroundImage(): # pylint:disable=too-few-public-methods
class BackgroundImage():
""" The background image of the canvas """
def __init__(self, canvas):
self._canvas = canvas

View file

@ -21,7 +21,7 @@ if T.TYPE_CHECKING:
logger = logging.getLogger(__name__)
class MaskGenerator: # pylint:disable=too-few-public-methods
class MaskGenerator:
""" Uses faceswap's extract pipeline to generate masks and update them into the alignments file
and/or extracted face PNG Headers

View file

@ -26,7 +26,7 @@ if T.TYPE_CHECKING:
logger = logging.getLogger(__name__)
class Import: # pylint:disable=too-few-public-methods
class Import:
""" Import masks from disk into an Alignments file
Parameters

View file

@ -23,7 +23,7 @@ if T.TYPE_CHECKING:
logger = logging.getLogger(__name__)
class Model(): # pylint:disable=too-few-public-methods
class Model():
""" Tool to perform actions on a model file.
Parameters
@ -105,7 +105,7 @@ class Model(): # pylint:disable=too-few-public-methods
self._job.process()
class Inference(): # pylint:disable=too-few-public-methods
class Inference():
""" Save an inference model from a trained Faceswap model.
Parameters
@ -153,7 +153,7 @@ class Inference(): # pylint:disable=too-few-public-methods
inference.save(self._output_file)
class NaNScan(): # pylint:disable=too-few-public-methods
class NaNScan():
""" Tool to scan for NaN and Infs in model weights.
Parameters
@ -245,7 +245,7 @@ class NaNScan(): # pylint:disable=too-few-public-methods
self._parse_output(errors)
class Restore(): # pylint:disable=too-few-public-methods
class Restore():
""" Restore a model from backup.
Parameters

View file

@ -22,7 +22,7 @@ if T.TYPE_CHECKING:
logger = logging.getLogger(__name__)
class SortAlignedMetric(SortMethod): # pylint:disable=too-few-public-methods
class SortAlignedMetric(SortMethod):
""" Sort by comparison of metrics stored in an Aligned Face objects. This is a parent class
for sort by aligned metrics methods. Individual methods should inherit from this class