LogicGoInfotechSpaces commited on
Commit
1651cda
·
1 Parent(s): 6abea90

Update app.py: OMP=1, CUDA providers, prefer HF inswapper download

Browse files
Files changed (2) hide show
  1. .gitignore +0 -0
  2. app.py +11 -4
.gitignore CHANGED
Binary files a/.gitignore and b/.gitignore differ
 
app.py CHANGED
@@ -6,6 +6,12 @@ from typing import Optional
6
  import traceback
7
  import os as _os
8
 
 
 
 
 
 
 
9
  # Local pipeline imports
10
  import DeepFakeAI.globals as DF_G
11
  from DeepFakeAI import utilities as DF_U
@@ -60,8 +66,8 @@ def _run_local_faceswap(source_image_path: str, target_video_path: str) -> Optio
60
  DF_G.reference_frame_number = 0
61
  DF_G.execution_thread_count = 2
62
  DF_G.execution_queue_count = 2
63
- # Force CPU for stability first
64
- DF_G.execution_providers = DF_U.decode_execution_providers(['cpu'])
65
  # Fix invalid OMP thread settings in container
66
  try:
67
  _os.environ["OMP_NUM_THREADS"] = "1"
@@ -74,10 +80,11 @@ def _run_local_faceswap(source_image_path: str, target_video_path: str) -> Optio
74
  model_path = os.path.join(model_dir, 'inswapper_128.onnx')
75
  if not os.path.exists(model_path):
76
  token = os.environ.get('TOKEN') or os.environ.get('HF_TOKEN')
 
77
  for repo_id in [
78
- 'banodoco/inswapper_128.onnx',
79
- 'linyi/inswapper_128.onnx',
80
  'zihaomu/inswapper_128.onnx',
 
 
81
  ]:
82
  try:
83
  model_path = hf_hub_download(repo_id=repo_id, filename='inswapper_128.onnx', token=token)
 
6
  import traceback
7
  import os as _os
8
 
9
+ # Ensure sane OMP threads on startup (prevents libgomp warning in Spaces)
10
+ try:
11
+ _os.environ["OMP_NUM_THREADS"] = "1"
12
+ except Exception:
13
+ pass
14
+
15
  # Local pipeline imports
16
  import DeepFakeAI.globals as DF_G
17
  from DeepFakeAI import utilities as DF_U
 
66
  DF_G.reference_frame_number = 0
67
  DF_G.execution_thread_count = 2
68
  DF_G.execution_queue_count = 2
69
+ # Prefer CUDA (T4 GPU in HF Spaces); will fall back internally if unavailable
70
+ DF_G.execution_providers = DF_U.decode_execution_providers(['cuda'])
71
  # Fix invalid OMP thread settings in container
72
  try:
73
  _os.environ["OMP_NUM_THREADS"] = "1"
 
80
  model_path = os.path.join(model_dir, 'inswapper_128.onnx')
81
  if not os.path.exists(model_path):
82
  token = os.environ.get('TOKEN') or os.environ.get('HF_TOKEN')
83
+ # Prefer HF mirrors (avoid GitHub 404 in Spaces). Try most reliable first.
84
  for repo_id in [
 
 
85
  'zihaomu/inswapper_128.onnx',
86
+ 'linyi/inswapper_128.onnx',
87
+ 'banodoco/inswapper_128.onnx',
88
  ]:
89
  try:
90
  model_path = hf_hub_download(repo_id=repo_id, filename='inswapper_128.onnx', token=token)