deepguard 0.2.1__tar.gz → 0.2.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {deepguard-0.2.1 → deepguard-0.2.3}/PKG-INFO +198 -21
- {deepguard-0.2.1 → deepguard-0.2.3}/README.md +188 -8
- {deepguard-0.2.1 → deepguard-0.2.3}/deepguard.egg-info/PKG-INFO +198 -21
- {deepguard-0.2.1 → deepguard-0.2.3}/deepguard.egg-info/SOURCES.txt +28 -1
- deepguard-0.2.3/deepguard.egg-info/requires.txt +5 -0
- deepguard-0.2.3/deepguard.egg-info/top_level.txt +4 -0
- deepguard-0.2.3/explainability/__init__.py +13 -0
- deepguard-0.2.3/explainability/cam_evaluator.py +48 -0
- deepguard-0.2.3/explainability/explainer/base_explainer.py +194 -0
- deepguard-0.2.3/explainability/explainer/cam_explainer.py +319 -0
- deepguard-0.2.3/explainability/explainer/eigenvalue_explainer.py +35 -0
- deepguard-0.2.3/explainability/explainer/gradient_explainer.py +47 -0
- deepguard-0.2.3/explainability/explainer/misc_explainer.py +13 -0
- deepguard-0.2.3/explainability/explainer/perturbation_explainer.py +24 -0
- deepguard-0.2.3/explainability/metrics/cam_mult_image.py +37 -0
- deepguard-0.2.3/explainability/metrics/perturbation_confidence.py +109 -0
- deepguard-0.2.3/explainability/metrics/road.py +154 -0
- deepguard-0.2.3/explainability/utils/image.py +86 -0
- deepguard-0.2.3/explainability/utils/model_targets.py +16 -0
- deepguard-0.2.3/explainability/utils/reshape_transforms.py +11 -0
- deepguard-0.2.3/inference/image_predictor.py +114 -0
- deepguard-0.2.3/inference/image_predictor_prt.py +132 -0
- deepguard-0.2.3/inference/predict_video.py +154 -0
- deepguard-0.2.3/inference/utils.py +4 -0
- deepguard-0.2.3/inference/video_predictor.py +195 -0
- deepguard-0.2.3/inference/video_predictor_prt.py +258 -0
- deepguard-0.2.3/preprocess/celeb_df_v2/split_data.py +0 -0
- deepguard-0.2.3/preprocess/face_detector.py +199 -0
- deepguard-0.2.3/preprocess/ff++/__init__.py +0 -0
- deepguard-0.2.3/preprocess/frame_extractor.py +196 -0
- deepguard-0.2.3/preprocess/kodf/__init__.py +0 -0
- deepguard-0.2.3/preprocess/landmark_detector.py +96 -0
- deepguard-0.2.3/pyproject.toml +45 -0
- deepguard-0.2.1/deepguard.egg-info/top_level.txt +0 -2
- deepguard-0.2.1/setup.py +0 -30
- {deepguard-0.2.1 → deepguard-0.2.3}/LICENSE +0 -0
- {deepguard-0.2.1 → deepguard-0.2.3}/deepguard/__init__.py +0 -0
- {deepguard-0.2.1 → deepguard-0.2.3}/deepguard/data/__init__.py +0 -0
- {deepguard-0.2.1 → deepguard-0.2.3}/deepguard/data/dataset.py +0 -0
- {deepguard-0.2.1 → deepguard-0.2.3}/deepguard/data/dataset_cutmix.py +0 -0
- {deepguard-0.2.1 → deepguard-0.2.3}/deepguard/data/dataset_cutout.py +0 -0
- {deepguard-0.2.1 → deepguard-0.2.3}/deepguard/data/dataset_mixup.py +0 -0
- {deepguard-0.2.1 → deepguard-0.2.3}/deepguard/data/handle_imbalance.py +0 -0
- {deepguard-0.2.1 → deepguard-0.2.3}/deepguard/data/split_data.py +0 -0
- {deepguard-0.2.1 → deepguard-0.2.3}/deepguard/data/transforms.py +0 -0
- {deepguard-0.2.1 → deepguard-0.2.3}/deepguard/layers/__init__.py +0 -0
- {deepguard-0.2.1 → deepguard-0.2.3}/deepguard/layers/attention.py +0 -0
- {deepguard-0.2.1 → deepguard-0.2.3}/deepguard/layers/drop.py +0 -0
- {deepguard-0.2.1 → deepguard-0.2.3}/deepguard/layers/featextractor.py +0 -0
- {deepguard-0.2.1 → deepguard-0.2.3}/deepguard/layers/global_query.py +0 -0
- {deepguard-0.2.1 → deepguard-0.2.3}/deepguard/layers/mlp.py +0 -0
- {deepguard-0.2.1 → deepguard-0.2.3}/deepguard/layers/patch.py +0 -0
- {deepguard-0.2.1 → deepguard-0.2.3}/deepguard/layers/reducesize.py +0 -0
- {deepguard-0.2.1 → deepguard-0.2.3}/deepguard/layers/se.py +0 -0
- {deepguard-0.2.1 → deepguard-0.2.3}/deepguard/layers/transformer.py +0 -0
- {deepguard-0.2.1 → deepguard-0.2.3}/deepguard/layers/weight_init.py +0 -0
- {deepguard-0.2.1 → deepguard-0.2.3}/deepguard/layers/window.py +0 -0
- {deepguard-0.2.1 → deepguard-0.2.3}/deepguard/models/__init__.py +0 -0
- {deepguard-0.2.1 → deepguard-0.2.3}/deepguard/models/ms_eff_gcvit.py +0 -0
- {deepguard-0.2.1 → deepguard-0.2.3}/deepguard/models/ms_eff_vit.py +0 -0
- {deepguard-0.2.1 → deepguard-0.2.3}/deepguard/optimizer/__init__.py +0 -0
- {deepguard-0.2.1 → deepguard-0.2.3}/deepguard/optimizer/build_optimizer.py +0 -0
- {deepguard-0.2.1 → deepguard-0.2.3}/deepguard/scheduler/__init__.py +0 -0
- {deepguard-0.2.1 → deepguard-0.2.3}/deepguard/scheduler/fetch_scheduler.py +0 -0
- {deepguard-0.2.1 → deepguard-0.2.3}/deepguard/utils/__init__.py +0 -0
- {deepguard-0.2.1 → deepguard-0.2.3}/deepguard/utils/build_metrics.py +0 -0
- {deepguard-0.2.1 → deepguard-0.2.3}/deepguard/utils/early_stopping.py +0 -0
- {deepguard-0.2.1 → deepguard-0.2.3}/deepguard/utils/meter.py +0 -0
- {deepguard-0.2.1 → deepguard-0.2.3}/deepguard/utils/seed.py +0 -0
- {deepguard-0.2.1 → deepguard-0.2.3}/deepguard.egg-info/dependency_links.txt +0 -0
- {deepguard-0.2.1/preprocess/celeb_df_v2 → deepguard-0.2.3/explainability/metrics}/__init__.py +0 -0
- {deepguard-0.2.1/preprocess/ff++ → deepguard-0.2.3/inference}/__init__.py +0 -0
- {deepguard-0.2.1/preprocess/kodf → deepguard-0.2.3/preprocess}/__init__.py +0 -0
- /deepguard-0.2.1/preprocess/celeb_df_v2/split_data.py → /deepguard-0.2.3/preprocess/celeb_df_v2/__init__.py +0 -0
- {deepguard-0.2.1 → deepguard-0.2.3}/preprocess/celeb_df_v2/crop_face.py +0 -0
- {deepguard-0.2.1 → deepguard-0.2.3}/preprocess/celeb_df_v2/detect_original_face.py +0 -0
- {deepguard-0.2.1 → deepguard-0.2.3}/preprocess/celeb_df_v2/utils.py +0 -0
- {deepguard-0.2.1 → deepguard-0.2.3}/preprocess/ff++/crop_face.py +0 -0
- {deepguard-0.2.1 → deepguard-0.2.3}/preprocess/ff++/detect_original_face.py +0 -0
- {deepguard-0.2.1 → deepguard-0.2.3}/preprocess/ff++/split_data.py +0 -0
- {deepguard-0.2.1 → deepguard-0.2.3}/preprocess/ff++/utils.py +0 -0
- {deepguard-0.2.1 → deepguard-0.2.3}/preprocess/kodf/crop_face.py +0 -0
- {deepguard-0.2.1 → deepguard-0.2.3}/preprocess/kodf/detect_original_face.py +0 -0
- {deepguard-0.2.1 → deepguard-0.2.3}/preprocess/kodf/generate_metadata.py +0 -0
- {deepguard-0.2.1 → deepguard-0.2.3}/preprocess/kodf/split_data.py +0 -0
- {deepguard-0.2.1 → deepguard-0.2.3}/preprocess/kodf/utils.py +0 -0
- {deepguard-0.2.1 → deepguard-0.2.3}/setup.cfg +0 -0
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: deepguard
|
|
3
|
-
Version: 0.2.
|
|
4
|
-
Summary: Multi-Scale Efficient Vision Transformer for Robust Deepfake Detection
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
Version: 0.2.3
|
|
4
|
+
Summary: Multi-Scale Efficient Global Context Vision Transformer for Robust Deepfake Detection
|
|
5
|
+
Author-email: seoyunje <seoyunje2001@gmail.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/HanMoonSub/DeepGuard
|
|
8
8
|
Project-URL: Bug Tracker, https://github.com/HanMoonSub/DeepGuard/issues
|
|
9
9
|
Project-URL: Source Code, https://github.com/HanMoonSub/DeepGuard
|
|
10
|
+
Project-URL: Hugging Face, https://huggingface.co/KoreaPeter/ms-eff-gcvit-deepfake
|
|
10
11
|
Classifier: Programming Language :: Python :: 3
|
|
11
12
|
Classifier: Programming Language :: Python :: 3.10
|
|
12
13
|
Classifier: Programming Language :: Python :: 3.11
|
|
@@ -16,28 +17,27 @@ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
|
16
17
|
Requires-Python: >=3.10
|
|
17
18
|
Description-Content-Type: text/markdown
|
|
18
19
|
License-File: LICENSE
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
Dynamic: home-page
|
|
20
|
+
Requires-Dist: torchmetrics>=1.6.1
|
|
21
|
+
Requires-Dist: ultralytics>=8.4.41
|
|
22
|
+
Requires-Dist: grad-cam>=1.5.5
|
|
23
|
+
Requires-Dist: timm>=1.0.12
|
|
24
|
+
Requires-Dist: torch>=2.10.0
|
|
25
25
|
Dynamic: license-file
|
|
26
|
-
Dynamic: project-url
|
|
27
|
-
Dynamic: requires-python
|
|
28
|
-
Dynamic: summary
|
|
29
26
|
|
|
30
27
|
# Deepfakes Detection
|
|
31
28
|
|
|
32
|
-
<p align="center">
|
|
33
|
-
<img src="https://raw.githubusercontent.com/HanMoonSub/DeepGuard/main/Images/deepfake2.png" alt="DeepGuard Banner" width="800" height="400">
|
|
34
|
-
</p>
|
|
35
|
-
|
|
36
29
|
<p align="center">
|
|
37
30
|
<img src="https://img.shields.io/github/license/HanMoonSub/DeepGuard?style=flat-square&color=555555&logo=github&logoColor=white" alt="License">
|
|
38
31
|
<img src="https://img.shields.io/github/stars/HanMoonSub/DeepGuard?style=flat-square&color=FFD700&logo=github&logoColor=white" alt="Stars">
|
|
32
|
+
<img src="https://img.shields.io/github/downloads/HanMoonSub/DeepGuard/total?style=flat-square&color=brightgreen&logo=github&logoColor=white" alt="Downloads">
|
|
33
|
+
<img src="https://img.shields.io/github/last-commit/HanMoonSub/DeepGuard?style=flat-square&color=lightgrey&logo=github&logoColor=white" alt="Last Commit">
|
|
39
34
|
<img src="https://img.shields.io/badge/Status-Active-brightgreen?style=flat-square" alt="Status">
|
|
40
35
|
<img src="https://img.shields.io/badge/Release-v0.2.0-orange?style=flat-square&logo=github&logoColor=white" alt="Release">
|
|
36
|
+
<img src="https://img.shields.io/github/repo-size/HanMoonSub/DeepGuard?style=flat-square&color=blueviolet" alt="Repo Size">
|
|
37
|
+
</p>
|
|
38
|
+
|
|
39
|
+
<p align="center">
|
|
40
|
+
<img src="https://raw.githubusercontent.com/HanMoonSub/DeepGuard/main/docs/samples/deepfake_thumbnails.png" alt="DeepGuard Banner" width="800" height="400">
|
|
41
41
|
</p>
|
|
42
42
|
|
|
43
43
|
<p align="center">
|
|
@@ -56,6 +56,7 @@ Dynamic: summary
|
|
|
56
56
|
|
|
57
57
|
<p align="center">
|
|
58
58
|
<a href="README_KR.md"><b>🇰🇷 한국어 버전</b></a> |
|
|
59
|
+
<a href="README_JP.md"><b>🇯🇵 日本語版</b></a> |
|
|
59
60
|
<a href="#-model-evaluation"><b>📈 Model Evaluation</b></a> |
|
|
60
61
|
<a href="#-predict-image--video"><b>🔮 Try Demo</b></a>
|
|
61
62
|
</p>
|
|
@@ -72,6 +73,8 @@ Dynamic: summary
|
|
|
72
73
|
- [📈 Model Evaluation](#-model-evaluation) - Benchmarking results
|
|
73
74
|
- [💻 Model Usage](#-model-usage) - How to integrate DeepGuard models into your own Python code or via timm
|
|
74
75
|
- [🔮 Predict Image & Video](#-predict-image--video) - Simple Inference examples for detecting deepfakes in image and video
|
|
76
|
+
- [🎨 DeepFake AI Explainability](#-deepfake-ai-explainability) - Visualizing model focus using Grad-CAM and attention maps
|
|
77
|
+
- [📓 Tutorials](#-tutorials) - Hands-on Colab notebooks for inference and dual-branch XAI visualization
|
|
75
78
|
- [📬 Authors](#-authors)
|
|
76
79
|
- [📝 Reference](#-reference)
|
|
77
80
|
- [⚖️ License](#-license)
|
|
@@ -167,7 +170,7 @@ Multi Scale Efficient Global Context Vision Transformer is an optimized multi-sc
|
|
|
167
170
|
|
|
168
171
|
|
|
169
172
|
<p align="center">
|
|
170
|
-
<img src="https://raw.githubusercontent.com/HanMoonSub/DeepGuard/main/
|
|
173
|
+
<img src="https://raw.githubusercontent.com/HanMoonSub/DeepGuard/main/docs/architectures/ms_eff_gcvit.JPG" width="100%" height="700">
|
|
171
174
|
</p>
|
|
172
175
|
|
|
173
176
|
We utilizes two distinct types of self-attention to capture both long-range and short-range information across feature maps.
|
|
@@ -178,7 +181,7 @@ We utilizes two distinct types of self-attention to capture both long-range and
|
|
|
178
181
|
|
|
179
182
|
|
|
180
183
|
<p align="center">
|
|
181
|
-
<img src=https://raw.githubusercontent.com/HanMoonSub/DeepGuard/main/
|
|
184
|
+
<img src=https://raw.githubusercontent.com/HanMoonSub/DeepGuard/main/docs/architectures/window_attention.JPG width="100%" height="300">
|
|
182
185
|
</p>
|
|
183
186
|
|
|
184
187
|
## 🧬 Model Zoo
|
|
@@ -255,7 +258,8 @@ You can load the models directly via the `DeepGuard` package or through the `tim
|
|
|
255
258
|
**Installation**
|
|
256
259
|
|
|
257
260
|
```bash
|
|
258
|
-
pip install -U git+https://github.com/HanMoonSub/DeepGuard.git
|
|
261
|
+
# pip install -U git+https://github.com/HanMoonSub/DeepGuard.git
|
|
262
|
+
pip install deepguard
|
|
259
263
|
```
|
|
260
264
|
|
|
261
265
|
|
|
@@ -278,6 +282,21 @@ model = timm.create_model("ms_eff_gcvit_b0", pretrained=True, dataset="ff++")
|
|
|
278
282
|
model = timm.create_model("ms_eff_gcvit_b5", pretrained=True, dataset="kodf")
|
|
279
283
|
```
|
|
280
284
|
|
|
285
|
+
**Option C: Hugging Face Hub**
|
|
286
|
+
|
|
287
|
+
```python
|
|
288
|
+
import torch
|
|
289
|
+
from huggingface_hub import hf_hub_download
|
|
290
|
+
from deepguard import ms_eff_gcvit_b0 # or ms_eff_gcvit_b5
|
|
291
|
+
|
|
292
|
+
REPO_ID = "KoreaPeter/ms-eff-gcvit-deepfake"
|
|
293
|
+
|
|
294
|
+
ckpt = hf_hub_download(REPO_ID, "ms_eff_gcvit_b0_kodf.bin") # celeb_df_v2 | ff++ | kodf
|
|
295
|
+
model = ms_eff_gcvit_b0(pretrained=False)
|
|
296
|
+
model.load_state_dict(torch.load(ckpt, map_location="cpu"))
|
|
297
|
+
model.eval()
|
|
298
|
+
```
|
|
299
|
+
|
|
281
300
|
## 🔮 Predict Image & Video
|
|
282
301
|
|
|
283
302
|
#### Predict DeepFake Image
|
|
@@ -331,6 +350,163 @@ print(f"Deepfake Probability: {result:.4f}")
|
|
|
331
350
|
|
|
332
351
|
```
|
|
333
352
|
|
|
353
|
+
## 🎨 DeepFake AI Explainability
|
|
354
|
+
|
|
355
|
+
Deepfake detection is only as trustworthy as its explanations. DeepGuard integrates a production-ready XAI Toolkit that visualizes where and why the model flags a face as manipulated — turning a black-box score into actionable forensic evidence.
|
|
356
|
+
|
|
357
|
+
⭐ Validated on hybrid CNN-ViT architectures, specifically `MS-EffViT` and `MS-EffGCViT`.
|
|
358
|
+
⭐ Dual-Branch Analysis: Dual-branch design mirrors the model's own multi-scale reasoning
|
|
359
|
+
|
|
360
|
+
### 🧠 How Dual-Branch XAI Works
|
|
361
|
+
|
|
362
|
+
<p align="center">
|
|
363
|
+
<img src="https://raw.githubusercontent.com/HanMoonSub/DeepGuard/main/docs/architectures/dual_branch.gif" width="70%" height="300">
|
|
364
|
+
</p>
|
|
365
|
+
|
|
366
|
+
|
|
367
|
+
| Branch | Feature Map | Focus | Best For |
|
|
368
|
+
| ------ | ----------- | ----- | -------- |
|
|
369
|
+
|  | High Resolution | Local Forgery artifacts | Skin texture, boundary blending, compression traces |
|
|
370
|
+
|  | Low Resolution | Global Semantic Structure | Lighting inconsistency, facial geometry, Shadow artifacts |
|
|
371
|
+
|
|
372
|
+
### 📐 XAI Methods
|
|
373
|
+
|
|
374
|
+
Each method is assigned to the branch where it performs best empirically.
|
|
375
|
+
|
|
376
|
+
| Branch | Method | 🎯 Core Idea |
|
|
377
|
+
| :--- | :--- | :--- |
|
|
378
|
+
| **`low level`** | **HiResCAM** | Like GradCAM but element-wise multiply the activations with the gradients; provably guaranteed faithfulness for certain models |
|
|
379
|
+
| **`low level`** | **GradCAMElementWise** | Like GradCAM but element-wise multiply the activations with the gradients then apply a ReLU operation before summing |
|
|
380
|
+
| **`low level`** | **LayerCAM** | Spatially weight the activations by positive gradients. Works better especially in lower layers |
|
|
381
|
+
| --- | --- | --- | --- |
|
|
382
|
+
| **`high level`** | **EigenGradCAM** | Like EigenCAM but with class discrimination: First principle component of Activations*Grad. Looks like GradCAM, but cleaner |
|
|
383
|
+
| **`high level`** | **GradCAM++** | Like GradCAM but uses second order gradients |
|
|
384
|
+
| **`high level`** | **XGradCAM** | Like GradCAM but scale the gradients by the normalized activations |
|
|
385
|
+
|
|
386
|
+
- **`aug_smooth`** applies TTA (horizontal flips) before averaging CAMs → smoother, more object-aligned maps
|
|
387
|
+
- **`eigen_smooth`** applies PCA noise reduction → retains dominant forgery pattern only
|
|
388
|
+
|
|
389
|
+
### 💡 DeepFake XAI Usage
|
|
390
|
+
|
|
391
|
+
**Low-Level Branch — Local Artifact Detection**
|
|
392
|
+
|
|
393
|
+
```python
|
|
394
|
+
from explainability import HiResCAMExplainer, GradCAMElementWiseExplainer, LayerCAMExplainer
|
|
395
|
+
|
|
396
|
+
explainer = HiResCAMExplainer(
|
|
397
|
+
model_name = "ms_eff_gcvit_b0", # or ms_eff_vit_b0, ms_eff_gcvit_b5, ms_eff_vit_b5
|
|
398
|
+
dataset = "celeb_df_v2", # or ff++, kodf
|
|
399
|
+
branch_level = "low",
|
|
400
|
+
)
|
|
401
|
+
```
|
|
402
|
+
|
|
403
|
+
**High-Level Branch — Global Semantic Detection**
|
|
404
|
+
```python
|
|
405
|
+
from explainability import EigenGradCAMExplainer, GradCAMPlusPlusExplainer, XGradCAMExplainer
|
|
406
|
+
|
|
407
|
+
explainer = EigenGradCAMExplainer(
|
|
408
|
+
model_name = "ms_eff_gcvit_b0",
|
|
409
|
+
dataset = "celeb_df_v2",
|
|
410
|
+
branch_level = "high",
|
|
411
|
+
)
|
|
412
|
+
```
|
|
413
|
+
|
|
414
|
+
### 🎨 Visualization Modes
|
|
415
|
+
|
|
416
|
+
<p align="center">
|
|
417
|
+
<img src="https://raw.githubusercontent.com/HanMoonSub/DeepGuard/main/docs/xai-results/xai_demo.gif" width="80%" height=300>
|
|
418
|
+
</p>
|
|
419
|
+
|
|
420
|
+
**1. Heatmap — Continuous activation distribution**
|
|
421
|
+
|
|
422
|
+
```python
|
|
423
|
+
result = explainer.display_heatmap_on_image(
|
|
424
|
+
img_path = "path/to/image.jpg",
|
|
425
|
+
category = 1, # 0: Real, 1: Fake
|
|
426
|
+
threshold = 0.5, # binarization cutoff (0.5~1.0), or "auto" for Otsu
|
|
427
|
+
image_weight = 0.5, # 0.0: heatmap only ← → 1.0: original only
|
|
428
|
+
aug_smooth = False, # TTA smoothing (not supported on 'pro' models)
|
|
429
|
+
eigen_smooth = False, # PCA noise reduction
|
|
430
|
+
)
|
|
431
|
+
```
|
|
432
|
+
|
|
433
|
+
**2. Bounding Box — Discrete forgery region localization**
|
|
434
|
+
|
|
435
|
+
```python
|
|
436
|
+
result = explainer.display_bbox_on_image(
|
|
437
|
+
img_path = "path/to/image.jpg",
|
|
438
|
+
category = 1,
|
|
439
|
+
threshold = 0.5,
|
|
440
|
+
thickness = 1,
|
|
441
|
+
aug_smooth = False,
|
|
442
|
+
eigen_smooth = False,
|
|
443
|
+
)
|
|
444
|
+
```
|
|
445
|
+
|
|
446
|
+
**3. Heatmap + BBox — Full overlay (recommended for reporting)**
|
|
447
|
+
```python
|
|
448
|
+
result = explainer.display_heatmap_bbox_on_image(
|
|
449
|
+
img_path = "path/to/image.jpg",
|
|
450
|
+
category = 1,
|
|
451
|
+
threshold = 0.5,
|
|
452
|
+
image_weight = 0.5,
|
|
453
|
+
aug_smooth = False,
|
|
454
|
+
eigen_smooth = False,
|
|
455
|
+
)
|
|
456
|
+
```
|
|
457
|
+
|
|
458
|
+
### 📊 Visual Results
|
|
459
|
+
|
|
460
|
+
<p align="center">
|
|
461
|
+
<table>
|
|
462
|
+
<tr>
|
|
463
|
+
<td><img src="https://raw.githubusercontent.com/HanMoonSub/DeepGuard/main/docs/architectures/low_branch.gif" width="100%"></td>
|
|
464
|
+
<td width="20%"></td>
|
|
465
|
+
<td><img src="https://raw.githubusercontent.com/HanMoonSub/DeepGuard/main/docs/architectures/high_branch.gif" width="100%"></td>
|
|
466
|
+
</tr>
|
|
467
|
+
</table>
|
|
468
|
+
</p>
|
|
469
|
+
|
|
470
|
+
#### MS-EFF-VIT — Low-Level Branch
|
|
471
|
+
|
|
472
|
+
| Model | Branch-Level | Image | HiresCam | GradCamElementwise | LayerCam |
|
|
473
|
+
| :--- | :---: | :---: | :---: | :---: | :---: |
|
|
474
|
+
| **⚡ ms-eff-vit-b0** |  | <img src="https://raw.githubusercontent.com/HanMoonSub/DeepGuard/main/docs/samples/images/western/western_fake_1.JPG" width="100"> | <img src="https://raw.githubusercontent.com/HanMoonSub/DeepGuard/main/docs/xai-results/ms_eff_vit_b0_low_hirescam.JPG" width="100"> | <img src="https://raw.githubusercontent.com/HanMoonSub/DeepGuard/main/docs/xai-results/ms_eff_vit_b0_low_gradcamelementwise.JPG" width="100"> | <img src="https://raw.githubusercontent.com/HanMoonSub/DeepGuard/main/docs/xai-results/ms_eff_vit_b0_low_layercam.JPG" width="100"> |
|
|
475
|
+
| **🔥 ms-eff-vit-b5** |  | <img src="https://raw.githubusercontent.com/HanMoonSub/DeepGuard/main/docs/samples/images/western/western_fake_1.JPG" width="100"> | <img src="https://raw.githubusercontent.com/HanMoonSub/DeepGuard/main/docs/xai-results/ms_eff_vit_b5_low_hirescam.JPG" width="100"> | <img src="https://raw.githubusercontent.com/HanMoonSub/DeepGuard/main/docs/xai-results/ms_eff_vit_b5_low_gradcamelementwise.JPG" width="100"> | <img src="https://raw.githubusercontent.com/HanMoonSub/DeepGuard/main/docs/xai-results/ms_eff_vit_b5_low_layercam.JPG" width="100"> |
|
|
476
|
+
|
|
477
|
+
#### MS-Eff-ViT — High-Level Branch
|
|
478
|
+
|
|
479
|
+
| Model | Branch-Level | Image | EigenGradCam | GradCamPlusPlus | XGradCam |
|
|
480
|
+
| :--- | :---: | :---: | :---: | :---: | :---: |
|
|
481
|
+
| **⚡ ms-eff-vit-b0** |  | <img src="https://raw.githubusercontent.com/HanMoonSub/DeepGuard/main/docs/samples/images/western/western_fake_1.JPG" width="100"> | <img src="https://raw.githubusercontent.com/HanMoonSub/DeepGuard/main/docs/xai-results/ms_eff_vit_b0_high_eigengradcam.JPG" width="100"> | <img src="https://raw.githubusercontent.com/HanMoonSub/DeepGuard/main/docs/xai-results/ms_eff_vit_b0_high_gradcamplusplus.JPG" width="100"> | <img src="https://raw.githubusercontent.com/HanMoonSub/DeepGuard/main/docs/xai-results/ms_eff_vit_b0_high_xgradcam.JPG" width="100"> |
|
|
482
|
+
| **🔥 ms-eff-vit-b5** |  | <img src="https://raw.githubusercontent.com/HanMoonSub/DeepGuard/main/docs/samples/images/western/western_fake_1.JPG" width="100"> | <img src="https://raw.githubusercontent.com/HanMoonSub/DeepGuard/main/docs/xai-results/ms_eff_vit_b5_high_eigengradcam.JPG" width="100"> | <img src="https://raw.githubusercontent.com/HanMoonSub/DeepGuard/main/docs/xai-results/ms_eff_vit_b5_high_gradcamplusplus.JPG" width="100"> | <img src="https://raw.githubusercontent.com/HanMoonSub/DeepGuard/main/docs/xai-results/ms_eff_vit_b5_high_xgradcam.JPG" width="100"> |
|
|
483
|
+
|
|
484
|
+
#### MS-EFF-GCVIT — Low-Level Branch
|
|
485
|
+
|
|
486
|
+
| Model | Branch-Level | Image | HiresCam | GradCamElementwise | LayerCam |
|
|
487
|
+
| :--- | :---: | :---: | :---: | :---: | :---: |
|
|
488
|
+
| **⚡ ms-eff-gcvit-b0** |  | <img src="https://raw.githubusercontent.com/HanMoonSub/DeepGuard/main/docs/samples/images/western/western_fake_1.JPG" width="100"> | <img src="https://raw.githubusercontent.com/HanMoonSub/DeepGuard/main/docs/xai-results/ms_eff_gcvit_b0_low_hirescam.JPG" width="100"> | <img src="https://raw.githubusercontent.com/HanMoonSub/DeepGuard/main/docs/xai-results/ms_eff_gcvit_b0_low_gradcamelementwise.JPG" width="100"> | <img src="https://raw.githubusercontent.com/HanMoonSub/DeepGuard/main/docs/xai-results/ms_eff_gcvit_b0_low_layercam.JPG" width="100"> |
|
|
489
|
+
| **🔥 ms-eff-gcvit-b5** |  | <img src="https://raw.githubusercontent.com/HanMoonSub/DeepGuard/main/docs/samples/images/western/western_fake_1.JPG" width="100"> | <img src="https://raw.githubusercontent.com/HanMoonSub/DeepGuard/main/docs/xai-results/ms_eff_gcvit_b5_low_hirescam.JPG" width="100"> | <img src="https://raw.githubusercontent.com/HanMoonSub/DeepGuard/main/docs/xai-results/ms_eff_gcvit_b5_low_gradcamelementwise.JPG" width="100"> | <img src="https://raw.githubusercontent.com/HanMoonSub/DeepGuard/main/docs/xai-results/ms_eff_gcvit_b5_low_layercam.JPG" width="100"> |
|
|
490
|
+
|
|
491
|
+
#### MS-Eff-GCViT — High-Level Branch
|
|
492
|
+
|
|
493
|
+
| Model | Branch-Level | Image | EigenGradCam | GradCamPlusPlus | XGradCam |
|
|
494
|
+
| :--- | :---: | :---: | :---: | :---: | :---: |
|
|
495
|
+
| **⚡ ms-eff-gcvit-b0** |  | <img src="https://raw.githubusercontent.com/HanMoonSub/DeepGuard/main/docs/samples/images/western/western_fake_1.JPG" width="100"> | <img src="https://raw.githubusercontent.com/HanMoonSub/DeepGuard/main/docs/xai-results/ms_eff_gcvit_b0_high_eigengradcam.JPG" width="100"> | <img src="https://raw.githubusercontent.com/HanMoonSub/DeepGuard/main/docs/xai-results/ms_eff_gcvit_b0_high_gradcamplusplus.JPG" width="100"> | <img src="https://raw.githubusercontent.com/HanMoonSub/DeepGuard/main/docs/xai-results/ms_eff_gcvit_b0_high_xgradcam.JPG" width="100"> |
|
|
496
|
+
| **🔥 ms-eff-gcvit-b5** |  | <img src="https://raw.githubusercontent.com/HanMoonSub/DeepGuard/main/docs/samples/images/western/western_fake_1.JPG" width="100"> | <img src="https://raw.githubusercontent.com/HanMoonSub/DeepGuard/main/docs/xai-results/ms_eff_gcvit_b5_high_eigengradcam.JPG" width="100"> | <img src="https://raw.githubusercontent.com/HanMoonSub/DeepGuard/main/docs/xai-results/ms_eff_gcvit_b5_high_gradcamplusplus.JPG" width="100"> | <img src="https://raw.githubusercontent.com/HanMoonSub/DeepGuard/main/docs/xai-results/ms_eff_gcvit_b5_high_xgradcam.JPG" width="100"> |
|
|
497
|
+
|
|
498
|
+
## 📓 Tutorials
|
|
499
|
+
|
|
500
|
+
The jupyter notebooks themselves can be found under the tutorials folder in the git repository.
|
|
501
|
+
|
|
502
|
+
- [Notebook tutorial: Predict DeepFake Image with ImagePredictor](./tutorials/predict_image.ipynb)
|
|
503
|
+
- [Notebook tutorial: Predict DeepFake Video with VideoPredictor](./tutorials/predict_video.ipynb)
|
|
504
|
+
- [Notebook tutorial: Low-Level Branch XAI Visualization (HiResCAM, GradCAMElementWise, LayerCAM)](./tutorials/low_level_visualization.ipynb)
|
|
505
|
+
- [Notebook tutorial: High-Level Branch XAI Visualization (EigenGradCAM, GradCAM++, XGradCAM)](./tutorials/high_level_visualization.ipynb)
|
|
506
|
+
- [Notebook tutorial: MS-EffViT Low-Level Branch Explainability](./tutorials/ms_eff_vit_low_level.ipynb)
|
|
507
|
+
- [Notebook tutorial: MS-EffViT High-Level Branch Explainability](./tutorials/ms_eff_vit_high_level.ipynb)
|
|
508
|
+
- [Notebook tutorial: MS-EffGCViT Low-Level Branch Explainability](./tutorials/ms_eff_gcvit_low_level.ipynb)
|
|
509
|
+
- [Notebook tutorial: MS-EffGCViT High-Level Branch Explainability](./tutorials/ms_eff_gcvit_high_level.ipynb)
|
|
334
510
|
|
|
335
511
|
## 📬 Authors
|
|
336
512
|
|
|
@@ -351,6 +527,7 @@ _**This project was developed as a Senior Graduation Project by the Department o
|
|
|
351
527
|
6. [`deepfake-detection-project-v4`](https://github.com/ameencaslam/deepfake-detection-project-v4) - _Multiple Deep Learning Models by Ameen Caslam_
|
|
352
528
|
7. [`Awesome-Deepfake-Detection`](https://github.com/Daisy-Zhang/Awesome-Deepfakes-Detection
|
|
353
529
|
) - _A curated list of tools, papers and code by Daisy Zhang_
|
|
530
|
+
8. [`Pytorch-Grad-Cam`](https://github.com/jacobgil/pytorch-grad-cam) - _Advanced Visual Explanations for PyTorch Models_
|
|
354
531
|
|
|
355
532
|
## ⚖️ License
|
|
356
533
|
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
# Deepfakes Detection
|
|
2
2
|
|
|
3
|
-
<p align="center">
|
|
4
|
-
<img src="https://raw.githubusercontent.com/HanMoonSub/DeepGuard/main/Images/deepfake2.png" alt="DeepGuard Banner" width="800" height="400">
|
|
5
|
-
</p>
|
|
6
|
-
|
|
7
3
|
<p align="center">
|
|
8
4
|
<img src="https://img.shields.io/github/license/HanMoonSub/DeepGuard?style=flat-square&color=555555&logo=github&logoColor=white" alt="License">
|
|
9
5
|
<img src="https://img.shields.io/github/stars/HanMoonSub/DeepGuard?style=flat-square&color=FFD700&logo=github&logoColor=white" alt="Stars">
|
|
6
|
+
<img src="https://img.shields.io/github/downloads/HanMoonSub/DeepGuard/total?style=flat-square&color=brightgreen&logo=github&logoColor=white" alt="Downloads">
|
|
7
|
+
<img src="https://img.shields.io/github/last-commit/HanMoonSub/DeepGuard?style=flat-square&color=lightgrey&logo=github&logoColor=white" alt="Last Commit">
|
|
10
8
|
<img src="https://img.shields.io/badge/Status-Active-brightgreen?style=flat-square" alt="Status">
|
|
11
9
|
<img src="https://img.shields.io/badge/Release-v0.2.0-orange?style=flat-square&logo=github&logoColor=white" alt="Release">
|
|
10
|
+
<img src="https://img.shields.io/github/repo-size/HanMoonSub/DeepGuard?style=flat-square&color=blueviolet" alt="Repo Size">
|
|
11
|
+
</p>
|
|
12
|
+
|
|
13
|
+
<p align="center">
|
|
14
|
+
<img src="https://raw.githubusercontent.com/HanMoonSub/DeepGuard/main/docs/samples/deepfake_thumbnails.png" alt="DeepGuard Banner" width="800" height="400">
|
|
12
15
|
</p>
|
|
13
16
|
|
|
14
17
|
<p align="center">
|
|
@@ -27,6 +30,7 @@
|
|
|
27
30
|
|
|
28
31
|
<p align="center">
|
|
29
32
|
<a href="README_KR.md"><b>🇰🇷 한국어 버전</b></a> |
|
|
33
|
+
<a href="README_JP.md"><b>🇯🇵 日本語版</b></a> |
|
|
30
34
|
<a href="#-model-evaluation"><b>📈 Model Evaluation</b></a> |
|
|
31
35
|
<a href="#-predict-image--video"><b>🔮 Try Demo</b></a>
|
|
32
36
|
</p>
|
|
@@ -43,6 +47,8 @@
|
|
|
43
47
|
- [📈 Model Evaluation](#-model-evaluation) - Benchmarking results
|
|
44
48
|
- [💻 Model Usage](#-model-usage) - How to integrate DeepGuard models into your own Python code or via timm
|
|
45
49
|
- [🔮 Predict Image & Video](#-predict-image--video) - Simple Inference examples for detecting deepfakes in image and video
|
|
50
|
+
- [🎨 DeepFake AI Explainability](#-deepfake-ai-explainability) - Visualizing model focus using Grad-CAM and attention maps
|
|
51
|
+
- [📓 Tutorials](#-tutorials) - Hands-on Colab notebooks for inference and dual-branch XAI visualization
|
|
46
52
|
- [📬 Authors](#-authors)
|
|
47
53
|
- [📝 Reference](#-reference)
|
|
48
54
|
- [⚖️ License](#-license)
|
|
@@ -138,7 +144,7 @@ Multi Scale Efficient Global Context Vision Transformer is an optimized multi-sc
|
|
|
138
144
|
|
|
139
145
|
|
|
140
146
|
<p align="center">
|
|
141
|
-
<img src="https://raw.githubusercontent.com/HanMoonSub/DeepGuard/main/
|
|
147
|
+
<img src="https://raw.githubusercontent.com/HanMoonSub/DeepGuard/main/docs/architectures/ms_eff_gcvit.JPG" width="100%" height="700">
|
|
142
148
|
</p>
|
|
143
149
|
|
|
144
150
|
We utilizes two distinct types of self-attention to capture both long-range and short-range information across feature maps.
|
|
@@ -149,7 +155,7 @@ We utilizes two distinct types of self-attention to capture both long-range and
|
|
|
149
155
|
|
|
150
156
|
|
|
151
157
|
<p align="center">
|
|
152
|
-
<img src=https://raw.githubusercontent.com/HanMoonSub/DeepGuard/main/
|
|
158
|
+
<img src=https://raw.githubusercontent.com/HanMoonSub/DeepGuard/main/docs/architectures/window_attention.JPG width="100%" height="300">
|
|
153
159
|
</p>
|
|
154
160
|
|
|
155
161
|
## 🧬 Model Zoo
|
|
@@ -226,7 +232,8 @@ You can load the models directly via the `DeepGuard` package or through the `tim
|
|
|
226
232
|
**Installation**
|
|
227
233
|
|
|
228
234
|
```bash
|
|
229
|
-
pip install -U git+https://github.com/HanMoonSub/DeepGuard.git
|
|
235
|
+
# pip install -U git+https://github.com/HanMoonSub/DeepGuard.git
|
|
236
|
+
pip install deepguard
|
|
230
237
|
```
|
|
231
238
|
|
|
232
239
|
|
|
@@ -249,6 +256,21 @@ model = timm.create_model("ms_eff_gcvit_b0", pretrained=True, dataset="ff++")
|
|
|
249
256
|
model = timm.create_model("ms_eff_gcvit_b5", pretrained=True, dataset="kodf")
|
|
250
257
|
```
|
|
251
258
|
|
|
259
|
+
**Option C: Hugging Face Hub**
|
|
260
|
+
|
|
261
|
+
```python
|
|
262
|
+
import torch
|
|
263
|
+
from huggingface_hub import hf_hub_download
|
|
264
|
+
from deepguard import ms_eff_gcvit_b0 # or ms_eff_gcvit_b5
|
|
265
|
+
|
|
266
|
+
REPO_ID = "KoreaPeter/ms-eff-gcvit-deepfake"
|
|
267
|
+
|
|
268
|
+
ckpt = hf_hub_download(REPO_ID, "ms_eff_gcvit_b0_kodf.bin") # celeb_df_v2 | ff++ | kodf
|
|
269
|
+
model = ms_eff_gcvit_b0(pretrained=False)
|
|
270
|
+
model.load_state_dict(torch.load(ckpt, map_location="cpu"))
|
|
271
|
+
model.eval()
|
|
272
|
+
```
|
|
273
|
+
|
|
252
274
|
## 🔮 Predict Image & Video
|
|
253
275
|
|
|
254
276
|
#### Predict DeepFake Image
|
|
@@ -302,6 +324,163 @@ print(f"Deepfake Probability: {result:.4f}")
|
|
|
302
324
|
|
|
303
325
|
```
|
|
304
326
|
|
|
327
|
+
## 🎨 DeepFake AI Explainability
|
|
328
|
+
|
|
329
|
+
Deepfake detection is only as trustworthy as its explanations. DeepGuard integrates a production-ready XAI Toolkit that visualizes where and why the model flags a face as manipulated — turning a black-box score into actionable forensic evidence.
|
|
330
|
+
|
|
331
|
+
⭐ Validated on hybrid CNN-ViT architectures, specifically `MS-EffViT` and `MS-EffGCViT`.
|
|
332
|
+
⭐ Dual-Branch Analysis: Dual-branch design mirrors the model's own multi-scale reasoning
|
|
333
|
+
|
|
334
|
+
### 🧠 How Dual-Branch XAI Works
|
|
335
|
+
|
|
336
|
+
<p align="center">
|
|
337
|
+
<img src="https://raw.githubusercontent.com/HanMoonSub/DeepGuard/main/docs/architectures/dual_branch.gif" width="70%" height="300">
|
|
338
|
+
</p>
|
|
339
|
+
|
|
340
|
+
|
|
341
|
+
| Branch | Feature Map | Focus | Best For |
|
|
342
|
+
| ------ | ----------- | ----- | -------- |
|
|
343
|
+
|  | High Resolution | Local Forgery artifacts | Skin texture, boundary blending, compression traces |
|
|
344
|
+
|  | Low Resolution | Global Semantic Structure | Lighting inconsistency, facial geometry, Shadow artifacts |
|
|
345
|
+
|
|
346
|
+
### 📐 XAI Methods
|
|
347
|
+
|
|
348
|
+
Each method is assigned to the branch where it performs best empirically.
|
|
349
|
+
|
|
350
|
+
| Branch | Method | 🎯 Core Idea |
|
|
351
|
+
| :--- | :--- | :--- |
|
|
352
|
+
| **`low level`** | **HiResCAM** | Like GradCAM but element-wise multiply the activations with the gradients; provably guaranteed faithfulness for certain models |
|
|
353
|
+
| **`low level`** | **GradCAMElementWise** | Like GradCAM but element-wise multiply the activations with the gradients then apply a ReLU operation before summing |
|
|
354
|
+
| **`low level`** | **LayerCAM** | Spatially weight the activations by positive gradients. Works better especially in lower layers |
|
|
355
|
+
| --- | --- | --- | --- |
|
|
356
|
+
| **`high level`** | **EigenGradCAM** | Like EigenCAM but with class discrimination: First principle component of Activations*Grad. Looks like GradCAM, but cleaner |
|
|
357
|
+
| **`high level`** | **GradCAM++** | Like GradCAM but uses second order gradients |
|
|
358
|
+
| **`high level`** | **XGradCAM** | Like GradCAM but scale the gradients by the normalized activations |
|
|
359
|
+
|
|
360
|
+
- **`aug_smooth`** applies TTA (horizontal flips) before averaging CAMs → smoother, more object-aligned maps
|
|
361
|
+
- **`eigen_smooth`** applies PCA noise reduction → retains dominant forgery pattern only
|
|
362
|
+
|
|
363
|
+
### 💡 DeepFake XAI Usage
|
|
364
|
+
|
|
365
|
+
**Low-Level Branch — Local Artifact Detection**
|
|
366
|
+
|
|
367
|
+
```python
|
|
368
|
+
from explainability import HiResCAMExplainer, GradCAMElementWiseExplainer, LayerCAMExplainer
|
|
369
|
+
|
|
370
|
+
explainer = HiResCAMExplainer(
|
|
371
|
+
model_name = "ms_eff_gcvit_b0", # or ms_eff_vit_b0, ms_eff_gcvit_b5, ms_eff_vit_b5
|
|
372
|
+
dataset = "celeb_df_v2", # or ff++, kodf
|
|
373
|
+
branch_level = "low",
|
|
374
|
+
)
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
**High-Level Branch — Global Semantic Detection**
|
|
378
|
+
```python
|
|
379
|
+
from explainability import EigenGradCAMExplainer, GradCAMPlusPlusExplainer, XGradCAMExplainer
|
|
380
|
+
|
|
381
|
+
explainer = EigenGradCAMExplainer(
|
|
382
|
+
model_name = "ms_eff_gcvit_b0",
|
|
383
|
+
dataset = "celeb_df_v2",
|
|
384
|
+
branch_level = "high",
|
|
385
|
+
)
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
### 🎨 Visualization Modes
|
|
389
|
+
|
|
390
|
+
<p align="center">
|
|
391
|
+
<img src="https://raw.githubusercontent.com/HanMoonSub/DeepGuard/main/docs/xai-results/xai_demo.gif" width="80%" height=300>
|
|
392
|
+
</p>
|
|
393
|
+
|
|
394
|
+
**1. Heatmap — Continuous activation distribution**
|
|
395
|
+
|
|
396
|
+
```python
|
|
397
|
+
result = explainer.display_heatmap_on_image(
|
|
398
|
+
img_path = "path/to/image.jpg",
|
|
399
|
+
category = 1, # 0: Real, 1: Fake
|
|
400
|
+
threshold = 0.5, # binarization cutoff (0.5~1.0), or "auto" for Otsu
|
|
401
|
+
image_weight = 0.5, # 0.0: heatmap only ← → 1.0: original only
|
|
402
|
+
aug_smooth = False, # TTA smoothing (not supported on 'pro' models)
|
|
403
|
+
eigen_smooth = False, # PCA noise reduction
|
|
404
|
+
)
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
**2. Bounding Box — Discrete forgery region localization**
|
|
408
|
+
|
|
409
|
+
```python
|
|
410
|
+
result = explainer.display_bbox_on_image(
|
|
411
|
+
img_path = "path/to/image.jpg",
|
|
412
|
+
category = 1,
|
|
413
|
+
threshold = 0.5,
|
|
414
|
+
thickness = 1,
|
|
415
|
+
aug_smooth = False,
|
|
416
|
+
eigen_smooth = False,
|
|
417
|
+
)
|
|
418
|
+
```
|
|
419
|
+
|
|
420
|
+
**3. Heatmap + BBox — Full overlay (recommended for reporting)**
|
|
421
|
+
```python
|
|
422
|
+
result = explainer.display_heatmap_bbox_on_image(
|
|
423
|
+
img_path = "path/to/image.jpg",
|
|
424
|
+
category = 1,
|
|
425
|
+
threshold = 0.5,
|
|
426
|
+
image_weight = 0.5,
|
|
427
|
+
aug_smooth = False,
|
|
428
|
+
eigen_smooth = False,
|
|
429
|
+
)
|
|
430
|
+
```
|
|
431
|
+
|
|
432
|
+
### 📊 Visual Results
|
|
433
|
+
|
|
434
|
+
<p align="center">
|
|
435
|
+
<table>
|
|
436
|
+
<tr>
|
|
437
|
+
<td><img src="https://raw.githubusercontent.com/HanMoonSub/DeepGuard/main/docs/architectures/low_branch.gif" width="100%"></td>
|
|
438
|
+
<td width="20%"></td>
|
|
439
|
+
<td><img src="https://raw.githubusercontent.com/HanMoonSub/DeepGuard/main/docs/architectures/high_branch.gif" width="100%"></td>
|
|
440
|
+
</tr>
|
|
441
|
+
</table>
|
|
442
|
+
</p>
|
|
443
|
+
|
|
444
|
+
#### MS-EFF-VIT — Low-Level Branch
|
|
445
|
+
|
|
446
|
+
| Model | Branch-Level | Image | HiresCam | GradCamElementwise | LayerCam |
|
|
447
|
+
| :--- | :---: | :---: | :---: | :---: | :---: |
|
|
448
|
+
| **⚡ ms-eff-vit-b0** |  | <img src="https://raw.githubusercontent.com/HanMoonSub/DeepGuard/main/docs/samples/images/western/western_fake_1.JPG" width="100"> | <img src="https://raw.githubusercontent.com/HanMoonSub/DeepGuard/main/docs/xai-results/ms_eff_vit_b0_low_hirescam.JPG" width="100"> | <img src="https://raw.githubusercontent.com/HanMoonSub/DeepGuard/main/docs/xai-results/ms_eff_vit_b0_low_gradcamelementwise.JPG" width="100"> | <img src="https://raw.githubusercontent.com/HanMoonSub/DeepGuard/main/docs/xai-results/ms_eff_vit_b0_low_layercam.JPG" width="100"> |
|
|
449
|
+
| **🔥 ms-eff-vit-b5** |  | <img src="https://raw.githubusercontent.com/HanMoonSub/DeepGuard/main/docs/samples/images/western/western_fake_1.JPG" width="100"> | <img src="https://raw.githubusercontent.com/HanMoonSub/DeepGuard/main/docs/xai-results/ms_eff_vit_b5_low_hirescam.JPG" width="100"> | <img src="https://raw.githubusercontent.com/HanMoonSub/DeepGuard/main/docs/xai-results/ms_eff_vit_b5_low_gradcamelementwise.JPG" width="100"> | <img src="https://raw.githubusercontent.com/HanMoonSub/DeepGuard/main/docs/xai-results/ms_eff_vit_b5_low_layercam.JPG" width="100"> |
|
|
450
|
+
|
|
451
|
+
#### MS-Eff-ViT — High-Level Branch
|
|
452
|
+
|
|
453
|
+
| Model | Branch-Level | Image | EigenGradCam | GradCamPlusPlus | XGradCam |
|
|
454
|
+
| :--- | :---: | :---: | :---: | :---: | :---: |
|
|
455
|
+
| **⚡ ms-eff-vit-b0** |  | <img src="https://raw.githubusercontent.com/HanMoonSub/DeepGuard/main/docs/samples/images/western/western_fake_1.JPG" width="100"> | <img src="https://raw.githubusercontent.com/HanMoonSub/DeepGuard/main/docs/xai-results/ms_eff_vit_b0_high_eigengradcam.JPG" width="100"> | <img src="https://raw.githubusercontent.com/HanMoonSub/DeepGuard/main/docs/xai-results/ms_eff_vit_b0_high_gradcamplusplus.JPG" width="100"> | <img src="https://raw.githubusercontent.com/HanMoonSub/DeepGuard/main/docs/xai-results/ms_eff_vit_b0_high_xgradcam.JPG" width="100"> |
|
|
456
|
+
| **🔥 ms-eff-vit-b5** |  | <img src="https://raw.githubusercontent.com/HanMoonSub/DeepGuard/main/docs/samples/images/western/western_fake_1.JPG" width="100"> | <img src="https://raw.githubusercontent.com/HanMoonSub/DeepGuard/main/docs/xai-results/ms_eff_vit_b5_high_eigengradcam.JPG" width="100"> | <img src="https://raw.githubusercontent.com/HanMoonSub/DeepGuard/main/docs/xai-results/ms_eff_vit_b5_high_gradcamplusplus.JPG" width="100"> | <img src="https://raw.githubusercontent.com/HanMoonSub/DeepGuard/main/docs/xai-results/ms_eff_vit_b5_high_xgradcam.JPG" width="100"> |
|
|
457
|
+
|
|
458
|
+
#### MS-EFF-GCVIT — Low-Level Branch
|
|
459
|
+
|
|
460
|
+
| Model | Branch-Level | Image | HiresCam | GradCamElementwise | LayerCam |
|
|
461
|
+
| :--- | :---: | :---: | :---: | :---: | :---: |
|
|
462
|
+
| **⚡ ms-eff-gcvit-b0** |  | <img src="https://raw.githubusercontent.com/HanMoonSub/DeepGuard/main/docs/samples/images/western/western_fake_1.JPG" width="100"> | <img src="https://raw.githubusercontent.com/HanMoonSub/DeepGuard/main/docs/xai-results/ms_eff_gcvit_b0_low_hirescam.JPG" width="100"> | <img src="https://raw.githubusercontent.com/HanMoonSub/DeepGuard/main/docs/xai-results/ms_eff_gcvit_b0_low_gradcamelementwise.JPG" width="100"> | <img src="https://raw.githubusercontent.com/HanMoonSub/DeepGuard/main/docs/xai-results/ms_eff_gcvit_b0_low_layercam.JPG" width="100"> |
|
|
463
|
+
| **🔥 ms-eff-gcvit-b5** |  | <img src="https://raw.githubusercontent.com/HanMoonSub/DeepGuard/main/docs/samples/images/western/western_fake_1.JPG" width="100"> | <img src="https://raw.githubusercontent.com/HanMoonSub/DeepGuard/main/docs/xai-results/ms_eff_gcvit_b5_low_hirescam.JPG" width="100"> | <img src="https://raw.githubusercontent.com/HanMoonSub/DeepGuard/main/docs/xai-results/ms_eff_gcvit_b5_low_gradcamelementwise.JPG" width="100"> | <img src="https://raw.githubusercontent.com/HanMoonSub/DeepGuard/main/docs/xai-results/ms_eff_gcvit_b5_low_layercam.JPG" width="100"> |
|
|
464
|
+
|
|
465
|
+
#### MS-Eff-GCViT — High-Level Branch
|
|
466
|
+
|
|
467
|
+
| Model | Branch-Level | Image | EigenGradCam | GradCamPlusPlus | XGradCam |
|
|
468
|
+
| :--- | :---: | :---: | :---: | :---: | :---: |
|
|
469
|
+
| **⚡ ms-eff-gcvit-b0** |  | <img src="https://raw.githubusercontent.com/HanMoonSub/DeepGuard/main/docs/samples/images/western/western_fake_1.JPG" width="100"> | <img src="https://raw.githubusercontent.com/HanMoonSub/DeepGuard/main/docs/xai-results/ms_eff_gcvit_b0_high_eigengradcam.JPG" width="100"> | <img src="https://raw.githubusercontent.com/HanMoonSub/DeepGuard/main/docs/xai-results/ms_eff_gcvit_b0_high_gradcamplusplus.JPG" width="100"> | <img src="https://raw.githubusercontent.com/HanMoonSub/DeepGuard/main/docs/xai-results/ms_eff_gcvit_b0_high_xgradcam.JPG" width="100"> |
|
|
470
|
+
| **🔥 ms-eff-gcvit-b5** |  | <img src="https://raw.githubusercontent.com/HanMoonSub/DeepGuard/main/docs/samples/images/western/western_fake_1.JPG" width="100"> | <img src="https://raw.githubusercontent.com/HanMoonSub/DeepGuard/main/docs/xai-results/ms_eff_gcvit_b5_high_eigengradcam.JPG" width="100"> | <img src="https://raw.githubusercontent.com/HanMoonSub/DeepGuard/main/docs/xai-results/ms_eff_gcvit_b5_high_gradcamplusplus.JPG" width="100"> | <img src="https://raw.githubusercontent.com/HanMoonSub/DeepGuard/main/docs/xai-results/ms_eff_gcvit_b5_high_xgradcam.JPG" width="100"> |
|
|
471
|
+
|
|
472
|
+
## 📓 Tutorials
|
|
473
|
+
|
|
474
|
+
The jupyter notebooks themselves can be found under the tutorials folder in the git repository.
|
|
475
|
+
|
|
476
|
+
- [Notebook tutorial: Predict DeepFake Image with ImagePredictor](./tutorials/predict_image.ipynb)
|
|
477
|
+
- [Notebook tutorial: Predict DeepFake Video with VideoPredictor](./tutorials/predict_video.ipynb)
|
|
478
|
+
- [Notebook tutorial: Low-Level Branch XAI Visualization (HiResCAM, GradCAMElementWise, LayerCAM)](./tutorials/low_level_visualization.ipynb)
|
|
479
|
+
- [Notebook tutorial: High-Level Branch XAI Visualization (EigenGradCAM, GradCAM++, XGradCAM)](./tutorials/high_level_visualization.ipynb)
|
|
480
|
+
- [Notebook tutorial: MS-EffViT Low-Level Branch Explainability](./tutorials/ms_eff_vit_low_level.ipynb)
|
|
481
|
+
- [Notebook tutorial: MS-EffViT High-Level Branch Explainability](./tutorials/ms_eff_vit_high_level.ipynb)
|
|
482
|
+
- [Notebook tutorial: MS-EffGCViT Low-Level Branch Explainability](./tutorials/ms_eff_gcvit_low_level.ipynb)
|
|
483
|
+
- [Notebook tutorial: MS-EffGCViT High-Level Branch Explainability](./tutorials/ms_eff_gcvit_high_level.ipynb)
|
|
305
484
|
|
|
306
485
|
## 📬 Authors
|
|
307
486
|
|
|
@@ -322,7 +501,8 @@ _**This project was developed as a Senior Graduation Project by the Department o
|
|
|
322
501
|
6. [`deepfake-detection-project-v4`](https://github.com/ameencaslam/deepfake-detection-project-v4) - _Multiple Deep Learning Models by Ameen Caslam_
|
|
323
502
|
7. [`Awesome-Deepfake-Detection`](https://github.com/Daisy-Zhang/Awesome-Deepfakes-Detection
|
|
324
503
|
) - _A curated list of tools, papers and code by Daisy Zhang_
|
|
504
|
+
8. [`Pytorch-Grad-Cam`](https://github.com/jacobgil/pytorch-grad-cam) - _Advanced Visual Explanations for PyTorch Models_
|
|
325
505
|
|
|
326
506
|
## ⚖️ License
|
|
327
507
|
|
|
328
|
-
This project is licensed under the terms of the MIT license.
|
|
508
|
+
This project is licensed under the terms of the MIT license.
|