Septaneuron
Home Services Work About Contact
Start a Project
← Back to selected work
AI / EXPLAINABLE COMPUTER VISION

A deepfake detector that shows its work.

XAI Forensics pairs a fine-tuned EfficientNet classifier with Grad-CAM heatmaps, turning a plain "real or fake" label into a visual, defendable verdict — built to be verified, not just trusted.

Final Year Project · 3-person team2025
DEEPFAKE
DETECTION

MTCNN → EfficientNet → GRAD-CAM / ONLINE
01 / Introduction

Detection without explanation isn't good enough anymore.

Deepfake detectors are everywhere, but most of them are black boxes — they return a probability and nothing else. XAI Forensics was built to close that gap: a full-stack system that classifies uploaded images and videos as real or fake, and then shows exactly which region of the face drove that decision.

The project pairs a fine-tuned EfficientNet binary classifier with MTCNN face detection and Grad-CAM explainability on the backend, delivered through a Flask API and a React/TanStack Start forensic dashboard designed to feel like an actual investigative tool rather than a demo toy.

Introduction project view

A label without a reason isn't evidence.

Most deepfake classifiers output a single confidence score and stop there. That's a dead end for journalists, forensic analysts, and platforms that need to justify a decision, not just receive one — a black-box "94% fake" verdict can't be cross-examined, cited, or trusted at face value.

The goal was to build a system that keeps the accuracy of a modern CNN classifier while adding a second, independent layer: visual proof of where the model is looking, so a human reviewer can agree or disagree with the reasoning, not just the label.

03 / The solution

Detect the face, classify it, then explain the classification.

Rather than treating detection as a single opaque step, the pipeline separates face localization, binary classification, and explainability into three distinct stages — so each one can be inspected, tested, and improved independently.

01

Locate

MTCNN extracts and aligns the most prominent face from an uploaded image, or from up to 15 evenly sampled frames of an uploaded video.

02

Classify

A EfficientNet backbone, fine-tuned with a custom dropout-linear-ReLU head, scores each detected face and averages the results across all sampled frames for a single verdict.

03

Explain

Grad-CAM hooks into the final convolutional layer of EfficientNet to generate a heatmap over the highest-confidence face, overlaid and returned alongside the verdict.

SOLUTION / PIPELINE FLOWUPLOAD → MTCNN FACE CROP → EFFICIENTNET SCORE → GRAD-CAM HEATMAP → VERDICT
04 / Model architecture & inference

How a single upload becomes a verdict with visual evidence.

FRAME SAMPLING

Video-aware, not just image-aware

Images are analyzed directly; videos are decoded and evenly sampled at up to 15 frames using OpenCV, so a short clip and a longer one both get proportional coverage without processing every frame.

FACE DETECTION

MTCNN with margin-padded crops

Each sampled frame is passed through MTCNN with a 20px margin around the detected face, producing consistently sized 224×224 crops that feed directly into the classifier's expected input shape.

SCORE AGGREGATION

Averaging across frames, not just one

Each face crop gets an independent sigmoid probability from EfficientNet; the final verdict is the mean across all detected faces, giving a video-level judgment instead of a single fragile frame-level guess.

05 / Build process

From a trained checkpoint to a live, explainable API.

01Model loadingEfficientNet checkpoint loaded with a custom classification head, with automatic CUDA/CPU fallback.
02Face pipelineMTCNN wired in for consistent face alignment on both images and sampled video frames.
03ExplainabilityCustom Grad-CAM class registered on EfficientNet's final conv block, with gradient-enabled inference for the top-scoring face.
04API + dashboardFlask /analyze endpoint wired to a React drag-and-drop upload flow with live pipeline-stage animation.
BUILD PROCESS / MODEL LOADING → INFERENCE → GRAD-CAM → API RESPONSEPYTORCH → FLASK → REACT
06 / The dashboard

A forensic interface, not just an upload box.

Built with React, TanStack Start, and Framer Motion, the interface walks the reviewer through each pipeline stage in real time — frame extraction, spatial scan, confidence fusion — before surfacing the verdict, spatial and temporal sub-scores, and the Grad-CAM heatmap overlaid directly on the uploaded media.

07 / Limitations and honest framing

What "explainable" does and doesn't mean here.

TEMPORAL SCORE

Heuristic, not a dedicated network

The "temporal anomaly" score shown in the dashboard is derived from the variance of per-frame predictions rather than a purpose-built temporal model like an LSTM or 3D-CNN — a reasonable proxy, but not true motion-consistency analysis.

NATURAL-LANGUAGE FINDINGS

Illustrative, not independently detected

The listed "findings" (lighting inconsistency, lip-sync drift, frequency artifacts) are selected from a fixed set based on the confidence score rather than each being independently verified by a dedicated detector — useful context, but not standalone evidence.

SINGLE-FACE FOCUS

One face per frame, by design

MTCNN is configured to detect only the most prominent face per frame, so multi-person videos are evaluated on one subject at a time rather than analyzing every face present.

08 / Outcomes and reflections

A working system where the verdict comes with proof, not just a percentage.

XAI Forensics runs end to end: a real upload triggers real MTCNN face detection, real EfficientNet inference, and a real Grad-CAM heatmap — not mocked data. That heatmap is the core deliverable of the project, turning an opaque classifier into something a reviewer can actually inspect and argue with.

The clearest next step is replacing the heuristic temporal score with a genuine sequence model (e.g. a frame-level LSTM or 3D-CNN) and validating the classifier against a public benchmark like FaceForensics++ or Celeb-DF to quantify accuracy beyond the current qualitative testing.

Outcomes and verdict visual evidence
Project details

Built as a NUML final year project, available on GitHub.

PythonPyTorchFlaskMTCNN / facenet-pytorchGrad-CAMReact / TanStack Start
View the project on GitHub
Have a similar problem?

Let's build the next system.

Tell us what you are trying to make clearer, faster, or more capable.

Start a conversation