|
|
--- |
|
|
license: apache-2.0 |
|
|
datasets: |
|
|
- dragonintelligence/CIFAKE-image-dataset |
|
|
--- |
|
|
Real vs. AI-Generated Image Detection Model |
|
|
This repository contains a deep learning model trained to classify images as either real or AI-generated (fake). The model was developed as part of a project on Big Data and leverages transfer learning with the powerful ResNet50 architecture. It achieves a test accuracy of 93.34% on the CIFAKE dataset. ๐ |
|
|
|
|
|
Model Architecture |
|
|
The model uses a transfer learning approach, which involves two main components: |
|
|
|
|
|
Base Model: A pre-trained ResNet50 model, with its weights trained on the ImageNet dataset, is used as a feature extractor. Its layers were frozen during training to retain the learned features. |
|
|
|
|
|
|
|
|
Custom Classifier Head: A custom head was added on top of the base model to perform the final binary classification. It consists of: |
|
|
|
|
|
A |
|
|
|
|
|
Flatten layer. |
|
|
|
|
|
A |
|
|
|
|
|
Dense layer with 512 units and a ReLU activation function. |
|
|
|
|
|
A |
|
|
|
|
|
Dropout layer with a rate of 0.5 to prevent overfitting. |
|
|
|
|
|
A final |
|
|
|
|
|
Dense output layer with a Sigmoid activation function for binary classification. |
|
|
|
|
|
Dataset |
|
|
The model was trained on the |
|
|
|
|
|
CIFAKE dataset, which is available on Kaggle. This dataset contains a large collection of images, split into two classes: |
|
|
|
|
|
REAL: Authentic, real-world photographs. |
|
|
|
|
|
FAKE: Images synthetically generated by AI models. |
|
|
|
|
|
To improve the model's ability to generalize and to prevent overfitting, |
|
|
|
|
|
data augmentation techniques were applied to the training set, including random flips, rotations, and zooms. |
|
|
|
|
|
Training & Performance |
|
|
|
|
|
Training Environment: The model was trained on Google Colab using an NVIDIA T4 GPU. |
|
|
|
|
|
|
|
|
Training Process: The model was trained for 20 epochs using the Adam optimizer and binary_crossentropy loss function. |
|
|
|
|
|
|
|
|
ModelCheckpoint was used to save the best weights after each epoch. |
|
|
|
|
|
|
|
|
Final Performance: The final model was evaluated on an unseen test set and achieved the following results: |
|
|
|
|
|
|
|
|
Test Accuracy: 93.34% |
|
|
|
|
|
|
|
|
Precision (for REAL class): 95% |
|
|
|
|
|
|
|
|
Recall (for FAKE class): 95% |
|
|
|
|
|
The model's performance slightly exceeds the 93% accuracy reported in the dataset's base paper, demonstrating its effectiveness. |
|
|
|
|
|
|
|
|
Confusion Matrix |
|
|
The confusion matrix below shows a detailed breakdown of the model's performance on the 20,000 images in the test set. |