diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 82a347bb72d55e953b2eca1befa52a8f9562f16a..138fade0ffd57dae5bf388620dc79338f41166e2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,6 +31,8 @@ jobs: python-version: "3.11" # Pure-stdlib check: validates every submissions/*.json and that LEADERBOARD.md is current. - run: python benchmark/leaderboard.py --check + # Pure-stdlib check: SynthScope's own submissions still match their repro/bench_results evidence. + - run: python benchmark/seed_reference_results.py --check lint: name: Ruff (errors only) diff --git a/.gitignore b/.gitignore index c390262f961697fcc0632ec286101227a18a721f..f60874632de56695a5902a89bb0c4ded825d7a28 100644 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,6 @@ dist/ # generator benchmark runs: keep manifest/results/RESULTS.md, not the (large) image sets benchmark/generator_runs/*/real/ benchmark/generator_runs/*/fake/ + +# Subagent-driven-development workspaces (local only) +.superpowers/ diff --git a/AGENTS.md b/AGENTS.md index fe1c0e3df699777aaa7d27c0de2c6978b81218cf..900ae704fc4533e79226bf64d658dd4cb8fd1e22 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -1,5 +1,80 @@ -# Codex Project Rules +# Working with SynthScope (guide for coding agents) -- For this SynthScope project, always run Python/project commands inside the `SynthScope` conda environment, for example: - `/home/ssalehi/miniconda3/bin/conda run -n SynthScope `. -- For this SynthScope project, discuss the intended approach and changes first. Only apply file/code changes after the user explicitly asks to run or make the changes. +SynthScope wraps published AI-generated image and video detectors behind one registry, one inference engine and one +benchmark harness. This file tells coding agents (Claude Code, Codex, Copilot, ...) how to use and extend it. Humans: +start with [README.md](README.md). + +## Setup + +```bash +pip install -e . # library + CLI; extras: ".[web]" web demo, ".[train]" training, ".[dev]" tests/lint +``` + +- Install the PyTorch build that matches the machine's CUDA first. `clip` and `fat_former` also need OpenAI CLIP: + `pip install git+https://github.com/openai/CLIP.git`. +- Weights are read from `$SYNTHSCOPE_CKPT_DIR/.pth` (default `~/.cache/synthscope/checkpoints`). Each detector's + `models///README.md` links the official download. Training-free detectors (`d3`, `split`, `stall`) + need no checkpoint. + +## Run a detector + +```python +import synthscope +synthscope.list_models() # detector keys + whether their weights are present +det = synthscope.load("npr") # any key from list_models() +det.predict("photo.png") # {'fake_probability': ..., 'verdict': 'fake' | 'real', ...} +``` + +```bash +synthscope list +synthscope detect photo.png --model npr --json +``` + +Pass a file path or bytes rather than an already-decoded image when you can: some detectors' official preprocessing +depends on the source format (e.g. a PNG is re-saved as JPEG before scoring), and the loaders record it. + +## Evaluate on a benchmark + +```bash +python benchmark/bench_eval.py --model npr --dataset synthwildx # downloads + organises the dataset if needed +python benchmark/bench_eval.py --help # protocols (--benchmark), --ckpt, --model-config, ... +python benchmark/bench_eval_video.py --help # video detectors +``` + +Results go to `repro/bench_results/.json` and one line in `repro/MASTER_RESULTS.jsonl`. Report numbers only from +those files, and state the protocol (subsets, threshold, metric) with every number. + +## Add a detector + +Follow [docs/ADD_DETECTOR.md](docs/ADD_DETECTOR.md) exactly. In short: + +- `models///` with the model class (vendor official code with its licence header) and a `README.md`; +- `conf/model//.yaml` whose `eval_transform_list` is the official test-time preprocessing; +- the dispatch in both `trainer.py` and `interface/backend/engine.py` (`_build_model`); +- a `ModelSpec` in `interface/backend/registry.py` using `model_transform()`; +- `tests/test__smoke.py` and a `LICENSES.md` row. + +Prove fidelity before claiming results: identical state dict and identical outputs to the official code on raw files, +then reproduce the paper's tables with `bench_eval.py` on full data. + +## Checks before a pull request + +```bash +python -m compileall -q synthscope interface models benchmark *.py +ruff check synthscope +python benchmark/leaderboard.py --check +python tests/test_model_transforms.py # plus tests/test__smoke.py for any detector you touched +``` + +## Conventions + +- Imports at the top of the file; helpers and classes at module level; short comments in the style of the surrounding + code. +- Never commit weights, datasets, `.env` or API keys. Third-party detectors, weights and datasets keep their own + licences ([LICENSES.md](LICENSES.md)); do not redistribute weights whose licence does not allow it. +- Keep the official preprocessing exact: a transform that "looks equivalent" can move a benchmark by several points. + +## Citing + +If SynthScope helped the user's work, point them to [CITATION.cff](CITATION.cff) (GitHub's "Cite this repository" +button) and to the original papers of the detectors they used. diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000000000000000000000000000000000000..43c994c2d3617f947bcb5adf1933e21dabe46bb5 --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1 @@ +@AGENTS.md diff --git a/LEADERBOARD.md b/LEADERBOARD.md index 1b72d0bc12d56e86e94d48010c61d2b080537183..eea1821c322507043029dba0cbfb3d478c0070bc 100644 --- a/LEADERBOARD.md +++ b/LEADERBOARD.md @@ -4,35 +4,35 @@ _Auto-generated by `benchmark/leaderboard.py` — do not edit by hand._ See [ben This is the **standardized, versioned** table: a few tracks with a fixed protocol that anyone can submit to. The web page's **Leaderboard** tab is broader (every paper benchmark, 30+ groups) and the repo supports many more datasets, which download and organize themselves: see [docs/BENCHMARKS.md](docs/BENCHMARKS.md). -Metrics are percentages. **mAP** = mean AP over generators. Each track is ranked by its primary metric (in bold). +Metrics are percentages. **mAP** = mean AP over generators. Each track is ranked by its primary metric (in bold). Unverified rows are listed after the ranked ones, without a rank. -## ForenSynths — image (ProGAN-trained, cross-generator) +## ForenSynths-8 (8 generators) — image (ProGAN-trained, cross-generator) | Rank | Method | Eval | Acc | **mAP** | AP | AUROC | Verified | Notes | | --- | --- | --- | --- | --- | --- | --- | --- | --- | -| 1 | FatFormer | official-weights | 98.39 | 99.70 | — | — | ✓ | ForenSynths-8 subset; official released weights | -| 2 | CO-SPY (official weights) | official-weights | 95.12 | 98.71 | — | — | ✓ | ForenSynths-8; vendored official architecture | -| 3 | UnivFD / CLIP | frozen-probe | — | 97.20 | — | 97.00 | ✓ | ForenSynths; frozen CLIP ViT-L/14 probe (ProGAN) | -| 4 | CO-SPY (from scratch) | from-scratch | — | 96.98 | — | 96.79 | ✓ | ForenSynths; SynthScope re-implementation trained on ProGAN | -| 5 | CNNDetection | from-scratch | — | 96.80 | — | 96.60 | ✓ | ForenSynths; ResNet-50 fine-tune (ProGAN) | -| 6 | DINOv2 probe | frozen-probe | — | 95.03 | — | 94.86 | ✓ | ForenSynths; frozen DINOv2 ViT-L/14 probe | -| 7 | SAFE | from-scratch | — | 94.13 | — | 93.68 | ✓ | ForenSynths; trained from scratch | -| 8 | AIDE | official-weights | — | 92.08 | — | — | ✓ | ForenSynths-8; mAP reproduces, acc@0.5 miscalibrated (single-view vs official 5-view DCT) | -| 9 | NPR | official-weights | 91.83 | 87.09 | — | — | ✓ | ForenSynths-8; official ProGAN weights | - -## GenImage SD-v1.4 — image +| 1 | FatFormer | official-weights | 98.39 | 99.70 | — | 99.57 | ✓ | ForenSynths-8; official 4-class ProGAN weights (the served fat_former.pth) | +| 2 | CO-SPY (official weights) | official-weights | 94.64 | 98.50 | — | 98.80 | ✓ | ForenSynths-8; official CO-SPY ProGAN checkpoint in the vendored official architecture (not the served co_spy.pth) | +| 3 | SAFE | from-scratch | 95.11 | 97.79 | — | 97.86 | ✓ | ForenSynths-8; trained in SynthScope on ProGAN, 40-epoch crop recipe (safe_full_v2/model_38, the served safe.pth) | +| 4 | UnivFD / CLIP | frozen-probe | 88.28 | 97.22 | — | 97.11 | ✓ | ForenSynths-8; frozen CLIP ViT-L/14 + linear head trained in SynthScope on ProGAN (the served clip.pth) | +| 5 | AIDE | official-weights | 88.38 | 96.03 | — | 95.60 | ✓ | ForenSynths-8; official ProGAN weights progan_train.pth, vendored official eval (native-resolution 5-view DCT); the served aide.pth is the SD-v1.4 release | +| 6 | CNNDetection | from-scratch | 76.36 | 94.42 | — | 94.42 | ✓ | ForenSynths-8; ImageNet ResNet-50 fine-tuned in SynthScope on ProGAN (the served cnn.pth) | +| 7 | NPR | official-weights | 92.30 | 94.22 | — | 96.08 | ✓ | ForenSynths-8; official ProGAN weights NPR.pth (the served npr.pth) | +| 8 | DINOv2 probe | frozen-probe | 78.98 | 90.61 | — | 90.83 | ✓ | ForenSynths-8; frozen DINOv2 ViT-L/14 + linear head trained in SynthScope on ProGAN (the served dinov2.pth) | +| — | CO-SPY (from scratch) | from-scratch | 89.21 | 97.18 | — | 97.62 | | Unverified: ForenSynths-8 score of the co_spy.pth of 2026-06-04, then labelled ProGAN-trained, whose training run is not recorded; not the served co_spy.pth (a GenImage SD-v1.4 retrain, not scored here) | + +## GenImage SD-v1.4 — image (diffusion-trained; in-distribution only for SD-v1.4-trained rows) | Rank | Method | Eval | Acc | mAP | AP | **AUROC** | Verified | Notes | | --- | --- | --- | --- | --- | --- | --- | --- | --- | -| 1 | VIB-Net | from-scratch | — | 99.33 | — | 99.33 | ✓ | GenImage SD-v1.4 single real/fake pool (mAP == AUROC by construction) | -| 2 | SPAI (official weights) | official-weights | — | — | 94.01 | 98.45 | ✓ | GenImage SD-v1.4; vendored official architecture, fixed-res 2x2x224 | -| 3 | SPAI (from scratch) | from-scratch | — | — | — | 97.66 | ✓ | DMID Latent-Diffusion vs COCO; SynthScope fixed-resolution variant | +| 1 | VIB-Net | from-scratch | 99.29 | 99.98 | — | 99.98 | ✓ | GenImage SD-v1.4, 6000 real + 6000 fake; trained in SynthScope on GenImage SD-v1.4 with the reconstructed recipe (job 267846, the served vib_net.pth); one generator, so mAP = AP | +| 2 | SPAI (from scratch) | from-scratch | 97.17 | 99.93 | — | 99.94 | ✓ | 300+300 subsample; trained on latent-diffusion (LDM) data, not SD-v1.4. GenImage SD-v1.4; trained in SynthScope with the official recipe (LDM vs COCO/LSUN, job 267192, epoch 8 by validation loss), native resolution | +| 3 | SPAI (official weights) | official-weights | 95.67 | 99.22 | — | 99.57 | ✓ | 300+300 subsample; trained on latent-diffusion (LDM) data, not SD-v1.4. GenImage SD-v1.4 (the run's per-generator cap); official weights remapped into the SynthScope class, native resolution (the served spai.pth) | ## GenVideo-Val — video (all 10,000 MSR-VTT reals vs every fake, per generator) | Rank | Method | Eval | Acc | mAP | AP | **AUROC** | Verified | Notes | | --- | --- | --- | --- | --- | --- | --- | --- | --- | | 1 | SPLIT | training-free | 99.41 | 99.79 | — | 99.97 | ✓ | Training-free X-CLIP patch roughness x motion incoherence; Acc at the real-only FPR-1% calibration | -| 2 | D3 | training-free | 95.53 | 68.84 | — | 98.45 | ✓ | Training-free X-CLIP 2nd-order feature volatility (official preprocessing) | -| 3 | STALL | training-free | 56.89 | 32.05 | — | 82.59 | ✓ | Training-free DINOv3 spatio-temporal likelihood under VATEX real-video statistics | -| 4 | ReStraV | frozen-probe | 30.01 | 33.60 | — | 43.06 | ✓ | Frozen DINOv2 trajectory geometry + MLP trained on GenVidBench; does not transfer to GenVideo-Val (AUROC below 50) | +| 2 | D3 | training-free | 95.53 | 68.84 | — | 98.45 | ✓ | Training-free X-CLIP 2nd-order feature volatility (official preprocessing). AP here is fake-as-positive against all 10k reals; the README's 99.0 AP is the paper protocol (real-as-positive, first 1000 clips) | +| 3 | STALL | training-free | 56.89 | 32.05 | — | 82.59 | ✓ | Training-free DINOv3 spatio-temporal likelihood under VATEX real-video statistics. Full run; the README's 83.5 AUROC is the June subsample run | +| 4 | ReStraV | frozen-probe | 30.01 | 33.60 | — | 43.06 | ✓ | Frozen DINOv2 trajectory geometry + MLP trained in SynthScope (the served restrav.pth; its training set is not recorded); does not transfer to GenVideo-Val (AUROC below 50) | diff --git a/LICENSES.md b/LICENSES.md index ecff337d6a02e152dd65f1078b60cd4465b9912f..296af4611ae54cd798a14f125e4f287bae9e0719 100644 --- a/LICENSES.md +++ b/LICENSES.md @@ -20,30 +20,33 @@ third-party components, and every **pretrained checkpoint / backbone** SynthScop | `model_type` | Method (venue) | Upstream code | Code license | Released weights SynthScope can load | Weights license | | --- | --- | --- | --- | --- | --- | -| `cnn` | CNNDetection (CVPR'20) | PeterWang512/CNNDetection | ⚠ verify | ProGAN-trained (SynthScope-trained here) | ⚠ verify | -| `clip` | UnivFD (CVPR'23) | WisconsinAIVision/UniversalFakeDetect | ⚠ verify | — (SynthScope-trained probe) | n/a | +| `cnn` | CNNDetection (CVPR'20) | PeterWang512/CNNDetection | ⚠ verify | — (SynthScope-trained on ProGAN) | n/a (backbone: see below) | +| `clip` | UnivFD (CVPR'23) | WisconsinAIVision/UniversalFakeDetect | MIT (repo `LICENSE`) | — (SynthScope-trained probe) | n/a (backbone: see below) | | `npr` | NPR (CVPR'24) | chuangchuangtan/NPR-DeepfakeDetection | no license in the repo; **written permission** from the first author (C. Tan, 2026-10-11) to include SynthScope's implementation under Apache-2.0, with credit and citation | **official** ProGAN weights (`NPR.pth`) | same permission: benchmarking and the free, non-commercial public demo, crediting the paper and repository | -| `fat_former` | FatFormer (CVPR'24) | Michel-liu/FatFormer (verify) | ⚠ verify | **official** weights | ⚠ verify | -| `aide` | AIDE (ICLR'25) | ⚠ verify (official repo) | ⚠ verify | **official** weights | ⚠ verify | -| `co_spy` | CO-SPY (CVPR'25) | ⚠ verify (official repo) | ⚠ verify | **official** weights | ⚠ verify | -| `spai` | SPAI (CVPR'25) | mever-team/spai (verify) | ⚠ verify | **official** weights | ⚠ verify | -| `vib_net` | VIB-Net (CVPR'25) | ⚠ verify (official repo) | ⚠ verify | — (SynthScope-trained) | n/a | +| `fat_former` | FatFormer (CVPR'24) | Michel-liu/FatFormer | Apache-2.0 (repo `LICENSE`) | **official** weights | ⚠ verify | +| `aide` | AIDE (ICLR'25) | shilinyan99/AIDE | MIT (repo `LICENSE`) | **official** weights | ⚠ verify | +| `co_spy` | CO-SPY (CVPR'25) | Megum1/CO-SPY | ⚠ verify | — (SynthScope-trained on GenImage SD v1.4; the official checkpoints are used only as references) | n/a (backbones: see below) | +| `spai` | SPAI (CVPR'25) | mever-team/spai | Apache-2.0 (repo `LICENSE`) | **official** weights | Apache-2.0 (repo README: code and weights); its MFM backbone is under the S-Lab License (below) | +| `vib_net` | VIB-Net (CVPR'25) | ⚠ verify (official repo) | ⚠ verify | — (SynthScope-trained) | n/a (backbone: see below) | +| `vib_net_official` | VIB-Net, official model (CVPR'25) | ⚠ verify (official repo) | ⚠ verify | **official** checkpoints (restricted Google Drive; access requested), or a SynthScope-trained one | ⚠ verify; not redistributed | | `safe` | SAFE (KDD'25) | ⚠ verify (official repo) | ⚠ verify | — (SynthScope-trained) | n/a | -| `pgc` | PGC | ⚠ verify (official repo) | ⚠ verify | — (SynthScope-trained) | n/a | +| `pgc` | PGC | xiaoyu6868/PGC | ⚠ verify | **official** ProGAN checkpoint (`PGC_train_progan_ckpt.pth`, loaded as `pgc.pth`) | ⚠ verify | | `cure` | CuRe (arXiv 2609.14316) | manic-cui/CuRe | Apache-2.0 (repo `LICENSE`) | **official** 25 MB adapter (`cure_adapter.pt`, loads as `cure.pth`) | Apache-2.0 (shipped in the repo; verify before redistributing) | | `d3qe` | D3QE (ICCV'25) | Zhangyr2022/D3QE | MIT (repo `LICENSE`); `official/` vendors its network code — see the file headers | **official** checkpoint (`model_epoch_best.pth` from HF `Yanran21/D3QE`, loads as `d3qe.pth`) | MIT (HF model card license tag) | | `ltf` | LTF (arXiv 2611.04529) | HuiGuanLab/LTF | MIT (repo `LICENSE`, `NOTICE`); `official/` vendors `ltf/model.py`, `ltf/token_ops.py`, `ltf/mil/*.py` and `ltf/data/images.py` with the license in `official/LICENSE` — see the file headers | **official** GenImage checkpoint (`weights/epoch_20.pth` from HF `MuskAI/LTF-v3.3` @ `a2a2e29c`, loads as `ltf.pth`) | **no license tag** on the HF model card (`MuskAI/LTF-v3.3`, checked 2026-11-05); only the code repo is MIT. The weights are not uploaded to the zoo and `ltf` is not on the Space until the authors confirm the weights terms | | `dda` | DDA (NeurIPS'25) | roy-ch/Dual-Data-Alignment | Apache-2.0 (repo `LICENSE`); `official_arch.py` vendors its `lora.py` — see its header | **official** checkpoint (`DDA_ckpt.pth` from HF `Junwei-Xi/Dual-Data-Alignment`, loads as `dda.pth`) | Apache-2.0 (HF model card license tag) | | `omniaid`, `omniaid_v1`, `omniaid_genimage` | OmniAID (arXiv 2511.08423) | yunncheng/OmniAID | MIT (README badge; no LICENSE file in the repo); `official_arch.py` vendors `models/OmniAID.py` — see its header | **official** checkpoints (`ckpt/checkpoint_omniaid_{v2,v1,genimage_sd14}.pth` from HF `Yunncheng/OmniAID`, loaded as `.pth`) | MIT (HF model card license tag) | | `bfree` | B-Free (CVPR'25) | grip-unina/B-Free | GRIP-UNINA license: informational and **nonprofit use only** (notices kept); `official_arch.py` vendors `code/networks/wrapper5crops.py` — see its header | **official** checkpoint (`BFREE_dino2reg4/model_epoch_best.pth` from grip.unina.it, loaded as `bfree.pth`) | GRIP-UNINA license (nonprofit use only) | +| `mirror` | MIRROR (NeurIPS'26) | handsome-rich/MIRROR | **unclear**: the README badge says MIT, but the repo has no LICENSE file (the badge's link 404s); `official_arch.py` vendors `models/mirror.py`, and `preprocess.py` vendors the eval transform of `data/datasets.py` (see the file headers) | **official** phase-2 checkpoint (`checkpoint-h-cur.pth`, authors' Google Drive, loaded as `mirror.pth`; it contains the DINOv3 ViT-H+ weights) | **unclear** (no licence stated); not redistributed: not in the model zoo or on the Space | +| `vina`, `vina_video` | VINA (arXiv 2605.21977) | mgiant/VINA | **unclear**: the repo (commit 225d331) has no LICENSE file and the README states no licence; `official_arch.py` vendors the `DINOv3` class of `models/DINOv3.py` (see its header) | **official** checkpoint (`VINA_DINOv3-L_140k+DDA.pth` from HF `mgiant/VINA_checkpoints` @ f258349, loaded as `vina.pth`; it contains the DINOv3 ViT-L/16 weights) | **unclear** (no licence tag on the HF repo, empty model card); not redistributed: not in the model zoo or on the Space | | `moejepa` | MoE-JEPA (ECCV'26 W) | ALCOR-Lab-DIAG/MoE-JEPA | MIT; `official_arch.py` vendors the blocks of `model/model.py` — see its header | **official** checkpoint (`moejepa_sidset.safetensors`, v1.0 GitHub release, loaded as `moejepa.safetensors`) | MIT | -| `effort`, `effort_chameleon` | Effort (ICML'25) | YZY-stack/Effort-AIGI-Detection | CC BY-NC 4.0 (README badge); `official_arch.py` vendors the SVD-residual layers of `DeepfakeBench/training/detectors/effort_detector.py` — see its header | **official** checkpoints (`effort_clip_L14_trainOn_{sdv14,chameleon}.pth` from the authors' Google Drive, loaded as `.pth`) | CC BY-NC 4.0 (non-commercial) | +| `effort`, `effort_chameleon` | Effort (ICML'25) | YZY-stack/Effort-AIGI-Detection | CC BY-NC 4.0 (README badge); `official_arch.py` vendors the SVD-residual layers of `DeepfakeBench/training/detectors/effort_detector.py` — see its header | **official** checkpoints (`effort_clip_L14_trainOn_{sdv14,chameleon}.pth` from the authors' Google Drive, loaded as `.pth`); the SynthScope-trained ProGAN model (config `image/effort_ufd`) is not a served key and stays on the shared filesystem | CC BY-NC 4.0 (non-commercial) | | `dinov2` | DINOv2 probe | facebookresearch/dinov2 | Apache-2.0 (verify) | DINOv2 backbone | Apache-2.0 (verify) | | `dinov3` | DINOv3 probe | facebookresearch/dinov3 | DINOv3 License (gated) | DINOv3 backbone | **gated** — DINOv3 License | -| `adapted_dino` | Adapter-tuned DINOv2 (SynthScope) | this repo | Apache-2.0 | — (SynthScope-trained) | n/a | -| `d3` | D3 (ICCV'25) | ⚠ verify (official repo) | ⚠ verify | training-free (no weights) | n/a | +| `adapted_dino` | Adapter-tuned DINOv2 (SynthScope) | this repo | Apache-2.0 | — (SynthScope-trained) | n/a (backbone: see below) | +| `d3` | D3 (ICCV'25) | Zig-HS/D3 | MIT (repo `LICENSE`) | training-free (no weights) | n/a | | `split` | SPLIT (ECCV'26) | mldljyh/SPLIT | MIT (LICENSE added 2026-11-02); no code copied: `models/video/split/split.py` is SynthScope's own implementation of the paper's equations | training-free (no weights) | n/a | -| `restrav` | ReStraV | ⚠ verify (official repo) | ⚠ verify | — (SynthScope-trained) | n/a | +| `restrav` | ReStraV | ⚠ verify (official repo) | ⚠ verify | — (SynthScope-trained) | n/a (backbone: see below) | | `stall` | STALL (CVPR'26) | OmerBenHayun/STALL | CC BY-NC 4.0 (`LICENSE.txt`) | training-free; needs the DINOv3 backbone (and ships the VATEX calibration `.npz`) | DINOv3 License (gated download) | ## Backbones / foundation models (downloaded on first use) @@ -54,9 +57,10 @@ third-party components, and every **pretrained checkpoint / backbone** SynthScop | OpenAI CLIP ViT-L/14@336 (HF `openai/clip-vit-large-patch14-336`) | `omniaid`, `omniaid_v1`, `omniaid_genimage` | MIT | | OpenCLIP (ConvNeXt-XXL, LAION) | `aide` | code MIT; weights per LAION / model card (verify) | | DINOv2 (ViT-L/14, ViT-S/14) | `dinov2`, `adapted_dino`, `restrav`, `dda` | Apache-2.0 (verify) | -| DINOv3 (ViT-L/16) | `dinov3`, `stall` | **gated** download — DINOv3 License (use and redistribution allowed with the license and attribution; trade-control restrictions) | +| DINOv3 (ViT-L/16) | `dinov3`, `stall`, `vina` / `vina_video` (its weights are inside the VINA checkpoint; the gated HF `facebook/dinov3-vitl16-pretrain-lvd1689m` is only needed for training) | **gated** download — DINOv3 License (use and redistribution allowed with the license and attribution; trade-control restrictions) | +| DINOv3 ViT-H+/16 (HF `facebook/dinov3-vith16plus-pretrain-lvd1689m`) | `mirror` (its weights are inside the MIRROR checkpoint; the gated download is only needed for training) | **gated** - DINOv3 License | | SigLIP | `co_spy` | Apache-2.0 (verify) | -| MFM ViT-B/16 | `spai` | ⚠ verify | +| MFM ViT-B/16 | `spai` | S-Lab License 1.0 (non-commercial use; shipped as `mfm/LICENSE_S-Lab.txt` in the weights repo) | | Stable Diffusion VAE | `co_spy` | CreativeML Open RAIL-M (verify) | | V-JEPA 2 ViT-L (`facebook/vjepa2-vitl-fpc64-256`) | `moejepa` | MIT (HF model card) | | X-CLIP B/16 (`microsoft/xclip-base-patch16`) | `d3`, `split` | MIT (HF model card) | diff --git a/accelerate_config_ddp.yaml b/accelerate_config_ddp.yaml new file mode 100644 index 0000000000000000000000000000000000000000..fba14ec4e0aefaba92a7758376ac45fb7286cbc5 --- /dev/null +++ b/accelerate_config_ddp.yaml @@ -0,0 +1,15 @@ +# Plain multi-GPU data parallel (DDP), fp32: no DeepSpeed, hence no gradient clipping. For the recipes whose official code +# trains without clipping (e.g. experiments/image/fat_former.sh); accelerate_config.yaml is the DeepSpeed ZeRO-2 config +# with clipping 1.0. num_processes is set by `accelerate launch --num_processes`. +compute_environment: LOCAL_MACHINE +distributed_type: MULTI_GPU +mixed_precision: "no" +num_machines: 1 +num_processes: 1 +machine_rank: 0 +main_training_function: main +rdzv_backend: static +same_network: true +use_cpu: false +downcast_bf16: "no" +dynamo_backend: "NO" diff --git a/benchmark/README.md b/benchmark/README.md index ae7749d86dcc3cb232920068d6e64222f72ff2f5..43dbc71457b71e229ca5004e88304dce67214e90 100644 --- a/benchmark/README.md +++ b/benchmark/README.md @@ -15,8 +15,8 @@ from the submission files in [`submissions/`](submissions/) — see [LEADERBOARD | Track id | Modality | Test set | Train signal | Primary metric | | --- | --- | --- | --- | --- | -| `forensynths` | image | ForenSynths real/fake, scored **per generator** | ProGAN-trained (cross-generator generalization) | **mAP** (mean AP over generators) | -| `genimage-sdv1.4` | image | GenImage SD-v1.4 real/fake | in-distribution diffusion | **AUROC** | +| `forensynths` | image | ForenSynths-8: the 8 GAN test sets (ProGAN, StyleGAN, StyleGAN2, BigGAN, CycleGAN, StarGAN, GauGAN, Deepfake), real/fake, scored **per generator** | ProGAN-trained (cross-generator generalization) | **mAP** (mean AP over generators) | +| `genimage-sdv1.4` | image | the SD-v1.4 subset of the GenImage test set, real/fake (one generator, so mAP = AP; each row's notes give its image count) | diffusion-trained (in-distribution only for SD-v1.4-trained rows) | **AUROC** | | `genvideo-val` | video | GenVideo-Val: all 10,000 MSR-VTT reals against every fake, per generator | mixed | **AUROC** (AP with fake as positive is unstable here: as few as 56 fakes against 10,000 reals) | **These three tracks are only the start.** The repo supports 20 image and 8 video benchmark datasets (see the table in the @@ -38,8 +38,12 @@ over generators at threshold 0.5. 3. **Declare provenance** via `evaluation`: `official-weights`, `from-scratch`, `frozen-probe`, `training-free`, or `external` (numbers produced outside SynthScope). 4. **Verified numbers trace to a run.** `verified: true` means the result came from a logged SynthScope - evaluation (set `source` to the log/run path). Reference seed entries are transcribed from the - repo's reproduction table. + evaluation of the registry-default checkpoint at the date given (or the checkpoint the row names); set + `source` to the log/run path. SynthScope's own entries + are built by [`seed_reference_results.py`](seed_reference_results.py) from the committed + `repro/bench_results/*.json` of each run, with the job id in `source`; `--check` confirms they still + match. An entry whose checkpoint cannot be confirmed to fit the track is kept with `verified: false`; + unverified rows are listed unranked, after the ranked ones. ## Data layout diff --git a/benchmark/aggregate_results.py b/benchmark/aggregate_results.py index 94cd30a57b914516e6e49823f00d893fe8dd8700..1529e8d441904fb53386153b92cf4c919c9c793d 100644 --- a/benchmark/aggregate_results.py +++ b/benchmark/aggregate_results.py @@ -1,6 +1,7 @@ """Aggregate the self-recorded bench_eval results into a master reproduced-results table. -Reads every repro/bench_results/.json (latest run per tag), prints a compact summary, writes +Reads every repro/bench_results/.json (latest run per tag; the _superseded/ subfolder is not read, it holds runs +replaced by a corrected rerun, see its README), prints a compact summary, writes repro/RESULTS_TABLE.md (model | weights | benchmark | n_gen | acc / mAP / mAUROC), and supports computing a paper-matching subset mean from a run's per-generator dict: diff --git a/benchmark/bench_eval_video.py b/benchmark/bench_eval_video.py index fb3199147477b42b0036bb1db6ed2d9a3ff7e3c8..40338d8f7f29c081a3e37bb43cada4543a3b3489 100644 --- a/benchmark/bench_eval_video.py +++ b/benchmark/bench_eval_video.py @@ -1,4 +1,4 @@ -"""Unified VIDEO benchmark eval for SynthScope video detectors (d3, restrav, stall). +"""Unified VIDEO benchmark eval for SynthScope video detectors (d3, split, restrav, stall, vina_video). Scores each video through the SAME verified synthscope engine path the web app uses (engine.predict_video_clip -> native clip pipeline + per-model norm + fake-prob), computes @@ -129,7 +129,7 @@ def fake_recall_at_fpr(real_scores, fake_scores): def main(argv=None) -> int: ap = argparse.ArgumentParser() - ap.add_argument("-m", "--model", required=True, choices=["d3", "split", "restrav", "stall"]) + ap.add_argument("-m", "--model", required=True, choices=["d3", "split", "restrav", "stall", "vina_video"]) ap.add_argument("--benchmark", choices=["genvideo", "fakeonly", "pergen"], help="layout (not needed with --dataset)") ap.add_argument("--data", help="benchmark root (not needed with --dataset)") ap.add_argument("--dataset", help="a supported video dataset (genvideo, videophy, vidprom, evalcrafter, ...): downloads " diff --git a/benchmark/evaluate.py b/benchmark/evaluate.py index 1b0fb77cf54652a8feb2429ce12efee37b3bb765..8843f84382a320c953b3fa43c5c5b5cfdb5d9864 100644 --- a/benchmark/evaluate.py +++ b/benchmark/evaluate.py @@ -22,9 +22,10 @@ import json from pathlib import Path import torch -from PIL import Image, ImageFile +from PIL import ImageFile import synthscope +from interface.backend import media ImageFile.LOAD_TRUNCATED_IMAGES = True @@ -74,7 +75,7 @@ def score(det: "synthscope.Detector", paths: list[Path], batch_size: int) -> tor for i in range(0, len(paths), batch_size): batch = [] for p in paths[i:i + batch_size]: - batch.append(spec.transform(Image.open(p).convert("RGB"))) + batch.append(spec.transform(media.open_rgb(p))) # keeps the source-format hint (CuRe, MIRROR) x = torch.stack(batch).to(device) probs.append(det._engine._fake_prob(model, spec, x).detach().float().cpu()) return torch.cat(probs) if probs else torch.empty(0) diff --git a/benchmark/generator_bench.py b/benchmark/generator_bench.py index 62e5bf7a48768e5bfc90ae60115e71a7c3d0be99..5eeb4c9ac046b81c4797846345fd11d4498efad0 100644 --- a/benchmark/generator_bench.py +++ b/benchmark/generator_bench.py @@ -35,6 +35,7 @@ import numpy as np from PIL import Image from interface.backend import generators as G +from interface.backend import media from interface.backend.registry import list_specs IMG_EXT = (".jpg", ".jpeg", ".png", ".webp") @@ -124,8 +125,8 @@ def score(args, real_dir: Path, fake_dir: Path, out: Path) -> list: from sklearn.metrics import average_precision_score, roc_auc_score from interface.backend.engine import get_engine engine = get_engine() - reals = [Image.open(p).convert("RGB") for p in sorted(glob.glob(str(real_dir / "*.png")))] - fakes = [Image.open(p).convert("RGB") for p in sorted(glob.glob(str(fake_dir / "*.png")))] + reals = [media.open_rgb(p) for p in sorted(glob.glob(str(real_dir / "*.png")))] # keeps the PNG hint (CuRe, MIRROR) + fakes = [media.open_rgb(p) for p in sorted(glob.glob(str(fake_dir / "*.png")))] log(f"[score] {len(reals)} real + {len(fakes)} fake") y = np.array([0] * len(reals) + [1] * len(fakes)) keys = args.detectors.split(",") if args.detectors else None diff --git a/benchmark/generator_runs/flux2_klein_4b/RESULTS.md b/benchmark/generator_runs/flux2_klein_4b/RESULTS.md index 6a0e91a781cfc33d8fa166fe41c5ffefb7914591..5ac26832b5525f979b03236ad14a0d39a9f5e668 100644 --- a/benchmark/generator_runs/flux2_klein_4b/RESULTS.md +++ b/benchmark/generator_runs/flux2_klein_4b/RESULTS.md @@ -6,14 +6,14 @@ |---|---|---|---|---|---|---| | 1 | CO-SPY | 99.31 | 99.27 | 98.0 | 99.0 | 3.0 | | 2 | DDA | 99.19 | 99.2 | 93.0 | 90.0 | 4.0 | -| 3 | CuRe | 98.62 | 98.92 | 93.0 | 86.0 | 0.0 | -| 4 | PGC | 97.33 | 96.57 | 53.5 | 7.0 | 0.0 | -| 5 | VIB-Net | 97.16 | 97.27 | 88.0 | 81.0 | 5.0 | -| 6 | OmniAID (GenImage) | 96.8 | 95.77 | 89.5 | 86.0 | 7.0 | -| 7 | OmniAID (v1) | 96.26 | 95.36 | 93.5 | 97.0 | 10.0 | -| 8 | Effort | 96.08 | 95.31 | 85.5 | 81.0 | 10.0 | -| 9 | AIDE | 94.08 | 90.5 | 81.0 | 69.0 | 7.0 | -| 10 | SAFE | 92.04 | 82.32 | 87.0 | 84.0 | 10.0 | +| 3 | CuRe | 99.02 | 99.2 | 94.0 | 88.0 | 0.0 | +| 4 | VIB-Net | 97.16 | 97.27 | 88.0 | 81.0 | 5.0 | +| 5 | OmniAID (GenImage) | 96.8 | 95.77 | 89.5 | 86.0 | 7.0 | +| 6 | OmniAID (v1) | 96.26 | 95.36 | 93.5 | 97.0 | 10.0 | +| 7 | Effort | 96.08 | 95.31 | 85.5 | 81.0 | 10.0 | +| 8 | AIDE | 94.08 | 90.5 | 81.0 | 69.0 | 7.0 | +| 9 | SAFE | 92.04 | 82.32 | 87.0 | 84.0 | 10.0 | +| 10 | PGC | 90.7 | 83.29 | 52.5 | 7.0 | 2.0 | | 11 | NPR | 89.18 | 82.53 | 78.0 | 99.0 | 43.0 | | 12 | OmniAID | 84.95 | 86.48 | 64.5 | 31.0 | 2.0 | | 13 | SPAI | 78.08 | 75.23 | 65.0 | 38.0 | 8.0 | diff --git a/benchmark/generator_runs/flux2_klein_4b/results.json b/benchmark/generator_runs/flux2_klein_4b/results.json index c2e8be6acf1fd40329bfc148127a16a0b7b206cf..296e29daf47914dfc12159b34ffc297a5ff1b334 100644 --- a/benchmark/generator_runs/flux2_klein_4b/results.json +++ b/benchmark/generator_runs/flux2_klein_4b/results.json @@ -24,24 +24,13 @@ { "detector": "cure", "name": "CuRe", - "auroc": 98.62, - "ap": 98.92, - "acc": 93.0, - "fake_detect_rate": 86.0, - "real_false_pos": 0.0, - "mean_p_fake_on_fakes": 0.848, - "mean_p_fake_on_reals": 0.0129 - }, - { - "detector": "pgc", - "name": "PGC", - "auroc": 97.33, - "ap": 96.57, - "acc": 53.5, - "fake_detect_rate": 7.0, + "auroc": 99.02, + "ap": 99.2, + "acc": 94.0, + "fake_detect_rate": 88.0, "real_false_pos": 0.0, - "mean_p_fake_on_fakes": 0.438, - "mean_p_fake_on_reals": 0.2672 + "mean_p_fake_on_fakes": 0.8733, + "mean_p_fake_on_reals": 0.0115 }, { "detector": "vib_net", @@ -109,6 +98,17 @@ "mean_p_fake_on_fakes": 0.7562, "mean_p_fake_on_reals": 0.1425 }, + { + "detector": "pgc", + "name": "PGC", + "auroc": 90.7, + "ap": 83.29, + "acc": 52.5, + "fake_detect_rate": 7.0, + "real_false_pos": 2.0, + "mean_p_fake_on_fakes": 0.4145, + "mean_p_fake_on_reals": 0.2596 + }, { "detector": "npr", "name": "NPR", diff --git a/benchmark/generator_runs/flux2_klein_9b/RESULTS.md b/benchmark/generator_runs/flux2_klein_9b/RESULTS.md index 344e6e99ef91603e07d7e4b5d8a3298a7f5ea111..fc5e729e7a27fc71b94a4ef8cf76ded770933597 100644 --- a/benchmark/generator_runs/flux2_klein_9b/RESULTS.md +++ b/benchmark/generator_runs/flux2_klein_9b/RESULTS.md @@ -6,14 +6,14 @@ |---|---|---|---|---|---|---| | 1 | CO-SPY | 99.34 | 99.3 | 98.0 | 99.0 | 3.0 | | 2 | DDA | 98.52 | 98.65 | 92.0 | 88.0 | 4.0 | -| 3 | PGC | 97.35 | 96.45 | 53.5 | 7.0 | 0.0 | -| 4 | CuRe | 96.23 | 97.07 | 88.5 | 77.0 | 0.0 | -| 5 | VIB-Net | 96.12 | 96.19 | 84.5 | 74.0 | 5.0 | -| 6 | Effort | 95.46 | 94.17 | 84.5 | 79.0 | 10.0 | -| 7 | OmniAID (GenImage) | 94.25 | 91.19 | 80.5 | 68.0 | 7.0 | -| 8 | AIDE | 93.73 | 88.94 | 81.0 | 69.0 | 7.0 | -| 9 | OmniAID (v1) | 93.39 | 91.36 | 89.5 | 89.0 | 10.0 | -| 10 | SAFE | 92.32 | 84.09 | 88.5 | 87.0 | 10.0 | +| 3 | CuRe | 97.08 | 97.68 | 90.0 | 80.0 | 0.0 | +| 4 | VIB-Net | 96.12 | 96.19 | 84.5 | 74.0 | 5.0 | +| 5 | Effort | 95.46 | 94.17 | 84.5 | 79.0 | 10.0 | +| 6 | OmniAID (GenImage) | 94.25 | 91.19 | 80.5 | 68.0 | 7.0 | +| 7 | AIDE | 93.73 | 88.94 | 81.0 | 69.0 | 7.0 | +| 8 | OmniAID (v1) | 93.39 | 91.36 | 89.5 | 89.0 | 10.0 | +| 9 | SAFE | 92.32 | 84.09 | 88.5 | 87.0 | 10.0 | +| 10 | PGC | 90.72 | 83.54 | 52.5 | 7.0 | 2.0 | | 11 | NPR | 88.61 | 81.74 | 78.5 | 100.0 | 43.0 | | 12 | OmniAID | 76.57 | 79.4 | 60.0 | 22.0 | 2.0 | | 13 | SPAI | 66.54 | 63.78 | 56.0 | 20.0 | 8.0 | diff --git a/benchmark/generator_runs/flux2_klein_9b/results.json b/benchmark/generator_runs/flux2_klein_9b/results.json index 60bb5a56ed2e43349df1cc4275c5c32b804ce393..6df2e8b5eb11d5e6133b537a65459d263294eceb 100644 --- a/benchmark/generator_runs/flux2_klein_9b/results.json +++ b/benchmark/generator_runs/flux2_klein_9b/results.json @@ -21,27 +21,16 @@ "mean_p_fake_on_fakes": 0.8548, "mean_p_fake_on_reals": 0.0934 }, - { - "detector": "pgc", - "name": "PGC", - "auroc": 97.35, - "ap": 96.45, - "acc": 53.5, - "fake_detect_rate": 7.0, - "real_false_pos": 0.0, - "mean_p_fake_on_fakes": 0.4389, - "mean_p_fake_on_reals": 0.2672 - }, { "detector": "cure", "name": "CuRe", - "auroc": 96.23, - "ap": 97.07, - "acc": 88.5, - "fake_detect_rate": 77.0, + "auroc": 97.08, + "ap": 97.68, + "acc": 90.0, + "fake_detect_rate": 80.0, "real_false_pos": 0.0, - "mean_p_fake_on_fakes": 0.739, - "mean_p_fake_on_reals": 0.0129 + "mean_p_fake_on_fakes": 0.7736, + "mean_p_fake_on_reals": 0.0115 }, { "detector": "vib_net", @@ -109,6 +98,17 @@ "mean_p_fake_on_fakes": 0.7988, "mean_p_fake_on_reals": 0.1425 }, + { + "detector": "pgc", + "name": "PGC", + "auroc": 90.72, + "ap": 83.54, + "acc": 52.5, + "fake_detect_rate": 7.0, + "real_false_pos": 2.0, + "mean_p_fake_on_fakes": 0.4177, + "mean_p_fake_on_reals": 0.2596 + }, { "detector": "npr", "name": "NPR", diff --git a/benchmark/generator_runs/qwen_image_2_1/RESULTS.md b/benchmark/generator_runs/qwen_image_2_1/RESULTS.md index 19c4a7d82c29b7628304e864ccfff0be3f159054..091c3e2a10898572813e2702e4d67abd32aea7fa 100644 --- a/benchmark/generator_runs/qwen_image_2_1/RESULTS.md +++ b/benchmark/generator_runs/qwen_image_2_1/RESULTS.md @@ -6,11 +6,11 @@ |---|---|---|---|---|---|---| | 1 | VIB-Net | 99.82 | 99.83 | 97.5 | 99.0 | 4.0 | | 2 | CO-SPY | 98.87 | 98.7 | 95.5 | 94.0 | 3.0 | -| 3 | PGC | 98.5 | 98.3 | 60.0 | 20.0 | 0.0 | -| 4 | Effort | 97.14 | 96.74 | 90.0 | 90.0 | 10.0 | -| 5 | SPAI | 96.71 | 96.1 | 92.0 | 92.0 | 8.0 | +| 3 | Effort | 97.14 | 96.74 | 90.0 | 90.0 | 10.0 | +| 4 | SPAI | 96.71 | 96.1 | 92.0 | 92.0 | 8.0 | +| 5 | PGC | 94.43 | 92.19 | 62.5 | 27.0 | 2.0 | | 6 | OmniAID (v1) | 92.81 | 90.39 | 90.0 | 90.0 | 10.0 | -| 7 | CuRe | 92.67 | 94.29 | 82.0 | 64.0 | 0.0 | +| 7 | CuRe | 92.37 | 94.05 | 83.0 | 66.0 | 0.0 | | 8 | DDA | 91.51 | 92.19 | 78.0 | 60.0 | 4.0 | | 9 | OmniAID (GenImage) | 91.08 | 89.67 | 73.5 | 54.0 | 7.0 | | 10 | SAFE | 90.85 | 81.07 | 76.5 | 63.0 | 10.0 | diff --git a/benchmark/generator_runs/qwen_image_2_1/results.json b/benchmark/generator_runs/qwen_image_2_1/results.json index 682c62778577f778f9aa9964444e121df7b94a11..ff154e0dced707a0c229ff4e0d562e27a311b508 100644 --- a/benchmark/generator_runs/qwen_image_2_1/results.json +++ b/benchmark/generator_runs/qwen_image_2_1/results.json @@ -21,17 +21,6 @@ "mean_p_fake_on_fakes": 0.8087, "mean_p_fake_on_reals": 0.116 }, - { - "detector": "pgc", - "name": "PGC", - "auroc": 98.5, - "ap": 98.3, - "acc": 60.0, - "fake_detect_rate": 20.0, - "real_false_pos": 0.0, - "mean_p_fake_on_fakes": 0.4666, - "mean_p_fake_on_reals": 0.2672 - }, { "detector": "effort", "name": "Effort", @@ -54,6 +43,17 @@ "mean_p_fake_on_fakes": 0.8983, "mean_p_fake_on_reals": 0.0778 }, + { + "detector": "pgc", + "name": "PGC", + "auroc": 94.43, + "ap": 92.19, + "acc": 62.5, + "fake_detect_rate": 27.0, + "real_false_pos": 2.0, + "mean_p_fake_on_fakes": 0.4723, + "mean_p_fake_on_reals": 0.2596 + }, { "detector": "omniaid_v1", "name": "OmniAID (v1)", @@ -68,13 +68,13 @@ { "detector": "cure", "name": "CuRe", - "auroc": 92.67, - "ap": 94.29, - "acc": 82.0, - "fake_detect_rate": 64.0, + "auroc": 92.37, + "ap": 94.05, + "acc": 83.0, + "fake_detect_rate": 66.0, "real_false_pos": 0.0, - "mean_p_fake_on_fakes": 0.629, - "mean_p_fake_on_reals": 0.0129 + "mean_p_fake_on_fakes": 0.6506, + "mean_p_fake_on_reals": 0.0115 }, { "detector": "dda", diff --git a/benchmark/leaderboard.py b/benchmark/leaderboard.py index 2c40416e1ee232f59549ee619364cb95e25602b6..3342c5fb98f635d66aeea379793f7d39d48f26d7 100644 --- a/benchmark/leaderboard.py +++ b/benchmark/leaderboard.py @@ -19,11 +19,12 @@ LEADERBOARD_MD = BENCH_DIR.parent / "LEADERBOARD.md" # Track order, titles, and the metric each track ranks by. TRACKS = { "forensynths": { - "title": "ForenSynths — image (ProGAN-trained, cross-generator)", + "title": "ForenSynths-8 (8 generators) — image (ProGAN-trained, cross-generator)", "primary": "map", "modality": "image", }, "genimage-sdv1.4": { - "title": "GenImage SD-v1.4 — image", "primary": "auroc", "modality": "image", + "title": "GenImage SD-v1.4 — image (diffusion-trained; in-distribution only for SD-v1.4-trained rows)", + "primary": "auroc", "modality": "image", }, "genvideo-val": { "title": "GenVideo-Val — video (all 10,000 MSR-VTT reals vs every fake, per generator)", "primary": "auroc", @@ -82,8 +83,8 @@ def _fmt(v) -> str: def _sort_key(sub, primary): v = sub.get("metrics", {}).get(primary) - # rank desc by primary; missing primary sorts last - return (0, -v) if isinstance(v, (int, float)) else (1, 0.0) + # verified rows first, each group desc by primary; missing primary sorts last within its group + return (0 if sub.get("verified") else 1,) + ((0, -v) if isinstance(v, (int, float)) else (1, 0.0)) def render() -> str: @@ -94,7 +95,7 @@ def render() -> str: "See [benchmark/README.md](benchmark/README.md) for the protocol and how to submit.", "", "This is the **standardized, versioned** table: a few tracks with a fixed protocol that anyone can submit to. The web page's **Leaderboard** tab is broader (every paper benchmark, 30+ groups) and the repo supports many more datasets, which download and organize themselves: see [docs/BENCHMARKS.md](docs/BENCHMARKS.md).", "", "Metrics are percentages. **mAP** = mean AP over generators. Each track is ranked by " - "its primary metric (in bold).", "", + "its primary metric (in bold). Unverified rows are listed after the ranked ones, without a rank.", "", ] for track_id, cfg in TRACKS.items(): rows = [s for s in subs if s.get("track") == track_id] @@ -111,9 +112,12 @@ def render() -> str: rows.sort(key=lambda s: _sort_key(s, primary)) lines.append("| " + " | ".join(header_cells) + " |") lines.append("| " + " | ".join(["---"] * len(header_cells)) + " |") - for i, s in enumerate(rows, 1): + rank = 0 + for s in rows: m = s.get("metrics", {}) - cells = [str(i), s["method"], s["evaluation"]] + if s.get("verified"): + rank += 1 + cells = [str(rank) if s.get("verified") else "—", s["method"], s["evaluation"]] cells += [_fmt(m.get(key)) for key, _ in METRIC_COLS] cells.append("✓" if s.get("verified") else "") note = s.get("protocol_notes") or "" diff --git a/benchmark/seed_reference_results.py b/benchmark/seed_reference_results.py index 73e106609a0d0efb27263d2eb9d260d9544d9f1c..d3e66a78085c54cb7898989b976fd38e54aa9a48 100644 --- a/benchmark/seed_reference_results.py +++ b/benchmark/seed_reference_results.py @@ -1,70 +1,196 @@ -"""Generate the reference (already-reproduced) leaderboard submissions. +"""Build SynthScope's own leaderboard submissions from the logged evaluations in ``repro/bench_results``. -Every number here is **transcribed from the verified reproduction table in the repo README** -(each traces to a logged `Test Metrics` evaluation; see `repro/FINAL_RESULTS.md`). No number is -estimated. Re-run to regenerate `submissions/*.json`: +Each entry below names one committed ``repro/bench_results/*.json`` (written by a logged ``bench_eval.py`` / +``bench_eval_video.py`` run), the generators its track scores, and the job that wrote it. The metrics are read +from that file: the run's own means when the track scores every generator in it, otherwise the unweighted mean +of its per-generator values over the track's generators. No number is typed in by hand, so every SynthScope +row of LEADERBOARD.md can be recomputed from the repo: - python benchmark/seed_reference_results.py + python benchmark/seed_reference_results.py # rewrite submissions/.json for these entries + python benchmark/seed_reference_results.py --check # fail if a submission no longer matches its evidence, + # or a SynthScope submission has no entry here + python benchmark/leaderboard.py # then refresh LEADERBOARD.md + +Entries with ``verified=False`` have a logged evaluation whose checkpoint cannot be confirmed to fit the track; +their notes say why. Submissions from other people are not touched. """ +from __future__ import annotations + +import argparse import json +import sys from pathlib import Path +from typing import NamedTuple -SUB = Path(__file__).resolve().parent / "submissions" +BENCH_DIR = Path(__file__).resolve().parent +SUB = BENCH_DIR / "submissions" +RESULTS = BENCH_DIR.parent / "repro" / "bench_results" REPO = "https://github.com/SMSD75/SynthScope" -SOURCE = "SynthScope reproduction (logged Test Metrics); see repro/FINAL_RESULTS.md" -DATE = "2026-06-02" - -# (slug, method, track, modality, model_type, paper, evaluation, metrics, protocol_notes) -ROWS = [ - # --- ForenSynths (image) --- - ("fat_former", "FatFormer", "forensynths", "image", "fat_former", "Liu et al., CVPR'24", - "official-weights", {"acc": 98.39, "map": 99.70}, "ForenSynths-8 subset; official released weights"), - ("co_spy_official", "CO-SPY (official weights)", "forensynths", "image", "co_spy", "Cheng et al., CVPR'25", - "official-weights", {"acc": 95.12, "map": 98.71}, "ForenSynths-8; vendored official architecture"), - ("npr", "NPR", "forensynths", "image", "npr", "Tan et al., CVPR'24", - "official-weights", {"acc": 91.83, "map": 87.09}, "ForenSynths-8; official ProGAN weights"), - ("aide", "AIDE", "forensynths", "image", "aide", "Yan et al., ICLR'25", - "official-weights", {"map": 92.08}, "ForenSynths-8; mAP reproduces, acc@0.5 miscalibrated (single-view vs official 5-view DCT)"), - ("clip", "UnivFD / CLIP", "forensynths", "image", "clip", "Ojha et al., CVPR'23", - "frozen-probe", {"map": 97.2, "auroc": 97.0}, "ForenSynths; frozen CLIP ViT-L/14 probe (ProGAN)"), - ("cnn", "CNNDetection", "forensynths", "image", "cnn", "Wang et al., CVPR'20", - "from-scratch", {"map": 96.8, "auroc": 96.6}, "ForenSynths; ResNet-50 fine-tune (ProGAN)"), - ("dinov2", "DINOv2 probe", "forensynths", "image", "dinov2", "Oquab et al., 2023", - "frozen-probe", {"map": 95.03, "auroc": 94.86}, "ForenSynths; frozen DINOv2 ViT-L/14 probe"), - ("safe", "SAFE", "forensynths", "image", "safe", "Li et al., KDD'25", - "from-scratch", {"map": 94.13, "auroc": 93.68}, "ForenSynths; trained from scratch"), - ("co_spy_scratch", "CO-SPY (from scratch)", "forensynths", "image", "co_spy", "Cheng et al., CVPR'25", - "from-scratch", {"map": 96.98, "auroc": 96.79}, "ForenSynths; SynthScope re-implementation trained on ProGAN"), +METRIC_KEYS = ["acc", "map", "ap", "auroc"] + +# The ForenSynths track scores the 8 GAN test sets (ForenSynths-8). Runs over all 13 sets are subset to these. +FS8 = ["biggan", "cyclegan", "deepfake", "gaugan", "progan", "stargan", "stylegan", "stylegan2"] +# The GenImage SD-v1.4 track scores the SD-v1.4 subset of the GenImage test set. +SD14 = ["sdv1.4"] +JUNE_LOG = "job log not kept on the shared filesystem; MASTER_RESULTS.jsonl row of the same tag" + + + +class Entry(NamedTuple): + method: str + track: str + model_type: str + paper: str + evaluation: str + results_file: str # repro/bench_results/ + generators: list[str] | None # None = every generator in the file + job: str + verified: bool + notes: str + + +# slug (= submissions/.json) -> its evidence +ENTRIES = { + # --- ForenSynths-8 (image) --- + "fat_former": Entry( + "FatFormer", "forensynths", "fat_former", "Liu et al., CVPR'24", "official-weights", + "fatformer_official_forensynths.json", None, JUNE_LOG, True, + "ForenSynths-8; official 4-class ProGAN weights (the served fat_former.pth)"), + "co_spy_official": Entry( + "CO-SPY (official weights)", "forensynths", "co_spy", "Cheng et al., CVPR'25", "official-weights", + "cospy_official_forensynths.json", FS8, JUNE_LOG, True, + "ForenSynths-8; official CO-SPY ProGAN checkpoint in the vendored official architecture " + "(not the served co_spy.pth)"), + "npr": Entry( + "NPR", "forensynths", "npr", "Tan et al., CVPR'24", "official-weights", + "npr_official_nprpth_forensynths8.json", None, "job 265808 (repro/logs/nprevt_265808.out)", True, + "ForenSynths-8; official ProGAN weights NPR.pth (the served npr.pth)"), + "aide": Entry( + "AIDE", "forensynths", "aide", "Yan et al., ICLR'25", "official-weights", + "aide_official_forensynths.json", FS8, "repro/eval_logs/fixup_aide_gpu7_bs8.log (2026-06-05 rerun)", True, + "ForenSynths-8; official ProGAN weights progan_train.pth, vendored official eval (native-resolution " + "5-view DCT); the served aide.pth is the SD-v1.4 release"), + "clip": Entry( + "UnivFD / CLIP", "forensynths", "clip", "Ojha et al., CVPR'23", "frozen-probe", + "clip_synthscope_forensynths.json", FS8, JUNE_LOG, True, + "ForenSynths-8; frozen CLIP ViT-L/14 + linear head trained in SynthScope on ProGAN (the served clip.pth)"), + "cnn": Entry( + "CNNDetection", "forensynths", "cnn", "Wang et al., CVPR'20", "from-scratch", + "cnn_synthscope_forensynths.json", FS8, JUNE_LOG, True, + "ForenSynths-8; ImageNet ResNet-50 fine-tuned in SynthScope on ProGAN (the served cnn.pth)"), + "dinov2": Entry( + "DINOv2 probe", "forensynths", "dinov2", "Oquab et al., 2023", "frozen-probe", + "dinov2_synthscope_forensynths.json", FS8, JUNE_LOG, True, + "ForenSynths-8; frozen DINOv2 ViT-L/14 + linear head trained in SynthScope on ProGAN (the served dinov2.pth)"), + "safe": Entry( + "SAFE", "forensynths", "safe", "Li et al., KDD'25", "from-scratch", + "safe_v2_forensynths8.json", None, "job 186235 (repro/logs/safe_v2_fs8_186235.out)", True, + "ForenSynths-8; trained in SynthScope on ProGAN, 40-epoch crop recipe (safe_full_v2/model_38, " + "the served safe.pth)"), + "co_spy_scratch": Entry( + "CO-SPY (from scratch)", "forensynths", "co_spy", "Cheng et al., CVPR'25", "from-scratch", + "cospy_synthscope_forensynths.json", FS8, JUNE_LOG, False, + "Unverified: ForenSynths-8 score of the co_spy.pth of 2026-06-04, then labelled ProGAN-trained, whose " + "training run is not recorded; not the served co_spy.pth (a GenImage SD-v1.4 retrain, not scored here)"), # --- GenImage SD-v1.4 (image) --- - ("spai_official", "SPAI (official weights)", "genimage-sdv1.4", "image", "spai", "Karageorgiou et al., CVPR'25", - "official-weights", {"auroc": 98.45, "ap": 94.01}, "GenImage SD-v1.4; vendored official architecture, fixed-res 2x2x224"), - ("vib_net", "VIB-Net", "genimage-sdv1.4", "image", "vib_net", "Zhang et al., CVPR'25", - "from-scratch", {"map": 99.33, "auroc": 99.33}, "GenImage SD-v1.4 single real/fake pool (mAP == AUROC by construction)"), - ("spai_scratch", "SPAI (from scratch)", "genimage-sdv1.4", "image", "spai", "Karageorgiou et al., CVPR'25", - "from-scratch", {"auroc": 97.66}, "DMID Latent-Diffusion vs COCO; SynthScope fixed-resolution variant"), + "vib_net": Entry( + "VIB-Net", "genimage-sdv1.4", "vib_net", "Zhang et al., CVPR'25", "from-scratch", + "vib_net_trained_noresize_genimage7.json", SD14, "eval job 267928 (repro/logs/vibevt_267928.out)", True, + "GenImage SD-v1.4, 6000 real + 6000 fake; trained in SynthScope on GenImage SD-v1.4 with the " + "reconstructed recipe (job 267846, the served vib_net.pth); one generator, so mAP = AP"), + "spai_official": Entry( + "SPAI (official weights)", "genimage-sdv1.4", "spai", "Karageorgiou et al., CVPR'25", "official-weights", + "spai_official_genimage8.json", SD14, "job 273444 (repro/logs/spaiev_official_273444.out)", True, + "300+300 subsample; trained on latent-diffusion (LDM) data, not SD-v1.4. GenImage SD-v1.4 (the run's " + "per-generator cap); official weights remapped into the SynthScope class, native resolution (the served spai.pth)"), + "spai_scratch": Entry( + "SPAI (from scratch)", "genimage-sdv1.4", "spai", "Karageorgiou et al., CVPR'25", "from-scratch", + "spai_ep8_genimage8.json", SD14, "job 273445 (repro/logs/spaiev_ep8_273445.out)", True, + "300+300 subsample; trained on latent-diffusion (LDM) data, not SD-v1.4. GenImage SD-v1.4; trained in " + "SynthScope with the official recipe (LDM vs COCO/LSUN, job 267192, epoch 8 by validation loss), native resolution"), # --- GenVideo-Val (video) --- - ("d3", "D3", "genvideo-val", "video", "d3", "ICCV'25", - "training-free", {"ap": 95.6, "auroc": 93.6}, "Training-free frozen CLIP 2nd-order trajectory"), - ("restrav", "ReStraV", "genvideo-val", "video", "restrav", "2025", - "frozen-probe", {"ap": 96.67, "auroc": 97.06}, "Frozen DINOv2 trajectory geometry + MLP"), -] + "d3": Entry( + "D3", "genvideo-val", "d3", "Zheng et al., ICCV'25", "training-free", + "d3_genvideo_fpr.json", None, "job 270384 (repro/logs/spliteval_270384.out)", True, + "Training-free X-CLIP 2nd-order feature volatility (official preprocessing). AP here is fake-as-positive " + "against all 10k reals; the README's 99.0 AP is the paper protocol (real-as-positive, first 1000 clips)"), + "split": Entry( + "SPLIT", "genvideo-val", "split", "Hyun & Kim, ECCV'26", "training-free", + "split_genvideo_fpr.json", None, "job 270384 (repro/logs/spliteval_270384.out)", True, + "Training-free X-CLIP patch roughness x motion incoherence; Acc at the real-only FPR-1% calibration"), + "stall": Entry( + "STALL", "genvideo-val", "stall", "Ben Hayun et al., CVPR'26", "training-free", + "stall_genvideo_full.json", None, "job 271899 (repro/logs/stallgv_271899.out)", True, + "Training-free DINOv3 spatio-temporal likelihood under VATEX real-video statistics. Full run; the " + "README's 83.5 AUROC is the June subsample run"), + "restrav": Entry( + "ReStraV", "genvideo-val", "restrav", "Interno et al., 2025", "frozen-probe", + "restrav_genvideo_full.json", None, "job 271898 (repro/logs/restravgv_271898.out)", True, + "Frozen DINOv2 trajectory geometry + MLP trained in SynthScope (the served restrav.pth; its training " + "set is not recorded); does not transfer to GenVideo-Val (AUROC below 50)"), +} -METRIC_KEYS = ["acc", "map", "ap", "auroc"] + +def _mean(xs: list[float]) -> float: + return round(sum(xs) / len(xs), 2) + + +def build(slug: str) -> dict: + """Return the submission for one entry, with metrics read from its bench_results file.""" + e = ENTRIES[slug] + fname, gens = e.results_file, e.generators + res = json.loads((RESULTS / fname).read_text()) + pg = res["per_generator"] + video = e.track == "genvideo-val" + if gens is None: + gens = sorted(pg) + means = res["means"] + metrics = {"acc": means["acc"], "map": means["map"], "auroc": means["mauroc"]} + else: + missing = [g for g in gens if g not in pg] + if missing: + raise KeyError(f"{fname} has no per-generator result for {missing}") + metrics = {"acc": _mean([pg[g]["acc"] for g in gens]), "map": _mean([pg[g]["ap"] for g in gens]), + "auroc": _mean([pg[g]["auroc"] for g in gens])} + keep = ("auroc", "ap") if video else ("ap", "auroc", "acc") + scope = "all generators" if len(gens) == len(pg) else f"{len(gens)} of its {len(pg)} generators" + return { + "method": e.method, "track": e.track, "modality": "video" if video else "image", "model_type": e.model_type, + "paper": e.paper, "url": REPO, "evaluation": e.evaluation, + "metrics": {k: metrics.get(k) for k in METRIC_KEYS}, + "per_generator": {g: {k: pg[g][k] for k in keep} for g in gens}, + "submitted_by": "SynthScope", "date": res["date"][:10], "verified": e.verified, + "source": f"repro/bench_results/{fname} (tag {res['tag']}, {scope}); {e.job}", + "protocol_notes": e.notes, "synthscope_version": "0.1.0", + } -def main() -> None: - SUB.mkdir(parents=True, exist_ok=True) - for slug, method, track, modality, model_type, paper, evaluation, metrics, notes in ROWS: - full_metrics = {k: metrics.get(k) for k in METRIC_KEYS} - sub = { - "method": method, "track": track, "modality": modality, "model_type": model_type, - "paper": paper, "url": REPO, "evaluation": evaluation, "metrics": full_metrics, - "per_generator": None, "submitted_by": "SynthScope", "date": DATE, - "verified": True, "source": SOURCE, "protocol_notes": notes, "synthscope_version": "0.1.0", - } - (SUB / f"{slug}.json").write_text(json.dumps(sub, indent=2) + "\n") - print(f"Wrote {len(ROWS)} reference submissions to {SUB}") +def main(argv=None) -> int: + ap = argparse.ArgumentParser(description="Rebuild SynthScope's leaderboard submissions from repro/bench_results.") + ap.add_argument("--check", action="store_true", help="fail if a submission differs from its evidence") + args = ap.parse_args(argv) + stale = [] + for slug in ENTRIES: + text = json.dumps(build(slug), indent=2) + "\n" + path = SUB / f"{slug}.json" + if args.check: + if not path.exists() or path.read_text() != text: + stale.append(path.name) + else: + path.write_text(text) + if args.check: + # A SynthScope-authored submission must have an entry here, or its numbers have no recorded evidence. + for path in sorted(SUB.glob("*.json")): + if path.stem not in ENTRIES and json.loads(path.read_text()).get("submitted_by") == "SynthScope": + stale.append(f"{path.name} (SynthScope submission with no ENTRIES entry)") + if stale: + print("Out of date with repro/bench_results: " + ", ".join(stale), file=sys.stderr) + return 1 + print(f"OK: {len(ENTRIES)} SynthScope submissions match their bench_results evidence.") + return 0 + print(f"Wrote {len(ENTRIES)} SynthScope submissions to {SUB}") + return 0 if __name__ == "__main__": - main() + raise SystemExit(main()) diff --git a/benchmark/submissions/aide.json b/benchmark/submissions/aide.json index 5c97e1d5b59dfbbe12f62e31614e933d29a98cb1..ff2bf3fb20d1f8bdbdffe9309d1d2ec5b79559cb 100644 --- a/benchmark/submissions/aide.json +++ b/benchmark/submissions/aide.json @@ -7,16 +7,57 @@ "url": "https://github.com/SMSD75/SynthScope", "evaluation": "official-weights", "metrics": { - "acc": null, - "map": 92.08, + "acc": 88.38, + "map": 96.03, "ap": null, - "auroc": null + "auroc": 95.6 + }, + "per_generator": { + "biggan": { + "ap": 94.44, + "auroc": 94.43, + "acc": 83.95 + }, + "cyclegan": { + "ap": 99.89, + "auroc": 99.9, + "acc": 98.49 + }, + "deepfake": { + "ap": 76.22, + "auroc": 72.73, + "acc": 53.91 + }, + "gaugan": { + "ap": 97.69, + "auroc": 97.77, + "acc": 73.24 + }, + "progan": { + "ap": 100.0, + "auroc": 100.0, + "acc": 99.99 + }, + "stargan": { + "ap": 100.0, + "auroc": 100.0, + "acc": 99.9 + }, + "stylegan": { + "ap": 99.99, + "auroc": 99.99, + "acc": 99.62 + }, + "stylegan2": { + "ap": 99.97, + "auroc": 99.96, + "acc": 97.94 + } }, - "per_generator": null, "submitted_by": "SynthScope", - "date": "2026-06-02", + "date": "2026-06-05", "verified": true, - "source": "SynthScope reproduction (logged Test Metrics); see repro/FINAL_RESULTS.md", - "protocol_notes": "ForenSynths-8; mAP reproduces, acc@0.5 miscalibrated (single-view vs official 5-view DCT)", + "source": "repro/bench_results/aide_official_forensynths.json (tag aide_official_forensynths, 8 of its 13 generators); repro/eval_logs/fixup_aide_gpu7_bs8.log (2026-06-05 rerun)", + "protocol_notes": "ForenSynths-8; official ProGAN weights progan_train.pth, vendored official eval (native-resolution 5-view DCT); the served aide.pth is the SD-v1.4 release", "synthscope_version": "0.1.0" } diff --git a/benchmark/submissions/clip.json b/benchmark/submissions/clip.json index 6fa0e7423d955bb161c5b75ec0e707750057eeb4..d43fb71fd707d5d23cebff25f0c08d02d41cd699 100644 --- a/benchmark/submissions/clip.json +++ b/benchmark/submissions/clip.json @@ -7,16 +7,57 @@ "url": "https://github.com/SMSD75/SynthScope", "evaluation": "frozen-probe", "metrics": { - "acc": null, - "map": 97.2, + "acc": 88.28, + "map": 97.22, "ap": null, - "auroc": 97.0 + "auroc": 97.11 + }, + "per_generator": { + "biggan": { + "ap": 99.11, + "auroc": 99.03, + "acc": 95.07 + }, + "cyclegan": { + "ap": 99.71, + "auroc": 99.7, + "acc": 95.53 + }, + "deepfake": { + "ap": 87.82, + "auroc": 86.6, + "acc": 79.0 + }, + "gaugan": { + "ap": 99.98, + "auroc": 99.98, + "acc": 99.02 + }, + "progan": { + "ap": 99.99, + "auroc": 99.99, + "acc": 99.52 + }, + "stargan": { + "ap": 99.72, + "auroc": 99.68, + "acc": 93.22 + }, + "stylegan": { + "ap": 96.02, + "auroc": 96.14, + "acc": 76.3 + }, + "stylegan2": { + "ap": 95.44, + "auroc": 95.74, + "acc": 68.6 + } }, - "per_generator": null, "submitted_by": "SynthScope", - "date": "2026-06-02", + "date": "2026-06-04", "verified": true, - "source": "SynthScope reproduction (logged Test Metrics); see repro/FINAL_RESULTS.md", - "protocol_notes": "ForenSynths; frozen CLIP ViT-L/14 probe (ProGAN)", + "source": "repro/bench_results/clip_synthscope_forensynths.json (tag clip_synthscope_forensynths, 8 of its 13 generators); job log not kept on the shared filesystem; MASTER_RESULTS.jsonl row of the same tag", + "protocol_notes": "ForenSynths-8; frozen CLIP ViT-L/14 + linear head trained in SynthScope on ProGAN (the served clip.pth)", "synthscope_version": "0.1.0" } diff --git a/benchmark/submissions/cnn.json b/benchmark/submissions/cnn.json index 53cad9a9fe268579c3ec6179a999ec40144ecace..80d37e8225e241d9266cb1d9fed791f12fc6e091 100644 --- a/benchmark/submissions/cnn.json +++ b/benchmark/submissions/cnn.json @@ -7,16 +7,57 @@ "url": "https://github.com/SMSD75/SynthScope", "evaluation": "from-scratch", "metrics": { - "acc": null, - "map": 96.8, + "acc": 76.36, + "map": 94.42, "ap": null, - "auroc": 96.6 + "auroc": 94.42 + }, + "per_generator": { + "biggan": { + "ap": 94.05, + "auroc": 94.18, + "acc": 67.95 + }, + "cyclegan": { + "ap": 97.06, + "auroc": 96.9, + "acc": 83.69 + }, + "deepfake": { + "ap": 72.84, + "auroc": 73.86, + "acc": 55.92 + }, + "gaugan": { + "ap": 99.28, + "auroc": 99.35, + "acc": 88.65 + }, + "progan": { + "ap": 100.0, + "auroc": 100.0, + "acc": 100.0 + }, + "stargan": { + "ap": 95.89, + "auroc": 95.29, + "acc": 82.97 + }, + "stylegan": { + "ap": 98.3, + "auroc": 98.09, + "acc": 69.51 + }, + "stylegan2": { + "ap": 97.91, + "auroc": 97.7, + "acc": 62.21 + } }, - "per_generator": null, "submitted_by": "SynthScope", - "date": "2026-06-02", + "date": "2026-06-04", "verified": true, - "source": "SynthScope reproduction (logged Test Metrics); see repro/FINAL_RESULTS.md", - "protocol_notes": "ForenSynths; ResNet-50 fine-tune (ProGAN)", + "source": "repro/bench_results/cnn_synthscope_forensynths.json (tag cnn_synthscope_forensynths, 8 of its 13 generators); job log not kept on the shared filesystem; MASTER_RESULTS.jsonl row of the same tag", + "protocol_notes": "ForenSynths-8; ImageNet ResNet-50 fine-tuned in SynthScope on ProGAN (the served cnn.pth)", "synthscope_version": "0.1.0" } diff --git a/benchmark/submissions/co_spy_official.json b/benchmark/submissions/co_spy_official.json index 37b9d4960f4c33cf58fea9ffae05017641667624..131e26cb562e80ae71bfe6c59bc7c3982332f229 100644 --- a/benchmark/submissions/co_spy_official.json +++ b/benchmark/submissions/co_spy_official.json @@ -7,16 +7,57 @@ "url": "https://github.com/SMSD75/SynthScope", "evaluation": "official-weights", "metrics": { - "acc": 95.12, - "map": 98.71, + "acc": 94.64, + "map": 98.5, "ap": null, - "auroc": null + "auroc": 98.8 + }, + "per_generator": { + "biggan": { + "ap": 97.76, + "auroc": 98.18, + "acc": 93.95 + }, + "cyclegan": { + "ap": 99.43, + "auroc": 99.74, + "acc": 99.25 + }, + "deepfake": { + "ap": 93.4, + "auroc": 93.91, + "acc": 75.6 + }, + "gaugan": { + "ap": 97.49, + "auroc": 98.62, + "acc": 95.05 + }, + "progan": { + "ap": 100.0, + "auroc": 100.0, + "acc": 100.0 + }, + "stargan": { + "ap": 100.0, + "auroc": 100.0, + "acc": 99.4 + }, + "stylegan": { + "ap": 99.94, + "auroc": 99.93, + "acc": 93.85 + }, + "stylegan2": { + "ap": 100.0, + "auroc": 100.0, + "acc": 100.0 + } }, - "per_generator": null, "submitted_by": "SynthScope", - "date": "2026-06-02", + "date": "2026-06-04", "verified": true, - "source": "SynthScope reproduction (logged Test Metrics); see repro/FINAL_RESULTS.md", - "protocol_notes": "ForenSynths-8; vendored official architecture", + "source": "repro/bench_results/cospy_official_forensynths.json (tag cospy_official_forensynths, 8 of its 13 generators); job log not kept on the shared filesystem; MASTER_RESULTS.jsonl row of the same tag", + "protocol_notes": "ForenSynths-8; official CO-SPY ProGAN checkpoint in the vendored official architecture (not the served co_spy.pth)", "synthscope_version": "0.1.0" } diff --git a/benchmark/submissions/co_spy_scratch.json b/benchmark/submissions/co_spy_scratch.json index 3f9e100716e2f91cba860cab4eca7bef0a136c74..cbddff31e4a2509a2581260ecce5c77ea3356c35 100644 --- a/benchmark/submissions/co_spy_scratch.json +++ b/benchmark/submissions/co_spy_scratch.json @@ -7,16 +7,57 @@ "url": "https://github.com/SMSD75/SynthScope", "evaluation": "from-scratch", "metrics": { - "acc": null, - "map": 96.98, + "acc": 89.21, + "map": 97.18, "ap": null, - "auroc": 96.79 + "auroc": 97.62 + }, + "per_generator": { + "biggan": { + "ap": 99.35, + "auroc": 99.32, + "acc": 91.75 + }, + "cyclegan": { + "ap": 99.56, + "auroc": 99.52, + "acc": 96.8 + }, + "deepfake": { + "ap": 80.22, + "auroc": 83.88, + "acc": 72.75 + }, + "gaugan": { + "ap": 99.98, + "auroc": 99.98, + "acc": 99.05 + }, + "progan": { + "ap": 100.0, + "auroc": 99.99, + "acc": 99.75 + }, + "stargan": { + "ap": 99.6, + "auroc": 99.62, + "acc": 92.9 + }, + "stylegan": { + "ap": 99.22, + "auroc": 99.17, + "acc": 79.45 + }, + "stylegan2": { + "ap": 99.48, + "auroc": 99.47, + "acc": 81.25 + } }, - "per_generator": null, "submitted_by": "SynthScope", - "date": "2026-06-02", - "verified": true, - "source": "SynthScope reproduction (logged Test Metrics); see repro/FINAL_RESULTS.md", - "protocol_notes": "ForenSynths; SynthScope re-implementation trained on ProGAN", + "date": "2026-06-04", + "verified": false, + "source": "repro/bench_results/cospy_synthscope_forensynths.json (tag cospy_synthscope_forensynths, 8 of its 13 generators); job log not kept on the shared filesystem; MASTER_RESULTS.jsonl row of the same tag", + "protocol_notes": "Unverified: ForenSynths-8 score of the co_spy.pth of 2026-06-04, then labelled ProGAN-trained, whose training run is not recorded; not the served co_spy.pth (a GenImage SD-v1.4 retrain, not scored here)", "synthscope_version": "0.1.0" } diff --git a/benchmark/submissions/d3.json b/benchmark/submissions/d3.json index 1fed1db7cb2842a57e19d04581d4e7fed2b0effc..664f928c51a8357d3e25db81d084f41c87be446a 100644 --- a/benchmark/submissions/d3.json +++ b/benchmark/submissions/d3.json @@ -57,7 +57,7 @@ "submitted_by": "SynthScope", "date": "2026-10-31", "verified": true, - "source": "repro/bench_results/d3_genvideo_fpr.json (benchmark/bench_eval_video.py --dataset genvideo, no --limit)", - "protocol_notes": "Training-free X-CLIP 2nd-order feature volatility (official preprocessing)", + "source": "repro/bench_results/d3_genvideo_fpr.json (tag d3_genvideo_fpr, all generators); job 270384 (repro/logs/spliteval_270384.out)", + "protocol_notes": "Training-free X-CLIP 2nd-order feature volatility (official preprocessing). AP here is fake-as-positive against all 10k reals; the README's 99.0 AP is the paper protocol (real-as-positive, first 1000 clips)", "synthscope_version": "0.1.0" } diff --git a/benchmark/submissions/dinov2.json b/benchmark/submissions/dinov2.json index 5e1c8783e762d10693cd94b98e3e8efceae035cd..968b14301c9cbfb5b41161907c223846aacbd41e 100644 --- a/benchmark/submissions/dinov2.json +++ b/benchmark/submissions/dinov2.json @@ -7,16 +7,57 @@ "url": "https://github.com/SMSD75/SynthScope", "evaluation": "frozen-probe", "metrics": { - "acc": null, - "map": 95.03, + "acc": 78.98, + "map": 90.61, "ap": null, - "auroc": 94.86 + "auroc": 90.83 + }, + "per_generator": { + "biggan": { + "ap": 93.65, + "auroc": 93.36, + "acc": 83.92 + }, + "cyclegan": { + "ap": 97.08, + "auroc": 96.92, + "acc": 90.08 + }, + "deepfake": { + "ap": 76.42, + "auroc": 79.0, + "acc": 58.46 + }, + "gaugan": { + "ap": 99.08, + "auroc": 98.98, + "acc": 94.86 + }, + "progan": { + "ap": 99.74, + "auroc": 99.73, + "acc": 97.35 + }, + "stargan": { + "ap": 88.99, + "auroc": 88.36, + "acc": 73.44 + }, + "stylegan": { + "ap": 85.23, + "auroc": 85.44, + "acc": 66.1 + }, + "stylegan2": { + "ap": 84.7, + "auroc": 84.84, + "acc": 67.66 + } }, - "per_generator": null, "submitted_by": "SynthScope", - "date": "2026-06-02", + "date": "2026-06-04", "verified": true, - "source": "SynthScope reproduction (logged Test Metrics); see repro/FINAL_RESULTS.md", - "protocol_notes": "ForenSynths; frozen DINOv2 ViT-L/14 probe", + "source": "repro/bench_results/dinov2_synthscope_forensynths.json (tag dinov2_synthscope_forensynths, 8 of its 13 generators); job log not kept on the shared filesystem; MASTER_RESULTS.jsonl row of the same tag", + "protocol_notes": "ForenSynths-8; frozen DINOv2 ViT-L/14 + linear head trained in SynthScope on ProGAN (the served dinov2.pth)", "synthscope_version": "0.1.0" } diff --git a/benchmark/submissions/fat_former.json b/benchmark/submissions/fat_former.json index add0ac2f18d3dd95dc1c087211637474cec89c7d..5c1759d0436b427e1513cec6559224a22af3f29a 100644 --- a/benchmark/submissions/fat_former.json +++ b/benchmark/submissions/fat_former.json @@ -10,13 +10,54 @@ "acc": 98.39, "map": 99.7, "ap": null, - "auroc": null + "auroc": 99.57 + }, + "per_generator": { + "biggan": { + "ap": 99.98, + "auroc": 99.97, + "acc": 99.5 + }, + "cyclegan": { + "ap": 100.0, + "auroc": 100.0, + "acc": 99.36 + }, + "deepfake": { + "ap": 97.99, + "auroc": 97.01, + "acc": 93.26 + }, + "gaugan": { + "ap": 100.0, + "auroc": 100.0, + "acc": 99.43 + }, + "progan": { + "ap": 100.0, + "auroc": 100.0, + "acc": 99.89 + }, + "stargan": { + "ap": 100.0, + "auroc": 100.0, + "acc": 99.75 + }, + "stylegan": { + "ap": 99.75, + "auroc": 99.69, + "acc": 97.13 + }, + "stylegan2": { + "ap": 99.92, + "auroc": 99.9, + "acc": 98.8 + } }, - "per_generator": null, "submitted_by": "SynthScope", - "date": "2026-06-02", + "date": "2026-06-04", "verified": true, - "source": "SynthScope reproduction (logged Test Metrics); see repro/FINAL_RESULTS.md", - "protocol_notes": "ForenSynths-8 subset; official released weights", + "source": "repro/bench_results/fatformer_official_forensynths.json (tag fatformer_official_forensynths, all generators); job log not kept on the shared filesystem; MASTER_RESULTS.jsonl row of the same tag", + "protocol_notes": "ForenSynths-8; official 4-class ProGAN weights (the served fat_former.pth)", "synthscope_version": "0.1.0" } diff --git a/benchmark/submissions/npr.json b/benchmark/submissions/npr.json index afcad59e4096fd78feae20758e297d8da0579714..ac27029af9b79059d7bae12bbedcbffaeecc4cfa 100644 --- a/benchmark/submissions/npr.json +++ b/benchmark/submissions/npr.json @@ -7,16 +7,57 @@ "url": "https://github.com/SMSD75/SynthScope", "evaluation": "official-weights", "metrics": { - "acc": 91.83, - "map": 87.09, + "acc": 92.3, + "map": 94.22, "ap": null, - "auroc": null + "auroc": 96.08 + }, + "per_generator": { + "biggan": { + "ap": 87.8, + "auroc": 92.36, + "acc": 84.35 + }, + "cyclegan": { + "ap": 98.45, + "auroc": 99.04, + "acc": 96.1 + }, + "deepfake": { + "ap": 82.4, + "auroc": 86.85, + "acc": 80.24 + }, + "gaugan": { + "ap": 85.49, + "auroc": 90.75, + "acc": 82.5 + }, + "progan": { + "ap": 99.99, + "auroc": 99.99, + "acc": 99.79 + }, + "stargan": { + "ap": 99.94, + "auroc": 99.96, + "acc": 99.35 + }, + "stylegan": { + "ap": 99.78, + "auroc": 99.75, + "acc": 97.7 + }, + "stylegan2": { + "ap": 99.94, + "auroc": 99.94, + "acc": 98.38 + } }, - "per_generator": null, "submitted_by": "SynthScope", - "date": "2026-06-02", + "date": "2026-10-27", "verified": true, - "source": "SynthScope reproduction (logged Test Metrics); see repro/FINAL_RESULTS.md", - "protocol_notes": "ForenSynths-8; official ProGAN weights", + "source": "repro/bench_results/npr_official_nprpth_forensynths8.json (tag npr_official_nprpth_forensynths8, all generators); job 265808 (repro/logs/nprevt_265808.out)", + "protocol_notes": "ForenSynths-8; official ProGAN weights NPR.pth (the served npr.pth)", "synthscope_version": "0.1.0" } diff --git a/benchmark/submissions/restrav.json b/benchmark/submissions/restrav.json index f3b356c29a903d5256e2333cf8eaa4009c2a51b9..23c9e831dcb49a911abf542321333497f87acc8d 100644 --- a/benchmark/submissions/restrav.json +++ b/benchmark/submissions/restrav.json @@ -57,7 +57,7 @@ "submitted_by": "SynthScope", "date": "2026-11-02", "verified": true, - "source": "repro/bench_results/restrav_genvideo_full.json (benchmark/bench_eval_video.py --dataset genvideo, no --limit)", - "protocol_notes": "Frozen DINOv2 trajectory geometry + MLP trained on GenVidBench; does not transfer to GenVideo-Val (AUROC below 50)", + "source": "repro/bench_results/restrav_genvideo_full.json (tag restrav_genvideo_full, all generators); job 271898 (repro/logs/restravgv_271898.out)", + "protocol_notes": "Frozen DINOv2 trajectory geometry + MLP trained in SynthScope (the served restrav.pth; its training set is not recorded); does not transfer to GenVideo-Val (AUROC below 50)", "synthscope_version": "0.1.0" } diff --git a/benchmark/submissions/safe.json b/benchmark/submissions/safe.json index 5fc07feaa7b1c9932a9055a91b243b81b0009f50..d7069142e931d9ec691d56696e66de5ab8ba5690 100644 --- a/benchmark/submissions/safe.json +++ b/benchmark/submissions/safe.json @@ -7,16 +7,57 @@ "url": "https://github.com/SMSD75/SynthScope", "evaluation": "from-scratch", "metrics": { - "acc": null, - "map": 94.13, + "acc": 95.11, + "map": 97.79, "ap": null, - "auroc": 93.68 + "auroc": 97.86 + }, + "per_generator": { + "biggan": { + "ap": 96.42, + "auroc": 97.18, + "acc": 91.15 + }, + "cyclegan": { + "ap": 99.82, + "auroc": 99.85, + "acc": 98.6 + }, + "deepfake": { + "ap": 86.74, + "auroc": 86.37, + "acc": 77.37 + }, + "gaugan": { + "ap": 99.37, + "auroc": 99.48, + "acc": 94.39 + }, + "progan": { + "ap": 100.0, + "auroc": 100.0, + "acc": 100.0 + }, + "stargan": { + "ap": 100.0, + "auroc": 100.0, + "acc": 100.0 + }, + "stylegan": { + "ap": 100.0, + "auroc": 100.0, + "acc": 99.62 + }, + "stylegan2": { + "ap": 100.0, + "auroc": 100.0, + "acc": 99.72 + } }, - "per_generator": null, "submitted_by": "SynthScope", - "date": "2026-06-02", + "date": "2026-06-16", "verified": true, - "source": "SynthScope reproduction (logged Test Metrics); see repro/FINAL_RESULTS.md", - "protocol_notes": "ForenSynths; trained from scratch", + "source": "repro/bench_results/safe_v2_forensynths8.json (tag safe_v2_forensynths8, all generators); job 186235 (repro/logs/safe_v2_fs8_186235.out)", + "protocol_notes": "ForenSynths-8; trained in SynthScope on ProGAN, 40-epoch crop recipe (safe_full_v2/model_38, the served safe.pth)", "synthscope_version": "0.1.0" } diff --git a/benchmark/submissions/spai_official.json b/benchmark/submissions/spai_official.json index 94b89860a136fef5adc45767b99890c3824d87db..7e9c7578b2ff724df3dd6a65bebc9f46265007ee 100644 --- a/benchmark/submissions/spai_official.json +++ b/benchmark/submissions/spai_official.json @@ -7,16 +7,22 @@ "url": "https://github.com/SMSD75/SynthScope", "evaluation": "official-weights", "metrics": { - "acc": null, - "map": null, - "ap": 94.01, - "auroc": 98.45 + "acc": 95.67, + "map": 99.22, + "ap": null, + "auroc": 99.57 + }, + "per_generator": { + "sdv1.4": { + "ap": 99.22, + "auroc": 99.57, + "acc": 95.67 + } }, - "per_generator": null, "submitted_by": "SynthScope", - "date": "2026-06-02", + "date": "2026-11-03", "verified": true, - "source": "SynthScope reproduction (logged Test Metrics); see repro/FINAL_RESULTS.md", - "protocol_notes": "GenImage SD-v1.4; vendored official architecture, fixed-res 2x2x224", + "source": "repro/bench_results/spai_official_genimage8.json (tag spai_official_genimage8, 1 of its 8 generators); job 273444 (repro/logs/spaiev_official_273444.out)", + "protocol_notes": "300+300 subsample; trained on latent-diffusion (LDM) data, not SD-v1.4. GenImage SD-v1.4 (the run's per-generator cap); official weights remapped into the SynthScope class, native resolution (the served spai.pth)", "synthscope_version": "0.1.0" } diff --git a/benchmark/submissions/spai_scratch.json b/benchmark/submissions/spai_scratch.json index 5b990b2d2ee34527ff16a7a07161f2079bec0d8c..e247883f643f3a129ce55469cf3a5cb50e45b0aa 100644 --- a/benchmark/submissions/spai_scratch.json +++ b/benchmark/submissions/spai_scratch.json @@ -7,16 +7,22 @@ "url": "https://github.com/SMSD75/SynthScope", "evaluation": "from-scratch", "metrics": { - "acc": null, - "map": null, + "acc": 97.17, + "map": 99.93, "ap": null, - "auroc": 97.66 + "auroc": 99.94 + }, + "per_generator": { + "sdv1.4": { + "ap": 99.93, + "auroc": 99.94, + "acc": 97.17 + } }, - "per_generator": null, "submitted_by": "SynthScope", - "date": "2026-06-02", + "date": "2026-11-03", "verified": true, - "source": "SynthScope reproduction (logged Test Metrics); see repro/FINAL_RESULTS.md", - "protocol_notes": "DMID Latent-Diffusion vs COCO; SynthScope fixed-resolution variant", + "source": "repro/bench_results/spai_ep8_genimage8.json (tag spai_ep8_genimage8, 1 of its 8 generators); job 273445 (repro/logs/spaiev_ep8_273445.out)", + "protocol_notes": "300+300 subsample; trained on latent-diffusion (LDM) data, not SD-v1.4. GenImage SD-v1.4; trained in SynthScope with the official recipe (LDM vs COCO/LSUN, job 267192, epoch 8 by validation loss), native resolution", "synthscope_version": "0.1.0" } diff --git a/benchmark/submissions/split.json b/benchmark/submissions/split.json index 77d381df7f2edf03e8aa67a8e6efd996815aef1c..6f515d89f381591d6c82e8d9504255a9f7b2832c 100644 --- a/benchmark/submissions/split.json +++ b/benchmark/submissions/split.json @@ -57,7 +57,7 @@ "submitted_by": "SynthScope", "date": "2026-10-31", "verified": true, - "source": "repro/bench_results/split_genvideo_fpr.json (benchmark/bench_eval_video.py --dataset genvideo, no --limit)", + "source": "repro/bench_results/split_genvideo_fpr.json (tag split_genvideo_fpr, all generators); job 270384 (repro/logs/spliteval_270384.out)", "protocol_notes": "Training-free X-CLIP patch roughness x motion incoherence; Acc at the real-only FPR-1% calibration", "synthscope_version": "0.1.0" } diff --git a/benchmark/submissions/stall.json b/benchmark/submissions/stall.json index b66fd06b6df93a828a7faba76311cf05572438d8..fe36ae4c3bc8e4066ad212d5119e380c98e6b1a5 100644 --- a/benchmark/submissions/stall.json +++ b/benchmark/submissions/stall.json @@ -57,7 +57,7 @@ "submitted_by": "SynthScope", "date": "2026-11-02", "verified": true, - "source": "repro/bench_results/stall_genvideo_full.json (benchmark/bench_eval_video.py --dataset genvideo, no --limit)", - "protocol_notes": "Training-free DINOv3 spatio-temporal likelihood under VATEX real-video statistics", + "source": "repro/bench_results/stall_genvideo_full.json (tag stall_genvideo_full, all generators); job 271899 (repro/logs/stallgv_271899.out)", + "protocol_notes": "Training-free DINOv3 spatio-temporal likelihood under VATEX real-video statistics. Full run; the README's 83.5 AUROC is the June subsample run", "synthscope_version": "0.1.0" } diff --git a/benchmark/submissions/vib_net.json b/benchmark/submissions/vib_net.json index 0a4ec342ce81bdbd3f54f9274337171737c9f475..8aa62b8408d7b2d900ed849ad6887b5008b1e2b9 100644 --- a/benchmark/submissions/vib_net.json +++ b/benchmark/submissions/vib_net.json @@ -7,16 +7,22 @@ "url": "https://github.com/SMSD75/SynthScope", "evaluation": "from-scratch", "metrics": { - "acc": null, - "map": 99.33, + "acc": 99.29, + "map": 99.98, "ap": null, - "auroc": 99.33 + "auroc": 99.98 + }, + "per_generator": { + "sdv1.4": { + "ap": 99.98, + "auroc": 99.98, + "acc": 99.29 + } }, - "per_generator": null, "submitted_by": "SynthScope", - "date": "2026-06-02", + "date": "2026-10-29", "verified": true, - "source": "SynthScope reproduction (logged Test Metrics); see repro/FINAL_RESULTS.md", - "protocol_notes": "GenImage SD-v1.4 single real/fake pool (mAP == AUROC by construction)", + "source": "repro/bench_results/vib_net_trained_noresize_genimage7.json (tag vib_net_trained_noresize_genimage7, 1 of its 7 generators); eval job 267928 (repro/logs/vibevt_267928.out)", + "protocol_notes": "GenImage SD-v1.4, 6000 real + 6000 fake; trained in SynthScope on GenImage SD-v1.4 with the reconstructed recipe (job 267846, the served vib_net.pth); one generator, so mAP = AP", "synthscope_version": "0.1.0" } diff --git a/conf/model/image/fat_former.yaml b/conf/model/image/fat_former.yaml index 575105e370f2f309454ab0535014a794eddabcd1..6db2a2eb6865f7875593f03e7aff15209c792803 100644 --- a/conf/model/image/fat_former.yaml +++ b/conf/model/image/fat_former.yaml @@ -4,11 +4,15 @@ defaults: model_type: fat_former backbone_name: CLIP:ViT-L/14 -num_vit_adapter: 8 +# The released checkpoint has the forgery-aware adapter at blocks 7, 15, 23 (README: --num_vit_adapter 3 +# --num_context_embedding 8); the official code's argparse default would be 8. +num_vit_adapter: 3 num_context_embedding: 8 init_context_embedding: "" num_classes: 2 classnames: [real, fake] +# Trained: the forgery-aware adapters (FAA), the language-guided alignment (context tokens + patch-based enhancer), and the +# text-guided interactor; the whole CLIP (both towers, logit scale) is frozen. freeze_backbone: true force_fp32: true @@ -16,7 +20,7 @@ force_fp32: true # official-weights eval reproduces 98.39 acc / 99.70 mAP with it). # Test-time preprocessing (official): inference, benchmarks and the end-of-training test. eval_transform_list: [resize_256, center_crop_224, to_dtype, normalize_imagenet] -# Training augmentation. -train_transform_list: [resize_short_256, gaussian_blur, jpeg_compression, random_crop_224, random_horizontal_flip, to_dtype, normalize_imagenet] -# Validation during training (differs from the test-time preprocessing above). -val_transform_list: [resize_short_256, center_crop_224, to_dtype, normalize_imagenet] +# Training (paper: resize to 256, random crop 224 and random horizontal flip, "no other augmentations": no blur or JPEG). +train_transform_list: [resize_256, random_crop_224, random_horizontal_flip, to_dtype, normalize_imagenet] +# Validation during training: the test-time preprocessing. +val_transform_list: [resize_256, center_crop_224, to_dtype, normalize_imagenet] diff --git a/conf/model/image/mirror.yaml b/conf/model/image/mirror.yaml new file mode 100644 index 0000000000000000000000000000000000000000..cf528679abc723cfca8c7cc3ee1078cfc8371521 --- /dev/null +++ b/conf/model/image/mirror.yaml @@ -0,0 +1,19 @@ +defaults: + - /model/default + - _self_ + +# MIRROR (NeurIPS 2026, arXiv 2602.02222): DINOv3 ViT-H+/16 + LoRA (r 8, alpha 16) on q/k/v, a frozen 4096-slot +# memory bank of real prototypes (sparse top-128 attention, 8 heads) and a dual-branch head; P(fake) = softmax[:, 1]. +# The official phase-2 checkpoint-h-cur.pth holds the full model and loads key-for-key as mirror.pth. +model_type: mirror +backbone_name: dinov3_vith16plus +backbone_path: null # null: build the backbone from its config (mirror.pth has the weights); a HF-format directory + # (config.json + model.safetensors) loads pretrained DINOv3 weights, e.g. for training +memory_path: null # optional phase-1 memory bank (mirror_phase1.pth); the phase-2 checkpoint already holds it +use_amp: false # fp32, the official default (inference.py --use_amp is opt-in; the checkpoint trained with + # use_amp=False). true = CUDA fp16 autocast, as the README quick-start command; never in training +label_smoothing: 0.1 # official phase-2 loss (timm LabelSmoothingCrossEntropy, --smoothing 0.1) + +# Test-time preprocessing (official data/datasets.py): short side > 512 -> 512 (bicubic), center crop 224, JPEG q96 +# for PNG/BMP/TIFF sources ("format-aligned inputs"), ToTensor; ImageNet normalization is inside the model. +eval_transform_list: [mirror_eval, to_dtype] diff --git a/conf/model/image/vina.yaml b/conf/model/image/vina.yaml new file mode 100644 index 0000000000000000000000000000000000000000..58a034ad8a08d95eb5f741d1f6bf3184f6e0fc67 --- /dev/null +++ b/conf/model/image/vina.yaml @@ -0,0 +1,21 @@ +defaults: + - /model/default + - _self_ + +# VINA (arXiv 2605.21977): DINOv3 ViT-L/16 fine-tuned end to end + a linear head on the CLS (pooler) output, one model +# for images and videos; P(fake) = sigmoid(logit), a video's logit = the mean over its frames. The official +# VINA_DINOv3-L_140k+DDA.pth (HF mgiant/VINA_checkpoints) holds the full model and loads key-for-key as vina.pth. +model_type: vina +backbone_name: dinov3_vitl16 +backbone_path: null # null: build the backbone from its config (vina.pth has the weights); a HF-format + # directory (config.json + model.safetensors) loads pretrained DINOv3 weights +attn_implementation: eager # the official default (models/DINOv3.py) +use_bf16: false # fp32, the official default (configs/VINA_DINOv3.yaml leaves use_bf16 unset) + +# Test-time preprocessing (official dataset/dataloader.py, eval processing 'default' with width = height = 256): +# Resize(256, bicubic) on the short side, CenterCrop(256), ToImage, ToDtype(float32, scale=True), ImageNet +# normalization. +eval_transform_list: [resize_short_256_bicubic, center_crop_256, to_image, to_dtype, normalize_imagenet] +# The official dataloader's 'default' train processing (the VINA training recipe itself is not released). +train_transform_list: [resize_short_256_bicubic, random_crop_256, random_horizontal_flip, to_image, to_dtype, + normalize_imagenet] diff --git a/conf/trainer/image/fat_former.yaml b/conf/trainer/image/fat_former.yaml index 1b2529cf46d564de08a833ef5b2248f35da398cc..38ee870ae5cd0ea3c6fd01418a1256abb8f136f6 100644 --- a/conf/trainer/image/fat_former.yaml +++ b/conf/trainer/image/fat_former.yaml @@ -2,17 +2,31 @@ defaults: - /trainer/default - _self_ +# FatFormer's training recipe as the paper states it (CVPR 2024, Sec. 4.1 "Implementation details"; the authors released no +# training code): Adam (betas 0.9/0.999), initial learning rate 4e-4, 25 epochs, total batch size 256, learning rate x0.9 +# every 10 epochs. Adam without weight decay == AdamW with weight decay 0; no gradient clipping (so no DeepSpeed config). +# The total batch is micro-batch x GPUs x grad_accum_steps (experiments/image/fat_former.sh: 32 x 4 x 2 by default). +# The released checkpoint is taken as the last epoch's model (model_last.pth); model_best.pth (best validation accuracy) is kept +# for reference. trainer_type: fat_former epochs: 25 -lr: 0.0001 -weight_decay: 0.0001 +lr: 4.0e-4 +weight_decay: 0.0 label_smoothing: 0.0 val_interval: 1 test_interval: 1 save_interval: 1 -save: false +save: true save_policy: max +save_path: /ssdstore/ssalehi/SynthScope/models/fat_former +seed: 42 # unspecified in the paper warmup: - mode: on - warmup_ratio: 0.05 - lr_scheduler: cosine + mode: "off" # quoted: a bare off is YAML boolean False + warmup_ratio: 0.0 + lr_scheduler: linear +lr_step: + every: 10 + factor: 0.9 + phase: 1 # StepLR(step_size=10): epochs 1-10 at 4e-4, 11-20 at 3.6e-4, 21-25 at 3.24e-4 (1-based) + grad_accum_steps: 2 + log_every: 100 diff --git a/docs/BENCHMARKS.md b/docs/BENCHMARKS.md index 57cea879e36e503c00e297a36c3e34d4188e572d..ec153770350cae83537e75a29307f6a45041b340 100644 --- a/docs/BENCHMARKS.md +++ b/docs/BENCHMARKS.md @@ -192,6 +192,20 @@ The run writes `manifest.json`, `results.json` and `RESULTS.md` (commit these) p (git-ignored). The Generator benchmarks tab picks up every folder under `benchmark/generator_runs/` automatically; reload the page after a run. +**Rescore note (CuRe).** CuRe's rows in `benchmark/generator_runs/*` and `repro/ideogram_bench*` were first scored +before the scorers passed the source-format hint, so CuRe's official PNG to JPEG q96 step was skipped for the PNG inputs. +They were rescored on 2026-11-08 with the hint (same images and weights; only the CuRe row changed, ranks unchanged). +AUROC old -> new: FLUX.2 klein 4B 98.62 -> 99.02, 9B 96.23 -> 97.08, Qwen-Image-2.1 92.67 -> 92.37, Ideogram 86.88 -> 84.82, +Ideogram 1024 92.10 -> 91.35. + +**Rescore note (PGC).** PGC's rows in `benchmark/generator_runs/*` and `repro/ideogram_bench*` were first scored while the served +PGC dropped its trained LoRA (the official checkpoint's `rgb_stream.` prefix was not remapped; 2026-06-15 to 2026-11-09). They were +rescored on 2026-11-09 with the fixed load (same images; only the PGC row's values changed; the other detectors' values are identical, but their ranks shift where PGC moved). +AUROC old -> new (rank among 23): FLUX.2 klein 4B 97.33 -> 90.70 (4 -> 10), 9B 97.35 -> 90.72 (3 -> 10), Qwen-Image-2.1 +98.50 -> 94.43 (3 -> 5), Ideogram 97.53 -> 94.76 (1 -> 2), Ideogram 1024 98.67 -> 96.02 (1 -> 5). The broken model had the higher +AUROC; accuracy and fake-detection rate rose on Qwen-Image and Ideogram (Qwen 60.0 -> 62.5 and 20.0 -> 27.0, Ideogram 61.5 -> 72.5 and +23.0 -> 47.0; Ideogram 1024 64.5 -> 70.2 and 29.0 -> 43.6) and stayed about the same on FLUX.2 klein (acc 53.5 -> 52.5). + **What the numbers mean.** AUROC is threshold-free (50 is chance, 100 perfect). *Fakes caught* and *Reals flagged* use the detectors' 0.5 threshold, which is not tuned per generator, so accuracy can look poor even when AUROC is high. Real photos are JPEG-origin and of varying size, while the generated images are 1024x1024 PNGs, which can help size- or diff --git a/docs/CAPABILITIES.md b/docs/CAPABILITIES.md index 047e7b857c41ae0c88581a0a42450bd726458bf8..37e028db246d6f551e8888a312a5afcf145ec929 100644 --- a/docs/CAPABILITIES.md +++ b/docs/CAPABILITIES.md @@ -29,10 +29,12 @@ matching `conf/model//.yaml`, a `trainer.py._build_model` branch, | `co_spy` | image | bce | synthscope* | – | Semantic + artifact fusion (SigLIP + SD-VAE) | | `pgc` | image | bce | official | pgc_peak | LoRA-DINOv2 + YCbCr residual, peak-guided | | `cure` | image | ce | official | – | Frozen PE-Core L/14 + Q/V LoRA + source-response subspace (mixing-ratio regression) | -| `d3qe` | image | bce | official | – | LlamaGen VQ quantization error + codebook-aware transformer + CLIP ViT-L/14 (autoregressive images) | +| `d3qe` | image | bce | official | – | LlamaGen VQ quantization error + transformer (codebook-frequency bias zero in the released weights) + CLIP ViT-L/14 (autoregressive images) | | `omniaid` (+ `omniaid_v1`, `omniaid_genimage`) | image | ce | official | – | Hybrid MoE on CLIP ViT-L/14@336: routed semantic experts + an always-on artifact expert | | `dda` | image | bce | official | – | DINOv2 ViT-L/14 + LoRA, pixel- and frequency-aligned training data (center-crop 336) | | `bfree` | image | bce | official | – | DINOv2 ViT-B/14 + registers, bias-free training data; five 504 crops at native resolution | +| `mirror` | image | ce | official | – | Frozen DINOv3 ViT-H+/16 + LoRA + memory bank (seeded default initialization in the released checkpoint): reconstruction of an "ideal reference" (center-crop 224, JPEG q96 for PNG/BMP/TIFF) | +| `vina` | image | bce | official | – | DINOv3 ViT-L/16 + linear head trained on images and video frames together (short side 256, center-crop 256) | | `moejepa` | image | ce | official | – | Frozen V-JEPA 2 ViT-L + residual MoE + gated-attention MIL + BayarConv noise branch (3-way head) | | `effort` (+ `effort_chameleon`) | image | ce | official | – | CLIP ViT-L/14 + SVD-residual attention (orthogonal subspace decomposition) | | `ltf` | image | ce | official | – | Native-resolution 224 tiles + global view, frozen CLIP ViT-L/14, hierarchical MIL + gated fusion (evaluation only) | @@ -41,6 +43,7 @@ matching `conf/model//.yaml`, a `trainer.py._build_model` branch, | `split` | video | video | training-free | – | Temporal roughness x spatial patch-level motion incoherence (X-CLIP) | | `restrav` | video | video | synthscope | – | Representation-trajectory geometry (DINOv2) | | `stall` | video | video | training-free | – | Spatio-temporal whitened log-likelihoods (DINOv3) | +| `vina_video` | video | video | official | – | The `vina` model with the paper's video protocol: ffmpeg 2 fps JPEG frames, the central frame, sigmoid of the mean logit (needs ffmpeg) | `*` served via official weights remapped into the SynthScope class. **`predict_kind`** sets the score convention the engine applies to `forward()` logits: `ce`→`softmax[:,1]`, `bce`→`sigmoid`, diff --git a/docs/WILD_BENCHMARKS.md b/docs/WILD_BENCHMARKS.md index 4e097206dd358b813383c3d2b9319203d8377280..64d263881cbed4b5db04267cef0c432fd34ac15b 100644 --- a/docs/WILD_BENCHMARKS.md +++ b/docs/WILD_BENCHMARKS.md @@ -7,7 +7,8 @@ a balanced accuracy of 75 or more. `…` means the run has not finished yet. All six datasets download and lay themselves out on first use, for example `python benchmark/bench_eval.py --model cure --dataset realchain --root /data/RealChain`. -Each number comes from `repro/bench_results/_.json`; regenerate this page with +Each number comes from `repro/bench_results/_.json` (or `__fixed.json` when a corrected +rerun exists); regenerate this page with `python repro/build_wild_table.py`. | Detector | RealChain | EvalGEN | SynthWildX | WildRF | BFree-Online | RRDataset | Mean acc | @@ -23,11 +24,11 @@ Each number comes from `repro/bench_results/_.json`; regenerate | MoE-JEPA | 66.4 / 73.2 | 70.8 / 86.4 | 73.7 / 80.3 | 68.2 / 73.5 | 58.0 / 85.2 | 59.7 / 64.2 | 66.1 | | DINOv3 probe | 50.3 / 49.7 | 66.6 / 81.7 | 72.8 / 82.5 | **77.3 / 87.7** | 57.1 / 76.5 | 62.6 / 69.5 | 64.4 | | AIDE | 55.5 / 72.4 | 59.7 / 92.7 | 57.4 / 65.7 | 63.6 / 68.6 | 52.8 / 63.1 | 61.1 / 65.2 | 58.4 | +| PGC | 49.3 / 37.1 | 55.4 / 83.0 | 58.1 / 68.0 | 67.7 / 82.9 | 50.3 / 59.8 | 55.5 / 57.8 | 56.0 | | FatFormer | 48.9 / 38.7 | 62.1 / 62.7 | 53.5 / 58.6 | 59.5 / 72.8 | 50.0 / 52.7 | 53.0 / 53.4 | 54.5 | | SAFE | 49.8 / 53.7 | 50.8 / 60.0 | 50.0 / 51.1 | 58.5 / 58.5 | 50.2 / 48.7 | 62.9 / 65.7 | 53.7 | | NPR | 47.2 / 51.7 | 52.6 / 50.6 | 50.4 / 51.7 | 65.0 / 70.9 | 44.1 / 32.2 | 61.1 / 64.1 | 53.4 | | D3QE | 49.5 / 43.5 | 62.2 / 83.9 | 49.6 / 45.5 | 53.0 / 63.9 | 47.0 / 64.0 | 55.0 / 55.1 | 52.7 | -| PGC | 49.9 / 36.0 | 50.2 / 77.7 | 50.9 / 56.3 | 60.1 / 76.8 | 50.0 / 46.5 | 52.3 / 57.8 | 52.2 | | DINOv2 probe | 47.9 / 38.8 | 52.6 / 57.6 | 51.1 / 49.6 | 58.9 / 63.6 | 50.0 / 19.4 | 50.6 / 43.0 | 51.8 | | UnivFD / CLIP | 49.2 / 40.9 | 51.8 / 55.9 | 49.3 / 48.1 | 53.4 / 64.8 | 50.4 / 43.9 | 52.7 / 54.7 | 51.1 | | Adapted DINOv2 | 50.0 / 46.0 | 50.9 / 64.9 | 50.0 / 48.5 | 50.4 / 63.4 | 50.0 / 19.0 | 53.0 / 60.0 | 50.7 | @@ -57,6 +58,13 @@ Each number comes from `repro/bench_results/_.json`; regenerate every fake real (fake recall mostly under 15%), a new measurement that its paper does not report. - The other detectors were never evaluated on these sets by their authors, so their rows are new measurements, not reproductions. +- **Correction (2026-11-09), PGC.** From 2026-06-15 to 2026-11-09 the served PGC dropped the `rgb_stream.*` tensors of + the official checkpoint, including its trained LoRA (the checkpoint prefix was not remapped and the load did not fail), + so the PGC row of this table was scored with a model without its LoRA. The row now comes from the rescored + `pgc__fixed` runs (RealChain 49.9 -> 49.3, EvalGEN 50.2 -> 55.4, SynthWildX 50.9 -> 58.1, WildRF 60.1 -> 67.7, + BFree-Online 50.0 -> 50.3, RRDataset 52.3 -> 55.5 balanced accuracy; mean 52.2 -> 56.0, so PGC moves from 16th to + 12th of 20). It still does not generalize to these sets. Details: + [PGC investigation](../repro/investigate/pgc_gap_investigation.md). - Balanced accuracy uses a fixed 0.5 threshold. A detector with a high AUROC but a balanced accuracy near 50 separates real from fake but is miscalibrated for this data (it calls nearly everything one class). - An AUROC well below 50 means the detector ranks real images as more fake than the generated ones. We traced diff --git a/experiments/image/fat_former.sh b/experiments/image/fat_former.sh index d9c02fe9fdda2345c60574331bd41507218c2eec..0927035793f8c813de14a8020cae224a5e1a4a35 100644 --- a/experiments/image/fat_former.sh +++ b/experiments/image/fat_former.sh @@ -1,17 +1,49 @@ #!/bin/bash -export TRITON_CACHE_DIR=/nvmestore/ssalehi/.triton -export HF_HOME=/nvmestore/ssalehi/.cache/huggingface -export TORCH_HOME=/nvmestore/ssalehi/.cache/torch -export CUDA_VISIBLE_DEVICES=1,2 +# FatFormer (CVPR 2024): the training recipe of the paper (Sec. 4.1; the authors released no training code), in SynthScope. +# data ForenSynths / CNNDetection ProGAN train + val, the released 4-class setting (car, cat, chair, horse; 144k train images) +# model CLIP ViT-L/14 (both towers frozen) + forgery-aware adapters at blocks 7/15/23 (num_vit_adapter 3), language-guided +# alignment (8 context tokens + patch-based enhancer) and text-guided interactor: only those are trained +# train Resize((256, 256)) -> RandomCrop 224 -> flip -> ImageNet normalization ("no other augmentations": no blur/JPEG) +# val Resize((256, 256)) -> CenterCrop 224 -> ImageNet normalization +# loss cross-entropy on the summed logits (Eq. 10), fp32 +# optimizer Adam (AdamW with weight decay 0), lr 4e-4, total batch 256, 25 epochs, lr x0.9 every 10 epochs, no clipping +# batch 256 = NGPU x MICRO x ACCUM; the defaults 4 x 32 x 2 fit 24 GB GPUs (ACCUM is derived from NGPU and MICRO) +# checkpoint model_last.pth (the last epoch, taken as the released model); model_best.pth (best validation accuracy) for reference +# Evaluate with: python benchmark/bench_eval.py --model fat_former --ckpt /model_last.pth --benchmark forensynths --data +export TRITON_CACHE_DIR=${TRITON_CACHE_DIR:-/nvmestore/ssalehi/.triton} +export HF_HOME=${HF_HOME:-/nvmestore/ssalehi/.cache/huggingface} +export TORCH_HOME=${TORCH_HOME:-/nvmestore/ssalehi/.cache/torch} +export CUDA_VISIBLE_DEVICES=${CUDA_VISIBLE_DEVICES:-0,1,2,3} export OMP_NUM_THREADS=1 +DATA=${DATA:-/nvmestore/ssalehi/SynthScope/CNNDetection} +SAVE=${SAVE:-/nvmestore/ssalehi/SynthScope/models/fat_former} +NGPU=${NGPU:-4} +MICRO=${MICRO:-32} +TOTAL_BATCH=256 +if (( TOTAL_BATCH % (NGPU * MICRO) != 0 )); then echo "NGPU x MICRO must divide $TOTAL_BATCH" >&2; exit 1; fi +ACCUM=$((TOTAL_BATCH / (NGPU * MICRO))) -/home/ssalehi/miniconda3/bin/conda run --no-capture-output -n SynthScope accelerate launch --config_file accelerate_config.yaml --num_processes 2 main.py \ +# PREFETCH=false: never download a missing split (a node with only staged classes and no test split must not trigger one). +# Plain DDP (accelerate_config_ddp.yaml), not the repo's DeepSpeed accelerate_config.yaml: that one clips gradients at 1.0, +# which the paper's recipe does not mention. +if (( NGPU > 1 )); then + LAUNCH="accelerate launch --config_file accelerate_config_ddp.yaml --num_processes $NGPU" +else + LAUNCH="python" +fi +/home/ssalehi/miniconda3/bin/conda run --no-capture-output -n SynthScope $LAUNCH main.py \ trainer@TrainerConfig=image/fat_former \ model@ModelConfig=image/fat_former \ - dataset@DatasetConfig=image/aigibench \ - DatasetConfig.train_batch_size=32 \ - DatasetConfig.val_batch_size=32 \ - DatasetConfig.test_batch_size=32 \ + dataset@DatasetConfig=image/cnndetection \ + DatasetConfig.root_dir=$DATA \ + "+DatasetConfig.train_classes=[car,cat,chair,horse]" \ + DatasetConfig.train_batch_size=$MICRO \ + DatasetConfig.val_batch_size=64 \ + DatasetConfig.prefetch=${PREFETCH:-false} \ + TrainerConfig.lr_step.grad_accum_steps=$ACCUM \ + TrainerConfig.save_path=$SAVE \ + "metrics=[real_accuracy,fake_accuracy]" \ logger.name=fat_former \ - logger.mode=online \ - logger.tags=[SynthScope,FatFormer,aigibench] + logger.mode=offline \ + "logger.tags=[SynthScope,FatFormer,progan4]" \ + "$@" diff --git a/interface/backend/app.py b/interface/backend/app.py index ea80463a59caa67e1cc2864f42af480aa382a89e..0db8313b5712d02e64d830ccd1383dc566bce583 100644 --- a/interface/backend/app.py +++ b/interface/backend/app.py @@ -71,6 +71,11 @@ async def predict(file: UploadFile = File(...), model: str = Form(...)): raise HTTPException(status_code=404, detail=str(e)) engine = get_engine() + if engine.ffmpeg_missing(spec): + raise HTTPException( + status_code=409, + detail=f"'{spec.key}' needs ffmpeg (set SYNTHSCOPE_FFMPEG or pip install imageio-ffmpeg).", + ) if not engine.is_available(spec): raise HTTPException( status_code=409, @@ -290,9 +295,11 @@ def _registry_name(key: str) -> str: _FAMILY = [ # (substring -> benchmark family label); first match wins ("genimage", "GenImage"), ("forensynth", "ForenSynths"), ("universalfakedetect", "UniversalFakeDetect"), - ("ojha", "UniversalFakeDetect"), ("ufd", "UniversalFakeDetect"), ("aigcdetect", "AIGCDetect"), + ("ojha", "UniversalFakeDetect"), ("ufd", "UniversalFakeDetect"), ("univfakedetect", "UniversalFakeDetect"), + ("aigcdetect", "AIGCDetect"), ("co-spy-bench in-the-wild", "In-the-wild"), # before "co-spy-bench": a different benchmark - ("co-spy-bench", "Co-Spy-Bench"), ("aigibench", "AIGIBench"), ("aigi", "AIGIBench"), + ("co-spy-bench", "Co-Spy-Bench"), ("human-aigi", "Human-AIGI"), # before "aigi": its own benchmark + ("aigibench", "AIGIBench"), ("aigi", "AIGIBench"), ("commgen", "CommGen15"), ("genvideo", "GenVideo"), ("evalcrafter", "EvalCrafter"), ("videophy", "VideoPhy"), ("vidprom", "VidProM"), ("genvidbench", "GenVidBench"), ("ditfake", "DiTFake"), ("diffusionforensics", "DiffusionForensics"), diff --git a/interface/backend/build_repro_full.py b/interface/backend/build_repro_full.py index 753cd7a7bb93c52f03521d17aa53b726f8e48c8e..c025d4749af0610ebc06c9fe3928614bb4700de2 100644 --- a/interface/backend/build_repro_full.py +++ b/interface/backend/build_repro_full.py @@ -17,14 +17,17 @@ ROOT = str(Path(__file__).resolve().parents[2]) # the repository root, whereve VAL = { # AIGCDetect is the ProGAN-trained setting (B1); we only retrained the SDv1.4 setting, so no SynthScope_train here. ("aide", "AIGCDetect"): {"official": {"map": 97.94, "acc": 91.89}}, - # SynthScope_train = faithful native-res 5-view retrain (aide_native_v2/model_2) — reproduces official. + # SynthScope_train = faithful native-res 5-view retrain (aide_native_v2/model_2) — reproduces the official mAP (acc is lower). ("aide", "GenImage"): {"official": {"map": 97.12, "acc": 85.91}, "synthscope": {"map": 96.42, "acc": 77.87}}, - ("clip", "ForenSynths"): {"synthscope": {"map": 97.22, "acc": 88.28}, "official": {"map": 96.95}}, + # ForenSynths = the paper's 11 generators (no StyleGAN2 / WhichFaceIsReal), recomputed from the per-generator entries + # of {clip,cnn}_{synthscope,official}_forensynths.json; the 8-GAN subset gives clip 97.22 / 96.96, cnn 94.42 / 92.67. + ("clip", "ForenSynths"): {"synthscope": {"map": 92.83, "acc": 85.39}, "official": {"map": 92.33, "acc": 80.58}}, ("clip", "UniversalFakeDetect"): {"synthscope": {"map": 96.44, "acc": 87.23}, "official": {"map": 95.66}}, - ("cnn", "ForenSynths"): {"synthscope": {"map": 94.42, "acc": 76.36}, "official": {"map": 92.67}}, - ("co_spy", "Co-Spy-Bench"): {"synthscope": {"map": 96.6, "acc": 89.9}, "official": {"map": 86.65, "acc": 83.88}}, + ("cnn", "ForenSynths"): {"synthscope": {"map": 90.44, "acc": 74.57}, "official": {"map": 90.77, "acc": 75.82}}, + # synthscope Co-Spy-Bench / GenImage = cospy_full/model_1.pth, the checkpoint promoted to co_spy.pth (2026-06-08). + ("co_spy", "Co-Spy-Bench"): {"synthscope": {"map": 96.7, "acc": 90.28}, "official": {"map": 86.65, "acc": 83.88}}, ("co_spy", "AIGCDetect"): {"official": {"map": 94.59, "acc": 89.25}, "synthscope": {"map": 84.91}}, - ("co_spy", "GenImage"): {"official": {"map": 92.41}, "synthscope": {"map": 90.59, "acc": 75.91}}, + ("co_spy", "GenImage"): {"official": {"map": 92.41}, "synthscope": {"map": 90.59, "acc": 76.23}}, ("co_spy", "ForenSynths"): {"official": {"map": 87.97}, "synthscope": {"map": 96.17}}, # CuRe: only the official adapter exists (the training recipe is unreleased), so there is no SynthScope-trained number. ("cure", "AIGIBench"): {"official": {"map": 97.0, "acc": 92.85, "auroc": 97.48}}, @@ -106,13 +109,17 @@ VAL = { # official GenImage val (100,000 images; ltf_synthscope_genimage_val100k). On the 33k set the official ltf_ref # code gives 98.38, the same as SynthScope. ("ltf", "GenImage"): {"official": {"map": 99.86, "acc": 98.36, "auroc": 99.88}}, - ("fat_former", "4-class"): {"official": {"map": 99.7, "acc": 98.39}}, - ("fat_former", "Diffusion-model"): {"official": {"map": 98.6, "acc": 93.72}}, + # synthscope = trained in SynthScope with the paper's recipe (experiments/image/fat_former.sh; train job 277158), model_last + # (epoch 24); evals = DAS6 job 66626 (tags fat_former_trained_last_forensynths / _ufd). DMs = the 8 UFD subsets (paper: 10). + ("fat_former", "4-class"): {"official": {"map": 99.7, "acc": 98.39}, "synthscope": {"map": 99.56, "acc": 97.29, "auroc": 99.42}}, + ("fat_former", "Diffusion-model"): {"official": {"map": 98.6, "acc": 93.72}, "synthscope": {"map": 98.88, "acc": 92.09, "auroc": 98.67}}, # synthscope = trained in SynthScope with the official recipe (experiments/image/npr.sh; job 265720, eval 265808). ("npr", "Table 1"): {"official": {"map": 94.22, "acc": 92.30}, "synthscope": {"map": 93.83, "acc": 84.09, "auroc": 94.94}}, ("npr", "Table 2"): {"official": {"map": 96.49, "acc": 94.81}}, ("npr", "Table 3"): {"official": {"map": 99.4, "acc": 95.03}}, - ("npr", "Table 4"): {"official": {"map": 96.69, "acc": 93.94}, "synthscope": {"map": 97.49, "acc": 88.91, "auroc": 97.23}}, + # Table 4 official = NPR.pth, the served file (npr_official_nprpth_ufd); model_epoch_last_3090.pth gives 96.69 / 93.94. + # Tables 2, 3 and 5 were measured with model_epoch_last_3090.pth (the registry default before 2026-06-09) only. + ("npr", "Table 4"): {"official": {"map": 97.16, "acc": 94.57}, "synthscope": {"map": 97.49, "acc": 88.91, "auroc": 97.23}}, ("npr", "Table 5"): {"official": {"map": 83.47, "acc": 79.13}}, # SAFE now SERVES the SynthScope-trained checkpoint (retrain v2 / model_38), which reproduces the paper. ("safe", "ForenSynths"): {"official": {"map": 98.78, "acc": 96.2}, "synthscope": {"map": 97.79, "acc": 95.1}}, @@ -123,8 +130,14 @@ VAL = { ("safe", "DiffusionForensics"): {"synthscope": {"map": 99.34, "acc": 91.3}}, ("pgc", "GenImage"): {"official": {"map": 100.0, "acc": 99.49}, "synthscope": {"map": 97.62, "acc": 78.6}}, # synthscope UFD / ForenSynths = the official recipe in SynthScope, step 500 (experiments/image/pgc.sh; jobs 266276, 266282, 266660). - ("pgc", "UniversalFakeDetect"): {"official": {"map": 99.34, "acc": 94.16}, "synthscope": {"map": 98.99, "acc": 91.96, "auroc": 98.92}}, - ("pgc", "ForenSynths"): {"official": {"map": 96.25, "acc": 83.73}, "synthscope": {"map": 97.41, "acc": 85.89, "auroc": 97.63}}, + # official UFD / ForenSynths-8 = the served PGC_train_progan_ckpt.pth with the checkpoint load FIXED (2026-11-09), PadCenterCrop + # eval: tags pgc_official_ufd8_fixed and (FS-8 subset of) pgc_official_forensynths13_fixed. They match the official PGC code + # (pgc_official_eval.py: UFD 99.34 / 94.16, FS-13 96.25 / 83.73) within 0.03. Correction 2026-11-09: from 2026-06-15 to + # 2026-11-09 the load dropped the checkpoint's rgb_stream.* tensors, trained LoRA included, so the earlier tags + # (pgc_official_ufd8 99.17 / 83.57, FS-8 96.41 / 76.34 / 97.06, now in bench_results/_superseded/) understated accuracy. + # GenImage / AIGIBench / CommGen15 official = official-code numbers (never affected). + ("pgc", "UniversalFakeDetect"): {"official": {"map": 99.35, "acc": 94.19, "auroc": 99.31}, "synthscope": {"map": 98.99, "acc": 91.96, "auroc": 98.92}}, + ("pgc", "ForenSynths"): {"official": {"map": 97.83, "acc": 89.17, "auroc": 98.14}, "synthscope": {"map": 97.41, "acc": 85.89, "auroc": 97.63}}, ("pgc", "AIGIBench"): {"official": {"map": 95.36, "acc": 88.33}, "synthscope": {"map": 86.88}}, ("pgc", "CommGen15"): {"official": {"map": 99.26, "acc": 97.39}, "synthscope": {"map": 98.61, "acc": 66.66}}, # SPAI serves the official weights remapped into the SynthScope class, scored at NATIVE resolution (the faithful @@ -145,6 +158,40 @@ VAL = { # AUROC / acc at the calibrated threshold. synthscope = job 270384, official = official code end to end (job 270323). ("split", "GenVideo"): {"synthscope": {"map": 99.79, "auroc": 99.97, "acc": 99.41}, "official": {"map": 96.12, "auroc": 99.16}}, ("restrav", "GenVidBench"): {"synthscope": {"map": 92.7, "auroc": 95.9, "acc": 86.87}}, + # MIRROR: the official phase-2 checkpoint (DINOv3 ViT-H+; no SynthScope-trained number). acc = mean per-subset + # balanced accuracy at 0.5; the paper column is the README's DINOv3-H+ value. Synthbuster uses the official + # extension-based JPEG-q96 rule (99.43 with the served decoded-format rule); UnivFakeDetect uses the official + # code's 13-subset UnivFD list (93.81 on the paper's Table 7 list). Jobs 279513, 279527, 279550-279555. + ("mirror", "AIGCDetect"): {"official": {"map": 99.49, "acc": 97.39, "auroc": 99.51}}, + ("mirror", "GenImage"): {"official": {"map": 100.0, "acc": 99.78, "auroc": 100.0}}, + ("mirror", "UnivFakeDetect"): {"official": {"map": 97.04, "acc": 92.44, "auroc": 97.24}}, + ("mirror", "Synthbuster"): {"official": {"map": 99.92, "acc": 99.28, "auroc": 99.96}}, + ("mirror", "EvalGEN"): {"official": {"map": 100.0, "acc": 99.85, "auroc": 99.99}}, + ("mirror", "SynthWildX"): {"official": {"map": 97.71, "acc": 95.08, "auroc": 98.33}}, + ("mirror", "WildRF"): {"official": {"map": 99.8, "acc": 97.88, "auroc": 99.74}}, # official file set (no .jfif) + ("mirror", "AIGIBench"): {"official": {"map": 98.06, "acc": 94.98, "auroc": 98.66}}, + ("mirror", "RRDataset"): {"official": {"map": 93.86, "acc": 86.91, "auroc": 91.98}}, + ("mirror", "BFree-Online"): {"official": {"map": 99.78, "acc": 97.4, "auroc": 99.5}}, + ("mirror", "RealChain"): {"official": {"map": 91.76, "acc": 81.71, "auroc": 89.96}}, + # VINA: the official VINA_DINOv3-L_140k+DDA checkpoint (no SynthScope-trained number: the training code is not released). + # acc / mAP = the OFFICIAL metric (the _offmetric tags): per-subset pooled accuracy at 0.5 and AP, mean over subsets, as + # the paper reports them; mauroc is the mean AUROC from the same scores: bench_eval's own, except ForenSynths and + # ARForensics (the _offmetric files' mean over the official subsets) and GenVideo-Val (the _offmetric AUROC, pooled). + # ARForensics = the six subsets shared with the paper (our copy has Switti, no MAR; + # the 7-row bench_eval mean 96.88 / 99.60 is not comparable with the paper). GenImage = the full val split + # (vina_genimage_val100k); the 1500-per-class test bundle (vina_genimage_full) is its own reference row. + # Jobs: CPU 281654-281656, 281831; GPU 281657, DAS6 66630. + ("vina", "ForenSynths"): {"official": {"map": 97.8, "acc": 86.93, "auroc": 97.44}}, + ("vina", "UniversalFakeDetect"): {"official": {"map": 99.01, "acc": 94.84, "auroc": 98.71}}, + ("vina", "DiTFake"): {"official": {"map": 99.95, "acc": 97.98, "auroc": 99.94}}, + ("vina", "ARForensics"): {"official": {"map": 99.54, "acc": 96.36, "auroc": 99.38}}, + ("vina", "GenImage (8 subsets"): {"official": {"map": 99.05, "acc": 94.74, "auroc": 98.72}}, + ("vina", "GenImage test bundle"): {"official": {"map": 98.45, "acc": 93.29, "auroc": 97.98}}, + ("vina", "GenVideo-Val"): {"official": {"map": 99.26, "acc": 96.86, "auroc": 99.14}}, # overall pooled ACC / AP + ("vina", "SynthWildX"): {"official": {"map": 96.36, "acc": 91.82, "auroc": 97.46}}, + ("vina", "WildRF"): {"official": {"map": 99.41, "acc": 96.12, "auroc": 99.25}}, + ("vina", "AIGIBench"): {"official": {"map": 97.33, "acc": 92.72, "auroc": 97.6}}, + ("vina", "RRDataset"): {"official": {"map": 92.77, "acc": 82.89, "auroc": 91.69}}, ("stall", "GenVideo"): {"synthscope": {"map": 82.38, "auroc": 83.51, "acc": 56.88}}, ("stall", "VideoFeedback"): {"synthscope": {"map": 83.07, "auroc": 85.1, "acc": 62.12}}, ("stall", "ComGenVid"): {"synthscope": {"map": 82.59, "auroc": 84.0, "acc": 57.34}}, @@ -154,6 +201,17 @@ VAL = { ("co_spy", "In-the-wild"): {}, # genuinely not evaluated (prevents the "Co-Spy-Bench" substring collision) } +# Narrow label overrides applied after status_for (which stays unchanged for every other detector): +# (model, exact benchmark label) -> status. +# MIRROR RRDataset: 86.91 vs the README's 88.3 is 1.39 short, about 6x MIRROR's other deviations (all within 0.25), but +# inside the generic +-2.0 tolerance, which would label it "official". Every doc calls it short, so the site does too. +# VINA SynthWildX and WildRF: the paper prints per-subset values only; SynthScope is below it on both (and the unmodified +# official eval.py gives the same scores on our files, so the gap is the data). The means of the printed values (92.8, +# 97.13) are within the generic +-2.0 tolerance, which would label them "official". +STATUS_OVERRIDE = {("mirror", "RRDataset (pooled folder)"): "below", + ("vina", "SynthWildX (dalle3 / firefly / midjourney_v5)"): "below", + ("vina", "WildRF (facebook / reddit / twitter)"): "below"} + # Tolerance (percentage points) for calling a number a reproduction of the paper. TOL = {"map": 2.0, "acc": 2.0, "auroc": 2.5} @@ -279,6 +337,7 @@ for f in sorted(glob.glob(f"{ROOT}/repro/benchmark_specs/*.json")): spec_status = b.get("our_status", "") synthscope, official, sub = match_val(model, name) status = status_for(name, paper, synthscope, official, spec_status) + status = STATUS_OVERRIDE.get((model, name), status) on = b.get("our_number") note = "" if isinstance(on, dict) and on.get("note"): diff --git a/interface/backend/engine.py b/interface/backend/engine.py index a96c12cd33cd98fb913e6038b3534a8311a0fca8..c1a57abca69dc1c02e46cbdf6130dc9dff3f8c43 100644 --- a/interface/backend/engine.py +++ b/interface/backend/engine.py @@ -7,6 +7,7 @@ and kept in a small LRU so a shared GPU is not exhausted. All forward passes hap import base64 import gc import io +import logging import math import threading import time @@ -21,6 +22,8 @@ from . import config from .registry import ModelSpec, get_spec, input_note from . import media +logger = logging.getLogger(__name__) + def _png_b64(img: Image.Image) -> str: buf = io.BytesIO() @@ -124,6 +127,12 @@ def _build_model(cfg): if model_type == "ltf": from models.image.ltf.ltf import SynthScopeLTFModel return SynthScopeLTFModel(cfg) + if model_type == "mirror": + from models.image.mirror.mirror import SynthScopeMIRRORModel + return SynthScopeMIRRORModel(cfg) + if model_type == "vina": + from models.image.vina.vina import SynthScopeVINAModel + return SynthScopeVINAModel(cfg) if model_type == "stall": from models.video.stall.stall import SynthScopeSTALLModel return SynthScopeSTALLModel(cfg) @@ -186,6 +195,17 @@ def _load_checkpoint(model, spec: ModelSpec): f"{spec.key}: checkpoint mismatch missing={real_missing[:8]} " f"unexpected={unexpected[:8]}" ) + elif real_missing or unexpected: + # Non-official kinds are not raised on (a model may legitimately rebuild some tensors itself, declared via + # ``pretrained_prefixes``), but a mismatch must never be silent: dropped keys (e.g. a wrapper prefix the + # checkpoint carries and the class does not, which once left the served PGC without its LoRA weights) or + # tensors that kept their __init__ values change what the detector computes. + logger.warning( + "%s: checkpoint %s does not match the model exactly: %d unexpected key(s) were dropped and %d key(s) kept " + "their __init__ values (unexpected=%s, missing=%s). Fix the remap or declare the keys in the model's " + "pretrained_prefixes.", spec.key, path.name, len(unexpected), len(real_missing), unexpected[:4], + real_missing[:4], + ) return ( f"loaded {len(sd)} tensors from {path.name} " f"(missing={len(real_missing)}, unexpected={len(unexpected)})" @@ -209,11 +229,18 @@ class Engine: return None return config.CHECKPOINTS_DIR / spec.checkpoint + @staticmethod + def ffmpeg_missing(spec: ModelSpec) -> bool: + """True for a detector whose video protocol shells out to ffmpeg (vina_video) when none can be found.""" + return spec.video_sampler == "ffmpeg_fps_center" and not media.ffmpeg_available() + def is_available(self, spec: ModelSpec) -> bool: if spec.key == "stall": # training-free, but needs the gated DINOv3 ViT-L/16 weights import os from .registry import DINOV3_WEIGHTS return os.path.exists(os.environ.get("DINO_V3_WEIGHTS") or DINOV3_WEIGHTS) + if self.ffmpeg_missing(spec): + return False if spec.ckpt_kind == "none": # training-free (D3) return True p = self.checkpoint_path(spec) @@ -300,6 +327,8 @@ class Engine: z = -z return torch.sigmoid(z) out = model(frames) # [1,2] + if spec.video_prob == "sigmoid": # one fake logit (VINA: the mean of the frame logits) + return torch.sigmoid(out.reshape(-1)) if spec.key == "stall": # STALL returns [real_prob, fake_prob] (already calibrated percentiles); use directly. return out[:, 1] @@ -410,6 +439,9 @@ class Engine: def video_clip(self, spec: ModelSpec, path) -> torch.Tensor: """Decode and normalize a clip exactly as ``spec`` prescribes: ``[T, 3, H, W]``.""" + if spec.video_sampler == "ffmpeg_fps_center": # VINA: ffmpeg JPEG frames, central window, image transform + frames = media.ffmpeg_fps_frames(path, fps=spec.fps, num_frames=spec.num_frames) + return torch.stack([spec.transform(f) for f in frames]) clip = media.video_clip_tensor( path, num_frames=spec.num_frames, fps=spec.fps, frame_size=spec.frame_size, window_center=spec.window_center, interp=spec.resize_interp, diff --git a/interface/backend/media.py b/interface/backend/media.py index 390e7e3bb6e8230335f645cc61f7171834940219..5b7474ea3137264308b135d8ac28e9abd0d3ee8a 100644 --- a/interface/backend/media.py +++ b/interface/backend/media.py @@ -6,12 +6,21 @@ training/eval pipeline does: * ``dataset.sample_video_frames`` -> evenly-sampled clip [T,3,size,size] float in [0,1] """ import io +import os +import shutil +import subprocess +import tempfile from pathlib import Path import numpy as np import torch from PIL import Image, ImageFile +try: # optional: a static ffmpeg for the ffmpeg-based video protocols (VINA) + import imageio_ffmpeg +except ImportError: + imageio_ffmpeg = None + # Some user uploads are truncated/progressive; let PIL load what it can. ImageFile.LOAD_TRUNCATED_IMAGES = True @@ -38,15 +47,28 @@ def media_kind(filename: str, content_type: str | None = None) -> str: raise ValueError(f"Unsupported file type: {filename!r} (content_type={content_type})") -def decode_image(data: bytes) -> Image.Image: - """Decode raw bytes into an RGB PIL image.""" - source = Image.open(io.BytesIO(data)) - source_format = source.format +def to_rgb(source: Image.Image) -> Image.Image: + """``source.convert("RGB")`` that records the source file format (PNG, JPEG, ...) in ``info[SRC_FORMAT_KEY]``, so + format-aware eval transforms (CuRe, MIRROR: PNG sources get a JPEG round trip) see what the official loaders see. + A hint already present (an image that was converted before) is kept; the caller's image is not modified.""" + source_format = source.info.get(SRC_FORMAT_KEY) or source.format image = source.convert("RGB") - image.info[SRC_FORMAT_KEY] = source_format # lets format-aware transforms (CuRe) see PNG vs JPEG + if source_format: + image.info[SRC_FORMAT_KEY] = source_format return image +def decode_image(data: bytes) -> Image.Image: + """Decode raw bytes into an RGB PIL image (with the source-format hint, see ``to_rgb``).""" + return to_rgb(Image.open(io.BytesIO(data))) + + +def open_rgb(path: str | Path) -> Image.Image: + """Open an image file as RGB (with the source-format hint, see ``to_rgb``).""" + with Image.open(path) as source: + return to_rgb(source) + + def sample_video_pil(path: str | Path, num_frames: int) -> list[Image.Image]: """Sample ``num_frames`` frames spread across the whole video, at native resolution. @@ -75,6 +97,60 @@ def sample_video_pil(path: str | Path, num_frames: int) -> list[Image.Image]: return frames +def ffmpeg_available() -> bool: + try: + ffmpeg_exe() + except (FileNotFoundError, RuntimeError, OSError): # RuntimeError: imageio-ffmpeg found no binary + return False + return True + + +def ffmpeg_exe() -> str: + """The ffmpeg binary: ``$SYNTHSCOPE_FFMPEG``, else ``ffmpeg`` on the PATH, else imageio-ffmpeg's static build.""" + env = os.environ.get("SYNTHSCOPE_FFMPEG") + if env: + if not os.path.isfile(env) and shutil.which(env) is None: + raise FileNotFoundError(f"SYNTHSCOPE_FFMPEG={env!r} is not an executable file") + return env + exe = shutil.which("ffmpeg") + if exe: + return exe + if imageio_ffmpeg is not None: + try: + return imageio_ffmpeg.get_ffmpeg_exe() + except RuntimeError as e: + raise FileNotFoundError(f"imageio-ffmpeg found no ffmpeg binary ({e})") from e + raise FileNotFoundError("ffmpeg not found: install it, set SYNTHSCOPE_FFMPEG, or pip install imageio-ffmpeg") + + +def ffmpeg_fps_frames(path: str | Path, fps: float, num_frames: int, timeout: float = 300.0) -> list[Image.Image]: + """VINA's official video protocol: ffmpeg writes the video as JPEG frames at ``fps`` with its default JPEG settings + (preprocess/video2frame.py: ``ffmpeg -loglevel quiet -i