primerz commited on
Commit
f3383b1
·
verified ·
1 Parent(s): 25765c5

Update models.py

Browse files
Files changed (1) hide show
  1. models.py +5 -42
models.py CHANGED
@@ -67,49 +67,12 @@ def load_face_analysis():
67
  Downloads from DIAMONIK7777/antelopev2 which has the correct model structure.
68
  """
69
  print("Loading face analysis model...")
70
-
71
- # Use a persistent location for models
72
- local_model_root = '/data/models' if os.path.exists('/data') else './models'
73
- model_name = 'antelopev2'
74
-
75
- # This is the directory where the .onnx files must be
76
- local_model_path = os.path.join(local_model_root, model_name)
77
-
78
  try:
79
- # Download from DIAMONIK7777/antelopev2 repo (correct structure)
80
- print(f" Downloading antelopev2 models to {local_model_path}...")
81
-
82
- from huggingface_hub import snapshot_download
83
-
84
- # Download entire repo
85
- snapshot_kwargs = {
86
- "repo_id": "DIAMONIK7777/antelopev2",
87
- "local_dir": local_model_path,
88
- "local_dir_use_symlinks": False,
89
- "repo_type": "model"
90
- }
91
- if HUGGINGFACE_TOKEN:
92
- snapshot_kwargs["token"] = HUGGINGFACE_TOKEN
93
-
94
- antelope_download = snapshot_download(**snapshot_kwargs)
95
- print(f" [OK] Models downloaded to: {antelope_download}")
96
-
97
- # Initialize FaceAnalysis with correct paths
98
- # Note: root should be the PARENT of the model directory
99
- face_app = FaceAnalysis(
100
- name=model_name,
101
- root=local_model_root, # Parent directory
102
- providers=['CUDAExecutionProvider', 'CPUExecutionProvider']
103
- )
104
-
105
- face_app.prepare(
106
- ctx_id=FACE_DETECTION_CONFIG['ctx_id'],
107
- det_size=FACE_DETECTION_CONFIG['det_size']
108
- )
109
-
110
- print(" [OK] Face analysis model loaded successfully")
111
- print(f" [OK] Using providers: {face_app.det_model.providers}")
112
- return face_app, True
113
 
114
  except Exception as e:
115
  print(f" [ERROR] Face detection not available: {e}")
 
67
  Downloads from DIAMONIK7777/antelopev2 which has the correct model structure.
68
  """
69
  print("Loading face analysis model...")
70
+
 
 
 
 
 
 
 
71
  try:
72
+ antelope_download = snapshot_download(repo_id="DIAMONIK7777/antelopev2", local_dir="/data/models/antelopev2")
73
+ face_app = FaceAnalysis(name='antelopev2', root='/data', providers=['CUDAExecutionProvider', 'CPUExecutionProvider'])
74
+ face_app.prepare(ctx_id=0, det_size=(640, 640))
75
+ return face_app, True
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
76
 
77
  except Exception as e:
78
  print(f" [ERROR] Face detection not available: {e}")