fix: 🐛 repetitive warning (#177)
Co-authored-by: Mel Massadian <mel@melmassadian.com>
This commit is contained in:
co-authored by
Mel Massadian
parent
2fe0859476
commit
780c52f03a
@@ -34,7 +34,9 @@ class MTB_LoadFaceEnhanceModel:
|
||||
fr_models_path, um_models_path = cls.get_models_root()
|
||||
|
||||
if fr_models_path is None and um_models_path is None:
|
||||
log.warning("Face restoration models not found.")
|
||||
if not hasattr(cls, "_warned"):
|
||||
log.warning("Face restoration models not found.")
|
||||
cls._warned = True
|
||||
return []
|
||||
if not fr_models_path.exists():
|
||||
# log.warning(
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import contextlib
|
||||
import functools
|
||||
import importlib
|
||||
import math
|
||||
import os
|
||||
import shlex
|
||||
@@ -315,12 +316,6 @@ def _run_command(shell_cmd, ignored_lines_start):
|
||||
print("Command executed successfully!")
|
||||
|
||||
|
||||
# todo use the requirements library
|
||||
reqs_map = {value: key for key, value in pip_map.items()}
|
||||
|
||||
import importlib
|
||||
|
||||
|
||||
def import_install(package_name):
|
||||
package_spec = reqs_map.get(package_name, package_name)
|
||||
|
||||
@@ -368,6 +363,7 @@ font_path = here / "data" / "font.ttf"
|
||||
# - Add extern folder to path
|
||||
extern_root = here / "extern"
|
||||
add_path(extern_root)
|
||||
|
||||
for pth in extern_root.iterdir():
|
||||
if pth.is_dir():
|
||||
add_path(pth)
|
||||
@@ -376,6 +372,14 @@ for pth in extern_root.iterdir():
|
||||
add_path(comfy_dir)
|
||||
add_path(comfy_dir / "custom_nodes")
|
||||
|
||||
|
||||
# TODO: use the requirements library
|
||||
reqs_map = {value: key for key, value in pip_map.items()}
|
||||
|
||||
# NOTE: store already logged warnings to only alert once.
|
||||
warned_messages: set[str] = set()
|
||||
|
||||
|
||||
PIL_FILTER_MAP = {
|
||||
"nearest": Image.Resampling.NEAREST,
|
||||
"box": Image.Resampling.BOX,
|
||||
@@ -683,9 +687,10 @@ def get_model_path(fam, model=None):
|
||||
if res:
|
||||
if isinstance(res, list):
|
||||
if len(res) > 1:
|
||||
log.warning(
|
||||
f"Found multiple match, we will pick the first {res[0]}\n{res}"
|
||||
)
|
||||
warn_msg = f"Found multiple match, we will pick the first {res[0]}\n{res}"
|
||||
if warn_msg not in warned_messages:
|
||||
log.warning(warn_msg)
|
||||
warned_messages.add(warn_msg)
|
||||
res = res[0]
|
||||
res = Path(res)
|
||||
log.debug(f"Resolved model path from folder_paths: {res}")
|
||||
|
||||
Reference in New Issue
Block a user