LogicGoInfotechSpaces commited on
Commit
39f8e54
·
1 Parent(s): 6529bcc

FaceSwapper: remove broken name fallback; ensure HF hub + mirrors then cache env export

Browse files
DeepFakeAI/processors/frame/modules/face_swapper.py CHANGED
@@ -47,11 +47,18 @@ def get_frame_processor() -> Any:
47
  model_path = None # keep trying
48
  # If HF Hub failed, try public mirrors as a last resort
49
  if not model_path:
50
- # As a robust fallback, let insightface download by name into its own cache
51
- FRAME_PROCESSOR = insightface.model_zoo.get_model('inswapper_128.onnx', providers = DeepFakeAI.globals.execution_providers)
52
- return FRAME_PROCESSOR
 
 
 
 
53
  else:
54
  model_path = local_model_path
 
 
 
55
  FRAME_PROCESSOR = insightface.model_zoo.get_model(model_path, providers = DeepFakeAI.globals.execution_providers)
56
  return FRAME_PROCESSOR
57
 
 
47
  model_path = None # keep trying
48
  # If HF Hub failed, try public mirrors as a last resort
49
  if not model_path:
50
+ conditional_download(local_dir, [
51
+ 'https://huggingface.co/zihaomu/inswapper_128.onnx/resolve/main/inswapper_128.onnx',
52
+ 'https://huggingface.co/linyi/inswapper_128.onnx/resolve/main/inswapper_128.onnx',
53
+ 'https://huggingface.co/banodoco/inswapper_128.onnx/resolve/main/inswapper_128.onnx',
54
+ 'https://github.com/facefusion/facefusion-assets/releases/download/models/inswapper_128.onnx'
55
+ ])
56
+ model_path = local_model_path
57
  else:
58
  model_path = local_model_path
59
+ # export to env for downstream usage
60
+ if model_path and os.path.exists(model_path):
61
+ os.environ['INSWAPPER_PATH'] = model_path
62
  FRAME_PROCESSOR = insightface.model_zoo.get_model(model_path, providers = DeepFakeAI.globals.execution_providers)
63
  return FRAME_PROCESSOR
64