Multi-Scale Efficient Global Context Vision Transformer (MS-EffGCViT) is a hybrid CNN-ViT architecture for deepfake detection. It fuses CNN-driven spatial inductive bias with hierarchical global-context attention to catch both local artifacts (textures, blending seams) and global artifacts (lighting, structural inconsistency).
A single architecture ships in two sizes and three domain-tuned checkpoints, working on both static images and video at the frame level.
| π¬ Video Detection | πΌοΈ Image Detection | π Explainability (XAI) |
|---|---|---|
| Frame-level verdict with per-frame scores | Face crop β real / fake probability | Grad-CAM maps for low / high branches |
| Spec | Detail |
|---|---|
| Task | Binary deepfake detection (real / fake) |
| Domain | Frame-level, spatial-domain |
| Input | Image or video (face-cropped) |
| Output | Sigmoid probability in [0, 1] β higher = more likely fake |
| Backbone | EfficientNet (ImageNet-1K pretrained) |
| Framework | PyTorch / timm |
| Config | β‘ ms_eff_gcvit_b0 (fast) | π₯ ms_eff_gcvit_b5 (pro) |
|---|---|---|
| Model name | ms_eff_gcvit_b0 |
ms_eff_gcvit_b5 |
| Backbone | tf_efficientnet_b0.ns_jft_in1k |
tf_efficientnet_b5.ns_jft_in1k |
| Resolution | 224Γ224 | 384Γ384 |
| Params (M) | 8.70 | 50.34 |
| FLOPs (G) | 0.85 | 13.43 |
Latency is measured with batch size 1 on a single Tesla T4 and video (num_frames=20).
| Model | Mode | Target Deployment | Latency (s) | Ratio |
|---|---|---|---|---|
| β‘ ms_eff_gcvit_b0 | Fast Mode | Edge / on-device deployment | 0.051 | 1.00Γ |
| π₯ ms_eff_gcvit_b5 | Pro Mode | Enterprise deployment | 0.479 | 9.41Γ |
Learning to detect manipulated facial images [Paper] [Download], featuring 1,000 original YouTube videos manipulated by 5 face forgery methods.
| Source | Real/Fake | Videos | Description |
|---|---|---|---|
Deepfakes |
1,000 | Autoencoder-based face replacement | |
Face2Face |
1,000 | Expression transfer (reenactment) | |
FaceSwap |
1,000 | Graphics-based face replacement | |
FaceShifter |
1,000 | High-fidelity swap with occlusion handling | |
NeuralTextures |
1,000 | Neural-texture-based reenactment | |
Original |
1,000 | Unaltered authentic YouTube videos |
Trained and tested on the same dataset.
| Dataset | Variant | Accuracy | AUC | Log Loss |
|---|---|---|---|---|
| FaceForensics++ | β‘ Fast | 0.9808 | 0.9969 | 0.0637 |
| FaceForensics++ | π₯ Pro | 0.9850 | 0.9974 | 0.0492 |
| Model | Test@Acc | Test@Auc | #Params(M) | Params Ratio | #FLOPS(G) | FLOPS Ratio |
|---|---|---|---|---|---|---|
| ms_eff_gcvit_b0 | 98.1% | 99.7% | 8.7 | 1x | 0.85 | 1x |
| sia (ECCV,2022) | 95.0% | 97.5% | 17.57 | 2x | 2.05 | 2.4x |
| core (CVPR,2022) | 98.3% | 99.8% | 20.81 | 2.4x | 8.40 | 9.9x |
| ms_eff_gcvit_b5 | 98.5% | 99.7% | 50.34 | 5.8x | 13.43 | 15.8x |
| iid (CVPR,2023) | 97.3% | 99.6% | 65.5 | 7.5x | 12.7 | 14.9x |
| effort (ICML, 2025) | 98.4% | 99.8% | 303.4 | 34.9x | 155.9 | 183.4x |
Generalization to unseen domains β trained on FaceForensics++
| Tested on | Variant | Accuracy | AUC | Log Loss |
|---|---|---|---|---|
| Celeb-DF-v2 | β‘ Fast | 0.7259 | 0.6999 | 0.6794 |
| Celeb-DF-v2 | π₯ Pro | 0.7722 | 0.7309 | 0.6657 |
| KoDF | β‘ Fast | 0.7544 | 0.8620 | 0.8829 |
| KoDF | π₯ Pro | 0.7695 | 0.8821 | 0.7635 |
pip install "deepguard>=2.0.0"
from transformers import pipeline
clf = pipeline(
"image-classification",
model="KoreaPeter/ms-eff-gcvit-deepfake-b0-ff-plus-plus",
trust_remote_code=True,
)
# ββ Basic Inference βββββββββββββββββββββββββββββββββββββββββββββββ
result = clf("face.jpg")
# [{'label': 'fake', 'score': 0.9712}, {'label': 'real', 'score': 0.0288}]
# ββ Custom Parameters βββββββββββββββββββββββββββββββββββββββββββββ
result = clf(
"face.jpg",
margin_ratio=0.2, # Margin ratio around the detected face bbox (default: 0.2)
conf_thres=0.5, # Confidence threshold for YOLO face detection (default: 0.5)
min_face_ratio=0.01, # Minimum face-to-frame area ratio to process (default: 0.01)
tta_hflip=0.0, # Probability of horizontal flip for TTA (default: 0.0)
top_k=1, # Number of top labels to return (default: all)
)
# [{'label': 'fake', 'score': 0.9712}]
clf = pipeline(
"video-classification",
model="KoreaPeter/ms-eff-gcvit-deepfake-b0-ff-plus-plus",
trust_remote_code=True,
)
# ββ Basic Inference βββββββββββββββββββββββββββββββββββββββββββββββ
result = clf("video.mp4")
# [{'label': 'fake', 'score': 0.9634}, {'label': 'real', 'score': 0.0366}]
# ββ Custom Parameters βββββββββββββββββββββββββββββββββββββββββββββ
result = clf(
"video.mp4",
num_frames=20, # Number of frames to sample (default: 20)
margin_ratio=0.2, # Margin ratio around the detected face bbox (default: 0.2)
conf_thres=0.5, # Confidence threshold for YOLO face detection (default: 0.5)
min_face_ratio=0.01, # Minimum face-to-frame area ratio to process (default: 0.01)
tta_hflip=0.0, # Probability of horizontal flip for TTA (default: 0.0)
agg_mode="conf", # Aggregation mode: 'conf' | 'mean' | 'vote' (default: 'conf')
return_frame_scores=True, # Return per-frame scores (default: False)
)
# [{'label': 'fake', 'score': 0.9634},
# {'label': 'real', 'score': 0.0366},
# {'frame_scores': [0.97, 0.95, 0.98, ...], 'agg_mode': 'conf'}]
While traditional Vision Transformers (ViTs) utilize a Linear Projection for patch embedding, our proposed model adopts a CNN-based Patch Embedding module incorporating MBConvBlocks.
We utilizes two distinct types of self-attention to capture both long-range and short-range information across feature maps.
Local Window Attention: this model efficiently captures local textures and precise spatial details while maintaining linear computational complexity relative to the image size.
Global Window Attention: Unlike Swin Transformer, this module utilizes global-queries that interact with local window keys and values. This allows each local region to incorporate global context, effectively capturing long-range dependencies and providing a comprehensive understanding of the entire spatial structure
Efficient Backbone While both Xception and EfficientNet show great results on DeepFake benchmarks, EfficientNet is chosen for its superior computational efficiency. By utilizing MBconv (Inverted Residual Blocks) and depthwise convolutions, it achieves significantly lower FLOPS compared to Xception.
Window-based Attention: Instead of applying self-attention on raw images, this model operates on feature maps extracted from backbone blocks. By partitioning these maps into windows, the $O(N^2)$ complexity is restricted to the window size, siginificantly lowering the computational footprint.
Modern DeepFakes can leave very localized forgery region. To Capture this, we adopts a multi-scale strategy by extracting features from different levels of the backbone.
(Subtle Artifacts): High-Resolution feature maps are extracted from early backbone blocks(l_block_idx) to capture like skin texture or boundary artifacts
(Global Features): Low-Resolution feature maps are extracted from deeper blocks(h_block_idx) to analyze overall lighting, shadows, and structural consistency.
Feature Fusion: The Outputs from both branches (L-GCViT and H-GCViT) are fused to make a comprehensive decision based on both local and global context.
@misc{deepguard2026,
title = {DeepGuard: Multi-Scale Efficient Global Context Vision Transformer for Deepfake Detection},
author = {seoyunje},
year = {2026},
url = {https://github.com/HanMoonSub/DeepGuard}
}
timm/tf_efficientnet_b0.ns_jft_in1k