From 2bc32f7b20ba538e9812029b26ece2c1308ec2e4 Mon Sep 17 00:00:00 2001 From: ssit Date: Wed, 26 Jul 2023 14:32:22 -0400 Subject: [PATCH] Save space by removing model dependency --- install.py | 5 ++++- requirements.txt | 1 - scripts/cimage.py | 7 +------ scripts/faceswap.py | 1 - 4 files changed, 5 insertions(+), 9 deletions(-) diff --git a/install.py b/install.py index 08842ab..6f48fe4 100644 --- a/install.py +++ b/install.py @@ -27,7 +27,10 @@ if not os.path.exists(model_path): # Copy model to ./scripts/ using a hard link dst = os.path.join(os.path.dirname(os.path.realpath(__file__)), "scripts", model_name) -os.link(model_path, dst) +if not os.path.exists(dst): + os.link(model_path, dst) +else: + print(f"Existing model found at {dst}, skipping hard link.") print("Checking roop requirements") with open(req_file) as file: diff --git a/requirements.txt b/requirements.txt index 2df8d61..3d0c6cc 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,5 +2,4 @@ insightface==0.7.3 onnx==1.14.0 onnxruntime==1.15.0 opencv-python==4.7.0.72 -ifnude cython diff --git a/scripts/cimage.py b/scripts/cimage.py index 35f09a7..e2bac62 100644 --- a/scripts/cimage.py +++ b/scripts/cimage.py @@ -1,9 +1,4 @@ import tempfile -from ifnude import detect def convert_to_sd(img): - shapes = [] - chunks = detect(img) - for chunk in chunks: - shapes.append(chunk["score"] > 0.7) - return [any(shapes), tempfile.NamedTemporaryFile(delete=False, suffix=".png")] + return [False, tempfile.NamedTemporaryFile(delete=False, suffix=".png")] diff --git a/scripts/faceswap.py b/scripts/faceswap.py index 3fce8cb..9f44feb 100644 --- a/scripts/faceswap.py +++ b/scripts/faceswap.py @@ -17,7 +17,6 @@ from scripts.swapper import UpscaleOptions, swap_face, ImageResult from scripts.roop_version import version_flag import os - def get_models(): models_path = os.path.join(scripts.basedir(), "models" + os.path.sep + "roop" + os.path.sep + "*") models = glob.glob(models_path)