File size: 3,703 Bytes
3fd0afb
 
 
3b3ee7b
 
 
 
 
 
 
 
 
 
3fd0afb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3b3ee7b
 
3fd0afb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3b3ee7b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77



---
title: FakeOut
emoji: 🐨
colorFrom: gray
colorTo: indigo
sdk: gradio
sdk_version: 6.18.0
python_version: '3.13'
app_file: app.py
pinned: false
short_description: A patch-based DL model detecting microscopic AI artifacts.
---

# FAKEOUT: A Patch-Based Deep Learning Model for AI Image Detection

FAKEOUT is a forensic computer vision application built to expose synthetic modifications and AI-generated image patterns. Unlike traditional classifiers that inspect overall image composition, FAKEOUT operates as a patch-based detector. It isolates microscopic frequency anomalies and localized pixel artifacts left behind by generative architectures.

## How It Works

Traditional AI detection models often become confused by an image's overall subject matter or composition. FAKEOUT bypasses this limitation by looking at the world through a fixed window:
1. **Patch Extraction:** The engine extracts a strict, deterministic 224x224 pixel crop from the exact center of the uploaded image.
2. **Artifact Scan:** A specialized ResNet-50 architecture evaluates this dense sub-grid to scan for subtle, microscopic pixel noise, texture repetitions, and architectural anomalies typical of diffusion models and GANs.
3. **Classification:** The model calculates class probabilities to determine whether the high-frequency fingerprint matches a true photograph (REAL) or an AI generation (FAKE).

---

## Dataset & Architecture

* **Core Approach:** Original work featuring a strict patch-based training and inference pipeline.
* **Sourced Data:** Built by merging and curating two prominent image distribution libraries:
  * **Flickr30k Dataset** (8.86 GB) for diverse, high-resolution authentic photography.
  * **Defactify Image Dataset** (7.51 GB) for diverse synthetic and manipulated generations.
* **Volume:** Combined infrastructure representing 10,000 source images expanded seamlessly into 100,000 unique validation patches during pipeline engineering.

---

## Performance & Key Metrics

Evaluated against a strictly quarantined, un-leaked holdout test set containing complex wild generations:

* **Overall Classification Accuracy:** 76.92%
* **ROC-AUC Score:** 0.7143
* **AI-Detection Recall:** 83.33% (The model successfully catches and flags over 83% of actual AI-generated fakes).

### Model Evaluation Visualized

![ROC-AUC Curve](roc_auc.png)
![Confusion Matrix](confusion_matrix.png)


### Detailed Classification Report

![Classification Report](classification_report.png)

---

## Limitations & Best Results

To get the most accurate results out of FAKEOUT, keep the following mechanical constraints in mind:

* **Resolution Sweet Spot (512px - 1500px):** The model performs best on mid-sized dimensions (e.g., 640x832 or 880x1320). 
* **The 4K Danger Zone:** Ultra-high-resolution images (4K / 3840x2160) will degrade performance. Because the model's 'magnifying glass' is locked to a 224x224 footprint, it ends up scanning less than 0.6% of a 4K frame, completely losing contextual positioning.
* **Centered Subjects:** The patch extraction targets the dead-center. Structural AI defects occurring exclusively on frame borders or background edges will not be parsed.
* **Avoid Screenshots:** Compression passes from screenshot utilities or social media pipelines strip away the micro-level frequency data the model relies on. Always upload raw, uncompressed source files.

## Technology Stack

* **Core Engine:** PyTorch, Torchvision
* **Weights Format:** Safetensors (Optimized for lazy CPU execution)
* **Frontend:** Gradio Web Interface
* **Hosting Container:** Hugging Face Spaces

Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference