Commit
·
deb38be
1
Parent(s):
371dfef
fix: explicitly download inswapper_128.onnx to local cache before loading
Browse files
DeepFakeAI/processors/frame/modules/face_swapper.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
from typing import Any, List, Callable
|
|
|
|
| 2 |
import cv2
|
| 3 |
import insightface
|
| 4 |
import threading
|
|
@@ -22,13 +23,15 @@ def get_frame_processor() -> Any:
|
|
| 22 |
|
| 23 |
with THREAD_LOCK:
|
| 24 |
if FRAME_PROCESSOR is None:
|
| 25 |
-
#
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
|
|
|
|
|
|
| 32 |
return FRAME_PROCESSOR
|
| 33 |
|
| 34 |
|
|
@@ -39,7 +42,8 @@ def clear_frame_processor() -> None:
|
|
| 39 |
|
| 40 |
|
| 41 |
def pre_check() -> bool:
|
| 42 |
-
#
|
|
|
|
| 43 |
return True
|
| 44 |
|
| 45 |
|
|
|
|
| 1 |
from typing import Any, List, Callable
|
| 2 |
+
import os
|
| 3 |
import cv2
|
| 4 |
import insightface
|
| 5 |
import threading
|
|
|
|
| 23 |
|
| 24 |
with THREAD_LOCK:
|
| 25 |
if FRAME_PROCESSOR is None:
|
| 26 |
+
# Ensure model file exists locally; if missing, download from mirrors
|
| 27 |
+
local_dir = resolve_relative_path('../.assets/models')
|
| 28 |
+
local_model_path = os.path.join(local_dir, 'inswapper_128.onnx')
|
| 29 |
+
if not os.path.exists(local_model_path):
|
| 30 |
+
conditional_download(local_dir, [
|
| 31 |
+
'https://github.com/facefusion/facefusion-assets/releases/download/models/inswapper_128.onnx',
|
| 32 |
+
'https://huggingface.co/MonsterMMORPG/inswapper_128.onnx/resolve/main/inswapper_128.onnx'
|
| 33 |
+
])
|
| 34 |
+
FRAME_PROCESSOR = insightface.model_zoo.get_model(local_model_path, providers = DeepFakeAI.globals.execution_providers)
|
| 35 |
return FRAME_PROCESSOR
|
| 36 |
|
| 37 |
|
|
|
|
| 42 |
|
| 43 |
|
| 44 |
def pre_check() -> bool:
|
| 45 |
+
# Ensure directory exists; actual download handled in get_frame_processor
|
| 46 |
+
_ = resolve_relative_path('../.assets/models')
|
| 47 |
return True
|
| 48 |
|
| 49 |
|