JustinePP commited on
Commit
88e55d3
·
verified ·
1 Parent(s): bd973e8

Update modeles/liveness_check_folder.py

Browse files
Files changed (1) hide show
  1. modeles/liveness_check_folder.py +7 -7
modeles/liveness_check_folder.py CHANGED
@@ -20,29 +20,29 @@ def check_liveness_on_folder(folder_path, frame_interval=1, yaw_thresh=5, pitch_
20
  img_path = os.path.join(folder_path, filename)
21
  img = cv2.imread(img_path)
22
  if img is None:
23
- print(f"⚠️ Image illisible : {filename}")
24
- continue
25
 
26
  faces = model.get(img)
27
  if not faces:
28
- print(f"❌ Aucun visage détecté sur {filename}")
29
- continue
30
 
31
  pose = faces[0].pose # [yaw, pitch, roll]
32
  poses.append(pose)
33
 
34
  if len(poses) < 3:
35
- print("⛔ Pas assez de données pour vérifier la vivacité.")
36
  return False
37
 
38
  poses = np.array(poses)
39
  yaw_std = np.std(poses[:, 0])
40
  pitch_std = np.std(poses[:, 1])
41
 
42
- print(f"📈 Écarts-types — Yaw: {yaw_std:.2f}, Pitch: {pitch_std:.2f}")
43
 
44
  if yaw_std < yaw_thresh and pitch_std < pitch_thresh:
45
- print("🔴 Visage figé détecté — FAKE")
46
  return False
47
  else:
48
  print("🟢 Mouvement naturel détecté — REAL")
 
20
  img_path = os.path.join(folder_path, filename)
21
  img = cv2.imread(img_path)
22
  if img is None:
23
+ print(f"Image illisible : {filename}")
24
+ return False
25
 
26
  faces = model.get(img)
27
  if not faces:
28
+ print(f"Aucun visage détecté sur {filename}")
29
+ return False
30
 
31
  pose = faces[0].pose # [yaw, pitch, roll]
32
  poses.append(pose)
33
 
34
  if len(poses) < 3:
35
+ print("Pas assez de données pour vérifier la vivacité.")
36
  return False
37
 
38
  poses = np.array(poses)
39
  yaw_std = np.std(poses[:, 0])
40
  pitch_std = np.std(poses[:, 1])
41
 
42
+ print(f"Écarts-types — Yaw: {yaw_std:.2f}, Pitch: {pitch_std:.2f}")
43
 
44
  if yaw_std < yaw_thresh and pitch_std < pitch_thresh:
45
+ print("Visage figé détecté — FAKE")
46
  return False
47
  else:
48
  print("🟢 Mouvement naturel détecté — REAL")