Skip to main content

A Python port of Google MediaPipe Face Detection modules

Project description

Face Detection For Python

This package implements parts of Google®'s MediaPipe models in pure Python (with a little help from Numpy and PIL) without Protobuf graphs and with minimal dependencies (just TF Lite and Pillow).

Models and Examples

The package provides the following models:

  • Face Detection

Face detection example

  • Face Landmark Detection

Face landmark example

  • Iris Landmark Detection

Iris landmark example

  • Iris recoloring example

Iris recoloring example

Motivation

The package doesn't use the graph approach implemented by MediaPipe and is therefore not as flexible. It is, however, somewhat easier to use and understand and more accessible to recreational programming and experimenting with the pretrained ML models than the rather complex MediaPipe framework.

Here's how face detection works and an image like shown above can be produced:

from fdlite import FaceDetection
from fdlite.render import Colors, detections_to_render_data, render_to_image 
from PIL import Image

image = Image.open('group.jpg')
detect_faces = FaceDetection()
faces = detect_faces(image)
if len(faces) == 0:
    print('no faces detected :(')
else:
    render_data = detections_to_render_data(faces, bounds_color=Colors.GREEN)
    render_to_image(render_data, image).show()

While this example isn't that much simpler than the MediaPipe equivalent, some models (e.g. iris detection) aren't available in the Python API.

Installation

The latest release version is available in PyPI and can be installed via:

pip install -U face-detection-tflite

The package can be also installed from source by navigating to the folder containing setup.py and running

pip install .

from a shell or command prompt.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

face-detection-tflite-0.2.0.tar.gz (5.7 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

face_detection_tflite-0.2.0-py3-none-any.whl (5.2 MB view details)

Uploaded Python 3

File details

Details for the file face-detection-tflite-0.2.0.tar.gz.

File metadata

  • Download URL: face-detection-tflite-0.2.0.tar.gz
  • Upload date:
  • Size: 5.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.8

File hashes

Hashes for face-detection-tflite-0.2.0.tar.gz
Algorithm Hash digest
SHA256 d48fdf9dea6f2f2e353d82cd44b13b98546db85c93be1bfdcc2c088894e459bb
MD5 a184bc667e9f9d2d8ceb4f9b93fe0f10
BLAKE2b-256 4ac768e170513090d219d4d8ddcc537752b89a7fa03fe137640c47bda4b6ff50

See more details on using hashes here.

File details

Details for the file face_detection_tflite-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: face_detection_tflite-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 5.2 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.8

File hashes

Hashes for face_detection_tflite-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e91221b7a37d8a4da1745c3d55ffa4a2d6b5d77805177ef30a72001f1ea2b686
MD5 20a3408d6b3cd5ecc68fa39a1dd6775a
BLAKE2b-256 fae54fef567ab872871aa6bdfe7539e83411937def021d968d3ae5d9f1f69c90

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page