wikillm

Paper · 2023-03-24 · cs.CV, cs.AI, cs.LG

CIFAKE: Image Classification and Explainable Identification of AI-Generated Synthetic Images

Generates 60,000 Stable Diffusion v1.4 images that mirror the ten CIFAR-10 classes, then trains a small CNN (two 32-filter conv layers, one 64-unit dense layer) to label real versus generated images. Author-reported: 93.55% accuracy and F1 0.936 for the final model. Grad-CAM heatmaps suggest the model relies on background artefacts rather than the main subject.

Diffusion modelsImage manipulation detectionConvolutional neural networkFeature attributionsynthetic-image-detectionimage-classificationexplainable-aidataset

arXivPDFCodeMarkdown10 min read

AI-compiled by claude-haiku-5-5 on 2026-10-18, not yet reviewed by a human. Every claim cites its source; check it when a detail matters.

In plain words

Image generators can now produce pictures that look like ordinary photographs, and people often cannot tell the difference. This paper asks whether a computer can. The authors first made a matching fake dataset: they asked a Stable Diffusion model for pictures of the ten object types in the well-known CIFAR-10 dataset, so each real small photo has a generated counterpart. They then trained a small image classifier to answer one question per picture: real or generated?

The classifier gets about 93% of its test pictures right. To see what it looks at, the authors use a heatmap method that highlights the image regions that drove each decision. For the generated pictures, the bright regions were mostly small flaws in the background, not the main object. The dataset itself is released for other researchers.

TL;DR

  • Dataset CIFAKE: 120,000 images, 60,000 real CIFAR-10 images and 60,000 images generated with Stable Diffusion v1.4 §1 §3.1 §3.2.
  • Classifier: a small CNN with sigmoid output, binary cross-entropy loss, trained on 100,000 images and tested on 20,000 §3.3.
  • Final model (two conv layers of 32 filters, one dense layer of 64 units): 93.55% accuracy, F1 0.936, author-reported tab. 7 tab. 11.
  • The abstract's 92.98% belongs to a different, feature-extractor-only topology. See Pitfalls.
  • Grad-CAM heatmaps are qualitative and based on a few random samples §4.2.

Problem

The authors argue that generated images have become hard for humans to tell apart from photographs, so authenticity checks need automated help §1 §2. The paper notes that work on detecting generated images was young and that examples of synthetic training data were scarce §1 §2. Its contribution is a paired real and generated dataset, a classification baseline on it, and an explanation step §1.

Method

The method has four parts: building the real data, generating the fake data, training a CNN over a topology sweep, and explaining predictions with Grad-CAM.

  1. Real data. Take the 50,000 CIFAR-10 training images as the REAL class and the 10,000 CIFAR-10 test images as its test set. Images are 32 x 32 RGB, with ten classes of 6,000 images each §3.1.
  2. Fake data. Generate 6,000 images per class with Stable Diffusion v1.4, a latent diffusion model, using 50 denoising steps and the Euler Ancestral scheduler. Renders are 512 px and are then reduced to 32 px by bilinear interpolation §3.2 §3.5. Prompts follow the pattern "a photograph of {a/an} " with per-class modifiers from tab. 1. The paper says the modifiers are used equally across the 6,000 images, but not how they are combined into one prompt tab. 1.
  3. Diffusion background. The forward process mixes an image with Gaussian noise according to eq. 1. The paper quotes the usual latent diffusion training loss eq. 2 but does not train the diffusion model: it uses the published Stable Diffusion v1.4 weights §3.2 §3.5.
  4. Classifier. A CNN takes a 32 x 32 x 3 input, passes it through two blocks of convolution (32 filters, ReLU) and max pooling, flattens the result, applies a dense layer of 64 ReLU units, and ends with one sigmoid output fig. 5 §3.3. The text defines convolution in eq. 3 and the output size of a valid, stride-1 convolution in eq. 4. The sigmoid is eq. 5. The label is REAL = 1 and FAKE = 0; at inference the output is rounded to the nearest value §3.3.
  5. Topology sweep. Twelve feature extractors (filters {16, 32, 64, 128} x conv layers {1, 2, 3}) are compared first. Then the best one is fitted with a dense head of {32, 64, 128, ..., 4096} units x {1, 2, 3} layers. In total 36 networks are compared on the classification metrics §3.3 tab. 2 tab. 7.
  6. Metrics. Precision eq. 6, recall eq. 7 and F1 eq. 8 are reported. Because REAL is the positive class, these are computed for REAL §3.3.
  7. Explanation. Grad-CAM eq. 9 gives a heatmap for a chosen class. The paper applies it to randomly selected test images, judges the maps visually, and does not report a quantitative explanation metric §3.4 §4.2.
