Skip to content

Commit

Permalink
issue #118: changed parameter keys format
Browse files Browse the repository at this point in the history
  • Loading branch information
pozitronik committed Sep 30, 2024
1 parent 766bf2b commit 385be19
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions sinner/processors/frame/FaceSwapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class FaceSwapper(BaseFrameProcessor):
source_path: str
many_faces: bool = False
less_output: bool = True
target_gender: Literal['male', 'female', 'both', 'as_input'] = 'as_input'
target_gender: Literal['M', 'F', 'B', 'I'] = 'I'

_source_face: Face | None = None
_face_analyser: FaceAnalyser | None = None
Expand Down Expand Up @@ -53,9 +53,9 @@ def rules(self) -> Rules:
},
{
'parameter': 'target-gender',
'default': 'as_input',
'choices': ['male', 'female', 'both', 'as_input'],
'help': 'Select the gender of faces to swap: male, female, both, or as_input (based on source face)'
'default': 'I',
'choices': ['M', 'F', 'B', 'I'],
'help': 'Select the gender of faces to swap: [M]ale, [F]emale, [B]oth, or as_[I]nput (based on source face)'
},
{
'module_help': 'This module swaps faces on images'
Expand Down Expand Up @@ -127,16 +127,16 @@ def process_frame(self, frame: Frame) -> Frame:
return frame

def _get_target_gender(self) -> str:
if self.target_gender == 'as_input' and self.source_face:
if self.target_gender == 'I' and self.source_face:
return self.source_face.sex
return self.target_gender

def _should_swap_face(self, face: Face, target_gender: str) -> bool:
if target_gender == 'both':
if target_gender == 'B':
return True
if face.sex == target_gender:
return True
if face.sex not in ['male', 'female']:
if face.sex not in ['M', 'F']:
self.update_status(f"Unable to determine gender for a face. Skipping this face.", mood=Mood.NEUTRAL)
return False

Expand Down

0 comments on commit 385be19

Please sign in to comment.