Skip to content

Conversation

@sourcery-ai
Copy link

@sourcery-ai sourcery-ai bot commented Jun 30, 2022

Branch master refactored by Sourcery.

If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.

See our documentation here.

Run Sourcery locally

Reduce the feedback loop during development by using the Sourcery editor plugin:

Review changes via command line

To manually merge these changes, make sure you're on the master branch, then run:

git fetch origin sourcery/master
git merge --ff-only FETCH_HEAD
git reset HEAD^

Help us improve this pull request!

@sourcery-ai sourcery-ai bot requested a review from nlejus June 30, 2022 16:41
Copy link
Author

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sourcery timed out performing refactorings.

Due to GitHub API limits, only the first 60 comments can be shown.

so certain steps can be skipped/output limited """
self.conda_required_packages = [("tk", )]
self.output = logger if logger else Output()
self.output = logger or Output()
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Environment.__init__ refactored with the following changes:

Comment on lines -93 to +98
retval = (hasattr(sys, "real_prefix") or
(hasattr(sys, "base_prefix") and sys.base_prefix != sys.prefix))
else:
prefix = os.path.dirname(sys.prefix)
retval = (os.path.basename(prefix) == "envs")
return retval
return hasattr(sys, "real_prefix") or (
hasattr(sys, "base_prefix") and sys.base_prefix != sys.prefix
)

prefix = os.path.dirname(sys.prefix)
return (os.path.basename(prefix) == "envs")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Environment.is_virtualenv refactored with the following changes:

Comment on lines -102 to +113
args = [arg for arg in sys.argv] # pylint:disable=unnecessary-comprehension
args = list(sys.argv)
if self.updater:
from lib.utils import get_backend # pylint:disable=import-outside-toplevel
args.append("--{}".format(get_backend()))
args.append(f"--{get_backend()}")

for arg in args:
if arg == "--installer":
self.is_installer = True
if arg == "--nvidia":
self.enable_cuda = True
if arg == "--amd":
self.enable_amd = True
elif arg == "--installer":
self.is_installer = True
elif arg == "--nvidia":
self.enable_cuda = True
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Environment.process_arguments refactored with the following changes:

This removes the following comments ( why? ):

# pylint:disable=unnecessary-comprehension

Comment on lines -125 to +126
requirements = list()
git_requirements = list()
requirements = []
git_requirements = []
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Environment.get_required_packages refactored with the following changes:

Comment on lines -158 to +164
self.output.info("Setup in %s %s" % (self.os_version[0], self.os_version[1]))
if not self.updater and not self.os_version[0] in ["Windows", "Linux", "Darwin"]:
self.output.error("Your system %s is not supported!" % self.os_version[0])
self.output.info(f"Setup in {self.os_version[0]} {self.os_version[1]}")
if not self.updater and self.os_version[0] not in [
"Windows",
"Linux",
"Darwin",
]:
self.output.error(f"Your system {self.os_version[0]} is not supported!")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Environment.check_system refactored with the following changes:

Comment on lines -340 to +345
trm = "{}ERROR {} ".format(self.red, self.default_color)
trm = f"{self.red}ERROR {self.default_color} "
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Output.error refactored with the following changes:

Comment on lines -351 to -355

# Checks not required for installer
if self.env.is_installer:
return

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Checks.__init__ refactored with the following changes:

Comment on lines -479 to +482
path = os.popen(f"{locate} nvcc").read()
if path:
if path := os.popen(f"{locate} nvcc").read():
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function CudaCheck._cuda_check refactored with the following changes:

Comment on lines -559 to +561
cudnn_checkfiles = [os.path.join(cudnn_path, header) for header in header_files]
return cudnn_checkfiles
return [os.path.join(cudnn_path, header) for header in header_files]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function CudaCheck._get_checkfiles_linux refactored with the following changes:

Comment on lines -575 to +576
cudnn_checkfiles = [os.path.join(scandir, header) for header in self._cudnn_header_files]
return cudnn_checkfiles
return [os.path.join(scandir, header) for header in self._cudnn_header_files]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function CudaCheck._get_checkfiles_windows refactored with the following changes:

Comment on lines -643 to +646
if len(pkg[0].split("==")) > 1:
if pkg[0].split("==")[1] != self.env.installed_conda_packages.get(key):
self.env.conda_missing_packages.append(pkg)
continue
if len(pkg[0].split("==")) > 1 and pkg[0].split("==")[
1
] != self.env.installed_conda_packages.get(key):
self.env.conda_missing_packages.append(pkg)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Install.check_conda_missing_dep refactored with the following changes:

pkg = pkg[0]
if version:
pkg = "{}{}".format(pkg, ",".join("".join(spec) for spec in version))
pkg = f'{pkg}{",".join(("".join(spec) for spec in version))}'
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Install.install_python_packages refactored with the following changes:

specs = Requirement.parse(package).specs
for key, val in TENSORFLOW_REQUIREMENTS.items():
req_specs = Requirement.parse("foobar" + key).specs
req_specs = Requirement.parse(f"foobar{key}").specs
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Install.conda_installer refactored with the following changes:

pipexe = [sys.executable, "-m", "pip"]
# hide info/warning and fix cache hang
pipexe.extend(["install", "--no-cache-dir"])
pipexe = [sys.executable, "-m", "pip", "install", "--no-cache-dir"]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Install.pip_installer refactored with the following changes:

This removes the following comments ( why? ):

# hide info/warning and fix cache hang

mod = ".".join(("tools", tool_name, "cli"))
module = import_module(mod)
cliarg_class = getattr(module, "{}Args".format(tool_name.title()))
cliarg_class = getattr(module, f"{tool_name.title()}Args")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function _get_cli_opts refactored with the following changes:

Comment on lines -246 to +257
choices = list() if not choices else choices
choices = choices or list()

if None in (section, title, default, info):
raise ValueError("Default config items must have a section, title, defult and "
"information text")
if not self.defaults.get(section, None):
raise ValueError("Section does not exist: {}".format(section))
raise ValueError(f"Section does not exist: {section}")
if datatype not in (str, bool, float, int, list):
raise ValueError("'datatype' must be one of str, bool, float or "
"int: {} - {}".format(section, title))
raise ValueError(
f"'datatype' must be one of str, bool, float or int: {section} - {title}"
)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function FaceswapConfig.add_item refactored with the following changes:

Comment on lines -284 to +295
helptext += "\nChoose from: {}".format(choices)
helptext += f"\nChoose from: {choices}"
elif datatype == bool:
helptext += "\nChoose from: True, False"
elif datatype == int:
cmin, cmax = min_max
helptext += "\nSelect an integer between {} and {}".format(cmin, cmax)
helptext += f"\nSelect an integer between {cmin} and {cmax}"
elif datatype == float:
cmin, cmax = min_max
helptext += "\nSelect a decimal number between {} and {}".format(cmin, cmax)
helptext += "\n[Default: {}]".format(default)
helptext += f"\nSelect a decimal number between {cmin} and {cmax}"
helptext += f"\n[Default: {default}]"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function FaceswapConfig.expand_helptext refactored with the following changes:

Comment on lines -357 to +359
if is_section:
helptext = helptext.upper()
else:
helptext = "\n{}".format(helptext)
helptext = helptext.upper() if is_section else f"\n{helptext}"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function FaceswapConfig.format_help refactored with the following changes:

Comment on lines -420 to +419
if not all(val in opt["choices"] for val in opt_value):
if any(val not in opt["choices"] for val in opt_value):
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function FaceswapConfig.check_config_choices refactored with the following changes:

Comment on lines -484 to +485
config_file = os.path.join(configs_path, "{}.ini".format(section))
config_file = os.path.join(configs_path, f"{section}.ini")
if not os.path.exists(config_file):
mod = import_module("plugins.{}.{}".format(section, "_config"))
mod = import_module(f"plugins.{section}._config")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function generate_configs refactored with the following changes:

Comment on lines -49 to +53
retval = dict()
for fpath in reference_file_paths:
retval[fpath] = {"image": read_image(fpath, raise_error=True),
"type": "filter"}
retval = {
fpath: {"image": read_image(fpath, raise_error=True), "type": "filter"}
for fpath in reference_file_paths
}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function FaceFilter.load_images refactored with the following changes:

Comment on lines -142 to +154
msg = "Rejecting filter face: {} > {}".format(round(avgs["filter"], 2), self.threshold)
msg = f'Rejecting filter face: {round(avgs["filter"], 2)} > {self.threshold}'
retval = False
# nFilter no Filter
elif not distances["filter"] and avgs["nfilter"] < self.threshold:
msg = "Rejecting nFilter face: {} < {}".format(round(avgs["nfilter"], 2),
self.threshold)
msg = f'Rejecting nFilter face: {round(avgs["nfilter"], 2)} < {self.threshold}'
retval = False
# Filter with nFilter
elif distances["filter"] and distances["nfilter"] and mins["filter"] > mins["nfilter"]:
msg = ("Rejecting face as distance from nfilter sample is smaller: (filter: {}, "
"nfilter: {})".format(round(mins["filter"], 2), round(mins["nfilter"], 2)))
msg = f'Rejecting face as distance from nfilter sample is smaller: (filter: {round(mins["filter"], 2)}, nfilter: {round(mins["nfilter"], 2)})'

retval = False
elif distances["filter"] and distances["nfilter"] and avgs["filter"] > avgs["nfilter"]:
msg = ("Rejecting face as average distance from nfilter sample is smaller: (filter: "
"{}, nfilter: {})".format(round(mins["filter"], 2), round(mins["nfilter"], 2)))
msg = f'Rejecting face as average distance from nfilter sample is smaller: (filter: {round(mins["filter"], 2)}, nfilter: {round(mins["nfilter"], 2)})'

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function FaceFilter.check refactored with the following changes:

This removes the following comments ( why? ):

# Filter with nFilter
# nFilter no Filter

Comment on lines -65 to +73
self._log("debug", "Initializing {}".format(self.__class__.__name__))
self._log("debug", f"Initializing {self.__class__.__name__}")

self._plaid = None
self._initialized = False
self._device_count = 0
self._active_devices = list()
self._handles = list()
self._active_devices = []
self._handles = []
self._driver = None
self._devices = list()
self._devices = []
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function GPUStats.__init__ refactored with the following changes:

def cli_devices(self):
""" list: List of available devices for use in faceswap's command line arguments """
return ["{}: {}".format(idx, device) for idx, device in enumerate(self._devices)]
return [f"{idx}: {device}" for idx, device in enumerate(self._devices)]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function GPUStats.cli_devices refactored with the following changes:

Comment on lines -160 to +201
if not self._initialized:
if get_backend() == "amd":
self._log("debug", "AMD Detected. Using plaidMLStats")
loglevel = "INFO" if self._logger is None else self._logger.getEffectiveLevel()
self._plaid = plaidlib(log_level=loglevel, log=log)
elif IS_MACOS:
self._log("debug", "macOS Detected. Using pynvx")
try:
pynvx.cudaInit()
except RuntimeError:
self._initialized = True
return
else:
try:
self._log("debug", "OS is not macOS. Trying pynvml")
pynvml.nvmlInit()
except (pynvml.NVMLError_LibraryNotFound, # pylint: disable=no-member
if self._initialized:
return
if get_backend() == "amd":
self._log("debug", "AMD Detected. Using plaidMLStats")
loglevel = "INFO" if self._logger is None else self._logger.getEffectiveLevel()
self._plaid = plaidlib(log_level=loglevel, log=log)
elif IS_MACOS:
self._log("debug", "macOS Detected. Using pynvx")
try:
pynvx.cudaInit()
except RuntimeError:
self._initialized = True
return
else:
try:
self._log("debug", "OS is not macOS. Trying pynvml")
pynvml.nvmlInit()
except (pynvml.NVMLError_LibraryNotFound, # pylint: disable=no-member
pynvml.NVMLError_DriverNotLoaded, # pylint: disable=no-member
pynvml.NVMLError_NoPermission) as err: # pylint: disable=no-member
if plaidlib is not None:
self._log("debug", "pynvml errored. Trying plaidML")
self._plaid = plaidlib(log=log)
else:
msg = ("There was an error reading from the Nvidia Machine Learning "
"Library. Either you do not have an Nvidia GPU (in which case "
"this warning can be ignored) or the most likely cause is "
"incorrectly installed drivers. If this is the case, Please remove "
"and reinstall your Nvidia drivers before reporting."
"Original Error: {}".format(str(err)))
self._log("warning", msg)
self._initialized = True
return
except Exception as err: # pylint: disable=broad-except
msg = ("An unhandled exception occured loading pynvml. "
"Original error: {}".format(str(err)))
if self._logger:
self._logger.error(msg)
else:
print(msg)
if plaidlib is not None:
self._log("debug", "pynvml errored. Trying plaidML")
self._plaid = plaidlib(log=log)
else:
msg = f"There was an error reading from the Nvidia Machine Learning Library. Either you do not have an Nvidia GPU (in which case this warning can be ignored) or the most likely cause is incorrectly installed drivers. If this is the case, Please remove and reinstall your Nvidia drivers before reporting.Original Error: {str(err)}"

self._log("warning", msg)
self._initialized = True
return
self._initialized = True
self._get_device_count()
self._get_active_devices()
self._get_handles()
except Exception as err: # pylint: disable=broad-except
msg = f"An unhandled exception occured loading pynvml. Original error: {str(err)}"

if self._logger:
self._logger.error(msg)
else:
print(msg)
self._initialized = True
return
self._initialized = True
self._get_device_count()
self._get_active_devices()
self._get_handles()
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function GPUStats._initialize refactored with the following changes:

Comment on lines -285 to +303
msg = "Error while reading image (TypeError): '{}'".format(filename)
msg += ". Original error message: {}".format(str(err))
msg = (
f"Error while reading image (TypeError): '{filename}'"
+ f". Original error message: {str(err)}"
)

logger.error(msg)
if raise_error:
raise Exception(msg)
except ValueError as err:
success = False
msg = ("Error while reading image. This can be caused by special characters in the "
"filename or a corrupt image file: '{}'".format(filename))
msg += ". Original error message: {}".format(str(err))
msg = f"Error while reading image. This can be caused by special characters in the filename or a corrupt image file: '{filename}'"

msg += f". Original error message: {str(err)}"
logger.error(msg)
if raise_error:
raise Exception(msg)
except Exception as err: # pylint:disable=broad-except
success = False
msg = "Failed to load image '{}'. Original Error: {}".format(filename, str(err))
msg = f"Failed to load image '{filename}'. Original Error: {str(err)}"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function read_image refactored with the following changes:

Comment on lines -387 to +390
retval = dict()
retval = {}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function read_image_meta refactored with the following changes:

Comment on lines -488 to +491
retval = length + b"iTXt" + chunk + crc
return retval
return length + b"iTXt" + chunk + crc
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function pack_to_itxt refactored with the following changes:

Comment on lines -503 to +505
tmp_filename = filename + "~"
tmp_filename = f"{filename}~"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function update_existing_metadata refactored with the following changes:

Comment on lines -593 to +595
retval = png[:split] + pack_to_itxt(data) + png[split:]
return retval
return png[:split] + pack_to_itxt(data) + png[split:]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function png_write_meta refactored with the following changes:

@sourcery-ai
Copy link
Author

sourcery-ai bot commented Jun 30, 2022

Sourcery Code Quality Report

✅  Merging this PR will increase code quality in the affected files by 0.04%.

Quality metrics Before After Change
Complexity 4.31 ⭐ 4.21 ⭐ -0.10 👍
Method Length 62.58 🙂 62.30 🙂 -0.28 👍
Working memory 8.25 🙂 8.27 🙂 0.02 👎
Quality 70.68% 🙂 70.72% 🙂 0.04% 👍
Other metrics Before After Change
Lines 38861 39066 205
Changed files Quality Before Quality After Quality Change
setup.py 69.15% 🙂 68.80% 🙂 -0.35% 👎
tools.py 81.46% ⭐ 81.46% ⭐ 0.00%
_travis/simple_tests.py 73.97% 🙂 72.58% 🙂 -1.39% 👎
lib/config.py 69.19% 🙂 69.26% 🙂 0.07% 👍
lib/face_filter.py 62.10% 🙂 61.53% 🙂 -0.57% 👎
lib/gpu_stats.py 69.36% 🙂 70.25% 🙂 0.89% 👍
lib/image.py 61.45% 🙂 61.49% 🙂 0.04% 👍
lib/keypress.py 78.29% ⭐ 78.75% ⭐ 0.46% 👍
lib/logger.py 78.42% ⭐ 78.50% ⭐ 0.08% 👍
lib/multithreading.py 85.36% ⭐ 85.38% ⭐ 0.02% 👍
lib/plaidml_tools.py 79.86% ⭐ 79.73% ⭐ -0.13% 👎
lib/queue_manager.py 86.68% ⭐ 86.66% ⭐ -0.02% 👎
lib/serializer.py 84.71% ⭐ 83.82% ⭐ -0.89% 👎
lib/sysinfo.py 84.13% ⭐ 83.84% ⭐ -0.29% 👎
lib/utils.py 74.75% 🙂 74.63% 🙂 -0.12% 👎
lib/vgg_face.py 84.08% ⭐ 84.06% ⭐ -0.02% 👎
lib/align/aligned_face.py 71.09% 🙂 71.51% 🙂 0.42% 👍
lib/align/alignments.py 80.07% ⭐ 80.03% ⭐ -0.04% 👎
lib/align/detected_face.py 73.04% 🙂 73.09% 🙂 0.05% 👍
lib/cli/actions.py 81.21% ⭐ 82.57% ⭐ 1.36% 👍
lib/cli/args.py 65.45% 🙂 65.73% 🙂 0.28% 👍
lib/cli/launcher.py 71.52% 🙂 71.89% 🙂 0.37% 👍
lib/gui/_config.py 63.67% 🙂 63.76% 🙂 0.09% 👍
lib/gui/command.py 75.39% ⭐ 75.40% ⭐ 0.01% 👍
lib/gui/control_helper.py 68.53% 🙂 68.33% 🙂 -0.20% 👎
lib/gui/custom_widgets.py 76.98% ⭐ 77.60% ⭐ 0.62% 👍
lib/gui/display.py 87.48% ⭐ 87.61% ⭐ 0.13% 👍
lib/gui/display_analysis.py 78.39% ⭐ 78.36% ⭐ -0.03% 👎
lib/gui/display_command.py 78.16% ⭐ 78.20% ⭐ 0.04% 👍
lib/gui/display_graph.py 75.96% ⭐ 76.16% ⭐ 0.20% 👍
lib/gui/display_page.py 86.57% ⭐ 86.41% ⭐ -0.16% 👎
lib/gui/menu.py 68.48% 🙂 68.53% 🙂 0.05% 👍
lib/gui/options.py 71.22% 🙂 71.07% 🙂 -0.15% 👎
lib/gui/popup_configure.py 64.00% 🙂 64.24% 🙂 0.24% 👍
lib/gui/popup_session.py 65.28% 🙂 65.43% 🙂 0.15% 👍
lib/gui/project.py 78.23% ⭐ 78.12% ⭐ -0.11% 👎
lib/gui/theme.py 64.04% 🙂 64.34% 🙂 0.30% 👍
lib/gui/utils.py 71.93% 🙂 71.83% 🙂 -0.10% 👎
lib/gui/wrapper.py 66.72% 🙂 65.73% 🙂 -0.99% 👎
lib/gui/analysis/event_reader.py 74.05% 🙂 74.09% 🙂 0.04% 👍
lib/gui/analysis/stats.py 71.30% 🙂 71.39% 🙂 0.09% 👍
lib/model/backup_restore.py 76.00% ⭐ 76.26% ⭐ 0.26% 👍
lib/model/initializers.py 61.94% 🙂 61.93% 🙂 -0.01% 👎
lib/model/layers.py 72.34% 🙂 73.49% 🙂 1.15% 👍
lib/model/losses_plaid.py 69.60% 🙂 69.26% 🙂 -0.34% 👎
lib/model/losses_tf.py 69.60% 🙂 69.49% 🙂 -0.11% 👎
lib/model/nn_blocks.py 68.27% 🙂 68.54% 🙂 0.27% 👍
lib/model/session.py 75.31% ⭐ 75.66% ⭐ 0.35% 👍
lib/model/normalization/normalization_common.py 56.80% 🙂 57.09% 🙂 0.29% 👍
lib/model/normalization/normalization_plaid.py 64.10% 🙂 64.11% 🙂 0.01% 👍
lib/model/normalization/normalization_tf.py 72.85% 🙂 73.11% 🙂 0.26% 👍
lib/training/augmentation.py 62.50% 🙂 62.51% 🙂 0.01% 👍
lib/training/generator.py 65.35% 🙂 65.54% 🙂 0.19% 👍
plugins/plugin_loader.py 79.91% ⭐ 80.18% ⭐ 0.27% 👍
plugins/convert/color/color_transfer.py 56.73% 🙂 55.93% 🙂 -0.80% 👎
plugins/convert/color/manual_balance.py 74.19% 🙂 74.66% 🙂 0.47% 👍
plugins/convert/mask/_base.py 88.91% ⭐ 88.86% ⭐ -0.05% 👎
plugins/convert/mask/box_blend.py 83.83% ⭐ 83.85% ⭐ 0.02% 👍
plugins/convert/writer/_base.py 90.21% ⭐ 89.47% ⭐ -0.74% 👎
plugins/convert/writer/ffmpeg.py 77.18% ⭐ 77.27% ⭐ 0.09% 👍
plugins/convert/writer/gif.py 82.87% ⭐ 83.33% ⭐ 0.46% 👍
plugins/convert/writer/opencv.py 86.76% ⭐ 87.04% ⭐ 0.28% 👍
plugins/convert/writer/pillow.py 80.47% ⭐ 79.75% ⭐ -0.72% 👎
plugins/extract/_base.py 73.56% 🙂 73.73% 🙂 0.17% 👍
plugins/extract/pipeline.py 74.35% 🙂 74.09% 🙂 -0.26% 👎
plugins/extract/align/_base.py 63.82% 🙂 63.87% 🙂 0.05% 👍
plugins/extract/align/cv2_dnn.py 69.75% 🙂 69.50% 🙂 -0.25% 👎
plugins/extract/detect/_base.py 62.45% 🙂 62.48% 🙂 0.03% 👍
plugins/extract/detect/cv2_dnn.py 83.42% ⭐ 83.46% ⭐ 0.04% 👍
plugins/extract/detect/mtcnn.py 56.87% 🙂 57.38% 🙂 0.51% 👍
plugins/extract/detect/s3fd.py 64.48% 🙂 64.64% 🙂 0.16% 👍
plugins/extract/mask/_base.py 56.65% 🙂 56.69% 🙂 0.04% 👍
plugins/extract/mask/bisenet_fp.py 74.36% 🙂 74.38% 🙂 0.02% 👍
plugins/extract/mask/components.py 79.08% ⭐ 79.70% ⭐ 0.62% 👍
plugins/extract/mask/extended.py 71.25% 🙂 71.74% 🙂 0.49% 👍
plugins/extract/mask/vgg_clear.py 77.14% ⭐ 77.42% ⭐ 0.28% 👍
plugins/extract/mask/vgg_obstructed.py 76.97% ⭐ 77.24% ⭐ 0.27% 👍
plugins/extract/recognition/vgg_face2_keras.py 79.23% ⭐ 79.25% ⭐ 0.02% 👍
plugins/train/_config.py 61.53% 🙂 61.51% 🙂 -0.02% 👎
plugins/train/model/_base.py 69.73% 🙂 69.72% 🙂 -0.01% 👎
plugins/train/model/dfaker.py 60.11% 🙂 60.11% 🙂 0.00%
plugins/train/model/dfl_h128.py 73.37% 🙂 73.37% 🙂 0.00%
plugins/train/model/dfl_sae.py 65.84% 🙂 66.67% 🙂 0.83% 👍
plugins/train/model/dlight.py 60.69% 🙂 60.59% 🙂 -0.10% 👎
plugins/train/model/iae.py 77.49% ⭐ 77.82% ⭐ 0.33% 👍
plugins/train/model/lightweight.py 73.50% 🙂 74.60% 🙂 1.10% 👍
plugins/train/model/original.py 76.99% ⭐ 77.82% ⭐ 0.83% 👍
plugins/train/model/phaze_a.py 70.13% 🙂 70.04% 🙂 -0.09% 👎
plugins/train/model/realface.py 63.71% 🙂 63.58% 🙂 -0.13% 👎
plugins/train/model/unbalanced.py 57.99% 🙂 57.78% 🙂 -0.21% 👎
plugins/train/model/villain.py 56.53% 🙂 56.53% 🙂 0.00%
plugins/train/trainer/_base.py 63.02% 🙂 63.41% 🙂 0.39% 👍
scripts/convert.py 68.89% 🙂 68.75% 🙂 -0.14% 👎
scripts/extract.py 64.57% 🙂 63.88% 🙂 -0.69% 👎
scripts/fsmedia.py 74.02% 🙂 74.40% 🙂 0.38% 👍
scripts/gui.py 81.03% ⭐ 81.05% ⭐ 0.02% 👍
scripts/train.py 60.40% 🙂 60.50% 🙂 0.10% 👍
tests/lib/model/losses_test.py 60.03% 🙂 59.57% 🙂 -0.46% 👎
tests/lib/model/nn_blocks_test.py 67.60% 🙂 66.74% 🙂 -0.86% 👎
tests/lib/model/normalization_test.py 77.83% ⭐ 75.47% ⭐ -2.36% 👎
tools/alignments/cli.py 60.99% 🙂 61.67% 🙂 0.68% 👍
tools/alignments/jobs.py 74.69% 🙂 74.46% 🙂 -0.23% 👎
tools/alignments/media.py 79.72% ⭐ 79.90% ⭐ 0.18% 👍
tools/effmpeg/cli.py 66.84% 🙂 67.30% 🙂 0.46% 👍
tools/effmpeg/effmpeg.py 65.39% 🙂 66.10% 🙂 0.71% 👍

Here are some functions in these files that still need a tune-up:

File Function Complexity Length Working Memory Quality Recommendation
tools/effmpeg/effmpeg.py Effmpeg.process 43 ⛔ 516 ⛔ 11 😞 19.62% ⛔ Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
lib/model/normalization/normalization_common.py GroupNormalization.call 20 😞 350 ⛔ 21 ⛔ 21.13% ⛔ Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
lib/gui/wrapper.py FaceswapControl.read_stdout 35 ⛔ 214 ⛔ 15 😞 23.47% ⛔ Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
lib/gui/popup_configure.py DisplayArea.save 29 😞 261 ⛔ 14 😞 24.75% ⛔ Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
lib/image.py FfmpegReader._initialize 32 😞 281 ⛔ 12 😞 25.45% 😞 Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions

Legend and Explanation

The emojis denote the absolute quality of the code:

  • ⭐ excellent
  • 🙂 good
  • 😞 poor
  • ⛔ very poor

The 👍 and 👎 indicate whether the quality has improved or gotten worse with this pull request.


Please see our documentation here for details on how these metrics are calculated.

We are actively working on this report - lots more documentation and extra metrics to come!

Help us improve this quality report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants