This project tackles the problem of image forgery detection using deep learning. The objective is to distinguish between authentic and tampered images using visual evidence generated by Error Level Analysis (ELA). While transfer learning models were explored, the best results were achieved using a custom CNN model trained specifically on ELA-transformed images.
With the increasing accessibility of image editing tools, forged images are everywhere — from social media to news. Most forgeries leave subtle compression artifacts. ELA helps expose these inconsistencies, making it a valuable preprocessing tool for image forgery detection.
- CASIA 2.0 Dataset
- Contains two types of images:
Au/
folder → Authentic imagesTp/
folder → Tampered images
- Includes splicing and copy-move forgeries
- Contains two types of images:
To highlight tampered regions:
- Save each image at 90% JPEG quality
- Subtract the resaved image from the original
- Amplify the difference to highlight compression artifacts
- Resize and normalize for model input
All images (authentic & tampered) were transformed into ELA format before model training.
-
🔸 VGG16
- Val Accuracy: 82.37%
- Precision: 90.91%
- Recall: 73.17%
-
🔸 ResNet50
- Val Accuracy: 85.39%
- Precision: 88.48%
- Recall: 82.44%
-
🔸 MobileNetV2
- Val Accuracy: 84.38%
- Precision: 87.83%
- Recall: 80.98%
Despite their architectural strength, these models couldn’t fully exploit ELA-based features.
After observing limited performance from transfer learning, a custom CNN was built from scratch to focus on ELA-specific features.
Final Performance (Epoch 30):
- ✅ Validation Accuracy: 91.18%
- ✅ Precision: 97.75%
- ✅ Recall: 84.88%
- 🔸 Total Parameters: ~24.2M
Input (150x150x3)
↓
Conv2D (32 filters, 5x5) → ReLU
↓
Conv2D (32 filters, 5x5) → ReLU
↓
MaxPooling2D (2x2)
↓
Dropout (0.25)
↓
Flatten
↓
Dense (150) → ReLU
↓
Dropout (0.5)
↓
Dense (1) → Sigmoid
- All models were trained on ELA-transformed CASIA 2.0 images
- Transfer learning models underperformed, likely because their pretrained filters were not optimized for ELA noise patterns
- The custom CNN, being task-specific, generalized better
“Tailored architectures for domain-specific preprocessing like ELA can outperform large pretrained models in real-world forensic tasks.”
Model | 🔍 Val Accuracy | 🎯 Precision | 🔁 Recall | ⚙️ Params |
---|---|---|---|---|
✅ Custom CNN | 91.18% | 97.75% | 84.88% | 24.2M |
VGG16 | 82.37% | 90.91% | 73.17% | 14.7M |
ResNet50 | 85.39% | 88.48% | 82.44% | 23.6M |
MobileNetV2 | 84.38% | 87.83% | 80.98% | 2.4M |
python>=3.8
tensorflow>=2.9
opencv-python
pillow
matplotlib
scikit-learn
Install with:
pip install -r requirements.txt
Image-Forgery-Detection-ELA/
├── dataset/
│ ├── Au/ # Authentic images
│ └── Tp/ # Tampered images
├── ela_images/ # ELA-processed images
├── saved_model/ # Saved best model (optional)
├── ML_PROJECT_IMPLEMENTATION.ipynb
├── requirements.txt
└── README.md
- ✅ True Positives (TP): 45
- ✅ True Negatives (TN): 47
- ❌ False Positives (FP): 3
- ❌ False Negatives (FN): 5
- How ELA highlights compression artifacts in tampered images
- Importance of proper preprocessing for visual forensics
- Transfer learning is not always superior to custom-designed models
- Designing task-specific CNNs can lead to better generalization
- Transfer learning models couldn’t effectively extract ELA features
- Required large number of ELA-processed images and preprocessing time
- Needed to manually tune dropout and dense layers to avoid overfitting
- ELA differences can be subtle and sometimes confuse the model
- Introduce Vision Transformers (ViT) and compare with CNN
- Build a Streamlit or Flask-based UI to upload & detect forged images
- Train on a multi-class dataset (copy-move vs splicing vs authentic)
- Try feature fusion: combine ELA with other forensic indicators
- Clone the repo:
git clone https://github.com/Divyansh-git10/image-forgery-detection
cd image-forgery-detection
- Install requirements:
pip install -r requirements.txt
- Run the notebook:
jupyter notebook ML_PROJECT_IMPLEMENTATION.ipynb
Divyansh Gautam
AI/ML enthusiast passionate about computer vision, natural language processing (NLP), and deep learning.
- 📧 Email: [email protected]
- 🔗 LinkedIn: linkedin.com/in/divyansh-gautam-985610256
- 🐙 GitHub: github.com/Divyansh-git10