
Artwork by Elena Z.
Official implementation of the paper "AI-Generated Video Detection via Perceptual Straightening", NeurIPS 2025.
Figure 1: The ReStraV method. Video frames are processed by a self-supervised encoder (DINOv2) to get embeddings. In this representation space, natural videos trace "straighter" paths than AI-generated ones. The trajectory's geometry, especially its curvature, serves as a powerful signal for a lightweight classifier to distinguish real from fake.
Important (local setup knobs): several scripts include hard-coded values for
device(e.g.cuda:1),batch_size,num_workers, paths, and download worker counts.
You will likely need to open the files and change these values to match your machine (GPU index, RAM/VRAM, CPU cores, filesystem layout).
Core idea:
1. Sample a short clip from each video (default: ~2 seconds, 24 frames).
2. Encode frames with a pretrained vision backbone (DINOv2 ViT-S/14 via torch.hub).
3. Treat the per-frame embeddings as a trajectory in representation space.
4. Compute temporal geometry features: stepwise distances and curvature/turning angles across time.
5. Train a lightweight classifier (an MLP) on a 21-D feature vector per video.
6. Use the trained model to predict whether a new video is REAL or FAKE.
dinov2_features.py — video decoding + DINOv2 embedding extraction + 21-D feature computationtrain.py — trains the MLP classifier; saves model.pt, mean.npy, std.npy, best_tau.npydemo.py — Gradio demo (upload video or paste URL; uses yt-dlp to download)DATA/ — data + helper scripts (download/extract features) and generated artifactsThe feature builder in dinov2_features.py computes:
d[0:7]theta[0:6]μ_d, min_d, max_d, var_dμ_θ, min_θ, max_θ, var_θTotal: 7 + 6 + 8 = 21 features per video.
git clone https://github.com/ChristianInterno/ReStraV.git
cd ReStraV
````
### 2) Install dependencies
```bash
pip install -r requirements.txt
example/ subset from Hugging Face)python DATA/download_training_data.py
ref_file_paths.txt list.tar files into FAKE/Things you may need to edit inside the script:
MAX_WORKERS (default may be too high for your network / OS)TIMEOUTpython DATA/extract_training_features.py
This writes an HDF5 file:
path (string)label (int; 1=real, 0=fake)features (float; shape [N, 21])Things you may need to edit inside this script:
batch_sizedevicepython train.py
mean.npy and std.npy)τ* maximizing F1 on the training settest_predictions_all.csvmodel.ptThings you may need to edit inside train.py:
devicebatch_sizenum_workersepochs, learning rate, hidden sizesOutputs written in the working directory by default:
model.ptmean.npystd.npybest_tau.npytest_predictions_all.csvOnce you have model.pt, mean.npy, std.npy, and best_tau.npy in the repo root:
python demo.py
The demo supports:
yt-dlp into a temp folderIf you find our work useful in your research, please consider citing our paper:
@inproceedings{
interno2025aigenerated,
title={{AI}-Generated Video Detection via Perceptual Straightening},
author={Christian Intern{\`o} and Robert Geirhos and Markus Olhofer and Sunny Liu and Barbara Hammer and David Klindt},
booktitle={The Thirty-ninth Annual Conference on Neural Information Processing Systems},
year={2025},
url={https://openreview.net/forum?id=LsmUgStXby}
}
This research was partly funded by Honda Research Institute Europe and Cold Spring Harbor Laboratory. We would like to thank Eero Simoncelli for insightful discussions and feedback, as well as all our colleagues from Google DeepMind, the Machine Learning Group at Bielefeld University, Honda Research Institute for the insightful discussions and feedback.
All code in this repository was contributed by Sam Pagon (@sampagon).
$ claude mcp add ReStraV \
-- python -m otcore.mcp_server <graph>