Skip to content

Commit

Permalink
[Bugfix] Add back the support for --many-faces (#771)
Browse files Browse the repository at this point in the history
  • Loading branch information
barak353 committed Jul 26, 2023
1 parent a3f5ada commit a547bba
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions roop/processors/frame/face_swapper.py
Expand Up @@ -75,7 +75,10 @@ def process_frame(source_face: Face, reference_face: Face, temp_frame: Frame) ->

def process_frames(source_path: str, temp_frame_paths: List[str], update: Callable[[], None]) -> None:
source_face = get_one_face(cv2.imread(source_path))
reference_face = get_face_reference()
if roop.globals.many_faces:
reference_face = None
else:
reference_face = get_face_reference()
for temp_frame_path in temp_frame_paths:
temp_frame = cv2.imread(temp_frame_path)
result = process_frame(source_face, reference_face, temp_frame)
Expand All @@ -87,13 +90,16 @@ def process_frames(source_path: str, temp_frame_paths: List[str], update: Callab
def process_image(source_path: str, target_path: str, output_path: str) -> None:
source_face = get_one_face(cv2.imread(source_path))
target_frame = cv2.imread(target_path)
reference_face = get_one_face(target_frame, roop.globals.reference_face_position)
if roop.globals.many_faces:
reference_face = None
else:
reference_face = get_one_face(target_frame, roop.globals.reference_face_position)
result = process_frame(source_face, reference_face, target_frame)
cv2.imwrite(output_path, result)


def process_video(source_path: str, temp_frame_paths: List[str]) -> None:
if not get_face_reference():
if not roop.globals.many_faces and not get_face_reference():
reference_frame = cv2.imread(temp_frame_paths[roop.globals.reference_frame_number])
reference_face = get_one_face(reference_frame, roop.globals.reference_face_position)
set_face_reference(reference_face)
Expand Down

0 comments on commit a547bba

Please sign in to comment.