Pseudocode
# Fake image generation  [§3.2] [§3.5] [tab. 1]
# Real images come from CIFAR-10 unchanged  [§3.1]
def make_fake_image(class_name, modifiers, seed):
    # Prompt: "a photograph of {a/an} <class>" plus modifiers  [tab. 1]
    # How modifiers are combined per image is not stated.
    prompt = build_prompt(class_name, modifiers)
    # 50 denoising steps, Euler Ancestral scheduler  [§3.5]
    image_512 = stable_diffusion_v1_4(prompt, steps=50, seed=seed)
    # Bilinear downscale to match CIFAR-10  [§3.5]
    return bilinear_resize(image_512, height=32, width=32)  # (32, 32, 3)
Pseudocode
# Classifier  [§3.3] [fig. 5]
# Kernel size, pool size and rescale factor are not stated.
def classify(images):
    # images: (B, 32, 32, 3), rescaled  [fig. 5]
    # First conv block: 32 filters, ReLU, then max pooling  [fig. 5]
    features = relu(conv2d(images, filters=32))
    features = max_pool(features)
    # Second conv block: 32 filters, ReLU, then max pooling  [fig. 5]
    features = relu(conv2d(features, filters=32))
    features = max_pool(features)
    # Flatten, dense layer of 64 ReLU units  [fig. 5]
    hidden = relu(dense(flatten(features), units=64))
    # One sigmoid output, close to 1 means REAL  [§3.3] [eq. 5]
    return sigmoid(dense(hidden, units=1))  # (B, 1)
Pseudocode
# Training and inference  [§3.3]
# Optimizer, learning rate, batch size and epochs are not stated.
def train_loss(probabilities, labels):
    # Binary cross-entropy, labels REAL = 1, FAKE = 0  [§3.3]
    return binary_cross_entropy(probabilities, labels)

def predict(probabilities):
    # Rounding to the nearest value, i.e. threshold 0.5 by implication  [§3.3]
    return round(probabilities)  # (B, 1), values 0 or 1
Pseudocode
# Grad-CAM heatmap  [§3.4] [eq. 9]
# Target layer and upsampling to input size are not stated.
def grad_cam(feature_maps, score_gradients):
    # feature_maps: (H, W, K), score_gradients: (H, W, K)
    # One weight per feature map: mean gradient over space  [eq. 9]
    weights = mean(score_gradients, axis=(0, 1))  # (K,)
    # Weighted sum over feature maps, then ReLU  [eq. 9]
    return relu(sum(weights * feature_maps, axis=2))  # (H, W)

Equations, as numbered in the paper:

x_t=\sqrt{\bar{\alpha}_t} x_0+\sqrt{1-\bar{\alpha}_t} \varepsilon eq. 1

Loss = E_{t, x_0, \varepsilon} \left[ \left| \left| \varepsilon - \varepsilon_\theta(x_t, t) \right| \right| ^2 \right] eq. 2

(x * w)(i, j) = \sum_{m=1}^{M}\sum_{n=1}^{N} x(i+m-1, j+n-1)\,w(m,n) eq. 3

(height - height_{kernel} + 1,\; width - width_{kernel} + 1) eq. 4

\sigma(x) = \frac{1}{1+e^{-x}} eq. 5

\text{Precision} = \frac{\text{TP}}{\text{TP} + \text{FP}} eq. 6

\text{Recall} = \frac{\text{TP}}{\text{TP} + \text{FN}} eq. 7

\text{F1} = 2 \times \frac{\text{Precision} \times \text{Recall}}{\text{Precision} + \text{Recall}} eq. 8

L^{c}_{\text{Grad-CAM}} = \text{ReLU}\Big(\sum_k \alpha_k A^k\Big), \quad \alpha_k = \frac{1}{Z}\sum_i\sum_j \frac{\partial y_c}{\partial A^k_{i,j}} eq. 9

