DeepFake Detection System
Upload a video and the app tells you whether it has been manipulated. It scores the frames with a CNN and LSTM model and answers FAKE, REAL or UNCERTAIN, with a confidence figure.
I built the whole path, from the upload to the verdict, in Python with PyTorch and OpenCV, and deployed it as a Streamlit web app.
- Date
- May 2026
- Type
- Personal project, deployed
- Stack
- Python · PyTorch · OpenCV · Streamlit
How it works
From upload to verdict
Upload
A Streamlit page takes an MP4 file, plays it back and saves a copy to work on.
Frames
OpenCV reads the video and keeps every fifth frame, up to 50 of them.
Preprocess
Each frame is resized to 640 × 480 and the middle of the picture is cut out, half its width and half its height. The crop is scaled to 112 × 112 and normalised with ImageNet's mean and standard deviation.
Inference
The model scores the frames one at a time and gives each a probability of being fake and of being real.
Classify
The scores of all the sampled frames become a single answer with a confidence figure, as described below.
Model
ResNeXt-50 with an LSTM
Written in PyTorch. The convolutional part is ResNeXt-50 (32×4d), torchvision's ImageNet model, with its own pooling and classifier layers removed, so it hands on features instead of ImageNet classes. The trained weights are loaded from a file, model.pt.
Frame
Output: 3 × 112 × 112
Colour, 112 × 112 pixels
ResNeXt-50 (32×4d)
Output: 2,048 × 4 × 4
Convolutional layers
Average pooling
Output: 2,048
One number per feature map
LSTM
Output: 2,048
One layer, 2,048 units
Linear
Output: 2
Two scores: fake and real
Softmax
Output: 2
Turns the scores into probabilities
Decision
Three answers, not two
The app sorts the frames' fake probabilities and reads the 15th highest. Above 0.65 the video is FAKE, below 0.35 it is REAL, and in between the app says UNCERTAIN instead of guessing.
- Not one frame
- Reading the 15th-highest score, not the highest, means a few odd frames can't decide the result on their own.
- Confidence
- How far that score sits from 0.5, as a percentage: |p − 0.5| × 200. It never shows more than 95%.
Deployment
Built to deploy
- CPU only
- The model loads onto the CPU, so the app needs no GPU.
- Weights on demand
- The trained weights stay out of the repository. The app downloads them from Google Drive with gdown the first time it starts.
- Loaded once
- Streamlit caches the loaded model, so it isn't loaded again for each upload.
- Pinned versions
- PyTorch 2.9.0 and torchvision 0.24.0 are pinned for the deployment, and OpenCV is the headless build, which runs without a display.
Stack
Built with
Python
The whole app, end to end.
PyTorch
The model and inference, with torchvision for ResNeXt-50 and the image transforms.
OpenCV
Reading the video and resizing its frames.
Streamlit
The web app: upload, playback and the result.
NumPy
Sorting the frame scores.
gdown
Downloading the weights from Google Drive.