Skip to content

Commit

Permalink
linting + typing
Browse files Browse the repository at this point in the history
  • Loading branch information
torzdf committed Apr 3, 2024
1 parent 70c064c commit ab8199e
Show file tree
Hide file tree
Showing 12 changed files with 21 additions and 21 deletions.
4 changes: 2 additions & 2 deletions tools/alignments/alignments.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
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.
Expand Down Expand Up @@ -239,7 +239,7 @@ def process(self):
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.
Expand Down
2 changes: 1 addition & 1 deletion tools/alignments/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ def reindex_faces(self) -> int:
return reindexed


class Spatial(): # pylint:disable=too-few-public-methods
class Spatial():
""" Apply spatial temporal filtering to landmarks
Parameters
Expand Down
8 changes: 4 additions & 4 deletions tools/alignments/jobs_faces.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
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
Expand Down Expand Up @@ -222,7 +222,7 @@ def _save_alignments(self,
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
Expand Down Expand Up @@ -319,7 +319,7 @@ def _rename_faces(self, filename_mappings: list[tuple[str, str]]) -> int:
return rename_count


class RemoveFaces(): # pylint:disable=too-few-public-methods
class RemoveFaces():
""" Remove items from alignments file.
Parameters
Expand Down Expand Up @@ -407,7 +407,7 @@ def _update_png_headers(self) -> None:
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.
Expand Down
4 changes: 2 additions & 2 deletions tools/alignments/jobs_frames.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
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.
Expand Down Expand Up @@ -171,7 +171,7 @@ def _annotate_pose(cls, image: np.ndarray, face: DetectedFace) -> None:
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
Expand Down
4 changes: 2 additions & 2 deletions tools/alignments/media.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,8 @@ def save_image(output_folder: str,
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:
Expand Down
2 changes: 1 addition & 1 deletion tools/manual/detected_faces.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ def _get_alignments(self, alignments_path: str, input_location: str) -> Alignmen
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.
Expand Down
2 changes: 1 addition & 1 deletion tools/manual/faceviewer/viewport.py
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,7 @@ def _shift(self):
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
Expand Down
2 changes: 1 addition & 1 deletion tools/manual/frameviewer/control.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def goto_last_frame(self):
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
Expand Down
2 changes: 1 addition & 1 deletion tools/mask/mask_generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
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
Expand Down
2 changes: 1 addition & 1 deletion tools/mask/mask_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
logger = logging.getLogger(__name__)


class Import: # pylint:disable=too-few-public-methods
class Import:
""" Import masks from disk into an Alignments file
Parameters
Expand Down
8 changes: 4 additions & 4 deletions tools/model/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
logger = logging.getLogger(__name__)


class Model(): # pylint:disable=too-few-public-methods
class Model():
""" Tool to perform actions on a model file.
Parameters
Expand Down Expand Up @@ -105,7 +105,7 @@ def process(self) -> None:
self._job.process()


class Inference(): # pylint:disable=too-few-public-methods
class Inference():
""" Save an inference model from a trained Faceswap model.
Parameters
Expand Down Expand Up @@ -153,7 +153,7 @@ def process(self) -> None:
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
Expand Down Expand Up @@ -245,7 +245,7 @@ def process(self) -> None:
self._parse_output(errors)


class Restore(): # pylint:disable=too-few-public-methods
class Restore():
""" Restore a model from backup.
Parameters
Expand Down
2 changes: 1 addition & 1 deletion tools/sort/sort_methods_aligned.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
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
Expand Down

0 comments on commit ab8199e

Please sign in to comment.