Eq. 4 is written for stride 1 and no padding, which the text adopts "for simplicity" §3.3. Eq. 2 is the diffusion training objective; this paper does not train a diffusion model §3.2.

Hyperparameters

NameValueWhereNotes
Real images60,000 CIFAR-10, 6,000 per class, 32 x 32 RGB§3.1
GeneratorStable Diffusion v1.4 (latent diffusion)§3.2 §3.5Published model; training not described
Denoising steps50§3.2 §3.5§3.2 says "50 noising steps"; §3.5 says denoising
SamplerEuler Ancestral§3.5
Guidance scale, negative prompt, seeds per imagenot statedOnly "random seed vectors" §3.5
Prompt template"a photograph of {a/an} " + modifierstab. 1Modifier combination not stated
Generated images6,000 per class, 60,000 total§3.2
Render size, then resize512 px, bilinear to 32 px§3.5
Classifier train set100,000 (50,000 real, 50,000 generated)§3.3
Classifier test set20,000 (10,000 each)§3.3Tables say "validation"; see Pitfalls
Input32 x 32 x 3fig. 5 §3.5Rescale factor not stated
Conv layers2, each 32 filters, ReLUfig. 5 §4.2Kernel size, stride, padding not stated fig. 5
PoolingMax pooling, 2 layersfig. 5Pool size and stride not stated
Dense head1 hidden layer of 64 ReLU unitsfig. 5 tab. 7
Output1 sigmoid unit§3.3 eq. 5Rounded at inference
LossBinary cross-entropy§3.3
Optimizer, learning rate, batch size, epochsnot stated
Random seedTensorFlow seeds set to 1§3.5
Grad-CAM target layernot stated§3.4
Hardware1 x NVIDIA RTX 3080 Ti, 12 GB§3.5

Results

Author-reported. Setup: binary CNN classifier on CIFAKE (REAL vs Stable Diffusion v1.4 output), 100,000 training and 20,000 test images, one GPU §3.3 §3.5. The paper reports no external baseline. The comparisons are between its own 36 topologies §4.2.

