Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Return face bounding boxes along landmarks #227

Open
wants to merge 1 commit into
base: master
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
9 changes: 8 additions & 1 deletion face_alignment/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,13 @@ def __int__(self):

class FaceAlignment:
def __init__(self, landmarks_type, network_size=NetworkSize.LARGE,
device='cuda', flip_input=False, face_detector='sfd', verbose=False):
device='cuda', flip_input=False, face_detector='sfd', verbose=False,
return_face_results=False):
self.device = device
self.flip_input = flip_input
self.landmarks_type = landmarks_type
self.verbose = verbose
self.return_face_results = return_face_results

network_size = int(network_size)

Expand Down Expand Up @@ -183,6 +185,8 @@ def get_landmarks_from_image(self, image_or_path, detected_faces=None):

landmarks.append(pts_img.numpy())

if self.return_face_results:
return landmarks, detected_faces
return landmarks

@torch.no_grad()
Expand Down Expand Up @@ -257,6 +261,9 @@ def get_landmarks_from_batch(self, image_batch, detected_faces=None):

landmark_set = np.concatenate(landmark_set, axis=0)
landmarks.append(landmark_set)

if self.return_face_results:
return landmarks, detected_faces
return landmarks

def get_landmarks_from_directory(self, path, extensions=['.jpg', '.png'], recursive=True, show_progress_bar=True):
Expand Down