Skip to content

Commit

Permalink
Hotfix many faces in analyser
Browse files Browse the repository at this point in the history
  • Loading branch information
henryruhs committed Jul 20, 2023
1 parent fd9ef82 commit 2e60fd8
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions roop/face_analyser.py
Expand Up @@ -27,12 +27,12 @@ def clear_face_analyser() -> Any:


def get_one_face(frame: Frame, position: int = 0) -> Optional[Face]:
faces = get_many_faces(frame)
if faces:
many_faces = get_many_faces(frame)
if many_faces:
try:
return faces[position]
return many_faces[position]
except IndexError:
return faces[-1]
return many_faces[-1]
return None


Expand All @@ -44,10 +44,11 @@ def get_many_faces(frame: Frame) -> Optional[List[Face]]:


def find_similar_face(frame: Frame, reference_face: Face) -> Optional[Face]:
faces = get_many_faces(frame)
for face in faces:
if hasattr(face, 'normed_embedding') and hasattr(reference_face, 'normed_embedding'):
distance = numpy.sum(numpy.square(face.normed_embedding - reference_face.normed_embedding))
if distance < roop.globals.similar_face_distance:
return face
many_faces = get_many_faces(frame)
if many_faces:
for face in many_faces:
if hasattr(face, 'normed_embedding') and hasattr(reference_face, 'normed_embedding'):
distance = numpy.sum(numpy.square(face.normed_embedding - reference_face.normed_embedding))
if distance < roop.globals.similar_face_distance:
return face
return None

0 comments on commit 2e60fd8

Please sign in to comment.