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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
# πΌοΈ Image Forgery Detection Model
|
| 6 |
|
| 7 |
+
license: mit
|
| 8 |
+
pipeline_tag: image-classification
|
| 9 |
+
library_name: tensorflow
|
| 10 |
+
tags:
|
| 11 |
+
- image-forgery-detection
|
| 12 |
+
- ai-generated-images
|
| 13 |
+
- deepfake-detection
|
| 14 |
+
- fake-image-detection
|
| 15 |
+
- image-forensics
|
| 16 |
+
- computer-vision
|
| 17 |
+
- mobilenetv2
|
| 18 |
+
- tensorflow
|
| 19 |
+
- keras
|
| 20 |
+
---
|
| 21 |
+
|
| 22 |
+
# π΅οΈ AI Image Forgery Detector (Real vs Fake)
|
| 23 |
+
|
| 24 |
+
This model detects whether an image is **REAL (camera-captured)** or **FAKE (AI-generated / manipulated)**.
|
| 25 |
+
|
| 26 |
+
It is a **fine-tuned MobileNetV2 model** trained using TensorFlow/Keras, designed for **AI image forgery detection**, including synthetic and deepfake-style images.
|
| 27 |
+
|
| 28 |
+
---
|
| 29 |
+
|
| 30 |
+
## π What This Model Can Do
|
| 31 |
+
|
| 32 |
+
β Detect AI-generated images
|
| 33 |
+
β Detect manipulated or synthetic content
|
| 34 |
+
β Works on faces, objects, landscapes, and artworks
|
| 35 |
+
β Outputs **prediction + confidence score**
|
| 36 |
+
|
| 37 |
+
### Class Labels
|
| 38 |
+
- **0 β Fake**
|
| 39 |
+
- **1 β Real**
|
| 40 |
+
|
| 41 |
+
---
|
| 42 |
+
|
| 43 |
+
## π§ Model Architecture
|
| 44 |
+
|
| 45 |
+
- **Base model:** MobileNetV2 (ImageNet pretrained)
|
| 46 |
+
- **Framework:** TensorFlow / Keras
|
| 47 |
+
- **Input size:** 224 Γ 224 RGB image
|
| 48 |
+
- **Output:** Sigmoid probability
|
| 49 |
+
- **Task:** Binary image classification
|
| 50 |
+
|
| 51 |
+
Additional layers:
|
| 52 |
+
- Global Average Pooling
|
| 53 |
+
- Dense (ReLU)
|
| 54 |
+
- Dropout (regularization)
|
| 55 |
+
- Sigmoid output layer
|
| 56 |
+
|
| 57 |
+
---
|
| 58 |
+
|
| 59 |
+
## π Evaluation Results
|
| 60 |
+
|
| 61 |
+
The model was evaluated using **accuracy, precision, recall, and F1-score**, with threshold optimization based on **macro F1-score** to handle class imbalance.
|
| 62 |
+
|
| 63 |
+
### Best Validation Results
|
| 64 |
+
- **Accuracy:** ~87%
|
| 65 |
+
- **Fake class:** High precision
|
| 66 |
+
- **Real class:** High recall
|
| 67 |
+
- **Threshold:** Optimized (~0.65)
|
| 68 |
+
|
| 69 |
+
> Results may vary depending on image quality and source.
|
| 70 |
+
|
| 71 |
+
---
|
| 72 |
+
|
| 73 |
+
## πΌοΈ Example Predictions
|
| 74 |
+
|
| 75 |
+
### β
Real Image (Correct Classification)
|
| 76 |
+

|
| 77 |
+
|
| 78 |
+
**Prediction:** REAL
|
| 79 |
+
**Confidence:** High
|
| 80 |
+
|
| 81 |
+
---
|
| 82 |
+
|
| 83 |
+
### β AI-Generated Image (Correct Classification)
|
| 84 |
+

