Uses openCV and Dlib to automatically align portraits in python, visualizing it out using p5.js
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.

Average Portrait

Uses openCV and dlib to automatically align portraits in python, average the portraits using processing & p5.js [ p5 Demo ]

portrait animation

Portrait Average

portrait average

Portrait Swap

portrait swap

Portrait Detection

portrait detection

How to Use

  • Download landmarks
  • Unzip it and move to landmarks folder
  • Face Align python image_folder image_format reference_image_path
  • Face Detection python image_folder
  • Face Swap python original_portrait.jpg new_portrait.jpg
  • Generating Image Metadata CSV exiftool -csv -FileSize -ImageWidth -ImageHeight image_folder/*.jpg > metadata.csv


Face Align

python portraits/ jpg portraits/01a4462309f79052d1a480170ef3d7ca7bcbd564.jpg

Generate Image Metadata CSV

// change directory
cd processing/average_portraits/data/
// scan images and generate metadata csv
exiftool -csv -FileSize -ImageWidth -ImageHeight ../../../result_align/*.jpg  > metadata.csv

Face Detection

python portraits/

Face Swap

python portraits/01a4462309f79052d1a480170ef3d7ca7bcbd564.jpg portraits/838ba61ea8d3fd1ff15d9549314e251f95ca5f68.jpg


Install OpenCV and Dlib

Install pip

sudo easy_install pip

Install cmake

// download binary
// install command line tool from application menu
Tools->How To Install For Command Line Use

Install homebrew

ruby -e "$(curl -fsSL []("

Install boost

brew install boost --with-python

Install boost-python

brew install boost-python

Install numpy

sudo pip install numpy

Install dlib

sudo pip install dlib

Install openCV Reference

brew tap homebrew/science
// opencv installation will be located at: /usr/local/Cellar/opencv/2.4.10/
brew install opencv
cat ~/.bash_profile | grep PYTHONPATH
ln -s /usr/local/Cellar/opencv/2.4.12/lib/python2.7/site-packages/
ln -s /usr/local/Cellar/opencv/2.4.12/lib/python2.7/site-packages/

Install skimage [ OPTIONAL ]

sudo pip install -U scikit-image

Install ExifTool

// download command line tool