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__) 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 """ 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. 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) 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 """ 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. Tools suite and should be called from the ``python tools.py alignments`` command.

View File

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

View File

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

View File

@ -25,7 +25,7 @@ if T.TYPE_CHECKING:
logger = logging.getLogger(__name__) 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 """ Draws annotations onto original frames and saves into a sub-folder next to the original
frames. 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) 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 """ Re-extract faces from source frames based on Alignment data
Parameters Parameters

View File

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

View File

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

View File

@ -636,7 +636,7 @@ class VisibleObjects():
return True return True
class HoverBox(): # pylint:disable=too-few-public-methods class HoverBox():
""" Handle the current mouse location when over the :class:`Viewport`. """ Handle the current mouse location when over the :class:`Viewport`.
Highlights the face currently underneath the cursor and handles actions when clicking 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) 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 """ """ The background image of the canvas """
def __init__(self, canvas): def __init__(self, canvas):
self._canvas = canvas self._canvas = canvas

View File

@ -21,7 +21,7 @@ if T.TYPE_CHECKING:
logger = logging.getLogger(__name__) 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 """ Uses faceswap's extract pipeline to generate masks and update them into the alignments file
and/or extracted face PNG Headers and/or extracted face PNG Headers

View File

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

View File

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

View File

@ -22,7 +22,7 @@ if T.TYPE_CHECKING:
logger = logging.getLogger(__name__) 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 """ 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 for sort by aligned metrics methods. Individual methods should inherit from this class