Thursday 8 September 2016

identifying a face

In this blog post I want to reproduce the idea of if you see a part of a face, ie only a subset of face features, you can predict who it belongs to. Nothing too technical. Just something I wanted to do.
-- load up a frequency list of names from the US census:
load names.sw

-- for example sake, let's just consider the top 30 most common female names, and remove the associated frequency using the clean operator:
list-of |female names> => clean select[1,30] names |female name>

-- define a list of face features:
list-of |face features> => |eye type> + |ear type> + |nose type> + |chin type> + |lip type> + |cheek type> + |hair type> + |eyebrow type>

-- let's create a data-set, that maps female faces to feature types, 5 variations per type:
features-op |*> #=> random-column[5] list-of |face features>
map[features-op,features] list-of |female names>

-- check out a couple of examples in this new data-set:
sa: features |mary>
|eye type: 4> + |ear type: 3> + |nose type: 4> + |chin type: 3> + |lip type: 1> + |cheek type: 0> + |hair type: 1> + |eyebrow type: 4>

sa: features |sarah>
|eye type: 1> + |ear type: 0> + |nose type: 0> + |chin type: 2> + |lip type: 3> + |cheek type: 1> + |hair type: 2> + |eyebrow type: 3>

sa: features |laura>
|eye type: 4> + |ear type: 0> + |nose type: 4> + |chin type: 4> + |lip type: 4> + |cheek type: 4> + |hair type: 3> + |eyebrow type: 2>
Now put it to use:
-- given "eye type 3", "chin type 0" and "ear type 4" let's guess who it might be (as a percent):
sa: 100 similar-input[features] (|eye type: 3> + |chin type: 0> + |ear type: 4>)
25|carol> + 25|angela> + 12.5|linda> + 12.5|barbara> + 12.5|elizabeth> + 12.5|jennifer> + 12.5|maria> + 12.5|dorothy> + 12.5|karen> + 12.5|helen> + 12.5|donna> + 12.5|sharon> + 12.5|kimberly> + 12.5|deborah>

-- let's try again, this time with a few more features:
sa: 100 similar-input[features] (|ear type: 0> + |nose type: 4> + |lip type: 4> + |cheek type: 2> + |hair type: 3>)
50|laura> + 25|linda> + 25|elizabeth> + 25|jennifer> + 25|lisa> + 25|betty> + 25|donna> + 25|kimberly> + 25|melissa> + 12.5|mary> + 12.5|patricia> + 12.5|barbara> + 12.5|maria> + 12.5|susan> + 12.5|margaret> + 12.5|nancy> + 12.5|helen> + 12.5|ruth> + 12.5|sharon> + 12.5|sarah> + 12.5|deborah> + 12.5|angela>

-- now feed in features we know has an exact match:
sa: 100 similar-input[features] (|eye type: 4> + |ear type: 0> + |nose type: 4> + |chin type: 4> + |lip type: 4> + |cheek type: 4> + |hair type: 3> + |eyebrow type: 2>)
100|laura> + 62.5|lisa> + 50|elizabeth> + 37.5|jennifer> + 37.5|margaret> + 37.5|donna> + 25|mary> + 25|linda> + 25|barbara> + 25|nancy> + 25|karen> + 25|betty> + 25|helen> + 25|ruth> + 25|kimberly> + 25|shirley> + 25|melissa> + 12.5|patricia> + 12.5|maria> + 12.5|susan> + 12.5|dorothy> + 12.5|sandra> + 12.5|michelle> + 12.5|sarah> + 12.5|deborah> + 12.5|angela>
And this structure of course is not specific to faces. Any time you have stored features for a list of objects, you can input a subset of features and guess/predict which object it might be. For example, if you see the head of an elephant you can pretty confidently predict an entire elephant. Or parts of a bike or car or etc, predicting the whole object.

No comments:

Post a Comment