fix path for model

pull/773/head
NeuroDonu 2024-11-09 16:43:13 +03:00 committed by GitHub
parent 4874282642
commit a840986159
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 7 deletions

View File

@ -11,7 +11,6 @@ from modules.face_analyser import get_one_face
from modules.typing import Frame, Face from modules.typing import Frame, Face
from modules.utilities import ( from modules.utilities import (
conditional_download, conditional_download,
resolve_relative_path,
is_image, is_image,
is_video, is_video,
) )
@ -21,9 +20,11 @@ THREAD_SEMAPHORE = threading.Semaphore()
THREAD_LOCK = threading.Lock() THREAD_LOCK = threading.Lock()
NAME = "DLC.FACE-ENHANCER" NAME = "DLC.FACE-ENHANCER"
abs_dir = os.path.dirname(os.path.abspath(__file__))
models_dir = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(abs_dir))), 'models')
def pre_check() -> bool: def pre_check() -> bool:
download_directory_path = resolve_relative_path("..\models") download_directory_path = models_dir
conditional_download( conditional_download(
download_directory_path, download_directory_path,
[ [
@ -47,11 +48,7 @@ def get_face_enhancer() -> Any:
with THREAD_LOCK: with THREAD_LOCK:
if FACE_ENHANCER is None: if FACE_ENHANCER is None:
if os.name == "nt": model_path = os.path.join(models_dir, 'GFPGANv1.4.pth')
model_path = resolve_relative_path("..\models\GFPGANv1.4.pth")
# todo: set models path https://github.com/TencentARC/GFPGAN/issues/399
else:
model_path = resolve_relative_path("../models/GFPGANv1.4.pth")
FACE_ENHANCER = gfpgan.GFPGANer(model_path=model_path, upscale=1) # type: ignore[attr-defined] FACE_ENHANCER = gfpgan.GFPGANer(model_path=model_path, upscale=1) # type: ignore[attr-defined]
return FACE_ENHANCER return FACE_ENHANCER