|
| 85 |
+
|
| 86 |
+
**Prediction:** FAKE
|
| 87 |
+
**Confidence:** High
|
| 88 |
+
|
| 89 |
+
---
|
| 90 |
+
|
| 91 |
+
## π How to Use This Model
|
| 92 |
+
|
| 93 |
+
```python
|
| 94 |
+
import tensorflow as tf
|
| 95 |
+
import numpy as np
|
| 96 |
+
from PIL import Image
|
| 97 |
+
|
| 98 |
+
IMG_SIZE = 224
|
| 99 |
+
|
| 100 |
+
# Load model
|
| 101 |
+
model = tf.keras.models.load_model("forgery_model.keras")
|
| 102 |
+
|
| 103 |
+
# Load and preprocess image
|
| 104 |
+
img = Image.open("test.jpg").convert("RGB")
|
| 105 |
+
img = img.resize((IMG_SIZE, IMG_SIZE))
|
| 106 |
+
img = np.array(img) / 255.0
|
| 107 |
+
img = np.expand_dims(img, axis=0)
|
| 108 |
+
|
| 109 |
+
# Predict
|
| 110 |
+
probability = model.predict(img)[0][0]
|
| 111 |
+
|
| 112 |
+
label = "REAL" if probability > 0.65 else "FAKE"
|
| 113 |
+
print("Prediction:", label)
|
| 114 |
+
print("Confidence:", probability)
|
| 115 |
+
π― Intended Use
|
| 116 |
+
This model is suitable for:
|
| 117 |
+
|
| 118 |
+
AI-generated image detection
|
| 119 |
+
|
| 120 |
+
Image forgery analysis
|
| 121 |
+
|
| 122 |
+
Academic projects
|
| 123 |
+
|
| 124 |
+
Research and experimentation
|
| 125 |
+
|
| 126 |
+
Educational demonstrations
|
| 127 |
+
|
| 128 |
+
β Not recommended for legal, forensic, or high-risk decision-making systems.
|
| 129 |
+
|
| 130 |
+
β οΈ Limitations
|
| 131 |
+
Extremely realistic AI images may still fool the model
|
| 132 |
+
|
| 133 |
+
Performance can drop on:
|
| 134 |
+
|
| 135 |
+
Heavy compression
|
| 136 |
+
|
| 137 |
+
Very low resolution
|
| 138 |
+
|
| 139 |
+
Extreme image edits
|
| 140 |
+
|
| 141 |
+
Model predictions are probabilistic, not absolute truth
|
| 142 |
+
|
| 143 |
+
Always validate outputs before real-world use.
|
| 144 |
+
|
| 145 |
+
π§ͺ Training Details
|
| 146 |
+
Base: MobileNetV2 (ImageNet weights)
|
| 147 |
+
|
| 148 |
+
Optimizer: Adam (low learning rate)
|
| 149 |
+
|
| 150 |
+
Loss: Binary Crossentropy
|
| 151 |
+
|
| 152 |
+
Data augmentation applied
|
| 153 |
+
|
| 154 |
+
Class imbalance handled using class weights
|
| 155 |
+
|
| 156 |
+
Threshold tuning performed after training
|
| 157 |
+
|
| 158 |
+
π§ Ethical Considerations
|
| 159 |
+
Predictions can be incorrect
|
| 160 |
+
|
| 161 |
+
False positives / negatives are possible
|
| 162 |
+
|
| 163 |
+
Use responsibly and transparently
|
| 164 |
+
|
| 165 |
+
Do not rely solely on this model for critical decisions
|
| 166 |
+
|
| 167 |
+
π License
|
| 168 |
+
This model is released under the MIT License.
|
| 169 |
+
|
| 170 |
+
π€ Author
|
| 171 |
+
Kumaran
|
| 172 |
+
Hugging Face: kumaran-0188
|
| 173 |
+
|
| 174 |
+
Built as part of an AI image forgery detection project using TensorFlow.
|
| 175 |
+
|
| 176 |
+
π Acknowledgements
|
| 177 |
+
TensorFlow & Keras
|
| 178 |
+
|
| 179 |
+
MobileNetV2
|
| 180 |
+
|
| 181 |
+
AI-generated image datasets (CIFAKE-style)
|
| 182 |
+
|
| 183 |
+
Hugging Face ecosystem
|