Spaces:
Running
Running
File size: 3,824 Bytes
0b8f50d |
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 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# 📦API integration note
## Overview
This system integrates **three image forensics methods**—**ELA**, **FFT**, and **Metadata analysis**—into a single detection pipeline to determine whether an image is AI-generated, manipulated, or authentic.
---
## 🔍 Detection Modules
### 1. **ELA (Error Level Analysis)**
* **Purpose:** Detects tampering or editing by analyzing compression error levels.
* **Accuracy:** ✅ *Most accurate method*
* **Performance:** ❗ *Slowest method*
* **Output:** `True` (edited) or `False` (authentic)
### 2. **FFT (Fast Fourier Transform)**
* **Purpose:** Identifies high-frequency patterns typical of AI-generated images.
* **Accuracy:** ⚠️ *Moderately accurate*
* **Performance:** ❗ *Moderate to slow*
* **Output:** `True` (likely AI-generated) or `False` (authentic)
### 3. **Metadata Analysis**
* **Purpose:** Detects traces of AI tools or editors in image metadata or binary content.
* **Accuracy:** ⚠️ *Fast but weaker signal*
* **Performance:** 🚀 *Fastest method*
* **Output:** One of:
* `"ai_generated"` – AI tool or generator identified
* `"edited"` – Edited using known software
* `"undetermined"` – No signature found
---
## 🧩 Integration Plan
### ➕ Combine all three APIs into one unified endpoint:
```bash
POST /api/detect-image
```
### Input:
* `image`: Image file (binary, any format supported by Pillow)
### Output:
```json
{
"ela_result": true,
"fft_result": false,
"metadata_result": "ai_generated",
"final_decision": "ai_generated"
}
```
> NOTE:Optionally recommending a default logic (e.g., trust ELA > FFT > Metadata).
## Result implementation
| `ela_result` | `fft_result` | `metadata_result` | Suggested Final Decision | Notes |
| ------------ | ------------ | ----------------- | ------------------------ | ----------------------------------------------------------------------- |
| `true` | `true` | `"ai_generated"` | `ai_generated` | Strong evidence from all three modules |
| `true` | `false` | `"edited"` | `edited` | ELA confirms editing, no AI signals |
| `true` | `false` | `"undetermined"` | `edited` | ELA indicates manipulation |
| `false` | `true` | `"ai_generated"` | `ai_generated` | No edits, but strong AI frequency & metadata signature |
| `false` | `true` | `"undetermined"` | `possibly_ai_generated` | Weak metadata, but FFT indicates possible AI generation |
| `false` | `false` | `"ai_generated"` | `ai_generated` | Metadata alone shows AI use |
| `false` | `false` | `"edited"` | `possibly_edited` | Weak signal—metadata shows editing but no structural or frequency signs |
| `false` | `false` | `"undetermined"` | `authentic` | No detectable manipulation or AI indicators |
### Decision Logic:
* Use **ELA** as the **primary indicator** for manipulation.
* Supplement with **FFT** and **Metadata** to improve reliability.
* Combine using a simple rule-based or voting system.
---
## ⚙️ Performance Consideration
| Method | Speed | Strength |
| -------- | ----------- | -------------------- |
| ELA | ❗ Slow | ✅ Highly accurate |
| FFT | ⚠️ Moderate | ⚠️ Somewhat reliable |
| Metadata | 🚀 Fast | ⚠️ Low confidence |
> For high-throughput systems, consider running Metadata first and conditionally applying ELA/FFT if suspicious.
|