diff --git a/face_alignment/api.py b/face_alignment/api.py index 2cadf683..2e138c93 100644 --- a/face_alignment/api.py +++ b/face_alignment/api.py @@ -247,8 +247,8 @@ def get_landmarks_from_batch(self, image_batch, detected_faces=None): else: pts, pts_img = pts.view(-1, 68, 2) * 4, pts_img.view(-1, 68, 2) landmark_set.append(pts_img.numpy()) - - landmark_set = np.concatenate(landmark_set, axis=0) + if 0 != len(landmark_set): + landmark_set = np.concatenate(landmark_set, axis=0) landmarks.append(landmark_set) return landmarks diff --git a/face_alignment/detection/blazeface/detect.py b/face_alignment/detection/blazeface/detect.py index 6258a92c..b1b2dfe1 100644 --- a/face_alignment/detection/blazeface/detect.py +++ b/face_alignment/detection/blazeface/detect.py @@ -14,7 +14,7 @@ def detect(net, img, device): preds = net.predict_on_image(img) if 0 == len(preds): - return np.zeros((1, 1, 5)) + return [[]] shift = np.array([xshift, yshift] * 2) scores = preds[:, -1:] @@ -48,9 +48,6 @@ def batch_detect(net, img_batch, device): locs = np.concatenate((pred[:, 1:2], pred[:, 0:1], pred[:, 3:4], pred[:, 2:3]), axis=1) bboxlists.append(np.concatenate((locs * orig_size + shift, scores), axis=1)) - if 0 == len(bboxlists): - bboxlists = np.zeros((1, 1, 5)) - return bboxlists diff --git a/face_alignment/detection/sfd/detect.py b/face_alignment/detection/sfd/detect.py index 35263e4d..1b75e8f1 100644 --- a/face_alignment/detection/sfd/detect.py +++ b/face_alignment/detection/sfd/detect.py @@ -22,9 +22,6 @@ def detect(net, img, device): # Creates a batch of 1 img = img.reshape((1,) + img.shape) - if 'cuda' in device: - torch.backends.cudnn.benchmark = True - img = torch.from_numpy(img).float().to(device) return batch_detect(net, img, device) @@ -72,10 +69,6 @@ def batch_detect(net, img_batch, device): bboxlists.append(bboxlist) bboxlists = np.array(bboxlists) - - if 0 == len(bboxlists): - bboxlists = np.zeros((1, 1, 5)) - return bboxlists