Skip to content
Open
Show file tree
Hide file tree
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
5 changes: 4 additions & 1 deletion src/face3d/extract_kp_videos_safe.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ def extract_keypoint(self, images, name=None, info=True):
# face detection -> face alignment.
img = np.array(images)
bboxes = self.det_net.detect_faces(images, 0.97)

if len(bboxes) == 0:
bboxes = self.det_net.detect_faces(images, 0.5)
if len(bboxes) == 0:
bboxes = self.det_net.detect_faces(images, 0.2)
bboxes = bboxes[0]
img = img[int(bboxes[1]):int(bboxes[3]), int(bboxes[0]):int(bboxes[2]), :]

Expand Down
2 changes: 1 addition & 1 deletion src/face3d/util/my_awing_arch.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def calculate_points(heatmaps):
indexes = np.argmax(heatline, axis=2)

preds = np.stack((indexes % W, indexes // W), axis=2)
preds = preds.astype(np.float, copy=False)
preds = preds.astype(float, copy=False)

inr = indexes.ravel()

Expand Down
11 changes: 7 additions & 4 deletions src/face3d/util/preprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
from skimage import transform as trans
import torch
import warnings
warnings.filterwarnings("ignore", category=np.VisibleDeprecationWarning)
try:
warnings.filterwarnings("ignore", category=np.VisibleDeprecationWarning)
except AttributeError:
pass # numpy 2.x removed VisibleDeprecationWarning
warnings.filterwarnings("ignore", category=FutureWarning)


Expand Down Expand Up @@ -43,9 +46,9 @@ def resize_n_crop_img(img, lm, t, s, target_size=224., mask=None):
w0, h0 = img.size
w = (w0*s).astype(np.int32)
h = (h0*s).astype(np.int32)
left = (w/2 - target_size/2 + float((t[0] - w0/2)*s)).astype(np.int32)
left = (w/2 - target_size/2 + np.array((t[0] - w0/2)*s).item()).astype(np.int32)
right = left + target_size
up = (h/2 - target_size/2 + float((h0/2 - t[1])*s)).astype(np.int32)
up = (h/2 - target_size/2 + np.array((h0/2 - t[1])*s).item()).astype(np.int32)
below = up + target_size

img = img.resize((w, h), resample=Image.BICUBIC)
Expand Down Expand Up @@ -98,6 +101,6 @@ def align_img(img, lm, lm3D, mask=None, target_size=224., rescale_factor=102.):

# processing the image
img_new, lm_new, mask_new = resize_n_crop_img(img, lm, t, s, target_size=target_size, mask=mask)
trans_params = np.array([w0, h0, s, t[0], t[1]])
trans_params = np.array([w0, h0, float(s), float(np.array(t[0]).flat[0]), float(np.array(t[1]).flat[0])])

return trans_params, img_new, lm_new, mask_new