Code Monkey home page Code Monkey logo

facial-keypoint-detection's Introduction

Facial Keypoint Detection

Computer Vision Nanodegree at Udacity

Use Pytorch to create a CNN that is able to predict facial keypoints on an image.

Requirements

The CNN Architecture

The CNN architecture that I used was influenced by NaimishNet and AlexNet. Mostly built by trial and error because the main purpose was to get some insights about CNN, its components and how a framework like PyTorch can do the heavy lifting to build and train a model.

Model: /saved_models/model_net.pt

  • Convolution | in: 1 | out: 32 | kernel: 10 x 10 | stride: 2

  • Relu

  • MaxPool | kernel: 2

  • Convolution | in: 32 | out: 64 | kernel: 5 x 5 | stride: 2

  • Relu

  • MaxPool | kernel: 2

  • Convolution | in: 64 | out: 128 | kernel: 5 x 5

  • Relu

  • MaxPool | kernel: 2

  • Convolution | in: 128 | out: 256 | kernel: 3 x 3

  • Relu

  • MaxPool | kernel: 2

  • Dense | in: 256 | out: 256

  • Relu

  • Dense | in: 256 | out: 136

Image Pre-Processing

I experimented a few variations of the pre-processing step. The majority of the experiments consisted in rescaling the image, performing a random crop and including RGB channels.

  • Rescaling the image to 224x224 worked best because:
    • It is the recommend size for this project
    • It is the same size proposed in the AlexNet paper
    • Ground truth values were consistently close to the left eye, the same as observed in the NaimishNet paper
    • All target keypoints were included
  • Random cropping was not used as it brought no significant benefits
  • Image normalization used default implementation of Normalize

Note: Image augmentation could be use to increase the size and add variation to the image dataset

Loss & Optimization

A regression function - MSE - was used to minimize the distance between the target and predicted points. This loss function provided good results. L1 and L1 Smooth losses were used but no advantage was observed.

The NaimishNet paper uses Adam optimizer with default parameters, I incorporated this strategy after experimenting with different optmizers, such as SGD, and different learning rates.

Number of Epochs

I took into consideration the training speed and error margin when training the model. Number of epochs was experimented with 1, 5, 30, 50, 100 and 150 iterations. In the end 150 epochs and batch size of 30 provided good results.

facial-keypoint-detection's People

Contributors

cezannec avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.