How srirammayan/deepfake-detection works
Purpose and Entry Points
This repository implements deepfake detection using Vision Transformer (ViT) and CLIP-style vision-language model components. It also intends to make detection records immutable through blockchain and distribute results through SMTP, though the available tree does not expose dedicated blockchain or email integration modules.
Primary execution and validation entry points are:
• main.py
• validate.py
Runtime Configuration
config.py is the central likely source of model, dataset, and runtime parameters consumed by the execution pipeline. Python is the primary runtime, with dependencies declared in:
• requirements.txt
• config.py
Detection Pipeline
The main flow is expected to accept image/video-derived visual input, preprocess it into model-ready tensors, execute deepfake classification, and report a result.
Core stages are represented by:
• Input transformation: preprocess.py
• Main orchestration: main.py
• Evaluation/inference validation: validate.py
The boundary between raw media handling and learned inference is preprocess.py, which should produce normalized inputs compatible with the vision models.
Vision Transformer Backbone
The repository contains a local ViT implementation rather than relying solely on an external model package. The backbone and its supporting mechanisms are separated into:
• Transformer model definition: vision_transformer.py
• Shared transformer utilities: vision_transformer_utils.py
• Supporting model pieces: vision_transformer_misc.py
This layer is the primary learned visual-feature extraction boundary. It converts preprocessed image patches into contextual token or embedding representations used by detection logic.
CLIP Model Layer
CLIP-related modules provide an additional multimodal or pretrained embedding path:
• CLIP interface/loading logic: clip.py
• CLIP model definitions: clip_models.py
These files form a distinct model boundary from the native ViT implementation. main.py can select or combine these representations for deepfake classification, while preprocessing must satisfy each model’s expected image format.
Region-Aware Analysis
region_awareness.py indicates a specialized stage that focuses inference on image regions rather than treating every image uniformly. It likely consumes visual embeddings or feature maps from the ViT/CLIP layers and produces region-sensitive signals that improve detection of localized GAN artifacts.
Relevant paths:
• region_awareness.py
• vision_transformer.py
• clip_models.py
Result Handling and External-Service Intent
The README specifies two post-detection concerns: immutable blockchain records and SMTP result delivery. No explicit service adapters, smart-contract code, credentials modules, or mail clients appear in the tree. Therefore, these integrations are either incomplete, embedded in orchestration code, or expected to be supplied externally.
The likely control boundary is:
• Model result generation in main.py
• Result checking/reporting in validate.py
Any production integration should keep blockchain persistence and SMTP delivery outside the model modules so inference remains usable without external network dependencies.
Main entry points: main.py Main Orchestrator · vision_transformer.py Local ViT Backbone · preprocess.py Media Preprocessing · region_awareness.py Region-Aware Analysis
Components 14
Runtime
- Dependencies
requirements.txt - Runtime Config · Model, dataset, and runtime parameters.
config.py
Vision Models
- Local ViT Backbone · Extracts contextual visual token or embedding features.
vision_transformer.py - ViT Utilities
vision_transformer_utils.py - ViT Components
vision_transformer_misc.py - CLIP Loader · Loads or exposes the CLIP-style vision-language path.
clip.py - CLIP Models
clip_models.py
Detection Pipeline
- Main Orchestrator · Runs preprocessing, model inference, and result generation.
main.py - Validation · Checks or reports inference results.
validate.py - Media Preprocessing · Converts visual input into normalized model tensors.
preprocess.py - Region-Aware Analysis · Produces localized signals for deepfake artifacts.
region_awareness.py - Detection Result
External-Service Intent
No dedicated integration modules are exposed.
- Blockchain Record · Intended immutable result persistence; adapter is not exposed.
- SMTP Delivery · Intended result delivery; mail client is not exposed.
Connections 16
- Dependencies → Main Orchestrator: provides dependencies
- Runtime Config → Main Orchestrator: configures
- Runtime Config → Validation: configures
- Main Orchestrator → Media Preprocessing: prepares input
- Media Preprocessing → Local ViT Backbone: normalized tensors
- Media Preprocessing → CLIP Loader: model-ready images
- ViT Utilities → Local ViT Backbone: supports
- ViT Components → Local ViT Backbone: supports
- CLIP Loader → CLIP Models: loads
- Local ViT Backbone → Region-Aware Analysis: visual features
- CLIP Models → Region-Aware Analysis: visual embeddings
- Region-Aware Analysis → Detection Result: region-sensitive signal
- Main Orchestrator → Detection Result: classifies and reports
- Detection Result → Validation: checked by
- Detection Result → Blockchain Record: intended persistence
- Detection Result → SMTP Delivery: intended delivery