Merge pull request #572 from pereiraroland26/main
Updates to multiple face support (webcam scenario)pull/588/head
commit
b2fa95e2fc
|
@ -101,19 +101,30 @@ def process_frame_v2(temp_frame: Frame, temp_frame_path: str = "") -> Frame:
|
||||||
for target_face in frame['faces']:
|
for target_face in frame['faces']:
|
||||||
temp_frame = swap_face(source_face, target_face, temp_frame)
|
temp_frame = swap_face(source_face, target_face, temp_frame)
|
||||||
else:
|
else:
|
||||||
many_faces = get_many_faces(temp_frame)
|
detected_faces = get_many_faces(temp_frame)
|
||||||
if modules.globals.many_faces:
|
if modules.globals.many_faces:
|
||||||
|
if detected_faces:
|
||||||
source_face = default_source_face()
|
source_face = default_source_face()
|
||||||
if many_faces:
|
for target_face in detected_faces:
|
||||||
for target_face in many_faces:
|
|
||||||
temp_frame = swap_face(source_face, target_face, temp_frame)
|
temp_frame = swap_face(source_face, target_face, temp_frame)
|
||||||
|
|
||||||
elif not modules.globals.many_faces:
|
elif not modules.globals.many_faces:
|
||||||
if many_faces:
|
if detected_faces:
|
||||||
for target_face in many_faces:
|
if len(detected_faces) <= len(modules.globals.simple_map['target_embeddings']):
|
||||||
closest_centroid_index, _ = find_closest_centroid(modules.globals.simple_map['target_embeddings'], target_face.normed_embedding)
|
for detected_face in detected_faces:
|
||||||
|
closest_centroid_index, _ = find_closest_centroid(modules.globals.simple_map['target_embeddings'], detected_face.normed_embedding)
|
||||||
|
|
||||||
temp_frame = swap_face(modules.globals.simple_map['source_faces'][closest_centroid_index], target_face, temp_frame)
|
temp_frame = swap_face(modules.globals.simple_map['source_faces'][closest_centroid_index], detected_face, temp_frame)
|
||||||
|
else:
|
||||||
|
detected_faces_centroids = []
|
||||||
|
for face in detected_faces:
|
||||||
|
detected_faces_centroids.append(face.normed_embedding)
|
||||||
|
i = 0
|
||||||
|
for target_embedding in modules.globals.simple_map['target_embeddings']:
|
||||||
|
closest_centroid_index, _ = find_closest_centroid(detected_faces_centroids, target_embedding)
|
||||||
|
|
||||||
|
temp_frame = swap_face(modules.globals.simple_map['source_faces'][i], detected_faces[closest_centroid_index], temp_frame)
|
||||||
|
i += 1
|
||||||
return temp_frame
|
return temp_frame
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue