Coder Social home page Coder Social logo

facer's Introduction

Facer

Face detection, alignment, and averaging using OpenCV and dlib.

Facer draws heavily on this tutorial from Satya Mallick. I had to update the code pretty heavily to get the project to work, so I thought I'd share my modifications.

Installation

You have my 100% money-back guarantee that the most difficult part of using this package is installing its requirements. Once you've got OpenCV installed, the rest will be smooth sailing.

OpenCV

On Mac, use homebrew to install OpenCV. On Windows, I have no clue. Sorry.

brew install opencv

Using brew to install OpenCV did actually work for me, but it also broke my previous Python installation and all my virtual environments. So uhh, good luck with that.

Python packages

After installing OpenCV, use pip to install dlib, matplotlib, and numpy from the requirements.txt file.

pip install -r requirements.txt

Pre-trained detection model

The face landmark detection relies on a pre-trained model that must be downloaded separately from the dlib package itself.

wget http://dlib.net/files/shape_predictor_68_face_landmarks.dat.bz2

Unzip the compressed file after it finishes downloading and move it into the ./Facer/dlib directory.

Usage

from facer import facer

# Load face images
path_to_images = "./face_images"
images = facer.load_images(path_to_images)

# Detect landmarks for each face
landmarks, faces = facer.detect_face_landmarks(images)

# Use  the detected landmarks to create an average face
average_face = facer.create_average_face(faces, landmarks, save_image=True)

# View the composite image
plt.imshow(average_face)
plt.show()

Facer also supports creating animated GIFs of the averaging process:

from facer import facer

path_to_images = "./face_images"
gif, average_face = facer.create_animated_gif(path_to_images)

facer's People

Contributors

johnwmillr avatar

Watchers

James Cloos 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.