From ffc2bd24854e960306d6f3a1cf9d5ac696f98cb5 Mon Sep 17 00:00:00 2001 From: henryruhs Date: Tue, 30 May 2023 21:12:19 +0200 Subject: [PATCH] Resolve absolute model path --- core/processor.py | 5 ++++- run.py | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/core/processor.py b/core/processor.py index a2028a1..ad1e183 100644 --- a/core/processor.py +++ b/core/processor.py @@ -1,3 +1,5 @@ +import os + import cv2 import insightface from core.config import get_face @@ -9,7 +11,8 @@ FACE_SWAPPER = None def get_face_swapper(): global FACE_SWAPPER if FACE_SWAPPER is None: - FACE_SWAPPER = insightface.model_zoo.get_model('inswapper_128.onnx') + model_path = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'inswapper_128.onnx') + FACE_SWAPPER = insightface.model_zoo.get_model(model_path) return FACE_SWAPPER diff --git a/run.py b/run.py index c3e50ba..0b61ab4 100644 --- a/run.py +++ b/run.py @@ -64,7 +64,8 @@ def pre_check(): quit(f'Python version is not supported - please upgrade to 3.8 or higher') if not shutil.which('ffmpeg'): quit('ffmpeg is not installed!') - if os.path.isfile('../inswapper_128.onnx'): + model_path = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'inswapper_128.onnx') + if not os.path.isfile(model_path): quit('File "inswapper_128.onnx" does not exist!') if '--gpu' in sys.argv: CUDA_VERSION = torch.version.cuda