reab5555 commited on
Commit
a29d032
·
verified ·
1 Parent(s): 9d41e7f

Update face_analysis.py

Browse files
Files changed (1) hide show
  1. face_analysis.py +1 -27
face_analysis.py CHANGED
@@ -24,7 +24,7 @@ def cluster_faces(embeddings):
24
  return np.zeros(len(embeddings), dtype=int)
25
 
26
  X = np.stack(embeddings)
27
- dbscan = DBSCAN(eps=0.2, min_samples=5, metric='cosine')
28
  clusters = dbscan.fit_predict(X)
29
 
30
  if np.all(clusters == -1):
@@ -40,29 +40,3 @@ def organize_faces_by_person(embeddings_by_frame, clusters, aligned_faces_folder
40
  src = os.path.join(aligned_faces_folder, f"frame_{frame_num}_face.jpg")
41
  dst = os.path.join(person_folder, f"frame_{frame_num}_face.jpg")
42
  shutil.copy(src, dst)
43
-
44
-
45
- def draw_facial_landmarks(image, landmarks):
46
- mp_face_mesh = mp.solutions.face_mesh
47
- mp_drawing = mp.solutions.drawing_utils
48
-
49
- # Adjust these values to make the drawing thinner and less obtrusive
50
- connection_drawing_spec = mp_drawing.DrawingSpec(color=(255, 0, 0), thickness=1)
51
-
52
- if landmarks:
53
- # Create a blank image with the same dimensions as the input image
54
- connections_layer = np.zeros_like(image)
55
-
56
- # Draw connections on the blank image
57
- mp_drawing.draw_landmarks(
58
- image=connections_layer,
59
- landmark_list=landmarks,
60
- connections=mp_face_mesh.FACEMESH_TESSELATION,
61
- landmark_drawing_spec=None, # Set to None to avoid drawing points
62
- connection_drawing_spec=connection_drawing_spec)
63
-
64
- # Blend the connections layer with the original image
65
- alpha = 0.25
66
- image = cv2.addWeighted(image, 1, connections_layer, alpha, 0)
67
-
68
- return image
 
24
  return np.zeros(len(embeddings), dtype=int)
25
 
26
  X = np.stack(embeddings)
27
+ dbscan = DBSCAN(eps=0.3, min_samples=5, metric='cosine')
28
  clusters = dbscan.fit_predict(X)
29
 
30
  if np.all(clusters == -1):
 
40
  src = os.path.join(aligned_faces_folder, f"frame_{frame_num}_face.jpg")
41
  dst = os.path.join(person_folder, f"frame_{frame_num}_face.jpg")
42
  shutil.copy(src, dst)