AdityaManojShinde commited on
Commit
729a487
Β·
verified Β·
1 Parent(s): 349f738

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +15 -68
README.md CHANGED
@@ -1,15 +1,12 @@
1
  ---
2
- license: mit
3
- tags:
4
- - deepfake-detection
5
- - computer-vision
6
- - transfer-learning
7
- - hybrid-cnn
8
- - pytorch
9
- datasets:
10
- - xhlulu/140k-real-and-fake-faces
11
- metrics:
12
- - accuracy
13
  ---
14
 
15
  # Deepfake Face Detector
@@ -18,33 +15,10 @@ A hybrid CNN model for detecting AI-generated (deepfake) face images, built usin
18
 
19
  ## Model Architecture
20
 
21
- This model combines two parallel CNN streams:
22
-
23
- - **Spatial Stream** β€” EfficientNet-B4 pretrained on ImageNet, fine-tuned to detect visible artifacts such as unnatural skin texture, blending edges, and facial inconsistencies
24
- - **Frequency Stream** β€” Xception backbone with fixed SRM (Steganalysis Rich Model) filters to detect invisible GAN noise fingerprints in pixel residuals
25
- - **Fusion Module** β€” Both stream outputs are concatenated (1792 + 2048 = 3840 features) and passed through a classification head with Dropout regularization
26
- - **Output** β€” Sigmoid activation producing a probability score (0 = fake, 1 = real)
27
-
28
- ## Training Strategy
29
-
30
- Three-phase transfer learning approach:
31
-
32
- | Phase | Layers Trained | Learning Rate | Epochs |
33
- |-------|---------------|---------------|--------|
34
- | 1 | Classifier head only | 1e-3 | 3 |
35
- | 2 | Top EfficientNet blocks + classifier | 1e-4 | 3 |
36
-
37
- ## Dataset
38
-
39
- Trained and evaluated on [140k Real and Fake Faces](https://www.kaggle.com/datasets/xhlulu/140k-real-and-fake-faces)
40
-
41
- | Split | Real | Fake | Total |
42
- |-------|------|------|-------|
43
- | Train | 50,000 | 50,000 | 100,000 |
44
- | Valid | 10,000 | 10,000 | 20,000 |
45
- | Test | 10,000 | 10,000 | 20,000 |
46
-
47
- Fake images are StyleGAN2-generated faces. Real images are sourced from Flickr-Faces-HQ (FFHQ).
48
 
49
  ## Performance
50
 
@@ -53,38 +27,11 @@ Fake images are StyleGAN2-generated faces. Real images are sourced from Flickr-F
53
  | Test Accuracy | 98.59% |
54
  | Validation Accuracy | 98.55% |
55
 
56
- ## Usage
57
- ```python
58
- import torch
59
- from torchvision import transforms
60
- from PIL import Image
61
-
62
- model = HybridDeepfakeDetector()
63
- model.load_state_dict(torch.load("deepfake_detector_phase2.pth", map_location="cpu"))
64
- model.eval()
65
-
66
- transform = transforms.Compose([
67
- transforms.Resize((224, 224)),
68
- transforms.ToTensor(),
69
- transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])
70
- ])
71
-
72
- image = Image.open("face.jpg").convert("RGB")
73
- tensor = transform(image).unsqueeze(0)
74
-
75
- with torch.no_grad():
76
- prob = model(tensor).item()
77
 
78
- label = "REAL" if prob > 0.5 else "FAKE"
79
- print(f"{label} ({prob*100:.1f}% confidence)")
80
- ```
81
 
82
  ## Limitations
83
-
84
- - Optimized for StyleGAN2 generated faces β€” may perform differently on other GAN architectures
85
  - Best results on frontal face images
86
  - Not tested on video deepfakes
87
-
88
- ## Try It
89
-
90
- Live demo available at [Hugging Face Spaces](https://huggingface.co/spaces/AdityaManojShinde/deepfake-detector-app)
 
1
  ---
2
+ title: Deepfake Detector
3
+ emoji: πŸ”
4
+ colorFrom: purple
5
+ colorTo: blue
6
+ sdk: gradio
7
+ sdk_version: "4.0.0"
8
+ app_file: app.py
9
+ pinned: false
 
 
 
10
  ---
11
 
12
  # Deepfake Face Detector
 
15
 
16
  ## Model Architecture
17
 
18
+ - **Spatial Stream** β€” EfficientNet-B4 pretrained on ImageNet, detects visible artifacts
19
+ - **Frequency Stream** β€” Xception + SRM filters, detects invisible GAN noise fingerprints
20
+ - **Fusion Module** β€” Concatenates both streams (3840 features) into a classification head
21
+ - **Output** β€” Sigmoid probability (0 = fake, 1 = real)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
 
23
  ## Performance
24
 
 
27
  | Test Accuracy | 98.59% |
28
  | Validation Accuracy | 98.55% |
29
 
30
+ ## Dataset
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
 
32
+ Trained on [140k Real and Fake Faces](https://www.kaggle.com/datasets/xhlulu/140k-real-and-fake-faces) β€” 100k training images, balanced real/fake split.
 
 
33
 
34
  ## Limitations
35
+ - Optimized for StyleGAN2 generated faces
 
36
  - Best results on frontal face images
37
  - Not tested on video deepfakes