Thermal-facial-alignment network (TFAN) trained on the T-FAKE dataset
Using the landmarker
Install and run:
pip install thermal-face-alignment
import cv2
from tfan import ThermalLandmarks
# Read a thermal image (grayscale)
image = cv2.imread("thermal.png", cv2.IMREAD_GRAYSCALE)
# Initialize landmarker (downloads weights on first use)
landmarker = ThermalLandmarks(device="cpu", n_landmarks=70)
landmarks, confidences = landmarker.process(image)
Predicted 70 and 478 point landmarks on an example from the TFW Dataset.
Predicted 70 and 478 point landmarks on an example from the BU-TIV Benchmark.
Practical Usage
The ThermalLandmarks wraps a landmarker trained on T-FAKE either with sliding window selecting the face with highest confidence or via a bbox computed with a smaller model.
Please note that we trained our network with temperature value range of 20°C to 40°C. While our implementation performs an automatic rescaling, please make sure that you adapt our landmarker options based on the input pixel values.
Initialization options
ThermalLandmarks(
model_path=None,
device="cpu",
gpus=[0, 1],
eta=0.75,
max_lvl=0,
stride=100,
n_landmarks=478, # 478 or 70 point landmarks are supported
normalize=True,
)
-
model_path(strorPath, optional) Path to a pretrained DMMv2 model (state_dict). If omitted, pretrained weights matchingn_landmarksare downloaded automatically. -
device("cpu"or"cuda", default"cpu") Torch device used for inference. When using"cuda", the model may be wrapped inDataParallel. -
gpus(list[int], default[0, 1]) GPU device IDs used whendevice="cuda". -
n_landmarks(int, default478) Number of facial landmarks predicted per face. Choices:70— sparse landmarks following the Face Synthetic convention of (Wood et al., 2021).478— dense landmarks following the MediaPipe face mesh convention.
-
normalize(bool, defaultTrue) Apply ImageNet normalization to cropped face patches before inference. Assumes inputs are scaled to[0, 255]. -
eta(float, default0.75) Pyramid scale factor used in sliding-window mode. -
max_lvl(int, default0) Maximum pyramid level for multi-scale sliding-window inference. -
stride(int, default100) Pixel stride used during sliding-window scanning.
Inference options
landmarks, confidences = landmarker.process(
image,
sliding_window=False,
multi=False,
mode="auto",
)
-
image(numpy.ndarray) Input frame:H×W: thermal or grayscale imageH×W×3: RGB/BGR image
-
mode("auto" | "temperature" | "pixel", default"auto") Controls how numeric values are interpreted:"temperature": 2D thermal image in °C"pixel": pixel intensities in[0, 255]or[0, 1]"auto": inferred from dtype and value range
-
multi(bool, defaultFalse) IfTrue, return landmarks for all detected faces. IfFalse, only the first face is returned. -
sliding_window(bool, defaultFalse) Enable multi-scale sliding-window inference. Note: currently only supported whenmulti=False.
Outputs
-
landmarksPixel coordinates in the original image:- List of
(n_landmarks, 2)arrays (multi-face) - Single
(n_landmarks, 2)array (sliding window)
- List of
-
confidencesPer-landmark confidence scores of shape(n_landmarks,)
Background
This landmarker is an implementation of our work presented in our CVPR paper on thermal landmarking (Main GitHub). We employed the TFW face detector for our inital face detection as it performed very well in our benchmark. Please note that this library is meant for research purposes only.
Landmarker Performance on our Charlotte Benchmark
Training Dataset
We trained our landmarker on our custom-made T-FAKE dataset consisting of synthetic thermal images. To download the original color images, sparse annotations, and segmentation masks for the dataset, please use the links in the FaceSynthetics repository.
Our dataset has been generated for a warm and for a cold condition. Each dataset can be downloaded separately as
- A small sample with 100 images from here warm and here cold
- A medium sample with 1,000 images from here warm and here cold
- The full dataset with 100,000 images from here warm and here cold
- The dense annotations are available from here
Pre-trained models
The models for the thermalization as well as the landmarkers can be downloaded from here.
License
Our landmarking methods and the training dataset are licensed under the Attribution-NonCommercial-ShareAlike 4.0 International license as it is derived from the FaceSynthetics dataset.
Citation
If you use this code for your own work, please cite our paper:
P. Flotho, M. Piening, A. Kukleva and G. Steidl, “T-FAKE: Synthesizing Thermal Images for Facial Landmarking,” Proceedings of the Computer Vision and Pattern Recognition Conference (CVPR), 2025. CVF Open Access
BibTeX entry
@InProceedings{tfake2025_CVPR,
author = {Flotho, Philipp and Piening, Moritz and Kukleva, Anna and Steidl, Gabriele},
title = {T-FAKE: Synthesizing Thermal Images for Facial Landmarking},
booktitle = {Proceedings of the Computer Vision and Pattern Recognition Conference (CVPR)},
month = {June},
year = {2025},
pages = {26356-26366}
}
The thermal face bounding box detection in this repo uses the TFW landmarker model, please additionally cite:
Kuzdeuov, A., Aubakirova, D., Koishigarina, D., & Varol, H. A. (2022). TFW: Annotated Thermal Faces in the Wild Dataset. IEEE Transactions on Information Forensics and Security, 17, 2084–2094. https://doi.org/10.1109/TIFS.2022.3177949
@article{9781417,
author={Kuzdeuov, Askat and Aubakirova, Dana and Koishigarina, Darina and Varol, Huseyin Atakan},
journal={IEEE Transactions on Information Forensics and Security},
title={TFW: Annotated Thermal Faces in the Wild Dataset},
year={2022},
volume={17},
pages={2084-2094},
doi={10.1109/TIFS.2022.3177949}
}
Metadata
Release files for thermal-face-alignment 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| thermal_face_alignment-1.0.0.tar.gz | 19.7 MB | With provenance | Details for thermal_face_alignment-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| thermal_face_alignment-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for thermal_face_alignment-1.0.0-py3-none-any.whl |
Total release size: 19.7 MB
Release files / thermal_face_alignment-1.0.0.tar.gz
| Download URL | thermal_face_alignment-1.0.0.tar.gz |
|---|---|
| Size | 19.7 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0aa1e452dd5ea1a9edcb71ed50dabd879704788f1af23bd02647b1766e404d85
|
|
BLAKE2b-256 checksum How to use checksums |
0a77da4df36f9fe58f8d1ca9d93e6ca5b48d983fe6da4c1ffa42410b358fb7e6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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 Dec 21, 2025.
Transparency logRelease files / thermal_face_alignment-1.0.0-py3-none-any.whl
| Download URL | thermal_face_alignment-1.0.0-py3-none-any.whl |
|---|---|
| Size | 14.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
745cf2b8c731cd4e697bd75455a952cff47adc22f039280c99ef578c802d821e
|
|
BLAKE2b-256 checksum How to use checksums |
b40ca82b2437e152a531d53d5c11d55d9bba7f726cd3a93d0b23cc0508a3c50b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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 Dec 21, 2025.
Transparency logSecurity for thermal-face-alignment 1.0.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
All 2 files in this release have been uploaded with provenance metadata.
Attestation for thermal_face_alignment-1.0.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 Dec 21, 2025.
Transparency logA 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.