diff --git a/modules/__init__.py b/modules/__init__.py index 6eca4a3..1e5a2ad 100644 --- a/modules/__init__.py +++ b/modules/__init__.py @@ -11,8 +11,8 @@ def imwrite_unicode(path, img, params=None): root, ext = os.path.splitext(path) if not ext: ext = ".png" - result, encoded_img = cv2.imencode(ext, img, params if params else []) - result, encoded_img = cv2.imencode(f".{ext}", img, params if params is not None else []) - encoded_img.tofile(path) - return True - return False \ No newline at end of file + result, encoded_img = cv2.imencode(ext, img, params if params is not None else []) + if not result: + return False + encoded_img.tofile(path) + return True \ No newline at end of file diff --git a/modules/core.py b/modules/core.py index c9457b8..6e50252 100644 --- a/modules/core.py +++ b/modules/core.py @@ -171,8 +171,6 @@ def limit_resources() -> None: # limit memory usage if modules.globals.max_memory: memory = modules.globals.max_memory * 1024 ** 3 - if platform.system().lower() == 'darwin': - memory = modules.globals.max_memory * 1024 ** 6 if platform.system().lower() == 'windows': import ctypes kernel32 = ctypes.windll.kernel32 diff --git a/modules/face_analyser.py b/modules/face_analyser.py index ba3f0e5..ce51017 100644 --- a/modules/face_analyser.py +++ b/modules/face_analyser.py @@ -257,6 +257,8 @@ def get_unique_faces_from_target_image() -> Any: modules.globals.source_target_map = [] target_frame = cv2.imread(modules.globals.target_path) many_faces = get_many_faces(target_frame) + if many_faces is None: + return None i = 0 for face in many_faces: @@ -291,6 +293,8 @@ def get_unique_faces_from_target_video() -> Any: for temp_frame_path in tqdm(temp_frame_paths, desc="Extracting face embeddings from frames"): temp_frame = cv2.imread(temp_frame_path) many_faces = get_many_faces(temp_frame) + if many_faces is None: + continue for face in many_faces: face_embeddings.append(face.normed_embedding) diff --git a/modules/processors/frame/core.py b/modules/processors/frame/core.py index a87412d..77f2fe9 100644 --- a/modules/processors/frame/core.py +++ b/modules/processors/frame/core.py @@ -37,6 +37,7 @@ def load_frame_processor_module(frame_processor: str) -> Any: frame_processor_module = importlib.import_module(f'modules.processors.frame.{frame_processor}') for method_name in FRAME_PROCESSORS_INTERFACE: if not hasattr(frame_processor_module, method_name): + print(f"Frame processor {frame_processor} is missing required method {method_name}") sys.exit() except ImportError: print(f"Frame processor {frame_processor} not found")