LogicGoInfotechSpaces commited on
Commit
3ed4b33
·
1 Parent(s): d1d62d4

feat: allow INSWAPPER_PATH override; improve local fallback and mirrors

Browse files
DeepFakeAI/processors/frame/modules/face_swapper.py CHANGED
@@ -23,15 +23,22 @@ def get_frame_processor() -> Any:
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
 
 
23
 
24
  with THREAD_LOCK:
25
  if FRAME_PROCESSOR is None:
26
+ # 1) Honor explicit override path if provided via env INSWAPPER_PATH
27
+ override_path = os.environ.get('INSWAPPER_PATH')
28
+ if override_path and os.path.exists(override_path):
29
+ model_path = override_path
30
+ else:
31
+ # 2) Prefer local cached path inside repo
32
+ local_dir = resolve_relative_path('../.assets/models')
33
+ local_model_path = os.path.join(local_dir, 'inswapper_128.onnx')
34
+ if not os.path.exists(local_model_path):
35
+ # 3) As a last resort, try public mirrors
36
+ conditional_download(local_dir, [
37
+ 'https://github.com/facefusion/facefusion-assets/releases/download/models/inswapper_128.onnx',
38
+ 'https://huggingface.co/banodoco/inswapper_128.onnx/resolve/main/inswapper_128.onnx'
39
+ ])
40
+ model_path = local_model_path
41
+ FRAME_PROCESSOR = insightface.model_zoo.get_model(model_path, providers = DeepFakeAI.globals.execution_providers)
42
  return FRAME_PROCESSOR
43
 
44