Skip to content

add threshold filtering, docstring, and 'else' statement #245

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion feat/MPDetector.py
Original file line number Diff line number Diff line change
Expand Up @@ -668,8 +668,9 @@ def detect_faces(self, images, face_size=256, face_detection_threshold=0.5):
detect faces and poses in a batch of images using img2pose

Args:
img (torch.Tensor): Tensor of shape (B, C, H, W) representing the images
images (torch.Tensor): Tensor of shape (B, C, H, W) representing the images
face_size (int): Output size to resize face after cropping.
face_detection_threshold (float): Threshold for face detection confidence

Returns:
Fex: Prediction results dataframe
Expand Down Expand Up @@ -701,6 +702,14 @@ def detect_faces(self, images, face_size=256, face_detection_threshold=0.5):
bbox = face_output["boxes"]
facescores = face_output["scores"]
_ = face_output["landmarks"]
else: # to modify once more face detectors are implemented
raise NotImplementedError(
f"Face Detector '{self.info['face_model']} not implemented. Use 'retinaface'.")

# Face detection threshold filtering
valid_indexes = facescores > face_detection_threshold
bbox = bbox[valid_indexes]
facescores = facescores[valid_indexes]

# Extract faces from bbox
if bbox.numel() != 0:
Expand Down