ModelMetricValueSource
Final: 2 conv x 32 filters, dense 64Accuracy93.55%tab. 7
Final: 2 conv x 32 filters, dense 64Binary cross-entropy0.182tab. 8
Final: 2 conv x 32 filters, dense 64Precision (REAL)0.925tab. 9
Final: 2 conv x 32 filters, dense 64Recall (REAL)0.948tab. 10
Final: 2 conv x 32 filters, dense 64F10.936tab. 11
Feature extractor only: 128 filters x 2 convAccuracy (abstract's headline)92.98%tab. 2 §4.2
Feature extractor only: 128 filters x 2 convBinary cross-entropy0.221tab. 3 §4.2
Feature extractor only: 32 filters x 2 convAccuracy92.93%tab. 2 §4.2
Feature extractor only: 32 filters x 2 convBinary cross-entropy0.18tab. 3 §4.2
All 12 feature extractorsMean accuracy91.79%tab. 2 §4.2

Across the 24 dense-head networks, accuracy runs from 92.52% to 93.55% tab. 7.

Qualitative results from Grad-CAM, reported on a few random samples fig. 6:

  • For real images, the heatmap covers most of the image §4.2 fig. 6.
  • For generated images, activation is sparse and sits on parts that the paper says are likely to show visual glitches; for a frog image the only cue was an out-of-focus background §4.2 fig. 6.
  • For the airplane, bird, frog, horse and ship examples, the object itself has little or no activation §4.2 fig. 6.

Dataset examples: generated samples per class fig. 2, visible defects such as letter-like shapes in the background, a jet without a cockpit window, and anatomical errors in animals fig. 3, and realistic water and reflections fig. 4. The paper gives no quantitative measure of image quality.

Paper vs code

Official repository found: jordan-bird/CIFAKE-Real-and-AI-Generated-Synthetic-Images (owner matches author Jordan J. Bird; its README cites this paper as the dataset source README.md). Cloned at commit e112a942abaecd02b6b1f6f646c807d56be8fb62. The paper itself links no code repository, and the arXiv page lists none. The GitHub search for "CIFAKE" returned many third-party reimplementations, which were not used.

What the repository contains: the dataset folder and a README, nothing else README.md. There is no model, training, configuration or Grad-CAM code. Consequently:

  • The architecture, optimizer, learning rate, batch size, epochs, kernel size, pooling and Grad-CAM layer are not verifiable against code. The values above come from the paper and fig. 5 only.
  • The Stable Diffusion sampling settings are not in the repository either.

Dataset check. The paper's split is 50,000 REAL and 50,000 FAKE training images, and 10,000 of each for test §3.3. The repository holds 50,000 and 50,000 training files and 10,000 and 10,000 test files . The README gives the same counts README.md. We did not check image dimensions or pixel content.

License of the repository. There is no LICENSE file. The README says the dataset is "published under the same MIT license as CIFAR-10" README.md. No code is quoted in this card.

Pitfalls

  • Headline number is not the final model. The abstract's 92.98% is the feature-extractor-only topology with 128 filters and two conv layers tab. 2. The model used for the final result and Grad-CAM is two conv layers of 32 filters with a dense head of 64 units fig. 5, which scores 93.55% tab. 7. Reproduce the second one if you want the paper's final model.
  • Selection rule is inconsistent. §3.3 says the best feature extractor is chosen by the classification metrics. §4.2 says the lowest-loss extractor (32 filters, two layers) was chosen, although 128 filters, two layers, has the highest accuracy tab. 2 tab. 3. Fig. 5 matches the lowest-loss choice.
  • F1 summary in §4.2 does not match the feature-extractor table. The text gives a mean F1 of 0.929 and a highest F1 of 0.936. Our sum of the 12 values in tab. 6 gives a mean of about 0.917 and a maximum of 0.930. The 0.929 mean and the 0.936 maximum match the dense-head table tab. 11.
  • "Validation" versus "test". The result tables are labelled validation, but §3.3 defines a 20,000-image test set. The paper does not say whether the choice among 36 topologies used the same images that are reported. If it did, the reported numbers are optimistic. No separate held-out split is described.
  • Positive class. REAL is the positive class, so precision, recall and F1 refer to REAL §3.3. A false negative is a real image labelled FAKE. Check this before comparing with papers that use the opposite convention.
  • Different preprocessing for the two classes. CIFAR-10 images are native 32 x 32. Generated images are rendered at 512 px and downscaled with bilinear interpolation §3.5. The paper does not discuss whether this difference could itself be a cue for the classifier.
  • Denoising wording. §3.2 says "50 noising steps" but describes the reverse process. §3.5 says the images were "denoised for a total of 50 steps". Use 50 sampler steps.
  • Unstated generation settings. Guidance scale, negative prompt, and how a seed is assigned to each image are not stated. The outputs cannot be regenerated exactly from the paper §3.5 tab. 1.
  • Unstated training settings. Optimizer, learning rate, batch size, epochs, early stopping, and the rescale factor in the input layer are not stated §3.3 fig. 5. Expect to tune these yourself.
  • Grad-CAM details. The target layer, whether the score before or after the sigmoid is used, and upsampling to input size are not stated §3.4 eq. 9. The heatmaps are shown on a few random samples only §4.2.
  • Scope of generalization. Only one generator (Stable Diffusion v1.4) and one source dataset (CIFAR-10) are used. The authors say future work should update the dataset with newer generators and other domains §5. Results on other generators are not reported.
  • Costs. Training 36 networks on one GPU is the stated budget §3.5. Run time per network and generation time for 60,000 images are not stated.

Lineage

  • Builds on: CIFAR-10 for the real images §3.1; Stable Diffusion v1.4 for the generated images §3.2; Grad-CAM for explanations §3.4. None of these has a card in this wiki.
  • Compared against: no external baseline is reported §4.2.
  • Superseded by: not known from content in this wiki.

Source and license

Adapted from “CIFAKE: Image Classification and Explainable Identification of AI-Generated Synthetic Images” by Jordan J. Bird, Ahmad Lotfi (arXiv:2303.14126), used under CC BY 4.0. Changes: condensed and restructured for implementation, with tables, equations and algorithms taken from the paper and its code, each cited to its source. Not affiliated with or endorsed by the authors. Code citations refer to https://github.com/jordan-bird/CIFAKE-Real-and-AI-Generated-Synthetic-Images at commit e112a942abae (none (no LICENSE file in repository; README states MIT for the dataset)). Any quoted code is shown under that license.