From c94d2aab4dced6bf4033ec624fb826a1f13ac7b6 Mon Sep 17 00:00:00 2001 From: Tran Xen <137925069+glucauze@users.noreply.github.com> Date: Sat, 9 Sep 2023 10:51:36 +0200 Subject: [PATCH] v1.2.7 --- install.py | 10 ++++++++-- requirements-gpu.txt | 1 - requirements.txt | 1 - scripts/faceswaplab_globals.py | 2 +- scripts/faceswaplab_swapping/face_checkpoints.py | 12 ++---------- scripts/faceswaplab_utils/models_utils.py | 12 +++++++++--- 6 files changed, 20 insertions(+), 18 deletions(-) diff --git a/install.py b/install.py index 7b82180..3d87755 100644 --- a/install.py +++ b/install.py @@ -62,5 +62,11 @@ def check_install() -> None: import timeit -check_time = timeit.timeit(check_install, number=1) -print(check_time) +try: + check_time = timeit.timeit(check_install, number=1) + print(check_time) +except Exception as e: + print("FaceswapLab install failed", e) + print( + "You can try to install dependencies manually by activating venv and installing requirements.txt or requirements-gpu.txt" + ) diff --git a/requirements-gpu.txt b/requirements-gpu.txt index e914f8d..75dd998 100644 --- a/requirements-gpu.txt +++ b/requirements-gpu.txt @@ -1,5 +1,4 @@ cython -dill ifnude insightface==0.7.3 onnx>=1.14.0 diff --git a/requirements.txt b/requirements.txt index cf934a2..8684bd2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,5 @@ protobuf>=3.20.2 cython -dill ifnude insightface==0.7.3 onnx>=1.14.0 diff --git a/scripts/faceswaplab_globals.py b/scripts/faceswaplab_globals.py index 93c8b05..99edff0 100644 --- a/scripts/faceswaplab_globals.py +++ b/scripts/faceswaplab_globals.py @@ -16,7 +16,7 @@ REFERENCE_PATH = os.path.join( ) # Defining the version flag for the application -VERSION_FLAG: str = "v1.2.5" +VERSION_FLAG: str = "v1.2.7" # Defining the path for 'sd-webui-faceswaplab' inside the 'extensions' directory EXTENSION_PATH = os.path.join("extensions", "sd-webui-faceswaplab") diff --git a/scripts/faceswaplab_swapping/face_checkpoints.py b/scripts/faceswaplab_swapping/face_checkpoints.py index ad952d3..240d835 100644 --- a/scripts/faceswaplab_swapping/face_checkpoints.py +++ b/scripts/faceswaplab_swapping/face_checkpoints.py @@ -14,7 +14,6 @@ from scripts.faceswaplab_utils import imgutils from scripts.faceswaplab_utils.models_utils import get_swap_models import traceback -import dill as pickle # will be removed in future versions from scripts.faceswaplab_swapping import swapper from pprint import pformat import re @@ -174,20 +173,13 @@ def load_face(name: str) -> Optional[Face]: if filename.endswith(".pkl"): logger.warning( - "Pkl files for faces are deprecated to enhance safety, they will be unsupported in future versions." + "Pkl files for faces are deprecated to enhance safety, you need to convert them" ) logger.warning("The file will be converted to .safetensors") logger.warning( "You can also use this script https://gist.github.com/glucauze/4a3c458541f2278ad801f6625e5b9d3d" ) - with open(filename, "rb") as file: - logger.info("Load pkl") - face = Face(pickle.load(file)) - logger.warning( - "Convert to safetensors, you can remove the pkl version once you have ensured that the safetensor is working" - ) - save_face(face, filename.replace(".pkl", ".safetensors")) - return face + return None elif filename.endswith(".safetensors"): face = {} diff --git a/scripts/faceswaplab_utils/models_utils.py b/scripts/faceswaplab_utils/models_utils.py index 2d8b8e9..5b51a8d 100644 --- a/scripts/faceswaplab_utils/models_utils.py +++ b/scripts/faceswaplab_utils/models_utils.py @@ -72,10 +72,16 @@ def get_current_swap_model() -> str: models = get_swap_models() model = models[0] if len(models) else None logger.info("Try to use model : %s", model) - if not os.path.isfile(model): # type: ignore - logger.error("The model %s cannot be found or loaded", model) + try: + if not os.path.isfile(model): # type: ignore + logger.error("The model %s cannot be found or loaded", model) + raise FileNotFoundError( + "No faceswap model found. Please add it to the faceswaplab directory." + ) + except: raise FileNotFoundError( - "No faceswap model found. Please add it to the faceswaplab directory." + "Was not able to check model, please ensure the model is in the proper directory" ) + assert model is not None return model