Back to the portfolio Code on GitHub

Write-up · November 2026

Does a deepfake detector still work on fakes it has never seen?

I trained two detectors on images from one generator, Stable Diffusion 1.4, and tested both on eight. The fine-tuned CNN was slightly better at home and fell apart away from it. A linear probe on frozen CLIP features held up much better, but not everywhere.

Setup

Results

GeneratorA: ConvNeXtB: CLIP probe
SD 1.4 trained on0.9950.986
SD 1.5 same family0.9930.984
Wukong same family0.9760.959
Midjourney0.7020.907
GLIDE0.5810.877
VQDM0.5690.716
ADM0.4670.699
BigGAN0.3760.675

A wins on its home ground by less than 0.02 AUC. Everywhere else B wins, often by a lot: Midjourney 0.91 against 0.70, GLIDE 0.88 against 0.58. A is below chance on ADM and BigGAN, which means it rates those fakes as more real than the real photos. B is still weak on ADM, VQDM and BigGAN.

The shortcut I had to rule out first

In the raw dataset the real photos are JPEGs and most fakes are PNGs. A model could get a perfect score by reading the file format and never look at the picture. To check, I trained a small classifier on file metadata only: format, size, byte count and the JPEG quantisation table. On the raw files it scored 1.00 AUC.

So I resized every image to 224 by 224 and saved it as a JPEG, and JPEG-compressed the fakes first at a random quality so they carry the same artefacts as the real photos. After that, metadata alone scored 0.52, close to chance. As a second check, B's scores with and without this format matching agree within about 0.01 AUC on every generator except BigGAN, so B isn't just detecting compression.

Ranking survives, the threshold doesn't

B's AUC stays well above its accuracy at a 0.5 cut-off, and the gap grows the further a generator is from SD 1.4: 0.05 on SD 1.4, 0.16 on BigGAN. At 0.5 it catches 94% of SD 1.4 fakes but only 9% of BigGAN fakes. B still orders the images sensibly, but a threshold learned on one generator doesn't carry over to the others, and in the real world you don't know which generator you're facing.

What failed

Each grid shows a model's 20 most confident mistakes, labelled generator, true label and score. I checked every pattern below against the score files.

Model A's 20 most confident mistakes: 15 BigGAN fakes, small soft animals and objects on plain backgrounds, all scored 0.00. Model B's 20 most confident mistakes: mostly ADM and VQDM fakes of busy everyday scenes, foliage, crowds and people, all scored 0.00.
Left: model A. Right: model B.
  1. Every confident mistake is a missed fake, never a false alarm. All 40 images are fakes that the models called real. False alarms stay low and flat: A flags 1 to 4% of real photos, B 6 to 9%. Anything that doesn't look like SD 1.4 falls back to "real".
  2. A is confidently wrong. B is mostly unsure. A misses all 500 BigGAN fakes and gives 462 of them a score below 0.01. B also misses 455, but only 67 of them score that low. B's misses sit closer to the line, which matches the threshold problem above.
  3. The two models fail on different images. A's worst cases are 15 BigGAN fakes: small, soft, smeared animals on plain backgrounds. B's are mostly ADM and VQDM fakes of busy everyday snapshots, like foliage, crowds and people. My reading, which I haven't tested: A learned SD 1.4's texture fingerprint, while B judges content, so fakes with realistic snapshot content fool it.

Limitations

Images from GenImage (Zhu et al.), licensed CC BY-NC-SA and shown here for non-commercial research. Full method, code and reproduction steps are in the repository.

Email me Back to the portfolio