Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -1,3 +1,50 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Deepfake Image Classification
|
| 2 |
+
|
| 3 |
+
This repository contains a TensorFlow/Keras model trained to classify **REAL vs FAKE (deepfake) images**.
|
| 4 |
+
The model is based on **EfficientNetB4** with data augmentation and fine-tuning.
|
| 5 |
+
|
| 6 |
+
## π Files
|
| 7 |
+
- `deepfake_image_classification_model.keras` β trained Keras model.
|
| 8 |
+
- `Deepfake_Image_Classification.ipynb` β full training notebook (Google Colab).
|
| 9 |
+
|
| 10 |
+
## π§ Model Details
|
| 11 |
+
- Backbone: EfficientNetB4 (pretrained on ImageNet).
|
| 12 |
+
- Input size: `224 x 224 x 3` RGB images.
|
| 13 |
+
- Output: Binary classification (REAL = 0, FAKE = 1).
|
| 14 |
+
- Loss: `binary_crossentropy`.
|
| 15 |
+
- Optimizer: `Adam (lr=0.001)`.
|
| 16 |
+
|
| 17 |
+
## π Dataset
|
| 18 |
+
Trained on [Deepfake Faces dataset](https://www.kaggle.com/datasets/dagnelies/deepfake-faces).
|
| 19 |
+
Balanced subset: 16,000 REAL + 16,000 FAKE images.
|
| 20 |
+
|
| 21 |
+
## π Usage
|
| 22 |
+
Install dependencies:
|
| 23 |
+
```bash
|
| 24 |
+
pip install tensorflow
|
| 25 |
+
Load and use the model:
|
| 26 |
+
|
| 27 |
+
python
|
| 28 |
+
Copy code
|
| 29 |
+
import tensorflow as tf
|
| 30 |
+
|
| 31 |
+
# Load model
|
| 32 |
+
model = tf.keras.models.load_model("deepfake_image_classification_model.keras")
|
| 33 |
+
|
| 34 |
+
# Preprocess image
|
| 35 |
+
img = tf.keras.utils.load_img("example.jpg", target_size=(224, 224))
|
| 36 |
+
x = tf.keras.utils.img_to_array(img)
|
| 37 |
+
x = tf.expand_dims(x, axis=0) # add batch dimension
|
| 38 |
+
|
| 39 |
+
# Predict
|
| 40 |
+
pred = model.predict(x)[0][0]
|
| 41 |
+
label = "FAKE" if pred > 0.5 else "REAL"
|
| 42 |
+
print(f"Prediction: {label} (score: {pred:.4f})")
|
| 43 |
+
π Performance
|
| 44 |
+
Validation Accuracy: ~92%
|
| 45 |
+
|
| 46 |
+
Test Accuracy: ~91%
|
| 47 |
+
|
| 48 |
+
π Training
|
| 49 |
+
For full details of the training pipeline (dataset loading, augmentation, callbacks, etc.), check the notebook:
|
| 50 |
+
Deepfake_Image_Classification.ipynb
|