Commit
·
9e14361
1
Parent(s):
bdd50c5
fix: avoid manual download; let insightface fetch 'inswapper_128.onnx' if not cached
Browse files
DeepFakeAI/processors/frame/modules/face_swapper.py
CHANGED
|
@@ -22,8 +22,13 @@ def get_frame_processor() -> Any:
|
|
| 22 |
|
| 23 |
with THREAD_LOCK:
|
| 24 |
if FRAME_PROCESSOR is None:
|
| 25 |
-
|
| 26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
return FRAME_PROCESSOR
|
| 28 |
|
| 29 |
|
|
@@ -34,12 +39,7 @@ def clear_frame_processor() -> None:
|
|
| 34 |
|
| 35 |
|
| 36 |
def pre_check() -> bool:
|
| 37 |
-
|
| 38 |
-
# Try multiple mirrors for inswapper_128.onnx
|
| 39 |
-
conditional_download(download_directory_path, [
|
| 40 |
-
'https://github.com/DeepFakeAI/DeepFakeAI-assets/releases/download/models/inswapper_128.onnx',
|
| 41 |
-
'https://huggingface.co/MonsterMMORPG/inswapper_128.onnx/resolve/main/inswapper_128.onnx'
|
| 42 |
-
])
|
| 43 |
return True
|
| 44 |
|
| 45 |
|
|
|
|
| 22 |
|
| 23 |
with THREAD_LOCK:
|
| 24 |
if FRAME_PROCESSOR is None:
|
| 25 |
+
# Prefer local cached model; if missing, let insightface download by name
|
| 26 |
+
local_model_path = resolve_relative_path('../.assets/models/inswapper_128.onnx')
|
| 27 |
+
try:
|
| 28 |
+
model_id = local_model_path if os.path.exists(local_model_path) else 'inswapper_128.onnx'
|
| 29 |
+
except Exception:
|
| 30 |
+
model_id = 'inswapper_128.onnx'
|
| 31 |
+
FRAME_PROCESSOR = insightface.model_zoo.get_model(model_id, providers = DeepFakeAI.globals.execution_providers)
|
| 32 |
return FRAME_PROCESSOR
|
| 33 |
|
| 34 |
|
|
|
|
| 39 |
|
| 40 |
|
| 41 |
def pre_check() -> bool:
|
| 42 |
+
# No-op: we will download through insightface if local file is missing
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
return True
|
| 44 |
|
| 45 |
|