TrustCheck.ir Sadra Milani Moghaddam

Try it yourself with TrustCheck.ir

Can you tell a photo from a picture a machine made? Drop one in, make your guess, then see what the detector thinks and which parts of the picture it relied on.

Looking for an AI portrait to try? thispersondoesnotexist.com

2.5Mimages in ArtiFact, the dataset behind the model2,496,738 in total · 964,989 real · 1,531,749 fake
25AI generators in that datasetGANs and diffusion models
2ways of seeing every picturecolors and a frequency spectrum
1,152features weighed for each verdict1,024 Swin + 128 frequency

The model was trained on the full training split; 124,830 ArtiFact images were held out for validation.

Two views of the same picture, one verdict. Here is what the model looks at and how its score is calibrated.

Two ways of looking at one picture

Color picture
Swin Transformer1024 features
Grayscale + 2D FFTlog-magnitude spectrum
Small CNN128 features
Combined: AI or real

The Swin backbone looks at the color image. The frequency branch looks for patterns in how brightness changes across space, such as traces left by upsampling. Its separate contribution to accuracy has not been measured.

Head: the 1024 Swin features and the 128 frequency features are joined (1152 in total), then dropout (0.1) and a linear layer with 2 outputs.

The frequency branch, step by step

  1. Grayscale input with values in [0, 1].
  2. Mean removal: subtract the image mean to suppress the constant (DC) component.
  3. Hann window: taper the borders to reduce spectral leakage from edge discontinuities.
  4. 2D FFT, then fftshift to move the zero frequency to the center.
  5. Log magnitude, log(1 + |F|), to compress the dynamic range. Phase is discarded.
  6. Per-image standardization to zero mean and unit standard deviation.
  7. Small CNN: four blocks of 3×3 convolution (stride 2), batch normalization and ReLU, with 32, 64, 128 and 128 channels.
  8. Global average pooling gives a 128-dimensional vector.

Steps 2–6 are fixed operations with no trainable parameters. The CNN has about 241K parameters and is trained jointly with the backbone. Such spectral patterns vary between generators and can be weakened by compression or resizing.

Input and output

  • Preprocessing: convert to RGB, resize the shorter side to 200 px, center-crop to 200×200, then resize to 224×224 (bicubic).
  • The Swin input uses ImageNet mean/std normalization. The frequency branch takes the grayscale version of the resized picture, before ImageNet normalization.
  • Output index 0 = AI-generated, index 1 = real.
  • Code and usage: coming soon.

Calibration

z = logitAI − logitreal, and P(AI) = sigmoid(z / 2.075 − 0.332).

  • Likely real: z ≤ 0.03
  • Uncertain: 0.03 < z < 4.95
  • Likely AI-generated: z ≥ 4.95

On validation, expected calibration error went from 0.0062 to 0.0021 (measured on the data used for fitting).

Validation results

99.27%accuracy (threshold 0.5, uncalibrated)
0.9996ROC AUC
0.9998average precision
99.44%TPR at 1% FPR
0.0153validation loss

These are validation results on 124,830 ArtiFact images, not independent test results. The same set was used to select the checkpoint and fit the calibration, so they may be optimistic. Performance on unseen generators or images outside ArtiFact has not been measured.

Training and data

  • Fine-tuned from umm-maybe/AI-image-detector on the ArtiFact dataset (the original classifier was replaced and the frequency branch added).
  • GPU: NVIDIA RTX 3060 12GB. 3 epochs, batch size 32, bfloat16 autocast.
  • AdamW (weight decay 0.05). Learning rate 1e-5 for the backbone and 1e-4 for the head and frequency branch.
  • Schedule: linear warmup (5% of steps), then cosine decay. Loss: class-weighted cross-entropy.
  • Frequency input: resized 224×224 grayscale. Augmentation: random horizontal flip.
  • ArtiFact, according to its authors: 2,496,738 images (964,989 real and 1,531,749 fake) at 200×200, from 8 real-image sources and 25 generators, including GAN and diffusion models.

The model was trained on the full training split (95% of ArtiFact); the remaining 5% (124,830 images) was held out for validation.