JustinePP commited on
Commit
d1afe9c
·
verified ·
1 Parent(s): 6bf97a9

Update modeles/insightface_template_utils.py

Browse files
modeles/insightface_template_utils.py CHANGED
@@ -2,15 +2,20 @@ import os
2
  import cv2
3
  import numpy as np
4
  import insightface
 
5
 
6
- os.environ['INSIGHTFACE_HOME'] = '/tmp/insightface'
7
-
8
- # Téléchargement du modèle dans le bon dossier
9
- model = insightface.app.FaceAnalysis(name="buffalo_l", root=os.environ['INSIGHTFACE_HOME'], providers=["CPUExecutionProvider"])
10
- model.prepare(ctx_id=0)
 
 
 
11
 
12
 
13
  def create_insightface_template(folder_path, output_path):
 
14
  embeddings = []
15
 
16
  for filename in os.listdir(folder_path):
 
2
  import cv2
3
  import numpy as np
4
  import insightface
5
+ model = None
6
 
7
+ def get_model():
8
+ global model
9
+ if model is None:
10
+ # On force le chargement à partir du dossier local
11
+ model_dir = os.path.join(os.path.dirname(__file__), "../models")
12
+ model = insightface.app.FaceAnalysis(name="buffalo_l", root=model_dir, providers=["CPUExecutionProvider"])
13
+ model.prepare(ctx_id=0)
14
+ return model
15
 
16
 
17
  def create_insightface_template(folder_path, output_path):
18
+ model = get_model()
19
  embeddings = []
20
 
21
  for filename in os.listdir(folder_path):