maxni94 commited on
Commit
788540e
·
verified ·
1 Parent(s): 192dc84

Update modeles/insightface_template_utils.py

Browse files
modeles/insightface_template_utils.py CHANGED
@@ -15,13 +15,20 @@ def get_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):
 
22
  if filename.lower().endswith((".jpg", ".jpeg", ".png")):
 
23
  img_path = os.path.join(folder_path, filename)
 
24
  img = cv2.imread(img_path)
 
25
  faces = model.get(img)
26
  if not faces:
27
  print(f"Aucun visage sur {filename}")
@@ -32,6 +39,8 @@ def create_insightface_template(folder_path, output_path):
32
  if not embeddings:
33
  raise RuntimeError("Aucun embedding extrait.")
34
 
 
35
  template = np.mean(np.array(embeddings), axis=0)
 
36
  np.save(output_path, template)
37
  print(f"Template enregistré dans : {output_path}")
 
15
 
16
 
17
  def create_insightface_template(folder_path, output_path):
18
+ print(output_path,template)
19
+ print("on récupére le model")
20
  model = get_model()
21
  embeddings = []
22
 
23
+ print("On liste les fichiers")
24
  for filename in os.listdir(folder_path):
25
+ print("fichier : ",filename)
26
  if filename.lower().endswith((".jpg", ".jpeg", ".png")):
27
+
28
  img_path = os.path.join(folder_path, filename)
29
+ print("on lis l'image img_path : ",img_path)
30
  img = cv2.imread(img_path)
31
+ print("on récupére les visages dans l'image: ",img_path)
32
  faces = model.get(img)
33
  if not faces:
34
  print(f"Aucun visage sur {filename}")
 
39
  if not embeddings:
40
  raise RuntimeError("Aucun embedding extrait.")
41
 
42
+ print("on fait la moyenne")
43
  template = np.mean(np.array(embeddings), axis=0)
44
+ print("on sauvegarde le template")
45
  np.save(output_path, template)
46
  print(f"Template enregistré dans : {output_path}")