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

Alignment: Corner case when fiducial points are outside of the image #39

Closed
bamos opened this issue Oct 28, 2015 · 6 comments
Closed

Alignment: Corner case when fiducial points are outside of the image #39

bamos opened this issue Oct 28, 2015 · 6 comments

Comments

@bamos
Copy link
Collaborator

bamos commented Oct 28, 2015

From @Strateus in #13:

Brandon, why do you have this test in python alignment warped image?:

if 0 <= l <= w and 0 <= r <= w and 0 <= b <= h and 0 <= t <= h:
There is quite big probability one of the points will be out of this range, dont you think its too strict?

@bamos bamos mentioned this issue Oct 28, 2015
6 tasks
@bamos
Copy link
Collaborator Author

bamos commented Oct 28, 2015

Hi @Strateus - why is there a big probability the points will be outside the range? Do you have examples where this is failing for reasonable images? I haven't extensively profiled or tested this portion of code, but the alignment code works for 13081 out of 13233 images from the LFW dataset.

This code portion checks if the boundary points of the detected landmarks are outside of the image, which should only happen in extreme cases like if somebody's face is outside of the image. There may be heuristics that can improve this, like filling in the missing portions with black pixels or using image completion.

@Strateus
Copy link

Well, i used my web camera, and added 30% margins to face, and still after warping there were points out of warped image all the time i tried, maybe 5% it was ok, but rest failed.
Anyways i would consider this check to be more thorough since you transform only on eyes and nose. Just thoughts, i elminated this check locally and will be testing it.

@bamos
Copy link
Collaborator Author

bamos commented Oct 28, 2015

Code reference:

if 0 <= l <= w and 0 <= r <= w and 0 <= b <= h and 0 <= t <= h:

@bamos
Copy link
Collaborator Author

bamos commented Oct 28, 2015

Be careful when expanding the margins since the neural network nn4.v1.t7 is trained with no margin added. I wouldn't be surprised if this severely hurts the accuracy.

You need to train a new neural network if you want to add margins.
Note that in a few experiments I ran, adding a margin didn't improve the accuracy,
which is why there is no margin in nn4.v1.t7.

Also, won't eliminating the check cause array out of bounds errors in:

cwImg = cv2.resize(warpedImg[t:b, l:r], (size, size))

@bamos bamos changed the title Alignment: Corner case when fiducial points aren't detected Alignment: Corner case when fiducial points are outside of the image Oct 28, 2015
@Strateus
Copy link

Yea i got the point about network. Accuracy is not my primary concern now.
As for eliminating, i did it like this:

    l = 0 if l < 0 else l
    r = w if r > w else r
    t = 0 if t < 0 else t
    b = h if b > h else b

@bamos
Copy link
Collaborator Author

bamos commented Jan 26, 2016

Fixed with the new alignment technique.

@bamos bamos closed this as completed Jan 26, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants