DeepGuard

Method

How the detector was built, what it measures, and where it fails

The problem

Face-swap tools place one person's identity onto another person's head. The result is convincing at a glance but leaves measurable traces: a blending boundary where the swapped region meets original skin, texture that does not match across that boundary, and lighting that is subtly inconsistent around the jaw and hairline. This project trains a classifier to find those traces and then shows you where it found them.

Dataset

10,852 images, roughly balanced between authentic photographs and swaps generated in-house with InsightFace inswapper_128, SimSwap and DeepFaceLab. Generating the fakes rather than downloading a public set meant the swap parameters were known, so the difficulty could be varied deliberately instead of accepting whatever a benchmark happened to contain. Held-out evaluation uses 4,500 of those images, and every metric on this page and in the repository is derived from the same confusion matrix.

Total images
10,852
Held-out set
4,500
Generators
3

Training setup

BackboneEfficientNet-B4 (timm)
Pre-trainingImageNet-21k
Input size380 × 380
Training images10,852
OptimiserAdamW, lr 3e-5
SchedulerCosine annealing
Batch size16
Epochs8, early stop at 3
AugmentationFlip, rotate, colour jitter
LossBinary cross-entropy

Explaining a prediction

A confidence score on its own is not much use — it tells you the model is sure without telling you why. GradCAM addresses this by taking the gradient of the predicted class with respect to the final convolutional block, then weighting that block's activation maps by how strongly each channel influenced the output. The result is a coarse map over the image showing which regions actually moved the score.

Hook point
model.backbone.blocks[-1]

The last MBConv block, chosen because it retains enough spatial resolution to localise a region of the face while still carrying high-level semantic features.

Results by generation method

Method
Accuracy
AUC
Relationship to training set
StyleGAN2
94.8%
0.9820
In training distribution
inswapper_128
91.5%
0.9486
In training distribution
FaceSwap
89.3%
0.9380
In training distribution
DeepFaceLab
85.1%
0.9210
Partially held out
Stable Diffusion
78.4%
0.8940
Out of distribution

What it does not do

It looks for swap artefacts, not synthesis

The training set was built from face-swap pipelines, so the model learned the seams those pipelines leave — blending boundaries, texture discontinuities, mismatched lighting at the jaw. A face generated whole by a diffusion model has no seam, which is why accuracy falls to 78.4% there.

Compression degrades it

Heavy JPEG compression and re-encoding destroy exactly the high-frequency detail the model relies on. An image that has been screenshotted, re-saved and passed through a messaging app is materially harder than the same image at source.

Single frames only

There is no temporal modelling. Video is handled by sampling frames independently, which discards the flicker and identity drift that are often the strongest signals in a manipulated clip.

False positives carry real cost

At the operating threshold, 143 of 2,174 authentic photographs were flagged — a false-positive rate of 6.58%. A verdict here is evidence to weigh, not proof, and the heatmap exists so a person can check the model's reasoning rather than defer to it.