Skip to content

Commit

Permalink
gen_landmarks_aug_XX: Filter out bad landmarks
Browse files Browse the repository at this point in the history
Landmarks that are located outside of the face
bounding box should be discarded, since only a
cropped face is fed into network in training
phase, and outside landmarks are corrupting
the loss function.

Signed-off-by: Ilya Nelkenbaum <[email protected]>
  • Loading branch information
Ilya Nelkenbaum committed Oct 29, 2017
1 parent 15e4cf7 commit d0a8e19
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
7 changes: 7 additions & 0 deletions prepare_data/gen_landmark_aug_12.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,13 @@ def GenerateData(ftxt, output,net,argument=False):
#print F_landmarks.shape
for i in range(len(F_imgs)):
print image_id

if np.sum(np.where(F_landmarks[i] <= 0, 1, 0)) > 0:
continue

if np.sum(np.where(F_landmarks[i] >= 1, 1, 0)) > 0:
continue

cv2.imwrite(join(dstdir,"%d.jpg" %(image_id)), F_imgs[i])
landmarks = map(str,list(F_landmarks[i]))
f.write(join(dstdir,"%d.jpg" %(image_id))+" -2 "+" ".join(landmarks)+"\n")
Expand Down
7 changes: 7 additions & 0 deletions prepare_data/gen_landmark_aug_24.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,13 @@ def GenerateData(ftxt, output,net,argument=False):
#print F_landmarks.shape
for i in range(len(F_imgs)):
print image_id

if np.sum(np.where(F_landmarks[i] <= 0, 1, 0)) > 0:
continue

if np.sum(np.where(F_landmarks[i] >= 1, 1, 0)) > 0:
continue

cv2.imwrite(join(dstdir,"%d.jpg" %(image_id)), F_imgs[i])
landmarks = map(str,list(F_landmarks[i]))
f.write(join(dstdir,"%d.jpg" %(image_id))+" -2 "+" ".join(landmarks)+"\n")
Expand Down
7 changes: 7 additions & 0 deletions prepare_data/gen_landmark_aug_48.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,13 @@ def GenerateData(ftxt, output,net,argument=False):
#print F_landmarks.shape
for i in range(len(F_imgs)):
print image_id

if np.sum(np.where(F_landmarks[i] <= 0, 1, 0)) > 0:
continue

if np.sum(np.where(F_landmarks[i] >= 1, 1, 0)) > 0:
continue

cv2.imwrite(join(dstdir,"%d.jpg" %(image_id)), F_imgs[i])
landmarks = map(str,list(F_landmarks[i]))
f.write(join(dstdir,"%d.jpg" %(image_id))+" -2 "+" ".join(landmarks)+"\n")
Expand Down

0 comments on commit d0a8e19

Please sign in to comment.