With the increasing usage of AI tools, distinguishing between real and AI-generated images has become crucial. Hyper-realistic human faces generated by models like GANs and Stable Diffusion pose serious risks in areas such as politics, social media, and digital forensics where misinformation and identity theft are major concerns.
This project aims to develop a machine learning system capable of identifying whether a given facial image is real or generated by AI using techniques like Convolutional Neural Networks (CNNs) for image classification.
We are using the 140K Real and Fake Faces Dataset from Kaggle, which includes:
- 70,000 real faces sourced from the Flickr dataset collected by Nvidia.
- 70,000 fake faces generated by StyleGAN.
Each image is in RGB format and has been resized to 224x224 pixels.
We followed a standard supervised machine learning pipeline with the following stages:
- Data Collection: Download and organize the real and fake face datasets from Kaggle.
- Data Preprocessing: Resize all images to 224x224 pixels, normalize pixel values, and apply contrast stretching and augmentation.
- Model Training:
- Simple CNN: A basic 3-layer convolutional model.
- Deep CNN: A custom deep architecture with additional convolutional layers.
- Transfer Learning: Models like ResNet50 and MobileNetV2 pretrained on ImageNet, adapted for binary classification.
- Model Evaluation: Assess performance using Accuracy, Log Loss, AUC, Precision, Recall, and F1 Score.
- Visualization: Plot Confusion Matrices, ROC Curves, training history curves, and sample predictions for interpretability.
- Experimentation: Compare model performances using bar plots and evaluate generalization on unseen test images.