CoolFace
Modelpublic

KoreaPeter/ms-eff-gcvit-deepfake-b0-celeb-df-v2

sourceHugging Facemitupdated 3mo agoView on Hugging Face
2likes7.7kdownloads
Model Card

๐Ÿš€ Multi Scale Efficient Global Context Vision Transformer

Task Image Classification Video Classification

FaceForensics++ Celeb-DF(v2)-00C853?style=flat-square) KODF

<img src="./mseffgcvit.JPG" width="900">

๐Ÿ”— GitHub Repository: HanMoonSub/DeepGuard
๐Ÿค— Live demo: DeepFake Video Detection
๐Ÿค— Live demo: DeepFake Image Detection
๐Ÿค— Live demo: DeepFake Detection XAI

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.

โœจ Core Features

  • โ€”๐ŸŽž๏ธ Frame-level โ€” one model handles both images and videos (frame-level inference + aggregation).
  • โ€”๐ŸŒ Cross-domain โ€” robust on both East-Asian (KoDF) and Western (Celeb-DF-v2, FaceForensics++) faces.
  • โ€”โšก๐Ÿ”ฅ Two variants โ€” Fast (b0) for real-time/edge, Pro (b5) for enterprise accuracy.
  • โ€”๐Ÿงฉ timm-compatible โ€” load via the timm interface or the deepguard package.

โš™๏ธ Model Specifications

SpecDetail
TaskBinary deepfake detection (real / fake)
DomainFrame-level, spatial-domain
InputImage or video (face-cropped)
OutputSigmoid probability in [0, 1] โ€” higher = more likely fake
BackboneEfficientNet (ImageNet-1K pretrained)
FrameworkPyTorch / timm

๐Ÿงฌ Model Zoo

โšก ms_eff_gcvit_b0 is Optimized for real-time inference and mobile deployment.

๐Ÿ”ฅ ms_eff_gcvit_b5 is Engineered for high-fidelity analysis and enterprise-grade accuracy.

Configโšก Fast (b0)๐Ÿ”ฅ Pro (b5)
Model namems_eff_gcvit_b0ms_eff_gcvit_b5
Backbonetf_efficientnet_b0.ns_jft_in1ktf_efficientnet_b5.ns_jft_in1k
Resolution224ร—224384ร—384
Params (M)8.750.3
FLOPs (G)0.8713.64

๐Ÿ“š Dataset: Celeb-DF-v2

A large-scale challenging dataset for deepfake forensics [[Paper]](https://openaccess.thecvf.com/contentCVPR2020/papers/LiCeleb-DFALarge-ScaleChallengingDatasetforDeepFakeForensicsCVPR2020_paper.pdf) [[Download]](https://github.com/yuezunli/celeb-deepfakeforensics/tree/master), featuring 590 YouTube celebrity videos with diverse ages, ethnic groups, and genders.

  • โ€”[x] Source: 590 original YouTube videos (celebrities)
  • โ€”[x] Synthesis: 5,639 deepfake videos generated from real videos
  • โ€”[x] Subjects: Diverse ages, ethnicities, and genders
SourceReal/FakeVideosDescription
celeb-realReal590Celebrity videos from YouTube
youtube-realReal300Additional YouTube videos
celeb-synthesisFake5,639Synthesized from celeb-real
๐Ÿ“Ž Available at GitHub or Kaggle

๐Ÿ“ˆ Test Evaluation

Trained and tested on the same dataset.

<img src="./celebdfv2_gcvit.png" width="900">

DatasetVariantAccuracyAUCLog Loss
Celeb-DF-v2โšก Fast0.98420.99650.0283
Celeb-DF-v2๐Ÿ”ฅ Pro0.99810.99840.0089

๐Ÿ“ˆ Cross-Dataset Evaluation (Trained on Celeb DF(v2))

Generalization to unseen domains โ€” trained on Celeb DF(v2)

Tested onVariantAccuracyAUCLog Loss
KoDFโšก Fast0.49350.72581.3459
KoDF๐Ÿ”ฅ Pro0.48320.71601.4897
FaceForensics++โšก Fast0.54920.73011.0556
FaceForensics++๐Ÿ”ฅ Pro0.58250.73070.8897

๐Ÿš€ Model Usage

python
pip install deepguard
from transformers import pipeline

๐Ÿ–ผ๏ธ Image Classification

python
clf = pipeline(
    "image-classification",
    model="KoreaPeter/ms-eff-gcvit-deepfake-b0-celeb-df-v2", 
    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}]

๐ŸŽฌ Video Classification

python
clf = pipeline(
    "video-classification",
    model="KoreaPeter/ms-eff-gcvit-deepfake-b0-celeb-df-v2",  
    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'}]

Deep Dive into Model

Part 1: CNN-based Patch Embedding for Spatial Inductive Bias

While traditional Vision Transformers (ViTs) utilize a Linear Projection for patch embedding, our proposed model adopts a CNN-based Patch Embedding module incorporating MBConvBlocks.

  • โ€”Injecting Inductive Bias : Standard ViTs often suffer from a lack of inherent spatial inductive bias, typically necessitating massive datasets to learn fundamental visual structures from scratch. In contrast, our CNN-based module leverages overlapping receptive fields to facilitate information sharing between neighboring patches. By explicitly injecting this spatial bias into the architecture, the model achieves more stable and accelerated convergence during the training process.

Part 2: Long-Short Range Spatial Interaction

We utilizes two distinct types of self-attention to capture both long-range and short-range information across feature maps.

<img src="./window_attention.JPG" width="900">

  • โ€”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

Part 3: Computational Efficiency

  • โ€”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.

Part 4: Multi-Scale Feature Map Fusion

<img src="./dual_branch.gif" width="900">

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.

  • โ€”![](https://img.shields.io/badge/Low_level_Branch-blue?style=flat-square) (_Subtle Artifacts_): High-Resolution feature maps are extracted from early backbone blocks(l_block_idx) to capture like skin texture or boundary artifacts
  • โ€”![](https://img.shields.io/badge/High_level_Branch-red?style=flat-square) (_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.

๐Ÿค Citation

bibtex
@misc{deepguard2026,
  title  = {DeepGuard: Multi-Scale Efficient Global Context Vision Transformer for Deepfake Detection},
  author = {seoyunje},
  year   = {2026},
  url    = {https://github.com/HanMoonSub/DeepGuard}
}