by Giovanni Affatato, Sara Mandelli, Paolo Bestagini, and Stefano Tubaro.
This repository is the official inference implementation of MOTIF, accepted at the 2026 IEEE International Workshop on Information Forensics and Security (WIFS). Read the paper on arXiv.
MOTIF is a visual person-of-interest deepfake detector. It enrolls a subject from genuine reference videos and scores a query video without retraining. The released detector uses two independently trained temporal transformers:
- a global branch over per-frame 3D morphable-model shape, expression, pose, and translation coefficients;
- a mouth branch over temporally centered 3D lip-vertex motion reconstructed from the same fit.
Both branches analyze 75-frame windows with 50% overlap. They compare query and reference embeddings using person-specific normalization and cosine similarity. The final score averages the two calibrated branch scores; higher values indicate greater consistency with the enrolled person.
MOTIF requires an NVIDIA GPU and Python 3.10 or newer. Video decoding uses PyAV's bundled FFmpeg libraries.
python -m pip install git+https://github.com/polimi-ispl/MOTIFThe first run downloads the two MOTIF checkpoints, normalization statistics, and upstream 3DDFA-V3 face-analysis assets. All files are cached by Hugging Face.
Use independent clips containing one clearly visible person. Ten reference videos match the paper protocol; at least two usable reference videos and enough valid reference windows are required for leave-one-out calibration.
motif score \
--reference genuine1.mp4 genuine2.mp4 genuine3.mp4 \
--test query.mp4For repeated use, extract the reference set once:
motif extract-reference \
--reference genuine1.mp4 genuine2.mp4 genuine3.mp4 \
--output person.npz
motif score --reference-set person.npz --test query.mp4Or keep the models loaded in Python:
from motif import MotifPipeline
pipeline = MotifPipeline()
reference = pipeline.extract_reference_set(
["genuine1.mp4", "genuine2.mp4", "genuine3.mp4"]
)
result = pipeline.score(reference, "query.mp4")
print(result["score"])The score is not a probability and does not define a universal real/fake threshold. Calibrate an operating threshold on separate validation data representative of the intended use.
git clone https://github.com/polimi-ispl/MOTIF.git
cd MOTIF
python -m pip install -e '.[demo]'
cd demo
./download.sh && ./prepare_clips.sh && python quickstart.pyDownloads may need browser cookies; the default is Firefox. Use
COOKIES_FROM_BROWSER=chrome ./download.sh to select Chrome. The demo also
needs the FFmpeg executable with libx264. Demo details.
It enrolls eight genuine reference clips, scores three independent genuine
clips and four deepfakes, and saves all global, mouth and fused scores plus AUC
and ranking margin in demo/results/scores.json.
Recorded demo at the default batch size of 8: AUC 1.000; genuine/fake margin +3.273773. Every genuine query ranked above every fake query. This seven-query demonstration is not a generalization benchmark.
| Required file | Source |
|---|---|
motif_global.pth |
MOTIF |
motif_mouth.pth |
MOTIF |
norm_stats_all.npz |
MOTIF |
norm_stats_mvrecon.npz |
MOTIF |
retinaface_resnet50_2020-07-20_old_torch.pth |
RetinaFace via the 3DDFA-V3 Hub repository |
large_base_net.pth |
HRN via the 3DDFA-V3 Hub repository |
net_recon.pth |
3DDFA-V3 via the 3DDFA-V3 Hub repository |
Only load trusted checkpoints and reference sets. MOTIF code is MIT licensed; vendored 3DDFA-V3 code retains its own notice. Third-party model assets and DiCaprio demo footage retain their respective terms; MIT does not grant redistribution rights for that footage.
Our implementation builds on code and model assets from 3DDFA-V3, Deep3D, HRN, and RetinaFace. We thank their authors for making these resources available.
@inproceedings{affatato2026motif,
title = {{MOTIF}: Person-of-Interest Deepfake Detection Beyond {3DMM} Coefficients},
author = {Affatato, Giovanni and Mandelli, Sara and Bestagini, Paolo and Tubaro, Stefano},
booktitle = {2026 IEEE International Workshop on Information Forensics and Security (WIFS)},
year = {2026},
eprint = {2610.09830},
archivePrefix = {arXiv},
primaryClass = {cs.CV},
url = {https://arxiv.org/abs/2610.09830}
}