Skip to main content

Dynaface

Dynaface Python Library

PyPI version Tests Coverage License Open in Colab

Dynaface is an AI-driven facial tracking Python Library utilizing computer vision techniques that integrate Convolutional Neural Networks (CNNs) with cascaded Graph Attention Network (GAT) regressors to enhance facial landmark detection by capturing both local appearance and global structural relationships (Prados-Torreblanca1, A & Buenaposada, J). This approach encodes both the appearance and spatial positioning of facial landmarks while employing an attention mechanism to prioritize reliable information. Such a method is particularly advantageous for assessing facial asymmetry in patients with facial paralysis, where conventional landmarking algorithms are often biased toward symmetric faces. By leveraging a global representation of facial structure, Dynaface enables precise detection of key landmarks despite asymmetries, facilitating the objective quantification of facial movement and asymmetry. These measurements, including the Facial Asymmetry Index (FAI) and Oral Commissure Excursion (OCE), serve as critical indicators of facial function and can be correlated with patient-reported outcomes to evaluate recovery and patient satisfaction.

Quick Start

Install from PyPI:

pip install dynaface

Measure a face in a photo. The first run downloads Dynaface's AI models (about 400 MB) to ~/.dynaface/models.

from dynaface import facial, measures, models

# Load the AI models, using a GPU or Apple silicon when one is available.
models.init_models(models.download_models(), models.detect_device())

# Find the face, crop it to a standard size and run every measure.
face = facial.load_face_image(
    "https://data.heatonresearch.com/dynaface/sample/img4-1024-frontal.jpg",
    measures=measures.all_measures(),
)
results = face.analyze()

# results maps each measure to its value, such as results["oce.l"] in millimeters.
print(f"Facial Asymmetry Index: {results['fai']:.2f}")

# Save the cropped face with every measure drawn on it.
face.save("face_measures.jpg")

For a step-by-step walkthrough, open the tutorial notebook in Colab. The full documentation, including the API reference, is at docs.dynaface.org.

Helpful Links

Helpful Python Commands

Activate Environment

source venv/bin/activate
.\venv\Scripts\activate.bat
.\venv\Scripts\Activate.ps1

Allow Windows to Use Environment

Set-ExecutionPolicy RemoteSigned -Scope CurrentUser

Run Unit Tests

For Mac/Linux:

cd dynaface-lib-python
python3.11 -m venv venv
source venv/bin/activate
pip install -e ".[dev]"
python -m unittest discover -s tests

For Windows:

cd dynaface-lib-python
python3.11 -m venv venv
.\venv\Scripts\Activate.ps1
pip install -e ".[dev]"
python -m unittest discover -s tests

⚠️ Note for Windows users: If you get an error like execution of scripts is disabled on this system when activating the virtual environment, you can temporarily bypass it with:

Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
.\venv\Scripts\Activate.ps1

Running Examples

The examples folder has scripts that measure images and videos. From dynaface-lib-python in a clone of this repository, run them on the bundled sample files:

# Measure a frontal photo and save it with the measures drawn on it.
python examples/process_image.py tests_data/img4-1024-frontal.jpg frontal.jpg

# Measure a side profile.
python examples/process_media.py --crop tests_data/img2-1024-right-lateral.jpg lateral.jpg

# Measure every frame of a video. This writes the annotated video-analyze.mp4,
# a chart of each measure over time (video-graph.png) and the values for every
# frame (video-data.csv).
python examples/process_media.py tests_data/video1-512.mp4 video.mp4

To Cite Dynaface

Metadata

Release files for dynaface 2.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dynaface 2.1.0
File Size Uploaded Provenance Actions
dynaface-2.1.0.tar.gz 128.2 kB With provenance Details for dynaface-2.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for dynaface 2.1.0
File Interpreter ABI Platform Actions
dynaface-2.1.0-py3-none-any.whl Python 3 none any Details for dynaface-2.1.0-py3-none-any.whl

Total release size: 262.6 kB

Release files / dynaface-2.1.0.tar.gz

Download URL dynaface-2.1.0.tar.gz
Size 128.2 kB
Tags Source
SHA-256 checksum
How to use checksums
c5cbc22b8f46be57631578c4b692fd709aea740f85959a9be4527d65d88ad96d
BLAKE2b-256 checksum
How to use checksums
0c2ff2e3201a666b184b2f865d9e202ea8a8bb42468ff2ad52a203edc69cb4ba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 20, 2026.

Transparency log

Release files / dynaface-2.1.0-py3-none-any.whl

Download URL dynaface-2.1.0-py3-none-any.whl
Size 134.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6f95fbd13bce755c87704429acc8527eb89dfae219237e96e6c74e7fc2349970
BLAKE2b-256 checksum
How to use checksums
e7cc056f1322f9bbab08f21942ca6b57533070775273dd324fd67838ba23e62f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 20, 2026.

Transparency log

Security for dynaface 2.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for dynaface-2.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 20, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page