explaingit

cleardusk/3ddfa

Analysis updated 2026-07-03

3,680PythonAudience · researcherComplexity · 4/5LicenseSetup · hard

TLDR

A Python and PyTorch library that reconstructs the full 3D shape, head pose, and facial landmarks from a single 2D photo. Outputs meshes, depth maps, and pose angles fast enough for near-real-time applications.

Mindmap

mindmap
  root((3ddfa))
    What it does
      3D face alignment from photo
      Head pose estimation
      68 landmark points
      3D mesh reconstruction
    Outputs
      Face mesh OBJ
      Depth map
      Yaw pitch roll angles
      Feature maps
    Tech
      Python and PyTorch
      OpenCV and Dlib
      Cython for speed
      C++ port available
    Who its for
      Computer vision researchers
      AR and animation devs
      Face recognition engineers
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Estimate head pose angles and 3D face geometry from photos for augmented reality or facial animation work.

USE CASE 2

Export a 3D face mesh as an OBJ or standard 3D file to open in Blender or other 3D software.

USE CASE 3

Process batches of face images at ~0.27ms each on GPU for real-time face recognition pipelines.

USE CASE 4

Deploy face alignment in a non-Python environment using the included C++ port.

What is it built with?

PythonPyTorchOpenCVDlibCythonC++

How does it compare?

cleardusk/3ddfamaxcountryman/flask-logincalesthio/openmontage
Stars3,6803,6803,681
LanguagePythonPythonPython
Setup difficultyhardeasymoderate
Complexity4/52/53/5
Audienceresearcherdevelopervibe coder

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · hard Time to first run · 1h+

Requires compiling a Cython module after cloning and installing PyTorch plus OpenCV, GPU needed for the stated near-real-time inference speed.

MIT, free to use for any purpose including commercial projects, as long as you keep the copyright notice.

In plain English

3DDFA is a research codebase for analyzing human faces in photographs using a technique called 3D face alignment. Given a photo of a person, it estimates the full three-dimensional shape of their face, including the position and orientation of the head even when it is turned sideways or tilted. This goes beyond simpler approaches that only work well when faces are looking straight at the camera. The project is an improved PyTorch implementation of a paper published in a major computer vision journal, with additional features added beyond what the original paper described. The system produces several types of output from a single input image: a set of 68 landmark points that map the face geometry in 3D, a reconstructed 3D face mesh, an estimated head pose (yaw, pitch, and roll angles), a depth map showing distance from the camera, and specialized feature maps used in pose-adaptive processing. These outputs can be saved as standard 3D files that work with common 3D software, or as image overlays. To use it, you clone the repository, install several Python libraries including PyTorch, OpenCV, and optionally Dlib for face detection, then compile a small Cython module for performance-critical parts. Running the main script on any image containing faces produces the various output files automatically. The inference speed is roughly 0.27 milliseconds per image on a GPU when processing a batch of images, which is fast enough for real-time or near-real-time applications. The repository has been updated over several years and includes a C++ port for environments where Python is not suitable. A follow-up version called 3DDFA_V2 was also released for people who need faster and more accurate results, and is linked from this README. This project is primarily aimed at researchers and developers working on computer vision applications such as face recognition, augmented reality, or facial animation. It is licensed under MIT.

Copy-paste prompts

Prompt 1
I cloned 3DDFA and installed PyTorch and OpenCV. How do I compile the Cython module and run the main script on a face photo to see the outputs?
Prompt 2
Write a Python script using 3DDFA that reads all JPG files in a folder, extracts yaw, pitch, and roll head pose angles for each, and saves the results to a CSV file.
Prompt 3
How do I export a 3D face mesh from 3DDFA as an OBJ file and import it into Blender for rendering?
Prompt 4
What is the practical difference between 3DDFA and 3DDFA_V2? When should I upgrade and is the API compatible?
Prompt 5
How do I integrate 3DDFA depth maps and feature maps into a downstream face recognition model as additional input channels?

Frequently asked questions

What is 3ddfa?

A Python and PyTorch library that reconstructs the full 3D shape, head pose, and facial landmarks from a single 2D photo. Outputs meshes, depth maps, and pose angles fast enough for near-real-time applications.

What language is 3ddfa written in?

Mainly Python. The stack also includes Python, PyTorch, OpenCV.

What license does 3ddfa use?

MIT, free to use for any purpose including commercial projects, as long as you keep the copyright notice.

How hard is 3ddfa to set up?

Setup difficulty is rated hard, with roughly 1h+ to a first successful run.

Who is 3ddfa for?

Mainly researcher.

Open on GitHub → Explain another repo

This repo across BitVibe Labs

Scan in gitsafehub Deploy in gitdeployhub cleardusk on gitmyhub

Verify against the repo before relying on details.