mirror of
https://github.com/s0md3v/roop.git
synced 2025-09-26 20:31:16 +08:00
Hotfix many faces in analyser
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
Reference in New Issue
Block a user