yinguobing / facial-landmark-dataset

A collection of facial landmark datasets and Python code to make use of them.
MIT License
100 stars 14 forks source link
facial-landmark-datasets

facial-landmark-dataset

A collection of public facial landmark datasets and the Python code to make use of them.

Watch this 1 minute introduction video.

Supported Datasets

Name Author Published #Marks #Samples
300-W Imperial College London 2013 68 600
300-VW Imperial College London 2015 68 218597
AFW Imperial College London 2013 68 337
AFLW2000-3D Chinese Academy of Sciences 2015 68 2000
HELEN Imperial College London 2013 68 2330
IBUG Imperial College London 2013 68 135
LFPW Imperial College London 2013 68 1035
WFLW Tsinghua National Laboratory 2018 98 10000

Face images and mark coordinates are required. Some dataset used existing images from other dataset, in which case the dataset was named after the image dataset.

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

Prerequisites

OpenCV 4.x

Installing

Just git clone this repo and you are good to go.

# From your favorite development directory
git clone https://github.com/yinguobing/facial-landmark-dataset

How to run

First, initialize the dataset. Take 300W as an example.

from fmd.ds300w import DS300W

# Set the path to the dataset directory.
DS300W_DIR = "/home/robin/data/facial-marks/300W"

# Construct a dataset.
ds = DS300W("300w")

# Populate the dataset with essential data
ds.populate_dataset(DS300W_DIR)

# See what we have got.
print(ds)

Possible output:

name: 300w
authors: Imperial College London
year: 2013
num_marks: 68
num_samples: 600

Pick one sample, randomly

Once the dataset is constructed:

sample = ds.pick_one()

Enumerate the dataset

This could be useful when you are trying to transform or export the dataset.

for sample in ds:
    # do whatever you want, like
    print(sample.marks)

Read image file

Read in the image file as a numpy array, and show the image.

image = sample.read_image()

import cv2
cv2.imshow("Preview", image)
cv2.waitKey()

Get the full marks

facial_marks = sample.marks

Get the key marks

The key marks are: left eye left corner, left eye right corner, right eye left corner, right eye right corner, mouse left corner, mouse right corner.

key_marks = sample.get_key_marks()

Draw the marks

draw_marks(image, facial_marks)

Authors

Yin Guobing (尹国冰) - yinguobing

wechat

License

GitHub

Acknowledgments

All the dataset authors who made their data public.