eyuhugging commited on
Commit
9bc8402
·
verified ·
1 Parent(s): b2f5e42

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -43
app.py CHANGED
@@ -44,7 +44,11 @@ if os.path.exists(zip_path):
44
  except Exception as e:
45
  print(f"解压异常: {e}")
46
 
47
- # 3. 强制同名别名映射(不管它要哪个名字,全部拷贝一份成双保险)
 
 
 
 
48
  def force_copy(src_candidates, target_filenames):
49
  found_src = None
50
  for cand in src_candidates:
@@ -53,45 +57,4 @@ def force_copy(src_candidates, target_filenames):
53
  if os.path.exists(p1) and os.path.getsize(p1) > 1024:
54
  found_src = p1
55
  break
56
- if os.path.exists(p2) and os.path.getsize(p2) > 1024:
57
- found_src = p2
58
- break
59
-
60
- if found_src:
61
- for tf in target_filenames:
62
- dest1 = os.path.join(home_models_dir, tf)
63
- dest2 = os.path.join(local_models_dir, tf)
64
- shutil.copyfile(found_src, dest1)
65
- shutil.copyfile(found_src, dest2)
66
- print(f"映射就绪: {found_src} -> {tf}")
67
- else:
68
- print(f"警告:未找到源模型 {src_candidates}")
69
-
70
- # 把 arcface 的各种可能名字都拷满成 arcface_w600k_r50.onnx
71
- force_copy(
72
- ["w600k_r50.onnx", "arcface_w600k.onnx", "arcface_w600k_r50.onnx"],
73
- ["arcface_w600k_r50.onnx", "arcface_w600k.onnx", "w600k_r50.onnx"]
74
- )
75
-
76
- # 把 retinaface 的各种可能名字都拷满成 retinaface_10g.onnx
77
- force_copy(
78
- ["det_10g.onnx", "retinaface_10g.onnx"],
79
- ["retinaface_10g.onnx", "det_10g.onnx"]
80
- )
81
-
82
- # 把 genderage 的各种可能名字都拷满成 gender_age.onnx
83
- force_copy(
84
- ["genderage.onnx", "gender_age.onnx"],
85
- ["gender_age.onnx", "genderage.onnx"]
86
- )
87
-
88
- # 4. 打印目录清单,眼见为实
89
- print("==== 当前 /app/.assets/models 目录下的全部文件 ====")
90
- print(os.listdir(local_models_dir))
91
- print("================================================")
92
-
93
- # 启动 FaceFusion
94
- from facefusion import core
95
-
96
- if __name__ == '__main__':
97
- core.cli()
 
44
  except Exception as e:
45
  print(f"解压异常: {e}")
46
 
47
+ # 3. 安全别名映射函数(跳过自身复制)
48
+ def safe_copy(src, dst):
49
+ if os.path.exists(src) and os.path.abspath(src) != os.path.abspath(dst):
50
+ shutil.copyfile(src, dst)
51
+
52
  def force_copy(src_candidates, target_filenames):
53
  found_src = None
54
  for cand in src_candidates:
 
57
  if os.path.exists(p1) and os.path.getsize(p1) > 1024:
58
  found_src = p1
59
  break
60
+ if os.path.exists(p2