# GAN fingerprint detection, explained

Source: https://passreal.com/guides/gan-fingerprints

A GAN fingerprint is a consistent statistical trace left by a generator's architecture and training: periodic patterns from upsampling layers, characteristic spectra and residual noise. Researchers showed that classifiers can attribute images to the model that made them. The traces weaken after resizing, compression and filtering, and newer diffusion models leave different ones.

## Where fingerprints come from

A generator is not a random-pixel machine. It is a specific network with specific
layers, trained on specific data, and those choices leave marks on every image it
produces. The marks are statistical, not visible, but they are stable enough that
a classifier can find them.

The most studied source is upsampling. A GAN generator starts from a small tensor
and enlarges it step by step. Layers such as transposed convolution place values on
a regular grid, with strides and kernel sizes that produce overlapping contributions
in a fixed pattern. The pattern repeats across the image.

## What it looks like in the spectrum

Compute a two-dimensional Fourier transform of a real photograph and you see energy
that falls off smoothly from the centre. Do the same for many GAN outputs and you
often see isolated bright peaks away from the centre at positions determined by the
architecture. Averaging the spectra of many images from one model sharpens the
peaks, because the scene content averages out and the architecture does not.

Beyond periodic peaks, researchers found that the noise residual left after
removing image content is itself a signature. Subtract a denoised version from the
image, and what remains can be matched to the model that produced it, much as sensor
pattern noise is matched to a camera.

## How detection works

Detectors in this literature use a few approaches.

- **Spectral features.** Train a classifier on the Fourier spectrum or on a
  reduced summary of it.
- **Residual features.** Train on the noise residual instead of the image.
- **Attribution.** Rather than a yes or no, ask which model made the image,
  using a classifier with one class per known generator.
- **End-to-end networks.** Feed pixels to a deep network and let it find its own
  cues.

All of them depend on the training set. A classifier shown only one family of
generators learns that family's habits and can fail on another.

## Limits you should know

- **Post-processing.** Resizing, cropping, blur and JPEG compression weaken many
  traces. Accuracy reported on clean files drops on images that have travelled.
- **Generalisation.** A detector trained on GAN outputs often misses diffusion
  images, which have a different upsampling and a different noise process.
- **Adversarial change.** Small deliberate changes to an image can move it across
  a classifier's boundary. That says something about the classifier, not about
  the picture.
- **False positives.** Heavy smoothing or upscaling of a real photograph can create
  statistics a classifier reads as synthetic.

## What changes a fingerprint

Anything that alters the pixel grid or the spectrum alters the trace. A low-pass
filter attenuates the high-frequency peaks. Grain adds noise that competes with the
residual. A re-encode adds its own quantisation pattern.

PassReal applies those steps. It removes C2PA, IPTC digital source type, XMP and
PNG text chunks, adds sensor grain and radial chromatic aberration, low-pass filters
the spectrum and encodes a JPEG with real-camera EXIF. We do not claim any of that
defeats a particular classifier; in our own tests ZeroGPT still scored processed
images at 0.96 to 0.97. It also does not remove SynthID, which is a deliberate
watermark rather than a fingerprint.

## Reading papers on the topic

When you read a detection paper, check which generators were in the test set, which
post-processing was applied, and whether the detector was tested on families it was
not trained on. The last point is the hardest and the most revealing.

## Try it on your own images

Compute a spectrum of one of your images, then process three free images at
PassReal and compute it again. The comparison is quick and shows which traces moved.

## Questions

### What is a GAN?

A generative adversarial network, in which a generator produces images and a discriminator tries to tell them from real ones. The two are trained against each other.

### Is a fingerprint the same as a watermark?

No. A watermark is inserted on purpose. A fingerprint is an accidental by-product of how the model is built and trained.

### Do diffusion models have fingerprints?

Research indicates they leave traces too, though different from GANs. Detectors trained on one family often generalise poorly to another.

### Can resizing remove a fingerprint?

It weakens many of them, since upsampling patterns depend on the pixel grid. Resizing also changes other statistics, and the net effect on a given classifier is not predictable.

### Does PassReal remove GAN fingerprints?

It filters the frequency spectrum and adds sensor-style grain, which alters some of these traces. No detection outcome is promised, and SynthID is not removed.

Try it: https://passreal.com/app (three images free)
