{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "Yesterday, I read this [recent article on medium about facial keypoint detection](https://medium.com/towards-data-science/detecting-facial-features-using-deep-learning-2e23c8660a7a). The article suggests that deep learning methods can easily be used to perform this task. It ends by suggesting that everyone should try it, since the data needed and the toolkits are all open source. This article is my attempt, since I've been interested in face detection for a long time and [written about it before](http://flothesof.github.io/smile-recognition.html).\n", "\n", "This is the outline of what we'll try:\n", "\n", "- loading the data\n", "- analyzing the data\n", "- building a Keras model\n", "- checking the results\n", "- applying the method to a fun problem " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Loading the data " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The data we will use comes from a [Kaggle challenge](https://www.kaggle.com/c/facial-keypoints-detection#description) called *Facial Keypoints Detection*. I've downloaded the *.csv* file and put it in a *data/* directory. Let's use pandas to read it." ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": true }, "outputs": [], "source": [ "import pandas as pd" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": true }, "outputs": [], "source": [ "df = pd.read_csv('data/training.csv')" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | left_eye_center_x | \n", "left_eye_center_y | \n", "right_eye_center_x | \n", "right_eye_center_y | \n", "left_eye_inner_corner_x | \n", "left_eye_inner_corner_y | \n", "left_eye_outer_corner_x | \n", "left_eye_outer_corner_y | \n", "right_eye_inner_corner_x | \n", "right_eye_inner_corner_y | \n", "... | \n", "nose_tip_y | \n", "mouth_left_corner_x | \n", "mouth_left_corner_y | \n", "mouth_right_corner_x | \n", "mouth_right_corner_y | \n", "mouth_center_top_lip_x | \n", "mouth_center_top_lip_y | \n", "mouth_center_bottom_lip_x | \n", "mouth_center_bottom_lip_y | \n", "Image | \n", "
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | \n", "66.033564 | \n", "39.002274 | \n", "30.227008 | \n", "36.421678 | \n", "59.582075 | \n", "39.647423 | \n", "73.130346 | \n", "39.969997 | \n", "36.356571 | \n", "37.389402 | \n", "... | \n", "57.066803 | \n", "61.195308 | \n", "79.970165 | \n", "28.614496 | \n", "77.388992 | \n", "43.312602 | \n", "72.935459 | \n", "43.130707 | \n", "84.485774 | \n", "238 236 237 238 240 240 239 241 241 243 240 23... | \n", "
1 | \n", "64.332936 | \n", "34.970077 | \n", "29.949277 | \n", "33.448715 | \n", "58.856170 | \n", "35.274349 | \n", "70.722723 | \n", "36.187166 | \n", "36.034723 | \n", "34.361532 | \n", "... | \n", "55.660936 | \n", "56.421447 | \n", "76.352000 | \n", "35.122383 | \n", "76.047660 | \n", "46.684596 | \n", "70.266553 | \n", "45.467915 | \n", "85.480170 | \n", "219 215 204 196 204 211 212 200 180 168 178 19... | \n", "
2 | \n", "65.057053 | \n", "34.909642 | \n", "30.903789 | \n", "34.909642 | \n", "59.412000 | \n", "36.320968 | \n", "70.984421 | \n", "36.320968 | \n", "37.678105 | \n", "36.320968 | \n", "... | \n", "53.538947 | \n", "60.822947 | \n", "73.014316 | \n", "33.726316 | \n", "72.732000 | \n", "47.274947 | \n", "70.191789 | \n", "47.274947 | \n", "78.659368 | \n", "144 142 159 180 188 188 184 180 167 132 84 59 ... | \n", "
3 | \n", "65.225739 | \n", "37.261774 | \n", "32.023096 | \n", "37.261774 | \n", "60.003339 | \n", "39.127179 | \n", "72.314713 | \n", "38.380967 | \n", "37.618643 | \n", "38.754115 | \n", "... | \n", "54.166539 | \n", "65.598887 | \n", "72.703722 | \n", "37.245496 | \n", "74.195478 | \n", "50.303165 | \n", "70.091687 | \n", "51.561183 | \n", "78.268383 | \n", "193 192 193 194 194 194 193 192 168 111 50 12 ... | \n", "
4 | \n", "66.725301 | \n", "39.621261 | \n", "32.244810 | \n", "38.042032 | \n", "58.565890 | \n", "39.621261 | \n", "72.515926 | \n", "39.884466 | \n", "36.982380 | \n", "39.094852 | \n", "... | \n", "64.889521 | \n", "60.671411 | \n", "77.523239 | \n", "31.191755 | \n", "76.997301 | \n", "44.962748 | \n", "73.707387 | \n", "44.227141 | \n", "86.871166 | \n", "147 148 160 196 215 214 216 217 219 220 206 18... | \n", "
5 rows × 31 columns
\n", "