Simplify bbox access

This commit is contained in:
henryruhs
2023-10-11 13:53:00 +02:00
parent ea8ecf7db0
commit a6bab3285c
3 changed files with 8 additions and 8 deletions
+6 -6
View File
@@ -70,17 +70,17 @@ def find_similar_faces(frame : Frame, reference_face : Face, face_distance : flo
def sort_by_direction(faces : List[Face], direction : FaceAnalyserDirection) -> List[Face]:
if direction == 'left-right':
return sorted(faces, key = lambda face: face['bbox'][0])
return sorted(faces, key = lambda face: face.bbox[0])
if direction == 'right-left':
return sorted(faces, key = lambda face: face['bbox'][0], reverse = True)
return sorted(faces, key = lambda face: face.bbox[0], reverse = True)
if direction == 'top-bottom':
return sorted(faces, key = lambda face: face['bbox'][1])
return sorted(faces, key = lambda face: face.bbox[1])
if direction == 'bottom-top':
return sorted(faces, key = lambda face: face['bbox'][1], reverse = True)
return sorted(faces, key = lambda face: face.bbox[1], reverse = True)
if direction == 'small-large':
return sorted(faces, key = lambda face: (face['bbox'][2] - face['bbox'][0]) * (face['bbox'][3] - face['bbox'][1]))
return sorted(faces, key = lambda face: (face.bbox[2] - face.bbox[0]) * (face.bbox[3] - face.bbox[1]))
if direction == 'large-small':
return sorted(faces, key = lambda face: (face['bbox'][2] - face['bbox'][0]) * (face['bbox'][3] - face['bbox'][1]), reverse = True)
return sorted(faces, key = lambda face: (face.bbox[2] - face.bbox[0]) * (face.bbox[3] - face.bbox[1]), reverse = True)
return faces
+1 -1
View File
@@ -2,7 +2,7 @@ METADATA =\
{
'name': 'FaceFusion',
'description': 'Next generation face swapper and enhancer',
'version': '1.3.1',
'version': 'NEXT',
'license': 'MIT',
'author': 'Henry Ruhs',
'url': 'https://facefusion.io'
+1 -1
View File
@@ -123,7 +123,7 @@ def extract_gallery_frames(reference_frame : Frame) -> List[Frame]:
crop_frames = []
faces = get_many_faces(reference_frame)
for face in faces:
start_x, start_y, end_x, end_y = map(int, face['bbox'])
start_x, start_y, end_x, end_y = map(int, face.bbox)
padding_x = int((end_x - start_x) * 0.25)
padding_y = int((end_y - start_y) * 0.25)
start_x = max(0, start_x - padding_x)