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
4 changes: 2 additions & 2 deletions src/face3d/extract_kp_videos_safe.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@ def extract_keypoint(self, images, name=None, info=True):
else:
print(e)
break
except TypeError:
except (TypeError, IndexError):
print('No face detected in this image')
shape = [68, 2]
keypoints = -1. * np.ones(shape)
keypoints = -1. * np.ones(shape)
break
if name is not None:
np.savetxt(os.path.splitext(name)[0]+'.txt', keypoints.reshape(-1))
Expand Down
12 changes: 10 additions & 2 deletions src/utils/croper.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,16 @@ def crop(self, img_np_list, still=False, xsize=512): # first frame for all vi
img_np = img_np_list[0]
lm = self.get_landmark(img_np)

if lm is None:
raise 'can not detect the landmark from source image'
# 顔未検出 + full モード時のフォールバック
if lm is None or len(lm) == 0:
if not still: # still=False = full モード
H, W = img_np_list[0].shape[:2]
# 画像全体を crop/quad に設定(クロップなし)
# preprocess.py が lx, ly, rx, ry = quad と4スカラーで受け取るため
crop = [0, 0, W, H]
quad = [0, 0, W, H] # [lx, ly, rx, ry]
return img_np_list, crop, quad
raise Exception('can not detect the landmark from source image')
rsize, crop, quad = self.align_face(img=Image.fromarray(img_np), lm=lm, output_size=xsize)
clx, cly, crx, cry = crop
lx, ly, rx, ry = quad
Expand Down