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.
Training setup
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.
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
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.