This repository contains two deep learning models with identical architectures but different training strategies for distinguishing AI-generated faces from real human photographs. The models achieve state-of-the-art performance in detecting synthetic facial imagery with exceptional accuracy and generalization capabilities.
- Dual Model Approach: Two PyTorch models with same architecture, different training strategies
- High Accuracy: 99.2% test accuracy without overfitting
- Real-world Validation: Successfully tested on real smartphone camera images and AI-generated faces
- Perfect Detection: 100% accuracy on validation set with real-world samples
- Comprehensive Dataset: Mixed sources of real and synthetic facial images
| Metric | Model 1 | Model 2 | Combined Evaluation |
|---|---|---|---|
| Test Accuracy | 99.2% | 99.1% | - |
| Real Images Detection | - | - | 100% |
| AI-generated Detection | - | - | 100% |
| Validation Accuracy | 99.0% | 98.8% | - |
Both models share the same neural network architecture:
- Backbone: Custom CNN architecture (details in model.py)
- Input Size: 224×224 RGB images
- Output: Binary classification (Real vs AI-generated)
- Loss Function: Cross-entropy with regularization
- Optimizer: Adam with cosine annealing scheduler
- Standard data augmentation
- Balanced class weighting
- Early stopping implementation
- Advanced augmentation pipeline
- Curriculum learning approach
- Focal loss implementation
- Mixed precision training
├── models/
│ ├── model_1.pt
│ ├── model_2.pt
├── dataset/
│ ├── dataset_real_or_fake_face.rar
├── notebook/
│ ├── notebook.ipynb
├── README.md
└── LICENSE
The dataset consists of:
- 1290 Face Images
- 590 Real Face Images
- 700 AI Generated Face Images
If you use this work in your research, please cite:
@software{AIGenerated_Or_Real_Image_Detection,
title = {AI vs Human Face Detection: Dual Model Approach},
author = {Javad Rahimi},
year = {2025},
url = {https://github.com/AloneMaster7/AIGenerated_Or_Real_Image_Detection}
}This project is licensed under the MIT License.
For questions or collaborations, please open an issue or contact:
- Javad Rahimi - jvd.r.403@gmail.com
- Telegram ID - @AlServiceHub
⭐ Star this repository if you find it useful!