Git Product home page Git Product logo

dnfal's Introduction

Dnfal

Build Status Test Coverage Python Version Contributions Welcome License

A deep learning-based library for real-time face analysis. The homepage of dnfal with user documentation is located on:

https://dnfal.readthedocs.io

./docs/source/_static/architecture.png

Features

  • Face detection, alignment and encoding in images and videos.
  • Real time performance on video analysis.
  • Built on top of state-of-the-art deep learning models.
  • High-performance pre-trained models available, you don't need to train any model.

Deep learning models and some core functionalities for face analysis where adapted from the following repositories:

  • Code for face detection was adapted from FaceBoxes.PyTorch, licensed under the Apache 2.0 license.
  • Code for face landmark detection, alignment and encoding was adapted from face.evoLVe.PyTorch, copyright Jian Zhao, 2019, licensed under the MIT license.

Getting started

You can use pip to install dnfal:

pip install dnfal

Alternatively, you can download the latest source code using git:

git clone git://github.com/raikel/dnfal.git

and run the setup command from the source directory:

python setup.py install

Next, you must download the pretrained deep learning models from here. Uncompress the downloaded files in any directory of your choice. Three models are provided: detector_weights.pth (for face detection), marker_weights.pth (for face landmark detection) and encoder_weights.pth (for face encoding).

Example usages

Here is some basic example usages of dnfal.

Face detection

from os import path
import cv2 as cv
from dnfal.detection import FaceDetector

# A valid path to a image file
IMAGE_PATH = 'people.jpg'

# A valid path to a file containing the model weights of face detector
WEIGHTS_PATH = 'detector_weights.pth'

faces_detector = FaceDetector(
    weights_path=WEIGHTS_PATH,
    min_score=0.9,
    nms_thresh=0.7
)

image = cv.imread(IMAGE_PATH)
h, w, = image.shape[0:2]

boxes, scores = faces_detector.detect(image)

for ind, box in enumerate(boxes):
    cv.rectangle(
        image,
        pt1=(box[0], box[1]),
        pt2=(box[2], box[3]),
        color=(255, 0, 0),
        thickness=2
    )
    cv2.putText(
        image,
        text=f'{scores[ind]:.3f}',
        org=(box[0], box[1] -10),
        fontFace=cv.FONT_HERSHEY_SIMPLEX,
        fontScale=0.5,
        color=(255, 255, 255),
        thickness=2,
        lineType=cv.LINE_AA
    )

cv.imshow(f'Faces', image)

ret = cv.waitKey()
cv.destroyAllWindows()

Workflow to contribute

To contribute to dnfal, first create an account on github. Once this is done, fork the dnfal repository to have your own repository, clone it using 'git clone' on the computers where you want to work. Make your changes in your clone, push them to your github account, test them on several computers, and when you are happy with them, send a pull request to the main repository.

dnfal's People

Contributors

raikel avatar

Watchers

 avatar

dnfal's Issues

Add an image quality measure functionality

Actually all detected face images in video analysis, included some blurred, occluded a and/or shadowed ones, are considered as candidates to be stored. These images can degrade the performance of face recognition, face analysis and face clustering in later processing steps. Adding some quality measure to these face images could help to discard these bad quality images.

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.