#12 but only works when there's one face selected

This commit is contained in:
Sida Liu
2024-08-13 01:38:01 +08:00
parent 66222f6ec6
commit b2139db9a8
2 changed files with 6 additions and 4 deletions
+1 -1
View File
@@ -106,7 +106,7 @@ class Pytorch_RetinaFace:
# Crop the region and add padding to form a square
cropped_imgs.append(image[crop_y1:crop_y2, crop_x1:crop_x2])
bbox_infos.append((original_crop_x1, original_crop_y1, original_crop_x2, original_crop_y2))
bbox_infos.append(((original_crop_x2-original_crop_x1, original_crop_y2-original_crop_y1),(original_crop_x1, original_crop_y1, original_crop_x2, original_crop_y2)))
return cropped_imgs, bbox_infos
def detect_faces(self, img):
+5 -3
View File
@@ -132,13 +132,14 @@ class AutoCropFaces:
# If we haven't selected anything, then return original images.
if len(selected_faces) == 0:
selected_crop_data = [(0, 0, img.shape[3], img.shape[2]) for img in original_images]
return (image, selected_crop_data)
# selected_crop_data = [(0, 0, img.shape[3], img.shape[2]) for img in original_images]
return (image, None)
# If there is only one detected face in batch of images, just return that one.
elif len(selected_faces) <= 1:
out = selected_faces[0]
return (out, selected_crop_data)
crop_data = selected_crop_data[0] # to be compatible with WAS
return (out, crop_data)
# Determine the index of the face with the maximum width
max_width_index = max(range(len(selected_faces)), key=lambda i: selected_faces[i].shape[1])
@@ -165,6 +166,7 @@ class AutoCropFaces:
else:
out = torch.cat((out, face_image), dim=0)
#TODO: WAS doesn't not support multiple faces, so this won't work with WAS.
return (out, selected_crop_data)
NODE_CLASS_MAPPINGS = {