diff --git a/LEADERBOARD.md b/LEADERBOARD.md index eea1821c322507043029dba0cbfb3d478c0070bc..e7708487c66c3678c11e88cda40c79c69e4f1cc0 100644 --- a/LEADERBOARD.md +++ b/LEADERBOARD.md @@ -11,7 +11,7 @@ Metrics are percentages. **mAP** = mean AP over generators. Each track is ranked | Rank | Method | Eval | Acc | **mAP** | AP | AUROC | Verified | Notes | | --- | --- | --- | --- | --- | --- | --- | --- | --- | | 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) | +| 2 | CO-SPY (official weights) | official-weights | 95.12 | 98.85 | — | 99.03 | ✓ | ForenSynths-8, full test sets; 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 | diff --git a/LICENSES.md b/LICENSES.md index 296af4611ae54cd798a14f125e4f287bae9e0719..a0458fa283de6115318f736906dd84597ec8361c 100644 --- a/LICENSES.md +++ b/LICENSES.md @@ -15,6 +15,9 @@ third-party components, and every **pretrained checkpoint / backbone** SynthScop > non-commercial-only**, and some weights are **gated** (require accepting an upstream license). > The table below is a starting point — verify each entry against its source. (`⚠ verify` = please > confirm and fill in from the official repo before relying on it.) +> +> `synthscope push` enforces this for the rows marked **unclear** / **not redistributed** below: the keys in +> `NEVER_REDISTRIBUTE` (`synthscope/hub.py`) are refused even with `--include-official`; update that constant together with the table when a licence is clarified. ## Detectors @@ -39,6 +42,7 @@ third-party components, and every **pretrained checkpoint / backbone** SynthScop | `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 | +| `probe`, `probe_resnet` | PROBE (ICML'26) | Amamiya-C/PROBE-AIGI-Detection | **unclear**: the repo (commit b145f71) has no LICENSE file, GitHub reports no licence and the README states none; `official/dino_classifier.py` and `official/resnet50.py` vendor `Detector/model/*.py`, and `preprocess.py` vendors `pad_image` and the sliding-patch step of `Detector/util.py` / `evaluate_dino.py` (see the file headers) | **official** checkpoints (`DINOv2_best_model_step_34999.pth` and `ResNet50_best_model_step_19343.pth` from ModelScope `shuinishaojiu/PROBE-AIGI-Detection`, loaded as `probe.pth` / `probe_resnet.pth`; the DINOv2 one contains the DINOv2-with-registers ViT-L/14 weights) | **unclear** (the ModelScope licence field is empty); 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`); 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) | @@ -47,6 +51,7 @@ third-party components, and every **pretrained checkpoint / backbone** SynthScop | `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 (backbone: see below) | +| `waverep`, `waverep_g4` | WaveRep (NeurIPS'25) | grip-unina/WaveRep-SyntheticVideoDetection | GRIP-UNINA license (`LICENSE.md`): informational and **nonprofit use only** (notices kept, authors credited); `official_utils.py` vendors `demo/utils.py` — see its header | **official** checkpoints (`weights_dinov2_G1.ckpt` / `weights_dinov2_G4.ckpt` from grip.unina.it, md5 as the demo README, loaded as `waverep.pth` / `waverep_g4.pth`; they contain the DINOv2 ViT-B/14 + registers weights) | GRIP-UNINA license (nonprofit use only); not in the model zoo; not on the Space (pending user approval) | | `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) @@ -57,6 +62,8 @@ 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) | +| DINOv2 with registers ViT-B/14 (timm `vit_base_patch14_reg4_dinov2.lvd142m`) | `bfree`, `waverep` / `waverep_g4` (their weights are inside the official checkpoints; the timm download is only needed for training) | Apache-2.0 (timm / DINOv2 model card) | +| DINOv2 with registers ViT-L/14 (HF `facebook/dinov2-with-registers-large`) | `probe` (its weights are inside the PROBE checkpoint; the HF download is only needed for training) | Apache-2.0 (HF model card) | | 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) | diff --git a/benchmark/bench_eval.py b/benchmark/bench_eval.py index 18341aee56845b248e3851a9fa0adc60e6a91882..e40ae0da206259c74e77d3b68ec5cf873c03d62b 100644 --- a/benchmark/bench_eval.py +++ b/benchmark/bench_eval.py @@ -191,8 +191,7 @@ def score(det, model, spec, paths: list[Path], bs: int, transform=None, tf = transform if transform is not None else spec.transform # Native-resolution specs (SPAI any-res) produce variable-size tensors that cannot be stacked, # so they MUST be scored one image at a time. - if getattr(spec, "native_res", False): - bs = 1 + bs = spec.eval_batch_size(bs) probs, kept = [], [] for i in range(0, len(paths), bs): batch = [] diff --git a/benchmark/bench_eval_video.py b/benchmark/bench_eval_video.py index 40338d8f7f29c081a3e37bb43cada4543a3b3489..6d1defb2d9887614da83947ed9b4cc462d14c5cb 100644 --- a/benchmark/bench_eval_video.py +++ b/benchmark/bench_eval_video.py @@ -1,4 +1,5 @@ -"""Unified VIDEO benchmark eval for SynthScope video detectors (d3, split, restrav, stall, vina_video). +"""Unified VIDEO benchmark eval for SynthScope video detectors (d3, split, restrav, stall, vina_video, waverep, +waverep_g4). 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 @@ -14,6 +15,17 @@ per-generator + mean acc@0.5 / AP / AUROC, and writes the SAME JSON schema as be Each generator reports AP with fake as the positive class (``ap``) and with real as the positive class (``ap_real``, what D3's official eval.py computes: ``average_precision_score(1 - y_true, std)``). +Resumable / parallel scoring (long benchmarks): ``--cache-dir DIR`` stores every scored video (P(fake), the raw logit +when the detector reports one, or the decode error) in DIR/scores.*.jsonl, keyed by the last three path components, and reuses it on the next run; ``--shard K/N`` scores only the K-th of N slices of the unique videos and stops +(run the N slices on N GPUs, then one final run without ``--shard`` reads every slice and writes the metrics). +A detector that reports a raw logit (WaveRep) is ranked by it (AP / AUROC), because the 6-dp rounded P(fake) ties +very confident videos at 0 / 1; accuracy still thresholds P(fake) at 0.5. Videos that cannot be decoded +(backend.media.VideoDecodeError) are counted per generator (failed_real / failed_fake) and in the result JSON +(failed_to_decode: decode failures only, cached); any other error (OOM, I/O) is counted in failed_other, never cached +and retried; both kinds are left out of the metrics. The cache directory carries cache_meta.json (model key, sha256 of +the resolved checkpoint, frame count / sampler / transform, format version): a run whose setup differs is refused. +The result JSON also records limit, reals, ckpt_sha256 and cache_dir. + Benchmark layouts: genvideo /Fake//*.mp4 + /Real/*.mp4 (shared real pool) [GenVideo-Val] fakeonly //*.mp4 (all fake) + --reals DIR of real videos [EvalCrafter] @@ -23,8 +35,11 @@ from __future__ import annotations import argparse import datetime +import hashlib import json +import os import sys +import time from pathlib import Path import numpy as np @@ -32,6 +47,7 @@ import torch sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "interface")) from backend.engine import get_engine # noqa: E402 +from backend.media import VideoDecodeError # noqa: E402 from backend.registry import get_spec # noqa: E402 from datasets_util import ensure_dataset # noqa: E402 @@ -90,13 +106,23 @@ def discover(benchmark: str, root: Path, shared_reals: Path | None, select): return out -def metrics(fake_probs: torch.Tensor, labels: torch.Tensor): +def metrics(fake_probs: torch.Tensor, labels: torch.Tensor, rank: np.ndarray | None = None): + """acc@0.5 on ``fake_probs``; AP / AP_real / AUROC on ``fake_probs`` (torchmetrics, unchanged) or, when ``rank`` (a + float64 raw score, higher = more likely fake, e.g. the logit) is given, on ``rank`` with scikit-learn, so that + saturated probabilities do not tie.""" from torchmetrics.functional import auroc, average_precision if labels.unique().numel() < 2: return None - ap = float(average_precision(fake_probs, labels, task="binary")) * 100 - ap_real = float(average_precision(1 - fake_probs, 1 - labels, task="binary")) * 100 - au = float(auroc(fake_probs, labels, task="binary")) * 100 + if rank is None: + ap = float(average_precision(fake_probs, labels, task="binary")) * 100 + ap_real = float(average_precision(1 - fake_probs, 1 - labels, task="binary")) * 100 + au = float(auroc(fake_probs, labels, task="binary")) * 100 + else: + from sklearn.metrics import average_precision_score, roc_auc_score + y = labels.numpy() + ap = float(average_precision_score(y, rank)) * 100 + ap_real = float(average_precision_score(1 - y, -rank)) * 100 + au = float(roc_auc_score(y, rank)) * 100 preds = (fake_probs >= 0.5).int() real_acc = float((preds[labels == 0] == 0).float().mean()) * 100 fake_acc = float((preds[labels == 1] == 1).float().mean()) * 100 @@ -107,17 +133,149 @@ def metrics(fake_probs: torch.Tensor, labels: torch.Tensor): FPRS = (0.001, 0.01, 0.05) +CACHE_FORMAT = 2 # 2: error records carry "kind" ("decode" is cached, anything else is retried) + + +def _sha256(path: Path) -> str: + h = hashlib.sha256() + with path.open("rb") as f: + for chunk in iter(lambda: f.read(1 << 24), b""): + h.update(chunk) + return h.hexdigest() + + +def cache_meta(engine, spec) -> dict: + """What a score cache is valid for: the detector key, the sha256 of the resolved checkpoint, and every spec field that + changes a video's score (frame count, sampler, preprocessing).""" + ck = engine.checkpoint_path(spec) + return {"model": spec.key, + "ckpt_sha256": _sha256(Path(ck).resolve()) if ck is not None else None, + "spec": {"num_frames": spec.num_frames, "video_sampler": spec.video_sampler, + "transform": repr(spec.transform), + **{k: repr(getattr(spec, k, None)) for k in ("fps", "frame_size", "window_center", "video_norm")}}, + "cache_format": CACHE_FORMAT} + + +class ScoreCache: + """Per-video score store shared by shards and re-runs: DIR/scores..jsonl, one JSON per line, keyed by the last + three components of the video path. All ``scores.*.jsonl`` in DIR are read; only ``scores.`` is written (created + on the first write). DIR/cache_meta.json records what the scores are valid for (``cache_meta``): the first use writes + it, a later use with a different model / checkpoint / spec / format is refused.""" + + def __init__(self, cache_dir, tag: str, meta: dict | None = None, write_meta=True): + self.rec, self.only, self.tag = {}, False, tag + self.dir = Path(cache_dir) + self.dir.mkdir(parents=True, exist_ok=True) + if meta is not None: + self._check_meta(meta, write_meta) + for f in sorted(self.dir.glob("scores.*.jsonl")): + for line in f.read_text().splitlines(): + if line.strip(): + r = json.loads(line) + self.rec[r["k"]] = r + self._out = None + + def _check_meta(self, meta: dict, write: bool): + mp = self.dir / "cache_meta.json" + if not mp.exists() and write: + tmp = mp.with_name(f".cache_meta.{os.getpid()}.tmp") + tmp.write_text(json.dumps(meta, indent=1, sort_keys=True) + "\n") + os.replace(tmp, mp) # shards racing here all write the same content + if not mp.exists(): + raise SystemExit(f"{self.dir} has no cache_meta.json: refusing to read scores of unknown origin") + have = json.loads(mp.read_text()) + want = json.loads(json.dumps(meta)) + diff = {k: (have.get(k), want[k]) for k in want if have.get(k) != want[k]} + if diff: + raise SystemExit(f"score cache {self.dir} was written for a different setup, refusing to reuse it " + f"(cache value, current value): {json.dumps(diff, sort_keys=True)}") + + def key(self, p: Path) -> str: + return "/".join(p.parts[-3:]) # //: the same on every node + + def get(self, p: Path): + return self.rec.get(self.key(p)) + + def put(self, p: Path, r: dict): + r = {"k": self.key(p), **r} + self.rec[r["k"]] = r + if self._out is None: + self._out = (self.dir / f"scores.{self.tag}.jsonl").open("a", buffering=1) + self._out.write(json.dumps(r) + "\n") + + +def is_decode_error(r: dict) -> bool: + """A genuine decode failure (cached). Records written before ``kind`` existed: the decoder's own message.""" + return "err" in r and (r.get("kind") == "decode" or ("kind" not in r and r["err"].startswith("ValueError: Could not decode"))) + + @torch.no_grad() -def score_videos(engine, spec, paths, raw=False): - """P(fake) per video; with ``raw`` (training-free detectors with a ``score``), the raw score oriented so that higher - means generated instead, which keeps the order at the extremes where probabilities saturate.""" - probs = [] - for p in paths: - try: - probs.append(engine.video_raw_score(spec, str(p)) if raw else engine.predict_video_clip(spec, str(p))["fake_probability"]) - except Exception as e: # noqa: BLE001 - print(f" bad video {p.name}: {e}") - return probs +def score_one(engine, spec, p: Path, raw=False, cache: ScoreCache | None = None) -> dict: + """{"p": P(fake), "logit": raw logit (only if the detector reports one), "raw": training-free score (if ``raw``; if + only that raises, "raw_err" and the video still counts)} or {"err", "kind"} when the video cannot be scored + (kind "decode": cached; anything else, e.g. OOM / I/O: not cached, retried next time).""" + r = cache.get(p) if cache else None + if r is not None and ("err" in r or not raw or "raw" in r or "raw_err" in r): + if "err" not in r or is_decode_error(r): + return r + r = None # a legacy / non-decode error record: retry + if r is None and cache is not None and cache.only: + raise SystemExit(f"--cache-only: {p} is not in the score cache") + try: + if r is None: + res = engine.predict_video_clip(spec, str(p)) + r = {"p": res["fake_probability"]} + if "logit" in res: + r["logit"] = res["logit"] + if raw: + try: + r["raw"] = engine.video_raw_score(spec, str(p)) + except Exception as e: # noqa: BLE001 # old behaviour: dropped from the raw scores only + r["raw_err"] = f"{type(e).__name__}: {e}"[:300] + print(f" no raw score for {p.name}: {r['raw_err']}", flush=True) + except Exception as e: # noqa: BLE001 + r = {"err": f"{type(e).__name__}: {e}"[:300], "kind": "decode" if isinstance(e, VideoDecodeError) else "other"} + print(f" bad video {p.name} ({r['kind']}): {r['err']}", flush=True) + if r["kind"] != "decode": + return r + if cache: + cache.put(p, r) + return r + + +def score_videos(engine, spec, paths, raw=False, cache: ScoreCache | None = None, label=""): + """Score ``paths`` -> (records of the videos that scored, decode failures, other failures).""" + out, bad, other, t0 = [], 0, 0, time.time() + for i, p in enumerate(paths, 1): + r = score_one(engine, spec, p, raw, cache) + if "err" not in r: + out.append(r) + elif is_decode_error(r): + bad += 1 + else: + other += 1 + if i % 250 == 0: + print(f" {label} {i}/{len(paths)} ({(time.time() - t0) / i:.2f} s/video, {bad} decode + {other} other failures)", + flush=True) + return out, bad, other + + +def rank_scores(recs) -> np.ndarray | None: + """The float64 raw logits to rank by (AP / AUROC) when every record has one, else None (rank by the P(fake)).""" + if recs and all("logit" in r for r in recs): + return np.array([r["logit"] for r in recs], dtype="float64") + return None + + +def unique_videos(gens, pool_key) -> list[Path]: + """The videos to score once: each distinct real pool (the same pool is hard-linked per generator) and every fake.""" + jobs, seen = [], set() + for _, reals, fakes in gens: + if pool_key(reals) not in seen: + seen.add(pool_key(reals)) + jobs += reals + jobs += fakes + return jobs def fake_recall_at_fpr(real_scores, fake_scores): @@ -129,7 +287,8 @@ 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", "vina_video"]) + ap.add_argument("-m", "--model", required=True, choices=["d3", "split", "restrav", "stall", "vina_video", "waverep", + "waverep_g4"]) 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 " @@ -141,7 +300,35 @@ def main(argv=None) -> int: ap.add_argument("--limit", type=int, default=None, help="cap videos per class per generator") ap.add_argument("--tag", help="run tag (output filename + log); default _") ap.add_argument("--out", default=None) + ap.add_argument("--cache-dir", default=None, help="store / reuse the per-video scores here (resumable, see above)") + ap.add_argument("--cache-only", action="store_true", help="with --cache-dir: fail on a video that is not cached " + "instead of scoring it (the final aggregation run)") + ap.add_argument("--list-out", default=None, help="with --shard: write the slice's video paths (relative to --base) to " + "this file and stop (no model needed); for staging only those files") + ap.add_argument("--score-list", default=None, help="score exactly the videos listed in this file (paths relative to " + "--base) into --cache-dir and stop (a staged slice, no discovery)") + ap.add_argument("--base", default=None, help="with --list-out / --score-list: the directory the listed paths are relative to") + ap.add_argument("--shard", default=None, help="K/N: score only slice K of N of the unique videos into --cache-dir, " + "then stop (no metrics)") args = ap.parse_args(argv) + if args.shard and not (args.cache_dir or args.list_out): + raise SystemExit("--shard needs --cache-dir (or --list-out)") + if args.list_out and not (args.shard and args.base): + ap.error("--list-out needs --shard K/N and --base") + + if args.score_list: + if not (args.cache_dir and args.base): + raise SystemExit("--score-list needs --cache-dir and --base") + engine, spec = get_engine(), get_spec(args.model) + engine._get_model(spec) + paths = [Path(args.base) / line.strip() for line in Path(args.score_list).read_text().splitlines() if line.strip()] + cache = ScoreCache(args.cache_dir, Path(args.score_list).stem, cache_meta(engine, spec)) + print(f"score cache {args.cache_dir}: {len(cache.rec)} videos already scored; {len(paths)} listed | device={engine.device}", + flush=True) + recs, bad, other = score_videos(engine, spec, paths, hasattr(engine._get_model(spec), "score"), cache, label="list") + print(f"=== LIST DONE {args.model} {Path(args.score_list).name}: scored {len(recs)} ok + {bad} decode failures + " + f"{other} other failures of {len(paths)} ===", flush=True) + return 0 if args.dataset: droot = ensure_dataset(args.dataset, "video", args.root, download=not args.no_download) @@ -155,51 +342,82 @@ def main(argv=None) -> int: if not (args.data and args.benchmark and args.tag): raise SystemExit("pass --dataset, or --data, --benchmark and --tag") - engine = get_engine() - spec = get_spec(args.model) - engine._get_model(spec) root = Path(args.data) select = set(args.select.split(",")) if args.select else None gens = discover(args.benchmark, root, Path(args.reals) if args.reals else None, select) if not gens: print(f"No generators with real+fake videos under {root} ({args.benchmark})") return 1 + if args.limit: + gens = [(n, r[:args.limit], f[:args.limit]) for n, r, f in gens] + pool_key = lambda reals: (len(reals), reals[0].name, reals[-1].name) # the same pool hard-linked per generator + if args.list_out: + k, n = (int(x) for x in args.shard.split("/")) + jobs = unique_videos(gens, pool_key) + Path(args.list_out).write_text("".join(f"{p.relative_to(args.base)}\n" for p in jobs[k::n])) + print(f"{args.list_out}: shard {k}/{n} = {len(jobs[k::n])} of {len(jobs)} unique videos") + return 0 + engine = get_engine() + spec = get_spec(args.model) + engine._get_model(spec) print(f"=== bench_eval_video {args.tag} | {args.model} | {args.benchmark} | {len(gens)} gens " f"| device={engine.device} ===", flush=True) + raw = hasattr(engine._get_model(spec), "score") # training-free detectors: also fake recall at fixed FPR + meta = cache_meta(engine, spec) + cache = None + if args.cache_dir: + tag = f"{args.shard.replace('/', 'of')}" if args.shard else f"agg{os.getpid()}" + cache = ScoreCache(args.cache_dir, tag, meta, write_meta=not args.cache_only) + cache.only = args.cache_only + print(f"score cache {args.cache_dir}: {len(cache.rec)} videos already scored", flush=True) + if args.shard: + k, n = (int(x) for x in args.shard.split("/")) + jobs = unique_videos(gens, pool_key) + mine = jobs[k::n] + print(f"shard {k}/{n}: {len(mine)} of {len(jobs)} unique videos", flush=True) + recs, bad, other = score_videos(engine, spec, mine, raw, cache, label=f"shard{k}") + print(f"=== SHARD DONE {args.tag} {k}/{n}: scored {len(recs)} ok + {bad} decode failures + {other} other failures " + f"of {len(mine)} ===", flush=True) + return 0 + per_gen, agg = {}, {"ap": [], "ap_real": [], "auroc": [], "acc": []} pooled_fake_raw = [] # every generator's fakes, for the pooled ("Overall") recall - raw = hasattr(engine._get_model(spec), "score") # training-free detectors: also fake recall at fixed FPR - # score the shared real pool once if it is identical across generators - real_cache = {} + real_cache = {} # score the shared real pool once if it is identical across generators + failed = {"fake": 0, "real_unique": 0} # decode failures (kind "decode") only + failed_other = {"fake": 0, "real_unique": 0} # any other error (OOM, I/O): dropped, never cached for name, reals, fakes in gens: - if args.limit: - reals, fakes = reals[:args.limit], fakes[:args.limit] - rk = (id(reals) if args.limit is None else None) print(f" {name}: {len(reals)} real + {len(fakes)} fake ...", flush=True) - key = (len(reals), reals[0].name, reals[-1].name) # the same pool hard-linked per generator is scored once + key = pool_key(reals) if key in real_cache: - rp = real_cache[key] + rrec, rbad, rother = real_cache[key] else: - rp = score_videos(engine, spec, reals) - real_cache[key] = rp - fp = score_videos(engine, spec, fakes) - if raw: - rraw = real_cache.setdefault(("raw",) + key, None) or score_videos(engine, spec, reals, raw=True) - real_cache[("raw",) + key] = rraw - fraw = score_videos(engine, spec, fakes, raw=True) - pooled_fake_raw += fraw - probs = torch.tensor(rp + fp) - labels = torch.tensor([0] * len(rp) + [1] * len(fp)) - m = metrics(probs, labels) + rrec, rbad, rother = score_videos(engine, spec, reals, raw, cache, label=f"{name} real") + real_cache[key] = (rrec, rbad, rother) + failed["real_unique"] += rbad + failed_other["real_unique"] += rother + frec, fbad, fother = score_videos(engine, spec, fakes, raw, cache, label=f"{name} fake") + failed["fake"] += fbad + failed_other["fake"] += fother + probs = torch.tensor([r["p"] for r in rrec + frec]) + labels = torch.tensor([0] * len(rrec) + [1] * len(frec)) + rank = rank_scores(rrec + frec) # the raw logit, not the rounded P(fake), when there is one + m = metrics(probs, labels, rank) if m is None: print(f" skip {name}: one class"); continue + m.update({"n_real": len(rrec), "n_fake": len(frec), "failed_real": rbad, "failed_fake": fbad, + "failed_other_real": rother, "failed_other_fake": fother, + "rank_by": "logit" if rank is not None else "fake_probability"}) if raw: + rraw = [r["raw"] for r in rrec if "raw" in r] + fraw = [r["raw"] for r in frec if "raw" in r] + pooled_fake_raw += fraw m["fake_recall_at_fpr"] = fake_recall_at_fpr(rraw, fraw) per_gen[name] = m for k in agg: agg[k].append(m[k]) - print(f" {name}: acc={m['acc']} AP={m['ap']} AP_real={m['ap_real']} AUROC={m['auroc']}", flush=True) + print(f" {name}: acc={m['acc']} AP={m['ap']} AP_real={m['ap_real']} AUROC={m['auroc']} " + f"(n={len(rrec)}+{len(frec)}, failed {rbad}+{fbad} decode + {rother}+{fother} other, rank by {m['rank_by']})", flush=True) if not per_gen: print("No generator produced metrics."); return 1 @@ -212,11 +430,13 @@ def main(argv=None) -> int: means["fake_recall_at_fpr"] = {k: mean([g["fake_recall_at_fpr"][k] for g in per_gen.values()]) for k in next(iter(per_gen.values()))["fake_recall_at_fpr"]} # Overall: all fakes against the real pool(s) (each distinct pool once), as the SPLIT paper's "Overall" row - pooled_real_raw = [s for k, v in real_cache.items() if k[0] == "raw" for s in v] + pooled_real_raw = [r["raw"] for rrec, _, _ in real_cache.values() for r in rrec if "raw" in r] means["overall_fake_recall_at_fpr"] = fake_recall_at_fpr(pooled_real_raw, pooled_fake_raw) result = {"tag": args.tag, "model": args.model, "ckpt": "registry-default", "benchmark": f"video:{args.benchmark}", "data_root": str(root), - "n_generators": len(per_gen), "means": means, "per_generator": per_gen, + "n_generators": len(per_gen), "means": means, "per_generator": per_gen, "failed_to_decode": failed, + "failed_other": failed_other, "limit": args.limit, "reals": args.reals, + "ckpt_sha256": meta["ckpt_sha256"], "cache_dir": args.cache_dir, "date": datetime.datetime.now().isoformat(timespec="seconds"), "synthscope_version": "video"} out = Path(args.out) if args.out else (REPRO / "bench_results" / f"{args.tag}.json") diff --git a/benchmark/evaluate.py b/benchmark/evaluate.py index 8843f84382a320c953b3fa43c5c5b5cfdb5d9864..144dea67d02364abbfb2cbc50ec0f7d833d0cf5c 100644 --- a/benchmark/evaluate.py +++ b/benchmark/evaluate.py @@ -71,6 +71,8 @@ def score(det: "synthscope.Detector", paths: list[Path], batch_size: int) -> tor det._ensure_weights() model = det._engine._get_model(det.spec) # build + load (verified path) spec, device = det.spec, det._engine.device + # native-resolution specs (LTF, B-Free, SPAI, PROBE) give variable-size tensors that cannot be stacked + batch_size = spec.eval_batch_size(batch_size) probs = [] for i in range(0, len(paths), batch_size): batch = [] diff --git a/benchmark/seed_reference_results.py b/benchmark/seed_reference_results.py index d3e66a78085c54cb7898989b976fd38e54aa9a48..671a57d69b8f8c557b6449b68c04689a10ebb501 100644 --- a/benchmark/seed_reference_results.py +++ b/benchmark/seed_reference_results.py @@ -58,8 +58,8 @@ ENTRIES = { "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 " + "cospy_official_fs8_nov.json", None, "DAS6 job 66671 (repro/logs/lbfu_cospyoff_das6_66671.out)", True, + "ForenSynths-8, full test sets; 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", diff --git a/benchmark/submissions/co_spy_official.json b/benchmark/submissions/co_spy_official.json index 131e26cb562e80ae71bfe6c59bc7c3982332f229..41976c6c602acbc0d5f0ba28ba1066c4c47a2c06 100644 --- a/benchmark/submissions/co_spy_official.json +++ b/benchmark/submissions/co_spy_official.json @@ -7,31 +7,31 @@ "url": "https://github.com/SMSD75/SynthScope", "evaluation": "official-weights", "metrics": { - "acc": 94.64, - "map": 98.5, + "acc": 95.12, + "map": 98.85, "ap": null, - "auroc": 98.8 + "auroc": 99.03 }, "per_generator": { "biggan": { - "ap": 97.76, - "auroc": 98.18, - "acc": 93.95 + "ap": 98.19, + "auroc": 98.47, + "acc": 94.6 }, "cyclegan": { - "ap": 99.43, + "ap": 99.38, "auroc": 99.74, - "acc": 99.25 + "acc": 99.28 }, "deepfake": { - "ap": 93.4, - "auroc": 93.91, - "acc": 75.6 + "ap": 95.15, + "auroc": 95.24, + "acc": 77.77 }, "gaugan": { - "ap": 97.49, - "auroc": 98.62, - "acc": 95.05 + "ap": 98.1, + "auroc": 98.88, + "acc": 95.16 }, "progan": { "ap": 100.0, @@ -41,23 +41,23 @@ "stargan": { "ap": 100.0, "auroc": 100.0, - "acc": 99.4 + "acc": 99.6 }, "stylegan": { - "ap": 99.94, - "auroc": 99.93, - "acc": 93.85 + "ap": 99.97, + "auroc": 99.96, + "acc": 97.75 }, "stylegan2": { - "ap": 100.0, - "auroc": 100.0, - "acc": 100.0 + "ap": 99.99, + "auroc": 99.99, + "acc": 96.78 } }, "submitted_by": "SynthScope", - "date": "2026-06-04", + "date": "2026-11-08", "verified": true, - "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)", + "source": "repro/bench_results/cospy_official_fs8_nov.json (tag cospy_official_fs8_nov, all generators); DAS6 job 66671 (repro/logs/lbfu_cospyoff_das6_66671.out)", + "protocol_notes": "ForenSynths-8, full test sets; official CO-SPY ProGAN checkpoint in the vendored official architecture (not the served co_spy.pth)", "synthscope_version": "0.1.0" } diff --git a/conf/dataset/image/cure_train.yaml b/conf/dataset/image/cure_train.yaml new file mode 100644 index 0000000000000000000000000000000000000000..9cde6ba373baec70a6b400ba4eec2e0361eead05 --- /dev/null +++ b/conf/dataset/image/cure_train.yaml @@ -0,0 +1,18 @@ +name: cure_train +# CuRe stage 1 (arXiv 2609.14316): GenImage SD v1.4 train, 162,000 ImageNet reals (JPEG) + 162,000 SD v1.4 images +# (PNG, re-encoded as JPEG q96 by the endpoint preprocessing, as the paper / DDA). An item is the pixel mixture +# (1 - a) x_r + a x_g of a real and an independently drawn generated image, a ~ U(0, 1), target a (dataset.CuReMixDataset); +# an epoch = one pass over the 162k reals. Validation: val_pairs fixed mixtures of the SD v1.4 test split (6k + 6k). +# Layout as GenImageDataset stores it: /{train,test}/{real,fake}; prefetch fetches it with that loader. +root_dir: /hddstore/ssalehi/SynthScope/GenImage +hf_repo_id: jzousz/GenImage +hf_subdir: stable_diffusion_v_1_4 +prefetch: false +train_batch_size: 64 # per GPU (the paper's per-GPU batch) +val_batch_size: 64 +num_workers: 8 +val_pairs: 2000 +max_images: null # smoke runs: the first N reals and N fakes of the split (sorted names) +val_max_images: null # null = the whole test split (independent of max_images) +seed: 0 # the validation pairs +train_augment: null # null = the recipe; dda = stage-1 investigation R3 (models/image/cure/train_augment.py) diff --git a/conf/model/image/aide.yaml b/conf/model/image/aide.yaml index 955788b47329cf0097da82510caa0b50ffd4ce85..d1fbec6fbba6cb0acdf1fa3fb298427935aad6b1 100644 --- a/conf/model/image/aide.yaml +++ b/conf/model/image/aide.yaml @@ -10,7 +10,9 @@ freeze_convnext: true semantic_dim: 3072 semantic_proj_dim: 256 -resnet_pretrained: true +# Not read by any code: the two ResNet-50 streams start from random weights, as in the official run (its AIDE_Model builds +# a pretrained state dict from --resnet_path but never calls load_state_dict, and conv1 takes 30 HPF channels anyway). +resnet_pretrained: false head_hidden: 1024 num_classes: 2 @@ -22,11 +24,13 @@ dct: # Test-time preprocessing (official): inference and benchmarks. eval_transform_list: [aide_five_view] -# Training augmentation: the five native-resolution views, long side capped at 1024 (the recipe of the SynthScope_train -# checkpoint, repro/retrain_aide_native_v2.sbatch). -train_transform_list: [random_horizontal_flip, aide_five_view_train] -# Validation during training (differs from the test-time preprocessing above). -val_transform_list: [aide_five_view_train] +# Training = the official TrainDataset (data/datasets.py): at native resolution Gaussian blur (3x3, sigma 0.1-3, p 0.1) +# then JPEG (QF 30-100, p 0.1), then the five views; no flip, no crop. aide_five_view_train differs from the official +# transform only in capping the long side at 1024 before the DCT (worker memory). +train_transform_list: [aide_blur, aide_jpeg, aide_five_view_train] +# Validation during training: the official run validates through the same TrainDataset, so the perturbations apply to the +# validation images too. +val_transform_list: [aide_blur, aide_jpeg, aide_five_view_train] # Caps the long side at 1024 to bound dataloader-worker memory during the end-of-training test; inference and -# benchmarks use the uncapped eval list. +# benchmarks use the uncapped eval list. No perturbations (the official TestDataset has none). test_transform_list: [aide_five_view_train] diff --git a/conf/model/image/cure.yaml b/conf/model/image/cure.yaml index 0e9741a5cd4f6073bae043549e4ce5dcb05fa27b..92b32967aae66f48a76069684b09722fb2bc19bb 100644 --- a/conf/model/image/cure.yaml +++ b/conf/model/image/cure.yaml @@ -16,3 +16,11 @@ label_smoothing: 0.0 # Test-time preprocessing (official): inference, benchmarks and the end-of-training test. eval_transform_list: [cure_eval] + +# Training (the paper's recipe; the official release has no training code): experiments/image/cure.sh. +# Stage 1 = training_stage: ratio (mixing-ratio regression; experiments/image/cure.sh sets it); +# stages 2-3 = models/image/cure/train_stages.py. Stage-1 endpoints use eval_transform_list (see dataset.CuReEndpoints). +training_stage: null # null = the released 2-way model; ratio = stage 1 (adds the 1024 -> 1 ratio head) +grad_checkpointing: false # stage 1: recompute each block in backward (per-GPU batch 64 at 336 px) +lora_weight_decay: 0.1 # stage 1 AdamW weight decay on the LoRA tensors (Appendix A) +head_weight_decay: 0.01 # stage 1 AdamW weight decay on the ratio head (Appendix A) diff --git a/conf/model/image/probe.yaml b/conf/model/image/probe.yaml new file mode 100644 index 0000000000000000000000000000000000000000..df8c455b977442447cf6c24188cc67af0fe892da --- /dev/null +++ b/conf/model/image/probe.yaml @@ -0,0 +1,20 @@ +defaults: + - /model/default + - _self_ + +# PROBE-DINOv2 (ICML 2026, arXiv 2605.24906): DINOv2 ViT-L/14 with registers + Linear(1024, 1) on the CLS token, scored +# as the mean logit of the image's non-overlapping 336x336 patches at native resolution; P(fake) = sigmoid(mean). +# The official DINOv2_best_model_step_34999.pth (ModelScope shuinishaojiu/PROBE-AIGI-Detection) holds the full model +# and loads key-for-key as probe.pth. +model_type: probe +backbone_name: dinov2_with_registers_large +backbone_path: null # null: build the backbone from its config (probe.pth has the weights); a HF-format + # directory or hub id (facebook/dinov2-with-registers-large) loads pretrained weights +classifier_type: linear # the official evaluate_dino.py: dino_classifier(classifier_type='linear') +patch_chunk_size: 32 # patches per backbone forward (0 = all of a batch at once, as the official code) + +# Test-time preprocessing (official evaluate_dino.py, README: --crop_size 336): pad_image(mode='repeat') tiles an image +# with a side under 336 with copies of itself, ToTensor + ImageNet normalization, then the non-overlapping 336 patches +# [N, 3, 336, 336]; the model averages the patch logits. The patch count depends on the image size. +eval_transform_list: [probe_pad_repeat_336, to_dtype, normalize_imagenet, sliding_patches_336] +# No training lists: the official fine-tuning code is not released. diff --git a/conf/model/image/probe_resnet.yaml b/conf/model/image/probe_resnet.yaml new file mode 100644 index 0000000000000000000000000000000000000000..d6aaf854c73ebc981fec59333eaf223416dee4e1 --- /dev/null +++ b/conf/model/image/probe_resnet.yaml @@ -0,0 +1,18 @@ +defaults: + - /model/default + - _self_ + +# PROBE-ResNet50 (ICML 2026, arXiv 2605.24906): the official resnet50(num_classes=1, classifier_type='linear'), +# scored as the mean logit of the image's non-overlapping 224x224 patches at native resolution; P(fake) = sigmoid(mean). +# The official ResNet50_best_model_step_19343.pth (ModelScope shuinishaojiu/PROBE-AIGI-Detection) holds the full model +# and loads key-for-key as probe_resnet.pth. +model_type: probe_resnet +backbone_name: resnet50 +classifier_type: linear +patch_chunk_size: 32 # patches per forward (0 = all of a batch at once, as the official code) + +# Test-time preprocessing (official evaluate_resnet.py, README: --crop_size 224): pad_image(mode='pad') pastes an image +# with a side under 224 on a black 224x224 square (a longer side is cut), ToTensor + ImageNet normalization, then the +# non-overlapping 224 patches [N, 3, 224, 224]; the model averages the patch logits. +eval_transform_list: [probe_pad_224, to_dtype, normalize_imagenet, sliding_patches_224] +# No training lists: the official fine-tuning code is not released. diff --git a/conf/model/video/waverep.yaml b/conf/model/video/waverep.yaml new file mode 100644 index 0000000000000000000000000000000000000000..c9018ae6325ba1e1007e895c869edffc64fecc25 --- /dev/null +++ b/conf/model/video/waverep.yaml @@ -0,0 +1,18 @@ +defaults: + - /model/default + - _self_ + +# WaveRep (NeurIPS'25, grip-unina/WaveRep-SyntheticVideoDetection): timm DINOv2 ViT-B/14 + 4 registers at a 504x504 +# input with one logit, fine-tuned end to end on single video frames; a video's logit is the mean over its frames. The +# released weights_dinov2_G{1,4}.ckpt hold the full timm model (strict load); pretrained_backbone: true starts from the +# timm DINOv2 weights instead (the official create_model does, then overwrites every key with the checkpoint). +model_type: waverep +timm_arch: vit_base_patch14_reg4_dinov2.lvd142m +crop_size: 504 +pretrained_backbone: false +frame_batch: 16 # frames per forward pass when a clip is scored (memory only; per-frame logits as official) + +# Per-frame test-time preprocessing (official demo/utils.py create_transform): CenterCrop((504, 504)) on the PIL frame, +# zero-padded when the frame is smaller, no resize; ToTensor; ImageNet normalization. Frame reading and aggregation are +# the registry's video settings (interface/backend/registry.py, video_sampler "cv2_frames"). +eval_transform_list: [center_crop_504, to_dtype, normalize_imagenet] diff --git a/conf/trainer/image/aide.yaml b/conf/trainer/image/aide.yaml index 1bb7bfb1844b0822bc78514fd37bb68f8aacf8ba..6ed68d12ebad554408a7717a44fd467d6a39a088 100644 --- a/conf/trainer/image/aide.yaml +++ b/conf/trainer/image/aide.yaml @@ -2,17 +2,35 @@ defaults: - /trainer/default - _self_ +# AIDE's released training recipe (shilinyan99/AIDE main_finetune.py + the paper's GenImage setting): AdamW (betas +# 0.9/0.999, eps 1e-8) lr 5e-4 at effective batch 256 (blr 5e-4 x 256 / 256), weight decay 0, 5 epochs, per-iteration +# half-cosine to min_lr 1e-6 without warmup, timm LabelSmoothingCrossEntropy 0.1, fp32, no gradient clipping, no EMA, seed 0. +# The official batch is 8 GPUs x 32; here 4 GPUs x 8 micro-batch x grad_accum_steps 8 = 256 (a 24 GB GPU fits 8). The +# BatchNorm statistics of the two ResNets are then taken over all 4 GPUs' micro-batches (sync_batchnorm), the 32 images the +# official run normalizes with on each of its GPUs. The checkpoint is the epoch with the highest validation accuracy +# (select: accuracy, the official max_accuracy -> model_best.pth); every epoch is kept as model_.pth. trainer_type: aide epochs: 5 -lr: 1.0e-4 +lr: 5.0e-4 weight_decay: 0.0 -label_smoothing: 0.0 +label_smoothing: 0.1 +seed: 0 +sync_batchnorm: true val_interval: 1 test_interval: 1 save_interval: 1 -save: false +save: true save_policy: max +save_path: /nvmestore/ssalehi/SynthScope/models/aide warmup: - mode: off + mode: "off" warmup_ratio: 0.05 lr_scheduler: linear +timm_cosine: + warmup_epochs: 0 + warmup_lr: 0.0 + min_lr: 1.0e-6 + grad_accum_steps: 8 + save_all: true + select: accuracy + log_every: 100 # optimizer steps between the loss / lr lines diff --git a/conf/trainer/image/cure.yaml b/conf/trainer/image/cure.yaml new file mode 100644 index 0000000000000000000000000000000000000000..ab2909ac0e03c6dd00d4533a692ae02973d7d63f --- /dev/null +++ b/conf/trainer/image/cure.yaml @@ -0,0 +1,30 @@ +defaults: + - /trainer/default + - _self_ + +# CuRe stage 1 (arXiv 2609.14316, Appendix A): LoRA (Q/V, all 24 layers, rank 64, alpha 128, dropout 0) + linear ratio +# head, BCE against the mixing ratio; AdamW lr 1e-5, weight decay 0.1 (LoRA) / 0.01 (head) (ModelConfig +# lora_weight_decay / head_weight_decay, applied through the model's optimizer_param_groups), betas (0.9, 0.999) (torch +# default; not stated), 5 epochs at per-GPU batch 64, two warmup epochs then cosine to 1e-6. Unstated, assumed: the +# warmup is linear from 0 per optimizer step and the cosine runs over the remaining 3 epochs from the peak lr (MAE-style, +# warmup_prefix); no gradient clipping; fp16 autocast with a loss scaler (the released inference runs fp16); seed 0; the +# last epoch is the stage-1 model (the paper states no model selection; every epoch is kept, model_last.pth is used). +trainer_type: cure +epochs: 5 +lr: 1.0e-5 +weight_decay: 0.1 # overridden per group by the model (0.1 LoRA / 0.01 head) +label_smoothing: 0.0 +seed: 0 +save: true +save_policy: min +save_path: /nvmestore/ssalehi/SynthScope/models/cure/stage1 +warmup: + mode: "off" # quoted: a bare off is YAML boolean False +timm_cosine: + warmup_epochs: 2 + warmup_lr: 0.0 + min_lr: 1.0e-6 + warmup_prefix: true # cosine over epochs 2-5, from 1e-5 down to 1e-6 + grad_accum_steps: 1 # MICRO < 64 per GPU: accumulate 64 / MICRO micro-batches per optimizer step + save_all: true + log_every: 50 diff --git a/dataset.py b/dataset.py index 6e5aa98e89441244669d582e4606c50890609300..621582855a6f0db1ccb736e5c55e81ad1cd3a380 100644 --- a/dataset.py +++ b/dataset.py @@ -32,6 +32,8 @@ from config_utils import compose_config from models.image.dda.official_train_data import MEAN as DDA_MEAN, STD as DDA_STD, build_item as dda_build_item, \ create_train_transforms as dda_train_transforms from models.image.dda.official_train_transforms import ComposedTransforms as DDAComposedTransforms +from models.image.cure.preprocess import SRC_FORMAT_KEY +from models.image.cure.train_augment import CuReDDAEndpoint def _decode_rgb(path) -> torch.Tensor: @@ -3092,6 +3094,134 @@ class SPAITrainDatasetModule: return None +class CuReEndpoints: + """The real and generated images of a GenImage-layout split (``//{real,fake}``, as + :class:`GenImageDataset` stores GenImage SD v1.4: 162k + 162k train, 6k + 6k test), each preprocessed on its own by + the CuRe endpoint transform. The transform is the model config's ``eval_transform_list`` (``cure_eval``: PNG sources + -> JPEG q96, which is the paper's re-encoding of the generated PNGs to match the JPEG reals; SmallestMaxSize 390, + CenterCrop 390, Resize 336, JPEG q70, mean = std = 0.5): the paper does not state its training preprocessing, and + the released test-time pipeline is the one the trained subspace and head are used with. Images are opened with PIL and + their source format is recorded (``SRC_FORMAT_KEY``), as ``bench_eval`` does, so the PNG step applies. + ``max_images`` keeps the first N reals and the first N fakes (sorted file names, over the whole split, not per + ImageNet class; smoke runs).""" + + def __init__(self, root_dir, split, transform, max_images=None, augment=None): + split_dir = Path(root_dir) / ("train" if split == "train" else "test") + # augment: optional ``callable(PIL image, seed) -> tensor`` used instead of ``transform`` when a seed is given + # (the stage-1 investigation's R3 run: models/image/cure/train_augment.py); None = the recipe (no augmentation) + self.augment = augment + self.reals = sorted(_iter_images(split_dir / "real")) + self.fakes = sorted(_iter_images(split_dir / "fake")) + if max_images: + self.reals, self.fakes = self.reals[:int(max_images)], self.fakes[:int(max_images)] + if not self.reals or not self.fakes: + raise RuntimeError(f"CuRe data: no real/ or fake/ images under {split_dir}") + self.transform = transform + + def load(self, path: Path, seed=None) -> torch.Tensor: + """``path`` -> the preprocessed float tensor ``[3, 336, 336]`` (with ``augment`` and a ``seed``: augmented).""" + with Image.open(path) as source: + source_format = source.format + image = source.convert("RGB") + image.info[SRC_FORMAT_KEY] = source_format + if self.augment is not None and seed is not None: + return self.augment(image, seed) + return self.transform(image) + + def load_any(self, paths, index: int, fallback, seed=None) -> torch.Tensor: + """``load(paths[index])``; an unreadable file (GenImage has a few 0-byte PNGs) is replaced by ``paths[fallback()]``.""" + for _ in range(10): + try: + return self.load(paths[index], seed) + except Exception as exc: # noqa: BLE001 + print(f"[cure data] unreadable image {paths[index]}: {exc}", flush=True) + index = fallback() + raise RuntimeError("CuRe data: 10 unreadable images in a row") + + +def cure_mix(x_real: torch.Tensor, x_gen: torch.Tensor, alpha) -> torch.Tensor: + """Eq. 1 / Eq. 5: ``(1 - alpha) x_0 + alpha x_1`` on preprocessed tensors (mean = std = 0.5 is affine, so this equals + the pixel-space mixture of the preprocessed images, normalized). ``alpha`` is a float or a tensor that broadcasts.""" + return (1 - alpha) * x_real + alpha * x_gen + + +class CuReMixDataset(Dataset): + """CuRe stage-1 data (arXiv 2609.14316, Sec. 3.1 / Appendix A): an item is the mixture x_a = (1 - a) x_r + a x_g of a + real image x_r and an independently drawn generated image x_g, a ~ U(0, 1) per pair, with a as the regression target: + ``(x_a [3, 336, 336], a, 0)``. Mixing happens after the endpoint preprocessing (see :class:`CuReEndpoints`). + + ``train``: one item per real image (an epoch = 162,000 pairs for GenImage SD v1.4, the reals in the loader's random + order); the generated partner and a are drawn at random in each ``__getitem__``, so pairs and ratios change every + epoch and partners are drawn with replacement. In a DataLoader worker the draw uses a generator seeded by the + worker's seed (new every epoch) and the item index: every DDP process gets the same worker seeds (one global seed), + but its own real indices, so the processes' draws stay independent. ``val``: ``val_pairs`` fixed pairs (real i, a + seeded random fake, a seeded random a), the same every epoch.""" + + def __init__(self, endpoints: CuReEndpoints, split, val_pairs=None, seed=0): + self.ep, self.split, self.seed = endpoints, split, int(seed) + self.n = len(endpoints.reals) if split == "train" else min(int(val_pairs or len(endpoints.reals)), len(endpoints.reals)) + + def __len__(self): + return self.n + + def __getitem__(self, idx): + ep = self.ep + if self.split == "train": + worker = torch.utils.data.get_worker_info() + g = None if worker is None else torch.Generator().manual_seed((worker.seed * 1_000_003 + idx) % 2 ** 63) + else: + g = torch.Generator().manual_seed(self.seed * 1_000_003 + idx) + draw_fake = lambda: int(torch.randint(len(ep.fakes), (), generator=g)) + draw_real = lambda: int(torch.randint(len(ep.reals), (), generator=g)) + fake_idx, alpha = draw_fake(), float(torch.rand((), generator=g)) + # R3 only (ep.augment set, train split): one augmentation seed per pair, shared by both endpoints (DDA's paired + # transforms); drawn after the pair and ratio so the recipe's draws are unchanged + aug_seed = int(torch.randint(2 ** 31 - 1, (), generator=g)) if (ep.augment is not None and self.split == "train") else None + x_real = ep.load_any(ep.reals, idx, draw_real, aug_seed) + x_gen = ep.load_any(ep.fakes, fake_idx, draw_fake, aug_seed) + return cure_mix(x_real, x_gen, alpha), torch.tensor(alpha, dtype=torch.float32), torch.tensor(0) + + +class CuReTrainDatasetModule: + """CuRe stage 1 for SynthScope's trainer: :class:`CuReMixDataset` on GenImage SD v1.4 ``train`` and, for the + per-epoch validation loss, ``val_pairs`` fixed mixtures from its ``test`` split. ``prefetch`` downloads the split + with :class:`GenImageDataset`'s loader (``hf_repo_id`` / ``hf_subdir``) when it is missing.""" + + def __init__(self, config): + self.config = config + cfg = config.DatasetConfig + root = Path(cfg.root_dir) + if bool(cfg.get("prefetch", False)): + GenImageDataset.hf_repo_id = cfg.get("hf_repo_id", None) + GenImageDataset.hf_subdir = cfg.get("hf_subdir", None) + for split in ("train", "test"): + GenImageDataset.prepare_split(root, split) + transform = AIGITransformations(list(config.ModelConfig.eval_transform_list)) + cap = cfg.get("max_images", None) + seed = int(cfg.get("seed", 0)) + augment = cfg.get("train_augment", None) + if augment not in (None, "dda"): + raise ValueError(f"cure_train: train_augment must be null or 'dda', got {augment!r}") + if augment == "dda": # stage-1 investigation R3 only; validation stays un-augmented + augment = CuReDDAEndpoint(augment=True) + self.train_dataset = CuReMixDataset(CuReEndpoints(root, "train", transform, cap, augment=augment), "train", seed=seed) + self.val_dataset = CuReMixDataset(CuReEndpoints(root, "test", transform, cfg.get("val_max_images", None)), "val", + val_pairs=cfg.get("val_pairs", None), seed=seed) + + def train_dataloader(self): + cfg = self.config.DatasetConfig + return DataLoader(self.train_dataset, batch_size=cfg.train_batch_size, shuffle=True, num_workers=cfg.num_workers, + pin_memory=True, drop_last=True, persistent_workers=False) + + def val_dataloader(self): + cfg = self.config.DatasetConfig + return DataLoader(self.val_dataset, batch_size=cfg.val_batch_size, shuffle=False, num_workers=cfg.num_workers, + pin_memory=True) + + def test_dataloader(self): + return None + + class _TestOnlyImageModule: """Shared loader for the eval-only image benchmarks (test split only).""" DATASET_CLASS = _TestOnlyImageDataset @@ -3438,6 +3568,7 @@ SynthScopeModuleDict = { "mirage_test": MirageTestDatasetModule, # Training sets of detectors trained in SynthScope with their official recipe. "spai_train": SPAITrainDatasetModule, + "cure_train": CuReTrainDatasetModule, # Video benchmarks. EvalCrafter/GenVidBench/VideoFeedback/ComGenVid have dedicated classes that # download + extract their HF archives into the real/fake layout; the rest use the generic # VideoFolderDatasetModule. diff --git a/docs/ADD_DETECTOR.md b/docs/ADD_DETECTOR.md index 0e2ad033f161749a716679eb62056f1724a3d703..23fef2dd8fb9b2fe263da4baee44714fadd93902 100644 --- a/docs/ADD_DETECTOR.md +++ b/docs/ADD_DETECTOR.md @@ -33,8 +33,12 @@ for the maintainers and stop. `conf/dataset/...` config are fallbacks, used only for models whose config sets none, and a warning is printed when a dataset list is shadowed. Validation and test pipelines run on PIL images like inference, so an end-of-training test with `eval_transform_list` preprocesses exactly as the benchmarks do. - Video models are out of scope for now: their preprocessing is the registry's video settings plus the dataset - lists. Add `conf/dataset/...` / `conf/trainer/...` only if a new recipe is needed. + Video models are mostly out of scope for training: their preprocessing is the registry's video settings (frame + sampler, `num_frames`, window) plus the dataset lists, and most do not use `eval_transform_list`. `waverep` is the exception: + its frames go through a per-frame transform, so it sets `eval_transform_list` (`center_crop_504`, + `to_dtype`, `normalize_imagenet`) and the registry builds its `transform` from it with `model_transform` + like an image detector (`tests/test_model_transforms.py` checks video configs that have a list). Add + `conf/dataset/...` / `conf/trainer/...` only if a new recipe is needed. 3. **Dispatch** — add a branch in `trainer.py` `_build_model` (the `if model_type == "": return SynthScopeModel(config)` chain, ~line 69+). The interface lazy-imports by `model_type` in `interface/backend/engine.py` — mirror it if needed. 4. **Interface registry** — `interface/backend/registry.py` `_add(ModelSpec(...))`: - `key`, `name`, `paper`, `modality` (`image`|`video`), `overrides=["model@ModelConfig=image/"]`, diff --git a/docs/CAPABILITIES.md b/docs/CAPABILITIES.md index 37e028db246d6f551e8888a312a5afcf145ec929..c00ac7b38cc1c78ae75d63d8678585498c03b04b 100644 --- a/docs/CAPABILITIES.md +++ b/docs/CAPABILITIES.md @@ -10,9 +10,10 @@ serves a web UI + a Python/CLI API. Read this before adding a method, then follo --- -## 1. What's already integrated (17 detectors) +## 1. What's already integrated -`synthscope.list_models()` / `from synthscope.api import list_specs`. Each is an `SynthScopeModel` with a +`synthscope.list_models()` / `from synthscope.api import list_specs` give the current set (36 registry keys on +2026-11-11: 29 image, 7 video; the table groups related keys such as the OmniAID, PROBE and Effort variants). Each is an `SynthScopeModel` with a matching `conf/model//.yaml`, a `trainer.py._build_model` branch, an `interface/backend/registry.py` `ModelSpec`, a per-model `README.md`, and a `tests/test__smoke.py`. @@ -35,14 +36,17 @@ matching `conf/model//.yaml`, a `trainer.py._build_model` branch, | `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) | +| `probe`, `probe_resnet` | image | bce | official | – | PROBE: DINOv2 ViT-L/14 + registers (`probe`, patches of 336) or ResNet-50 (`probe_resnet`, patches of 224), single-logit head; the score is the mean logit of the image's non-overlapping patches at native resolution | | `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) | | `vib_net` | image | vib | synthscope | – | Variational information bottleneck on frozen CLIP ViT-L/14 (trained in SynthScope; reproduces the paper) | +| `vib_net_official` | image | vib | official | – | The same model with the official architecture and test transform (center-crop 224); loads the released checkpoints or a SynthScope-trained one | | `d3` | video | video | training-free | – | Disentangled detail dynamics (X-CLIP) | | `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) | +| `waverep` (+ `waverep_g4`) | video | video | official | – | DINOv2 ViT-B/14 + registers fine-tuned frame by frame with a wavelet-band augmentation; the first 64 frames (OpenCV), center 504 crop, sigmoid of the mean frame logit (`waverep` = trained on one generator, `waverep_g4` on four) | | `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 @@ -93,7 +97,7 @@ To wire it in: `conf/model//.yaml` (`model_type: `), a branc ## 4. Evaluation / benchmarking - **Image**: `benchmark/bench_eval.py --model --benchmark {forensynths|ufd|pergen|pool} --data [--ckpt ] [--native-res] --tag `. Auto-discovers `/{0_real,1_fake}` (or `{ai,nature}`, shared-reals) layouts; prints per-generator acc/AP/AUROC + mean; writes `repro/bench_results/.json`. -- **Video**: `benchmark/bench_eval_video.py --model {d3|restrav|stall} --dataset NAME` (auto-download) or `--benchmark {genvideo|fakeonly|pergen} --data DIR`. +- **Video**: `benchmark/bench_eval_video.py --model {d3|split|restrav|stall|vina_video|waverep|waverep_g4} --dataset NAME` (auto-download) or `--benchmark {genvideo|fakeonly|pergen} --data DIR`. - `--ckpt` overrides the registry checkpoint (for official-vs-SynthScope side-by-side). - `--model-config NAME` (needs `--ckpt`) scores that checkpoint with `conf/model/NAME.yaml` instead of the served model config, keeping the registry's other overrides (e.g. `image/effort_ufd`: a training recipe with its own test preprocessing). - `benchmark/aggregate_results.py`, `leaderboard.py`, `evaluate.py`, `schema.json` aggregate runs. @@ -107,7 +111,7 @@ To wire it in: `conf/model//.yaml` (`model_type: `), a branc Known image sets: `cnndetection` (ForenSynths/ProGAN), `genimage`, `genimage_full` (8-gen), `universialfakedetection` (Ojha UFD), `aigibench`, `synthbuster`, `ditfake`, `diffusionforensics`, -`diffusion1kstep`, `aigcdetect`, `commgen15`, `realchain`, `evalgen`, `synthwildx`, `wildrf`, `bfree_online`, `rrdataset`, `cospy`/`cospy_subset`, `spai_ldm`, `freqnetdetection`. +`diffusion1kstep`, `aigcdetect`, `commgen15`, `realchain`, `evalgen`, `synthwildx`, `wildrf`, `bfree_online`, `rrdataset`, `mirage_test`, `arforensics`, `cospy`/`cospy_subset`, `spai_ldm`, `freqnetdetection`. Video: `genvideo_val`, `genvideo`, `videophy`, `vidprom`, `restrav_data`, `evalcrafter`, `genvidbench`, `videofeedback`, `comgenvid`. Each `DatasetDef` lists candidate roots; **`_resolve_root` is node-portable** — it remaps the configured diff --git a/experiments/image/aide.sh b/experiments/image/aide.sh index 92c41c3b934e9b34d5d8a0782feab7d155a2eac9..d123ec4212d66e24a62aa146b6aa9f8b363669f0 100644 --- a/experiments/image/aide.sh +++ b/experiments/image/aide.sh @@ -1,20 +1,52 @@ #!/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 +# AIDE (ICLR 2025): the official training recipe (shilinyan99/AIDE main_finetune.py, data/datasets.py + the paper's +# GenImage setting), reproduced in SynthScope. +# data GenImage SD v1.4 train (162k ImageNet reals + 162k SD v1.4 fakes); validation = the SD v1.4 val split +# model frozen OpenCLIP ConvNeXt-XXL (laion2b soup) + two ImageNet ResNet-50 on the SRM-filtered DCT patches + MLP head +# train at native resolution: Gaussian blur (3x3, sigma 0.1-3, p 0.1), JPEG (QF 30-100, p 0.1), DCT selection of +# 4 patches, every view resized to 256 (no flip, no crop). The one deviation: the long side is capped at +# 1024 before the DCT (dataloader-worker memory). The validation images get the same perturbations, as in +# the official run (it validates through the training dataset class). +# optimizer AdamW 5e-4 at effective batch 256, weight decay 0, 5 epochs, per-iteration cosine to 1e-6, no warmup, +# label smoothing 0.1, fp32, no gradient clipping, no EMA +# batch the official 8 GPUs x 32 becomes 4 GPUs x 8 x grad_accum 8 = 256 (a 24 GB GPU fits a micro-batch of 8); the +# BatchNorm statistics are synchronized over the 4 GPUs (32 images, as on each official GPU) +# checkpoint model_best.pth = the epoch with the highest validation accuracy (the official max_accuracy); every epoch +# is kept as model_.pth +# Plain DDP (accelerate --multi_gpu): the repo's accelerate_config.yaml uses DeepSpeed with gradient clipping 1.0, which the +# official recipe does not have. Resume: rerun with the same SAVE (the state is saved after every epoch). +# Evaluate: python benchmark/bench_eval.py --model aide --ckpt /model_best.pth --benchmark genimage +# Requires: pip install kornia==0.7.2 (the official perturbations) +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/GenImage} +SAVE=${SAVE:-/nvmestore/ssalehi/SynthScope/models/aide} +NUM_GPUS=${NUM_GPUS:-4} +MICRO=${MICRO:-8} # micro-batch per GPU +if [ $((256 % (NUM_GPUS * MICRO))) -ne 0 ]; then + echo "NUM_GPUS x MICRO = $((NUM_GPUS * MICRO)) must divide the effective batch 256" >&2; exit 1 +fi +ACCUM=$((256 / (NUM_GPUS * MICRO))) # effective batch 256 +WORKERS=${WORKERS:-5} +# wandb runs offline by default (batch nodes have no login, like the other recipe scripts); LOGGER_MODE=online to sync. -# Five native-resolution views per image (aide.yaml lists): batch 8 and 5 workers bound memory, as in the run behind -# the README's SynthScope_train checkpoint (repro/retrain_aide_native_v2.sbatch). -/home/ssalehi/miniconda3/bin/conda run --no-capture-output -n SynthScope accelerate launch --config_file accelerate_config.yaml --num_processes 2 main.py \ +/home/ssalehi/miniconda3/bin/conda run --no-capture-output -n SynthScope accelerate launch --multi_gpu \ + --num_processes $NUM_GPUS --mixed_precision no main.py \ trainer@TrainerConfig=image/aide \ model@ModelConfig=image/aide \ dataset@DatasetConfig=image/genimage \ - DatasetConfig.train_batch_size=8 \ - DatasetConfig.num_workers=5 \ + DatasetConfig.root_dir=$DATA \ + DatasetConfig.train_batch_size=$MICRO \ + DatasetConfig.num_workers=$WORKERS \ DatasetConfig.val_batch_size=16 \ DatasetConfig.test_batch_size=16 \ + TrainerConfig.timm_cosine.grad_accum_steps=$ACCUM \ + TrainerConfig.save_path=$SAVE \ + "metrics=[real_accuracy,fake_accuracy]" \ logger.name=aide \ - logger.mode=online \ - logger.tags=[SynthScope,AIDE,genimage] + logger.mode=${LOGGER_MODE:-offline} \ + "logger.tags=[SynthScope,AIDE,genimage]" \ + "$@" diff --git a/experiments/image/cure.sh b/experiments/image/cure.sh new file mode 100644 index 0000000000000000000000000000000000000000..7f514e62bdddd539c4b63f537291b98c0a30e5b8 --- /dev/null +++ b/experiments/image/cure.sh @@ -0,0 +1,97 @@ +#!/bin/bash +# CuRe (arXiv 2609.14316): the paper's three-stage training recipe (Sec. 3, 4.1-4.2, Appendix A); the official release +# (github.com/manic-cui/CuRe) has inference code only, so this follows the paper. See models/image/cure/README.md. +# data GenImage SD v1.4 train: 162,000 ImageNet reals + 162,000 SD v1.4 images (PNG -> JPEG q96 to match the reals) +# model Perception Encoder Core L/14 @336 (facebook/PE-Core-L14-336, frozen) + LoRA on Q and V of all 24 layers +# (rank 64, alpha 128, dropout 0); feature = mean of the 576 patch tokens (1024-d) +# stage 1 ratio regression: x_a = (1 - a) x_r + a x_g, a ~ U(0, 1), independent real / generated endpoints; linear +# ratio head + sigmoid, BCE with soft target a; AdamW lr 1e-5, weight decay 0.1 LoRA / 0.01 head, 5 epochs, +# per-GPU batch 64, 2 warmup epochs then cosine to 1e-6 (main.py, conf/trainer/image/cure.yaml) +# stage 2 frozen encoder; 20,000 endpoint pairs per trajectory type RF / RR / FF on {0, .2, .4, .6, .8, 1}; slopes, +# trace-normalised C_F, C_M, C_S, generalised eigenproblem -> W (1024 x 128), mu (train_stages.py stage2) +# stage 3 Linear(128, 2) on W^T (z - mu), dropout 0.05, CE, AdamW lr 2e-4, weight decay 0.1, batch 256, 5 epochs +# (train_stages.py stage3) -> $SAVE/stage23/cure_trained.pth, the released adapter's 100 keys +# batch per-GPU 64 = MICRO x ACCUM. Measured: 48 GB (A6000 / RTX 6000 Ada): MICRO 64, GRAD_CKPT=false, about 28 GiB; +# 24 GB (A5000): MICRO 64 + GRAD_CKPT=true (6.3 GiB peak) or MICRO 32 x ACCUM 2 without checkpointing (14.1 GiB); +# the paper does not state its GPU count (global batch = NGPU x 64) +# Plain DDP with fp16 autocast + loss scaling, no gradient clipping (not the repo's DeepSpeed accelerate_config.yaml, which +# clips at 1.0); the accelerate launch is pinned by an explicit +# minimal config file + flags (ACC_ARGS), independent of the host's default accelerate config. +# Stage 1 resumes after its last finished epoch when rerun with the same SAVE. +# Stage-1 epoch: every epoch is saved (stage1/model_.pth). The last epoch over-adapts to SD v1.4; the SynthScope-trained +# checkpoints that partially reproduce the paper use the epoch picked by the pre-registered, non-benchmark rule of +# repro/cure_stage1/epoch_select.py (epoch 0 in both runs), set with LORA=$SAVE/stage1/model_.pth for stages 2-3. Optional +# DDA-style training augmentation (an assumption; the paper states none): append DatasetConfig.train_augment=dda to stage 1. +# See models/image/cure/README.md "Trained checkpoint". +# Evaluate: python benchmark/bench_eval.py --model cure --ckpt $SAVE/stage23/cure_trained.pth --dataset wildrf +set -eo pipefail +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 OMP_NUM_THREADS=1 +DATA=${DATA:-/nvmestore/ssalehi/SynthScope/GenImage} +SAVE=${SAVE:-/nvmestore/ssalehi/SynthScope/models/cure} +NGPU=${NGPU:-1} +MICRO=${MICRO:-64} +GRAD_CKPT=${GRAD_CKPT:-true} +WORKERS=${WORKERS:-8} +STAGES=${STAGES:-"1 2 3"} +LORA=${LORA:-} # stage-1 checkpoint for stages 2-3 (default: $SAVE/stage1/model_last.pth) +PY=${PY:-/home/ssalehi/miniconda3/envs/SynthScope/bin/python} +if (( 64 % MICRO != 0 )); then echo "MICRO must divide the per-GPU batch 64" >&2; exit 1; fi +ACCUM=$((64 / MICRO)) +# STEP_MULT (default 1): accumulate STEP_MULT x the per-GPU 64 per optimizer step, i.e. global batch NGPU x 64 x STEP_MULT. +# Only for the stage-1 investigation's R2 run (global 512 = 2 GPUs x 64 x 4, the paper's per-GPU 64 on an assumed 8 GPUs); +# the recipe default is 1 (global NGPU x 64). +STEP_MULT=${STEP_MULT:-1} +ACCUM=$((ACCUM * STEP_MULT)) +MULTI=""; (( NGPU > 1 )) && MULTI="--multi_gpu" +# Every accelerate setting is explicit (a minimal config file AND flags), so a default accelerate config on the host +# (DeepSpeed, dynamo, other precision) cannot change the run: single machine, no dynamo, fp16 autocast + loss scaling +# (CuRe.features always autocasts to fp16). +ACC_CFG=$(mktemp --suffix=.yaml) +trap 'rm -f "$ACC_CFG"' EXIT +DIST=MULTI_GPU; (( NGPU > 1 )) || DIST="'NO'" +cat > "$ACC_CFG" <_.json; acc = mean balanced accuracy at 0.5 = the paper's metric). + # GenImage = the full val split (100,000 images) with all fakes JPEG q96 as in the paper. Synthbuster uses 5000 MSCOCO + # reals, NOT the paper's RAISE-1k (the spec marks it "reference": not like-for-like). AIGI-Bench = CommunityAI + SocialRF + # only. Chameleon and AIGI-Quality-Paradox were not run (no loader). Jobs DAS6 66753, 66755, 66790. + ("probe", "GenImage (8 subsets"): {"official": {"map": 99.77, "acc": 97.47, "auroc": 99.8}}, + ("probe", "Synthbuster"): {"official": {"map": 99.64, "acc": 98.2, "auroc": 99.93}}, + ("probe", "SynthWildX"): {"official": {"map": 98.8, "acc": 97.3, "auroc": 99.18}}, + ("probe", "WildRF"): {"official": {"map": 99.36, "acc": 96.92, "auroc": 99.26}}, + ("probe", "AIGI-Bench"): {"official": {"map": 96.46, "acc": 89.88, "auroc": 95.88}}, + ("probe_resnet", "GenImage (8 subsets"): {"official": {"map": 86.69, "acc": 78.38, "auroc": 84.81}}, + ("probe_resnet", "Synthbuster"): {"official": {"map": 85.23, "acc": 83.75, "auroc": 95.88}}, + ("probe_resnet", "SynthWildX"): {"official": {"map": 83.88, "acc": 75.2, "auroc": 82.8}}, + ("probe_resnet", "WildRF"): {"official": {"map": 89.45, "acc": 81.63, "auroc": 85.76}}, + ("probe_resnet", "AIGI-Bench"): {"official": {"map": 79.8, "acc": 70.44, "auroc": 77.55}}, ("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}}, + # WaveRep (NeurIPS'25): the two official checkpoints (waverep = G1, the paper's single-generator model; waverep_g4 = four + # generators); no SynthScope-trained number (no training code). acc / mAP / mauroc = bench_eval_video means (repro/bench_results/ + # _.json; acc = balanced accuracy at logit 0 = the paper's metric, mAP = AP with fake positive). The "paper's 8" row is the + # mean over the paper's 8 GenVideo columns (Crafter, Gen2, HotShot, LaVie, ModelScope, MorphStudio, Show-1, MoonValley) of + # _genvideo_full.json per_generator acc / auroc; the other rows are zero-shot references (no paper number). + # Jobs: IVI 285376_0 / 285390_3-4 / 285389_2 / 285886_2, DAS6 67328 / 67404, aggregation 286053 / 286059. + ("waverep", "GenVideo-Val, the paper's 8"): {"official": {"acc": 90.3, "auroc": 95.73}}, + ("waverep", "GenVideo-Val full"): {"official": {"map": 79.85, "acc": 86.87, "auroc": 92.13}}, + ("waverep", "GenVideo-Val --limit"): {"official": {"map": 89.81, "acc": 86.62, "auroc": 92.09}}, + ("waverep", "VideoPhy"): {"official": {"map": 93.21, "acc": 90.0, "auroc": 96.54}}, + ("waverep", "VidProM"): {"official": {"map": 98.11, "acc": 89.85, "auroc": 98.06}}, + ("waverep", "EvalCrafter"): {"official": {"map": 96.93, "acc": 92.84, "auroc": 97.17}}, + ("waverep_g4", "GenVideo-Val, the paper's 8"): {"official": {"acc": 96.3, "auroc": 99.05}}, + ("waverep_g4", "GenVideo-Val full"): {"official": {"map": 88.88, "acc": 93.28, "auroc": 96.69}}, + ("waverep_g4", "GenVideo-Val --limit"): {"official": {"map": 94.47, "acc": 92.65, "auroc": 96.53}}, + ("waverep_g4", "VideoPhy"): {"official": {"map": 98.2, "acc": 95.73, "auroc": 99.29}}, + ("waverep_g4", "VidProM"): {"official": {"map": 99.29, "acc": 95.8, "auroc": 99.25}}, + ("waverep_g4", "EvalCrafter"): {"official": {"map": 99.19, "acc": 96.55, "auroc": 99.29}}, # synthscope = trained in SynthScope with the reconstructed recipe at native resolution (experiments/image/vib_net.sh; # job 267846, eval 267928): 15 generators (7 GenImage + 8 ForenSynths GANs), registry vib_net_official. ("vib_net", "Diffusion-source (SDv1.4-trained)"): {"synthscope": {"map": 94.08, "acc": 85.22}}, diff --git a/interface/backend/engine.py b/interface/backend/engine.py index c1a57abca69dc1c02e46cbdf6130dc9dff3f8c43..10719277ae7bd4574c9fed33f7ba44afaac0f4af 100644 --- a/interface/backend/engine.py +++ b/interface/backend/engine.py @@ -18,7 +18,9 @@ import torch from PIL import Image from safetensors.torch import load_file as load_safetensors +from models.image.probe.preprocess import ProbePad, SlidingPatches from . import config +from .hf_compat import translate_hf_keys from .registry import ModelSpec, get_spec, input_note from . import media @@ -133,6 +135,12 @@ def _build_model(cfg): if model_type == "vina": from models.image.vina.vina import SynthScopeVINAModel return SynthScopeVINAModel(cfg) + if model_type == "probe": + from models.image.probe.probe import SynthScopePROBEModel + return SynthScopePROBEModel(cfg) + if model_type == "probe_resnet": + from models.image.probe.probe import SynthScopePROBEResNetModel + return SynthScopePROBEResNetModel(cfg) if model_type == "stall": from models.video.stall.stall import SynthScopeSTALLModel return SynthScopeSTALLModel(cfg) @@ -145,6 +153,9 @@ def _build_model(cfg): if model_type == "restrav": from models.video.restrav.restrav import SynthScopeReStraVModel return SynthScopeReStraVModel(cfg) + if model_type == "waverep": + from models.video.waverep.waverep import SynthScopeWaveRepModel + return SynthScopeWaveRepModel(cfg) if model_type == "cnn": from models.image.cnn_detection.cnn_detection import SynthScopeCNNModel return SynthScopeCNNModel(cfg) @@ -177,6 +188,11 @@ def _load_checkpoint(model, spec: ModelSpec): sd = raw["model"] if isinstance(raw, dict) and "model" in raw else raw if spec.remap is not None: sd = spec.remap(sd) + # A checkpoint that holds a transformers backbone carries the parameter names of the release that saved it; map them + # onto this release's names when the rename is exact (hf_compat.HF_RENAMES), else leave them for the checks below. + sd, hf_note = translate_hf_keys(sd, model.state_dict()) + if hf_note: + logger.info("%s: transformers parameter names translated (%s)", spec.key, hf_note) missing, unexpected = model.load_state_dict(sd, strict=False) # Buffers that are legitimately reconstructed in __init__ / not in official dumps. benign = {"clip_mean", "clip_std", "imnet_mean", "imnet_std"} @@ -209,9 +225,24 @@ def _load_checkpoint(model, spec: ModelSpec): return ( f"loaded {len(sd)} tensors from {path.name} " f"(missing={len(real_missing)}, unexpected={len(unexpected)})" + + (f" [transformers key names translated, {hf_note}]" if hf_note else "") ) +def patch_layout(spec: ModelSpec, pil: Image.Image, num_patches: int): + """For a detector that scores a bag of non-overlapping patches (PROBE: ``ProbePad`` then ``SlidingPatches``): the + padded image size ``(width, height)`` and the patch grid ``(rows, cols)`` the bag came from, or ``None`` when the + transform is not of that kind or the grid does not hold ``num_patches`` patches.""" + steps = spec.transform.transforms if spec.transform is not None else [] + pads = [t for t in steps if isinstance(t, ProbePad)] + cuts = [t for t in steps if isinstance(t, SlidingPatches)] + if len(pads) != 1 or len(cuts) != 1: + return None + width, height = pads[0](pil).size + rows, cols = height // cuts[0].size, width // cuts[0].size + return ((width, height), (rows, cols)) if rows * cols == num_patches else None + + class Engine: """Lazily builds, caches, and runs the detectors.""" @@ -378,10 +409,11 @@ class Engine: return None @staticmethod - def _model_input_data_url(spec: ModelSpec, x: torch.Tensor, max_side: int = 1280) -> str: + def _model_input_data_url(spec: ModelSpec, x: torch.Tensor, max_side: int = 1280, cols: int | None = None) -> str: """The image exactly as the network receives it (after this detector's preprocessing), as a PNG data URL. Normalization is undone for display; multi-view inputs are laid out side by side (up to 5 views, e.g. AIDE) - or in a near-square grid (LTF has one view per tile, up to dozens).""" + or in a near-square grid (LTF has one view per tile, up to dozens). ``cols`` fixes the number of columns of a + multi-view layout (PROBE: the patches' real grid).""" t = x[0].detach().float().cpu() norm = spec.transform.normalize_step() if norm is not None: @@ -389,7 +421,7 @@ class Engine: elif spec.key == "cure": # CuRe maps pixels to (x - 127.5) / 127.5 t = t * 0.5 + 0.5 if t.dim() == 4: - cols = len(t) if len(t) <= 5 else math.ceil(math.sqrt(len(t))) + cols = cols or (len(t) if len(t) <= 5 else math.ceil(math.sqrt(len(t)))) pad = -len(t) % cols if pad: t = torch.cat([t, torch.zeros(pad, *t.shape[1:])]) @@ -411,9 +443,15 @@ class Engine: res = self._result(spec, p, time.time() - t0) res["orig_size"] = [pil.width, pil.height] res["input_size"] = [int(x.shape[-1]), int(x.shape[-2])] # what the network actually received + layout = patch_layout(spec, pil, int(x.shape[1])) if x.dim() == 5 else None + if layout is not None: # a patch bag: report the padded image and its patch grid, not one patch's size + (width, height), (rows, cols) = layout + res["input_size"] = [width, height] + res["input_grid"] = [rows, cols] + res["input_patches"] = rows * cols res["input_note"] = input_note(spec) try: - res["input_image"] = self._model_input_data_url(spec, x) + res["input_image"] = self._model_input_data_url(spec, x, cols=layout[1][1] if layout else None) except Exception: # display-only: never fail a prediction over it pass amap = self._interpret_map(model, spec, x, pil) @@ -438,10 +476,19 @@ class Engine: return res def video_clip(self, spec: ModelSpec, path) -> torch.Tensor: - """Decode and normalize a clip exactly as ``spec`` prescribes: ``[T, 3, H, W]``.""" + """Decode and normalize a clip exactly as ``spec`` prescribes: ``[T, 3, H, W]``. + + For video_sampler "cv2_frames" (WaveRep) this materializes every selected frame at 504x504 float (~3 MB each): + with ``num_frames=0`` (the official demo's default, every frame) a long video needs that much memory per frame; + scoring goes through ``video_frame_logits`` instead, which streams.""" 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]) + if spec.video_sampler == "cv2_frames": # WaveRep: the first num_frames (0: all) OpenCV frames + frames = [spec.transform(f) for f in media.cv2_frames(path, limit=spec.num_frames or None)] + if not frames: + raise media.VideoDecodeError("Could not decode any frames from the video.") + return torch.stack(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, @@ -453,8 +500,34 @@ class Engine: mean, std = spec.video_norm return (clip - torch.tensor(mean).view(1, 3, 1, 1)) / torch.tensor(std).view(1, 3, 1, 1) + @torch.no_grad() + def video_frame_logits(self, spec: ModelSpec, path) -> torch.Tensor: + """The per-frame logits [T] of a frame-level video detector (video_sampler "cv2_frames", WaveRep): the frames + are read, transformed and scored ``frame_batch`` at a time, so a long video is never held in memory at once.""" + model = self._get_model(spec) + batch, logits = [], [] + for frame in media.cv2_frames(path, limit=spec.num_frames or None): + batch.append(spec.transform(frame)) + if len(batch) == model.frame_batch: + logits.append(model.frame_logits(torch.stack(batch).to(self.device)).float().cpu()) + batch = [] + if batch: + logits.append(model.frame_logits(torch.stack(batch).to(self.device)).float().cpu()) + if not logits: + raise media.VideoDecodeError("Could not decode any frames from the video.") + return torch.cat(logits) + def predict_video_clip(self, spec: ModelSpec, path) -> dict: """Run a native *video* detector on a decoded clip.""" + if spec.video_sampler == "cv2_frames": # frame-level: P(fake) = sigmoid(mean frame logit), official + self._get_model(spec) # load first: elapsed covers decoding and scoring only + t0 = time.time() + logits = self.video_frame_logits(spec, path) + logit = logits.double().mean() # the official mean (pandas, float64) of the float32 logits + res = self._result(spec, float(torch.sigmoid(logit)), time.time() - t0) # official: scipy expit + res["num_frames"] = int(logits.numel()) + res["logit"] = round(float(logit), 6) + return res model = self._get_model(spec) clip = self.video_clip(spec, path) t0 = time.time() diff --git a/interface/backend/hf_compat.py b/interface/backend/hf_compat.py new file mode 100644 index 0000000000000000000000000000000000000000..1a35542c3c103ebf1ee51c16a35825837ad332b1 --- /dev/null +++ b/interface/backend/hf_compat.py @@ -0,0 +1,67 @@ +"""Version-tolerant parameter names for checkpoints that hold a Hugging Face ``transformers`` backbone. + +A checkpoint that stores a whole ``transformers`` module (PGC's DINOv2-L, ...) carries the parameter names of the +``transformers`` release it was saved with. A later release may rename a module, and then a strict load fails on the +renamed tensors (``missing=[...q_proj...] unexpected=[...attention.query...]``) although the weights are identical. + +``translate_hf_keys`` maps such a state dict onto the model's names, in either direction (an older checkpoint into a +newer model, or a newer checkpoint into an older model), and only when the rename is exact: every renamed key must land +on a model key that the state dict does not already have, with the same shape. Anything else is returned untouched, so +a real mismatch still reaches the loader's strict check. +""" +from __future__ import annotations + +# (older name, newer name) of one parameter-path fragment. Every rule below was derived by building the model under +# both releases and matching the keys one-to-one by shape (transformers 5.5.4 and 5.22.2 are the two that were compared). +HF_RENAMES: tuple[tuple[str, str], ...] = ( + # Dinov2Model (DINOv2 / PGC): attention.attention.{query,key,value} and attention.output.dense (transformers + # <= 5.5.4) became attention.{q,k,v,o}_proj (5.22.2); 192 keys for DINOv2-L, all other keys unchanged. + (".attention.attention.query.", ".attention.q_proj."), + (".attention.attention.key.", ".attention.k_proj."), + (".attention.attention.value.", ".attention.v_proj."), + (".attention.output.dense.", ".attention.o_proj."), +) + + +def _rename(key: str, rules: tuple[tuple[str, str], ...]) -> str: + """Apply the first rule whose fragment occurs in ``key`` (the fragments are disjoint, so at most one does).""" + for old, new in rules: + if old in key: + return key.replace(old, new, 1) + return key + + +def translate_hf_keys(sd: dict, model_state: dict) -> tuple[dict, str]: + """Rename the ``transformers`` parameter names of ``sd`` that ``model_state`` does not know, when a rule of + ``HF_RENAMES`` maps them exactly onto it. + + ``model_state`` is the model's ``state_dict()``. Returns ``(state_dict, note)``: ``note`` says which direction was + applied and how many keys moved (empty when ``sd`` is returned unchanged). A direction is applied only if every key + it changes lands on a model key that is not already in ``sd`` (no collisions) and has the same shape. + """ + unknown = [k for k in sd if k not in model_state] + if not unknown: + return sd, "" + for label, rules in ( + ("older -> newer", HF_RENAMES), + ("newer -> older", tuple((new, old) for old, new in HF_RENAMES)), + ): + moved = {k: _rename(k, rules) for k in unknown} + moved = {k: new for k, new in moved.items() if new != k} + if not moved: + continue + targets = list(moved.values()) + exact = ( + len(set(targets)) == len(targets) + and all(new in model_state and new not in sd for new in targets) + and all( + hasattr(sd[k], "shape") and tuple(sd[k].shape) == tuple(model_state[new].shape) + for k, new in moved.items() + ) + ) + if exact: + return {moved.get(k, k): v for k, v in sd.items()}, f"{label}: renamed {len(moved)} key(s)" + return sd, "" + + +__all__ = ["HF_RENAMES", "translate_hf_keys"] diff --git a/interface/backend/media.py b/interface/backend/media.py index 5b7474ea3137264308b135d8ac28e9abd0d3ee8a..fc627a20bed386eade67d1bd994ba99dfdcd770b 100644 --- a/interface/backend/media.py +++ b/interface/backend/media.py @@ -12,6 +12,7 @@ import subprocess import tempfile from pathlib import Path +import cv2 import numpy as np import torch from PIL import Image, ImageFile @@ -28,6 +29,11 @@ ImageFile.LOAD_TRUNCATED_IMAGES = True from dataset import sample_video_frames # noqa: E402 from models.image.cure.preprocess import SRC_FORMAT_KEY # noqa: E402 +class VideoDecodeError(ValueError): + """The video file yields no decodable frame (corrupt / empty). A ValueError, so every existing handler still catches + it; benchmark/bench_eval_video.py counts and caches only these as failed-to-decode videos.""" + + IMAGE_EXTENSIONS = {".jpg", ".jpeg", ".jfif", ".png", ".webp", ".bmp", ".gif", ".tif", ".tiff"} VIDEO_EXTENSIONS = {".mp4", ".avi", ".mov", ".mkv", ".webm", ".m4v"} @@ -81,7 +87,7 @@ def sample_video_pil(path: str | Path, num_frames: int) -> list[Image.Image]: reader = decord.VideoReader(str(path), ctx=decord.cpu(0)) n_src = len(reader) if n_src == 0: - raise ValueError("Could not decode any frames from the video.") + raise VideoDecodeError("Could not decode any frames from the video.") n = max(1, min(num_frames, n_src)) indices = np.linspace(0, n_src - 1, num=n) indices = np.clip(np.rint(indices).astype(np.int64), 0, n_src - 1).tolist() @@ -93,7 +99,7 @@ def sample_video_pil(path: str | Path, num_frames: int) -> list[Image.Image]: except Exception: continue if not frames: - raise ValueError("Could not decode any frames from the video.") + raise VideoDecodeError("Could not decode any frames from the video.") return frames @@ -142,7 +148,7 @@ def ffmpeg_fps_frames(path: str | Path, fps: float, num_frames: int, timeout: fl raise ValueError(f"ffmpeg did not finish within {timeout:g} s for this video.") from e ids = sorted(int(p.stem) for p in Path(tmp).glob("*.jpg") if p.stem.isdigit()) if not ids: - raise ValueError("ffmpeg wrote no frames for this video.") + raise VideoDecodeError("ffmpeg wrote no frames for this video.") if len(ids) >= num_frames: start = (len(ids) - num_frames) // 2 ids = ids[start:start + num_frames] @@ -151,6 +157,38 @@ def ffmpeg_fps_frames(path: str | Path, fps: float, num_frames: int, timeout: fl return [open_rgb(Path(tmp) / f"{i}.jpg") for i in ids] +def cv2_frames(path: str | Path, limit: int | None = None): + """WaveRep's official frame reader (demo/utils.py ``ReadVideoIteratorCV``, vendored in + models/video/waverep/official_utils.py): every frame OpenCV's ``VideoCapture`` decodes, in order, converted from BGR + to RGB, as PIL images; reading stops at the first failed read, and after ``limit`` frames when it is set (the demo's + ``--limit``). A generator, so a long video is never held in memory at once. + + Errors (raised when the generator is first advanced): a path that does not exist is a ``FileNotFoundError`` and a + file OpenCV cannot open an ``OSError``; both are I/O problems, not a verdict on the video, so callers do not cache + them as decode failures. An existing but empty (0-byte) file is a ``VideoDecodeError``, as is a file that opens but + decodes no frame (raised by the caller, which sees the empty iterator).""" + path = str(path) + if not os.path.exists(path): + raise FileNotFoundError(f"Video file not found: {path}") + if os.path.getsize(path) == 0: + raise VideoDecodeError("The video file is empty (0 bytes).") + cap = cv2.VideoCapture(path) + try: + if not cap.isOpened(): + raise OSError(f"OpenCV could not open the video file: {path}") + idx = 0 + while cap.isOpened(): + ret, frame = cap.read() + if not ret: + break + yield Image.fromarray(cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)) + idx = idx + 1 + if limit and idx >= limit: + break + finally: + cap.release() + + def thumbnail_bytes(path: str | Path, modality: str, size: int = 256) -> bytes: """A small JPEG thumbnail for the dataset explorer grid. @@ -163,7 +201,7 @@ def thumbnail_bytes(path: str | Path, modality: str, size: int = 256) -> bytes: reader = decord.VideoReader(str(path), ctx=decord.cpu(0)) n = len(reader) if n == 0: - raise ValueError("Could not decode any frames from the video.") + raise VideoDecodeError("Could not decode any frames from the video.") arr = reader[n // 2].asnumpy() # [H,W,3] uint8, middle frame img = Image.fromarray(arr).convert("RGB") else: diff --git a/interface/backend/registry.py b/interface/backend/registry.py index e8308f90f0808f2f4d3eacc0e786635aebde3da7..eb7a5d309a284784e5fd3a638ebc5c2d3b9a3dc8 100644 --- a/interface/backend/registry.py +++ b/interface/backend/registry.py @@ -50,9 +50,14 @@ def remap_fatformer(sd: dict) -> dict: def remap_aide(sd: dict) -> dict: """Official AIDE checkpoint -> SynthScopeAIDEModel. The SynthScope class now wraps the GENUINE arch as ``self.net`` (key-for-key identical to the official ``AIDE_Model``), so we just strip any - DataParallel ``module.`` prefix and add the ``net.`` prefix; every official key loads strict.""" - return {("net." + (k[len("module."):] if k.startswith("module.") else k)): v - for k, v in sd.items()} + DataParallel ``module.`` prefix and add the ``net.`` prefix; every official key loads strict. A SynthScope-TRAINED + checkpoint (the trainer saves the model's own state dict) already carries ``net.`` and keeps it, so + ``bench_eval --model aide --ckpt `` loads it; no official key starts with ``net.``.""" + out = {} + for k, v in sd.items(): + k = k[len("module."):] if k.startswith("module.") else k + out[k if k.startswith("net.") else "net." + k] = v + return out def remap_npr(sd: dict) -> dict: @@ -116,6 +121,22 @@ def remap_vina(sd: dict) -> dict: return {k.replace("module.", ""): v for k, v in sd.items()} +def remap_waverep(sd: dict) -> dict: + """Official WaveRep checkpoint -> SynthScopeWaveRepModel: the released weights_dinov2_G{1,4}.ckpt are flat timm + state dicts; the official create_model also accepts a Lightning ``{"state_dict": {"model.": ...}}`` (it keeps + the keys starting with ``model`` and drops that prefix). Either way the timm keys go under ``model.``.""" + if "state_dict" in sd: + sd = {k[6:]: v for k, v in sd["state_dict"].items() if k.startswith("model")} + return {"model." + k: v for k, v in sd.items()} + + +def remap_probe(sd: dict) -> dict: + """Official PROBE checkpoint ({"model_state_dict": ...}) -> SynthScopePROBEModel / SynthScopePROBEResNetModel: the + official evaluate_dino.py / evaluate_resnet.py load ``checkpoint['model_state_dict']`` strictly; the names are the + official ones.""" + return sd.get("model_state_dict", sd) + + def remap_pgc(sd: dict) -> dict: """Official PGC checkpoint -> SynthScopePGCModel: the official ``PGCNetwork`` keeps the DINOv2 backbone inside its ``RgbStream`` wrapper (``rgb_stream.backbone.*``); the SynthScope class holds it as ``self.backbone``. Strip the @@ -160,6 +181,8 @@ class ModelSpec: bgr: bool = False # feed BGR channels (D3's official reader never converts cv2's BGR) # "ffmpeg_fps_center" (VINA): ffmpeg writes JPEG frames at ``fps``, the central ``num_frames`` are read back and # each goes through ``transform`` (the image eval preprocessing) instead of the clip settings above. + # "cv2_frames" (WaveRep): the first ``num_frames`` frames OpenCV decodes (0: every frame), each through + # ``transform`` and scored on its own; P(fake) = sigmoid of the mean frame logit (Engine.video_frame_logits). video_sampler: str = "" video_prob: str = "softmax" # video output -> P(fake): softmax[:, 1] of [1, 2] logits, or "sigmoid" notes: str = "" @@ -176,6 +199,11 @@ class ModelSpec: interpret: str = "" remap: Optional[Callable[[dict], dict]] = field(default=None, repr=False) + def eval_batch_size(self, batch_size: int) -> int: + """Batch size an evaluation loop may use: 1 for a ``native_res`` spec (its inputs differ in size and cannot be + stacked), else ``batch_size``.""" + return 1 if self.native_res else batch_size + # --------------------------------------------------------------------------- # The registry. @@ -419,6 +447,38 @@ _add(ModelSpec( "token give the score. Uses the OFFICIAL checkpoint. PNG/BMP inputs get a JPEG q96 round trip (the paper's " "format-aligned inputs), so use the registered transform. Runs fp32, the official default.", )) +# PROBE: two released detectors (Table 1 of the paper has both rows), each scored as the official evaluate_*.py does: +# the mean logit of the image's non-overlapping crop-size patches at native resolution. +_PROBE_NOTES = ("Trained with PROBE, which steers a generative model through small edits of its internal " + "representations to find realistic images the detector gets wrong, then refines the detector on them. ") +_add(ModelSpec( + key="probe", name="PROBE (DINOv2)", paper="Cao et al., ICML'26", + modality="image", predict_kind="bce", checkpoint="probe.pth", ckpt_kind="official_probe", remap=remap_probe, + weights="official", + # probe.pth = the official DINOv2_best_model_step_34999.pth unchanged (ModelScope + # shuinishaojiu/PROBE-AIGI-Detection, sha256 c8caa9ba...450156); it holds the full model (DINOv2-reg ViT-L/14 + + # head), so no backbone download. + overrides=["model@ModelConfig=image/probe"], + transform=model_transform("image/probe"), # official evaluate_dino.py: repeat-pad to 336, 336 patches, ImageNet + native_res=True, # the patch count depends on the image size: score one image at a time + notes=_PROBE_NOTES + "DINOv2 ViT-L/14 with registers + a linear head on the CLS token, trained on the paper's " + "reconstruction training set (SD 2.1 reconstructions of real images) plus PROBE samples. Uses " + "the OFFICIAL checkpoint (licence unclear: not in the zoo or on the Space). The image is cut " + "into 336x336 patches at its own resolution and the patch logits are averaged.", +)) +_add(ModelSpec( + key="probe_resnet", name="PROBE (ResNet-50)", paper="Cao et al., ICML'26", + modality="image", predict_kind="bce", checkpoint="probe_resnet.pth", ckpt_kind="official_probe", + remap=remap_probe, weights="official", + # probe_resnet.pth = the official ResNet50_best_model_step_19343.pth unchanged (same ModelScope repo, sha256 + # 71ef257e...20f0507c). + overrides=["model@ModelConfig=image/probe_resnet"], + transform=model_transform("image/probe_resnet"), # official evaluate_resnet.py: black-pad to 224, 224 patches + native_res=True, + notes=_PROBE_NOTES + "ResNet-50 with a linear head, trained on GenImage SD v1.4 plus PROBE samples. Uses the " + "OFFICIAL checkpoint (licence unclear: not in the zoo or on the Space). The image is cut into " + "224x224 patches at its own resolution and the patch logits are averaged.", +)) # VINA: one model for images and videos. `vina` scores images (and, like every image detector, sampled frames of a video # with the mean P(fake)); `vina_video` is the official video protocol, so the paper's video benchmarks run through it. _VINA_NOTES = ("DINOv3 ViT-L/16 fine-tuned end to end with a linear head, trained on images and video frames together " @@ -447,6 +507,32 @@ _add(ModelSpec( notes=_VINA_NOTES + "Videos: the official protocol - ffmpeg writes the clip as JPEG frames at 2 fps and the " "central frame is scored with the image preprocessing (needs ffmpeg).", )) +# WaveRep: two released checkpoints. The demo README says G1 is trained on "a single generator" and G4 on "four generators" +# (the demo's default); we infer the paper's Pyramid Flow detector (Tables 1-2) and its Table 5 set (+ CogVideoX 1.5, +# Allegro, Open-Sora Plan). +_WAVEREP_NOTES = ("DINOv2 ViT-B/14 with registers, fine-tuned end to end on single video frames with a forensic " + "augmentation: a fake frame's low-pass and horizontal / vertical wavelet bands are replaced by a " + "real frame's, steering the detector to the diagonal high-frequency bands. Uses the OFFICIAL checkpoint " + "{ckpt} (GRIP license: nonprofit use). The first 64 frames (the paper's protocol) are decoded with " + "OpenCV; each frame's central 504x504 pixels are scored (no resize; a smaller frame is zero-padded) " + "and P(fake) is the sigmoid of the mean frame logit.") +for _key, _name, _ckpt, _note in [ + ("waverep", "WaveRep (video)", "waverep.pth", "weights_dinov2_G1, trained on one generator (Pyramid Flow, as we infer)"), + ("waverep_g4", "WaveRep-G4 (video)", "waverep_g4.pth", "weights_dinov2_G4, trained on four generators"), +]: + _add(ModelSpec( + key=_key, name=_name, paper="Corvi et al., NeurIPS'25", + modality="video", predict_kind="video", checkpoint=_ckpt, ckpt_kind="official_waverep", remap=remap_waverep, + weights="official", + # .pth = the official weights_dinov2_G{1,4}.ckpt unchanged (grip.unina.it, md5 as the demo README); a flat + # timm state dict holding the full model, strict load. + overrides=["model@ModelConfig=video/waverep"], + transform=model_transform("video/waverep"), # official create_transform: CenterCrop(504), ToTensor, ImageNet + # official demo/utils.py: ReadVideoIteratorCV (every cv2 frame, BGR->RGB) limited to the paper's first 64 + # frames (the demo's --limit 64; without it the demo scores every frame), mean logit, expit. + num_frames=64, fps=None, frame_size=504, video_sampler="cv2_frames", video_prob="sigmoid", + notes=_WAVEREP_NOTES.format(ckpt=_note), + )) # OmniAID's official eval preprocessing: v2 resizes straight to 336 (data/datasets.py); the v1-era releases used a # double resize (512x512, then 336x336) - the commented-out pipeline that the official code says to use for v1 weights. for _key, _name, _ckpt, _note in [ @@ -567,6 +653,15 @@ INPUT_NOTES: dict[str, tuple[str, str]] = { "ltf": ("Native-res 224 tiles + global view", "The image is cut into 224×224 tiles at its own resolution (no " "scaling; edge tiles are aligned to the border, a side under 224 px is padded with black), plus one view of " "the whole image resized to 224 and center-cropped."), + "probe": ("Native-res 336 patches, mean logit", "The image is cut into non-overlapping 336×336 patches at its own " + "resolution (no scaling; a strip at the right / bottom edge narrower than 336 px is not seen); a side " + "under 336 px is first tiled with copies of the image. Each patch is scored and the scores are " + "averaged."), + "probe_resnet": ("Native-res 224 patches, mean logit", "The image is cut into non-overlapping 224×224 patches at " + "its own resolution (no scaling; a strip at the right / bottom edge narrower than 224 px is not " + "seen); an image with a side under 224 px is centered on a black 224×224 square instead (its " + "other side, if longer, is cut to the central 224 px). Each patch is scored and the scores are " + "averaged."), "vina": ("Resize + center-crop 256 (bicubic)", "The shorter side is scaled to 256 px (bicubic) and the central " "256×256 square is used. The aspect ratio is kept; anything outside the square is not seen by the " "detector."), @@ -585,6 +680,13 @@ def input_note(spec: ModelSpec) -> dict: f"them {'is' if one else 'are'} scored like an image: the shorter side is scaled to " f"{spec.frame_size} px (bicubic) and the central {spec.frame_size}×{spec.frame_size} " "square is used. This matches the paper's evaluation."} + if spec.video_sampler == "cv2_frames": + frames = f"The first {spec.num_frames} frames" if spec.num_frames else "Every frame" + return {"label": f"{frames}, center {spec.frame_size}", + "explanation": f"{frames} of the clip {'are' if spec.num_frames else 'is'} scored one by one: the " + f"central {spec.frame_size}×{spec.frame_size} pixels of each frame are used exactly " + "as they are (no scaling; a smaller frame is padded with black), and the frame scores " + "are averaged. This matches the paper's evaluation."} if spec.modality == "video": crop = f", after trimming {int(spec.edge_crop * 100)}% off every edge" if spec.edge_crop else "" return {"label": f"{spec.num_frames} sampled frames", diff --git a/interface/backend/repro_full.json b/interface/backend/repro_full.json index 0d1c63628cca7b5184ed39b31aea6ce871ae8791..e645c3ece033442bff63335552325c1eb8bb3047 100644 --- a/interface/backend/repro_full.json +++ b/interface/backend/repro_full.json @@ -14,11 +14,11 @@ "benchmark": "GenImage (B2, Setting-I, SDv1.4-trained)", "metric": "acc", "paper": "acc=86.88", - "ours": "SynthScope mAP=96.42 / acc=77.87 \u00b7 official mAP=97.12 / acc=85.91", - "ours_synthscope": "mAP=96.42 / acc=77.87", + "ours": "SynthScope mAP=93.9 / acc=80.73 / AUROC=91.66 \u00b7 official mAP=97.12 / acc=85.91", + "ours_synthscope": "mAP=93.9 / acc=80.73 / AUROC=91.66", "ours_official": "mAP=97.12 / acc=85.91", "status": "official", - "note": "official sd14_train.pth, faithful vendored eval; acc 85.91 ~ paper 86.88 (tag aide_official_genimage8). FROM-SCRATCH reproduction (native-res 5-view, aide_native_v2/model_2): GenImage-8 96.42 mAP / 97.07 mAUROC / 77.9 acc (tag aide_retrain_native_g8) = reproduces official 97.12. The old resize-256 retrains (91.75 / 92.47) were capped by the resize-before-DCT bug." + "note": "official sd14_train.pth, faithful vendored eval; acc 85.91 ~ paper 86.88 (tag aide_official_genimage8, full GenImage_full/test: 1500 real + 1500 fake per generator, 6000 + 6000 for sdv1.4). SYNTHSCOPE-TRAINED (the official recipe through experiments/image/aide.sh, train job 281041 on 4x A6000, model_best = epoch 4, val acc 0.9984): full GenImage-8 93.90 mAP / 91.66 mAUROC / 80.73 acc (tag\u2026" }, { "benchmark": "Chameleon (B3, Setting-II, in-the-wild)", @@ -224,111 +224,111 @@ "benchmark": "AIGIBench (20 full-image-synthesis subsets, full test data)", "metric": "balanced accuracy / AUROC", "paper": "acc=92.8 / auroc=97.5", - "ours": "mAP=97.0 / acc=92.85 / AUROC=97.48 (official wts)", - "ours_synthscope": "", + "ours": "SynthScope mAP=96.72 / acc=91.12 / AUROC=97.1 \u00b7 official mAP=97.0 / acc=92.85 / AUROC=97.48", + "ours_synthscope": "mAP=96.72 / acc=91.12 / AUROC=97.1", "ours_official": "mAP=97.0 / acc=92.85 / AUROC=97.48", - "status": "official", - "note": "Official adapter through SynthScope reproduces every one of the 20 subsets within 0.10 pt (92.85 acc / 97.48 AUROC)." + "status": "reproduced", + "note": "Reproduced by the SynthScope-trained r3e0 ONLY with the unstated augmentation assumption (pre-registered non-benchmark selection; single seed; the paper-settings-only r1e0 gives 88.85 acc, not reproduced); the served cure model is the official adapter. Official adapter through SynthScope reproduces every one of the 20 subsets within 0.10 pt (92.85 acc / 97.48 AUROC). SynthScope-trained: r3e0\u2026" }, { "benchmark": "UniversalFakeDetect (UFD-8, diffusion and DALL-E half)", "metric": "balanced accuracy", "paper": "\u2014", - "ours": "mAP=99.19 / acc=93.94 (official wts)", - "ours_synthscope": "", + "ours": "SynthScope mAP=98.73 / acc=93.89 / AUROC=98.31 \u00b7 official mAP=99.19 / acc=93.94", + "ours_synthscope": "mAP=98.73 / acc=93.89 / AUROC=98.31", "ours_official": "mAP=99.19 / acc=93.94", "status": "reference", - "note": "UFD-8 mean balanced accuracy 93.94; 16-generator union 89.27 (aggregation differs from the paper)." + "note": "UFD-8 mean balanced accuracy 93.94; 16-generator union 89.27 (aggregation differs from the paper). SynthScope-trained: r3e0, the best checkpoint by the pre-registered non-benchmark selection rule (paper recipe + DDA-style augmentation, stage-1 epoch 0; tag cure_trained_r3e0_ufd): acc 93.89 / AUROC 98.31 (reference); the recipe's last epoch (tag cure_trained_ufd): acc 82.69 / AUROC 93.85." }, { "benchmark": "ForenSynths (13 GAN generators)", "metric": "balanced accuracy", "paper": "\u2014", - "ours": "mAP=94.05 / acc=81.95 (official wts)", - "ours_synthscope": "", + "ours": "SynthScope mAP=97.22 / acc=89.36 / AUROC=96.58 \u00b7 official mAP=94.05 / acc=81.95", + "ours_synthscope": "mAP=97.22 / acc=89.36 / AUROC=96.58", "ours_official": "mAP=94.05 / acc=81.95", "status": "reference", - "note": "Mean balanced accuracy 81.95 (low scores are fake-recall; AP/AUROC are 95-99 on those generators)." + "note": "Mean balanced accuracy 81.95 (low scores are fake-recall; AP/AUROC are 95-99 on those generators). SynthScope-trained: r3e0, the best checkpoint by the pre-registered non-benchmark selection rule (paper recipe + DDA-style augmentation, stage-1 epoch 0; tag cure_trained_r3e0_forensynths): acc 89.36 / AUROC 96.58 (reference); the recipe's last epoch (tag cure_trained_forensynths): acc 75.83 /\u2026" }, { "benchmark": "GenImage-8 (CuRe's training set, in-distribution sanity check)", "metric": "balanced accuracy", "paper": "\u2014", - "ours": "mAP=97.3 / acc=85.18 (official wts)", - "ours_synthscope": "", + "ours": "SynthScope mAP=97.56 / acc=86.22 / AUROC=97.59 \u00b7 official mAP=97.3 / acc=85.18", + "ours_synthscope": "mAP=97.56 / acc=86.22 / AUROC=97.59", "ours_official": "mAP=97.3 / acc=85.18", "status": "reference", - "note": "SD-v1.4 99.73, SD-v1.5 99.80, Wukong 99.87; weaker on ADM/BigGAN/VQDM at the fixed 0.5 threshold." + "note": "SD-v1.4 99.73, SD-v1.5 99.80, Wukong 99.87; weaker on ADM/BigGAN/VQDM at the fixed 0.5 threshold. SynthScope-trained: r3e0, the best checkpoint by the pre-registered non-benchmark selection rule (paper recipe + DDA-style augmentation, stage-1 epoch 0; tag cure_trained_r3e0_genimage8): acc 86.22 / AUROC 97.59 (reference); the recipe's last epoch (tag cure_trained_genimage8): acc 77.7 / AUROC 87.88." }, { "benchmark": "AIGCDetectBenchmark (17 generators, full data)", "metric": "balanced accuracy", "paper": "acc=89.3 / auroc=98.0", - "ours": "mAP=98.08 / acc=89.3 / AUROC=98.02 (official wts)", - "ours_synthscope": "", + "ours": "SynthScope mAP=98.59 / acc=92.01 / AUROC=98.38 \u00b7 official mAP=98.08 / acc=89.3 / AUROC=98.02", + "ours_synthscope": "mAP=98.59 / acc=92.01 / AUROC=98.38", "ours_official": "mAP=98.08 / acc=89.3 / AUROC=98.02", - "status": "official", - "note": "Official adapter through SynthScope: 89.30 balanced acc / 98.02 AUROC (mAP 98.08) on all 17 generators, full test data, 76,299 real / 76,299 fake (tag cure_aigcdetect, job 251523)." + "status": "reproduced", + "note": "Reproduced by the SynthScope-trained r3e0 (pre-registered non-benchmark selection; single seed) and, without the augmentation assumption, by the paper-settings-only r1e0 (92.25 acc); the served cure model is the official adapter. Official adapter through SynthScope: 89.30 balanced acc / 98.02 AUROC (mAP 98.08) on all 17 generators, full test data, 76,299 real / 76,299 fake (tag cure_aigcdetect\u2026" }, { "benchmark": "EvalGEN (5 generators, full data)", "metric": "balanced accuracy", "paper": "acc=98.1", - "ours": "mAP=99.86 / acc=98.14 / AUROC=99.66 (official wts)", - "ours_synthscope": "", + "ours": "SynthScope mAP=99.47 / acc=93.32 / AUROC=98.85 \u00b7 official mAP=99.86 / acc=98.14 / AUROC=99.66", + "ours_synthscope": "mAP=99.47 / acc=93.32 / AUROC=98.85", "ours_official": "mAP=99.86 / acc=98.14 / AUROC=99.66", "status": "official", - "note": "Official adapter through SynthScope: 98.14 balanced acc (mAP 99.86, AUROC 99.66) on all 55,298 fakes vs MSCOCO val2017 (5000 reals; our choice of pool) (tag cure_evalgen, job 251412)." + "note": "Trained r3e0 not reproduced (-4.8 acc); the served cure model is the official adapter. Official adapter through SynthScope: 98.14 balanced acc (mAP 99.86, AUROC 99.66) on all 55,298 fakes vs MSCOCO val2017 (5000 reals; our choice of pool) (tag cure_evalgen, job 251412). SynthScope-trained: r3e0, the best checkpoint by the pre-registered non-benchmark selection rule (paper recipe + DDA-style\u2026" }, { "benchmark": "SynthWildX (3 generators, images still online on X)", "metric": "balanced accuracy", "paper": "acc=92.7", - "ours": "mAP=95.61 / acc=92.69 / AUROC=96.5 (official wts)", - "ours_synthscope": "", + "ours": "SynthScope mAP=97.12 / acc=91.76 / AUROC=97.09 \u00b7 official mAP=95.61 / acc=92.69 / AUROC=96.5", + "ours_synthscope": "mAP=97.12 / acc=91.76 / AUROC=97.09", "ours_official": "mAP=95.61 / acc=92.69 / AUROC=96.5", - "status": "official", - "note": "Official adapter through SynthScope: 92.69 balanced acc (mAP 95.61, AUROC 96.50) on the 1713 of 2000 images still online on X (413 real; 392/473/435 fake) (tag cure_synthwildx, job 251435)." + "status": "reproduced", + "note": "Reproduced by the SynthScope-trained r3e0 (pre-registered non-benchmark selection; single seed) and, without the augmentation assumption, by the paper-settings-only r1e0 (90.99 acc); the served cure model is the official adapter. Official adapter through SynthScope: 92.69 balanced acc (mAP 95.61, AUROC 96.50) on the 1713 of 2000 images still online on X (413 real; 392/473/435 fake) (tag\u2026" }, { "benchmark": "WildRF (Facebook, Reddit, Twitter test sets)", "metric": "balanced accuracy", "paper": "acc=95.8", - "ours": "mAP=99.13 / acc=95.89 / AUROC=99.14 (official wts)", - "ours_synthscope": "", + "ours": "SynthScope mAP=99.3 / acc=95.58 / AUROC=99.25 \u00b7 official mAP=99.13 / acc=95.89 / AUROC=99.14", + "ours_synthscope": "mAP=99.3 / acc=95.58 / AUROC=99.25", "ours_official": "mAP=99.13 / acc=95.89 / AUROC=99.14", - "status": "official", - "note": "Official adapter through SynthScope: 95.89 balanced acc (mAP 99.13, AUROC 99.14) on the full test split, 1251 real / 1252 fake (tag cure_wildrf, job 251440)." + "status": "reproduced", + "note": "Reproduced by the SynthScope-trained r3e0 (pre-registered non-benchmark selection; single seed) and, without the augmentation assumption, by the paper-settings-only r1e0 (95.23 acc); the served cure model is the official adapter. Official adapter through SynthScope: 95.89 balanced acc (mAP 99.13, AUROC 99.14) on the full test split, 1251 real / 1252 fake (tag cure_wildrf, job 251440).\u2026" }, { "benchmark": "BFree-Online (viral images still online)", "metric": "balanced accuracy", "paper": "acc=90.9", - "ours": "mAP=99.06 / acc=91.64 / AUROC=98.08 (official wts)", - "ours_synthscope": "", + "ours": "SynthScope mAP=89.48 / acc=71.19 / AUROC=79.51 \u00b7 official mAP=99.06 / acc=91.64 / AUROC=98.08", + "ours_synthscope": "mAP=89.48 / acc=71.19 / AUROC=79.51", "ours_official": "mAP=99.06 / acc=91.64 / AUROC=98.08", "status": "reference", - "note": "Official adapter through SynthScope: 91.64 balanced acc (mAP 99.06, AUROC 98.08) on the 807 of 1111 listed images still online (269 real / 538 fake), about 58% of the paper's set, so not a like-for-like comparison (tag cure_bfree_online, job 251449)." + "note": "Trained r3e0 not reproduced (-19.7 acc); the served cure model is the official adapter. Official adapter through SynthScope: 91.64 balanced acc (mAP 99.06, AUROC 98.08) on the 807 of 1111 listed images still online (269 real / 538 fake), about 58% of the paper's set, so not a like-for-like comparison (tag cure_bfree_online, job 251449). SynthScope-trained: r3e0, the best checkpoint by the\u2026" }, { "benchmark": "RRDataset (original / transfer / redigital)", "metric": "balanced accuracy", "paper": "acc=81.5", - "ours": "mAP=90.4 / acc=82.04 / AUROC=88.88 (official wts)", - "ours_synthscope": "", + "ours": "SynthScope mAP=84.91 / acc=73.46 / AUROC=85.32 \u00b7 official mAP=90.4 / acc=82.04 / AUROC=88.88", + "ours_synthscope": "mAP=84.91 / acc=73.46 / AUROC=85.32", "ours_official": "mAP=90.4 / acc=82.04 / AUROC=88.88", "status": "official", - "note": "Official adapter through SynthScope: 82.04 balanced acc (mAP 90.40, AUROC 88.88) on the public test archive, 25,499 real / 25,500 fake (original 91.08, transfer 85.52, redigital 69.51) (tag cure_rrdataset, job 251476)." + "note": "Trained r3e0 not reproduced (-8.0 acc); the served cure model is the official adapter. Official adapter through SynthScope: 82.04 balanced acc (mAP 90.40, AUROC 88.88) on the public test archive, 25,499 real / 25,500 fake (original 91.08, transfer 85.52, redigital 69.51) (tag cure_rrdataset, job 251476). SynthScope-trained: r3e0, the best checkpoint by the pre-registered non-benchmark selection\u2026" }, { "benchmark": "RealChain (7 generators, full data)", "metric": "balanced accuracy", "paper": "acc=79.7", - "ours": "mAP=87.39 / acc=79.69 / AUROC=85.47 (official wts)", - "ours_synthscope": "", + "ours": "SynthScope mAP=83.67 / acc=72.75 / AUROC=84.7 \u00b7 official mAP=87.39 / acc=79.69 / AUROC=85.47", + "ours_synthscope": "mAP=83.67 / acc=72.75 / AUROC=84.7", "ours_official": "mAP=87.39 / acc=79.69 / AUROC=85.47", "status": "official", - "note": "Official adapter through SynthScope: 79.69 balanced acc (mAP 87.39, AUROC 85.47) on the full released set (tag cure_realchain, job 251412). The release is one JPEG-q60 image set; the 7000 unpaired reals are split into 7 disjoint slices, so the mean per-generator balanced accuracy equals the pooled one." + "note": "Trained r3e0 not reproduced (-7.0 acc); the served cure model is the official adapter. Official adapter through SynthScope: 79.69 balanced acc (mAP 87.39, AUROC 85.47) on the full released set (tag cure_realchain, job 251412). The release is one JPEG-q60 image set; the 7000 unpaired reals are split into 7 disjoint slices, so the mean per-generator balanced accuracy equals the pooled one.\u2026" }, { "benchmark": "Chameleon", @@ -1213,6 +1213,150 @@ "note": "Official-weights-in-SynthScope reproduces the AP (99.26) and acc 97.39 ~= paper 97.9. SynthScope retrain matches on AP (98.61) but acc collapses (66.66) due to threshold/calibration drift in the from-scratch LoRA head; the released checkpoint's peak-guided calibration is what the paper headline relies on." } ], + "probe": [ + { + "benchmark": "GenImage (8 subsets, val100k, fakes JPEG q96)", + "metric": "balanced accuracy at 0.5 (mean of real and fake accuracy), mean over subsets", + "paper": "acc=96.8", + "ours": "mAP=99.77 / acc=97.47 / AUROC=99.8 (official wts)", + "ours_synthscope": "", + "ours_official": "mAP=99.77 / acc=97.47 / AUROC=99.8", + "status": "official", + "note": "97.47 bAcc / 99.77 mAP, +0.67 vs the paper. Caveats: fakes JPEG q96 as the paper; sdv1.5 8000 per class (paper 6000); DINOv2 ADM/GLIDE/BigGAN about +2 above the paper while SynthScope equals the official code on every file compared (not run on GenImage), cause undetermined. Per subset (diff to the paper): midjourney 98.73 (-0.07); sdv1.4 99.41 (+0.01); sdv1.5 99.39 (-0.01); adm 93.22 (+2.22)\u2026" + }, + { + "benchmark": "Synthbuster (9 subsets, vs 5000 MSCOCO reals - not the paper's RAISE-1k)", + "metric": "balanced accuracy at 0.5 (mean of real and fake accuracy), mean over subsets (reals: 5000 MSCOCO val2017, different from the paper)", + "paper": "acc=97.5", + "ours": "mAP=99.64 / acc=98.2 / AUROC=99.93 (official wts)", + "ours_synthscope": "", + "ours_official": "mAP=99.64 / acc=98.2 / AUROC=99.93", + "status": "reference", + "note": "98.2 bAcc / 99.64 mAP with DIFFERENT REALS: 5000 MSCOCO val2017 images (EvalGEN/Flux/0_real) instead of the paper's RAISE-1k (registration-gated, not in SynthScope), so this is not a like-for-like comparison and does not reproduce the paper's number. Per subset (diff to the paper): dalle2 93.47 (-1.13); dalle3 99.57 (+0.17); firefly 99.77 (+0.27); glide 92.22 (+5.52); midjourney-v5 99.77\u2026" + }, + { + "benchmark": "SynthWildX (dalle3 / firefly / midjourney_v5)", + "metric": "balanced accuracy at 0.5 (mean of real and fake accuracy), mean over subsets", + "paper": "acc=96.4", + "ours": "mAP=98.8 / acc=97.3 / AUROC=99.18 (official wts)", + "ours_synthscope": "", + "ours_official": "mAP=98.8 / acc=97.3 / AUROC=99.18", + "status": "official", + "note": "97.3 bAcc / 98.8 mAP, +0.90. Per subset (diff): dalle3 97.44 (+0.94); firefly 96.98 (+0.58); midjourney_v5 97.48 (+0.98). Our copy: 413 reals and 392 / 473 / 435 fakes (paper Table 12: 0.5k and 1.5k). The unmodified official code gives the same bAcc on every subset (max |dP| 4.8e-6, 0 flips). Tag probe_synthwildx, job 66753." + }, + { + "benchmark": "WildRF (facebook / reddit / twitter)", + "metric": "balanced accuracy at 0.5 (mean of real and fake accuracy), mean over subsets", + "paper": "acc=96.9", + "ours": "mAP=99.36 / acc=96.92 / AUROC=99.26 (official wts)", + "ours_synthscope": "", + "ours_official": "mAP=99.36 / acc=96.92 / AUROC=99.26", + "status": "official", + "note": "96.92 bAcc / 99.36 mAP, +0.02. Per subset (diff): facebook 98.75 (+0.35); reddit 93.33 (-0.07); twitter 98.68 (-0.32). 2503 files (the paper lists 1.25k + 1.25k). The official code drops the 262 .jfif files of twitter (.jpg/.jpeg/.png only); on the common files it equals SynthScope (0 flips, max |dP| 3.0e-6). Tag probe_wildrf, job 66753." + }, + { + "benchmark": "AIGI-Bench (CommunityAI + SocialRF)", + "metric": "balanced accuracy at 0.5 (mean of real and fake accuracy), mean over subsets", + "paper": "acc=89.9", + "ours": "mAP=96.46 / acc=89.88 / AUROC=95.88 (official wts)", + "ours_synthscope": "", + "ours_official": "mAP=96.46 / acc=89.88 / AUROC=95.88", + "status": "official", + "note": "89.88 bAcc / 96.46 mAP, -0.02. Per subset (diff): CommunityAI 90.38 (+0.58); SocialRF 89.38 (-0.52). Only the paper's two subsets were scored: CommunityAI 6000 + 6000, SocialRF 3000 + 3000. Tag probe_aigibench, job 66790." + }, + { + "benchmark": "Chameleon", + "metric": "balanced accuracy at 0.5 (mean of real and fake accuracy), mean over subsets", + "paper": "acc=86.6", + "ours": "", + "ours_synthscope": "", + "ours_official": "", + "status": "missing", + "note": "Not run: Chameleon is available by request only and has no loader in SynthScope." + }, + { + "benchmark": "AIGI-Quality-Paradox", + "metric": "balanced accuracy at 0.5 (mean of real and fake accuracy), mean over subsets", + "paper": "acc=92.9", + "ours": "", + "ours_synthscope": "", + "ours_official": "", + "status": "missing", + "note": "Not run: no loader in SynthScope." + } + ], + "probe_resnet": [ + { + "benchmark": "GenImage (8 subsets, val100k, fakes JPEG q96)", + "metric": "balanced accuracy at 0.5 (mean of real and fake accuracy), mean over subsets", + "paper": "acc=78.4", + "ours": "mAP=86.69 / acc=78.38 / AUROC=84.81 (official wts)", + "ours_synthscope": "", + "ours_official": "mAP=86.69 / acc=78.38 / AUROC=84.81", + "status": "official", + "note": "78.38 bAcc / 86.69 mAP, -0.02 vs the paper. Caveats: fakes JPEG q96 as the paper; sdv1.5 8000 per class (paper 6000). Equal to the paper in 7 of 8 subsets (within 0.1); ADM 58.94 vs 60.0. Per subset (diff to the paper): midjourney 90.73 (+0.03); sdv1.4 99.36 (-0.04); sdv1.5 99.24 (+0.04); adm 58.94 (-1.06); glide 63.01 (+0.01); wukong 99.41 (+0.01); vqdm 66.90 (+0.00); biggan 49.41 (+0.01). Full\u2026" + }, + { + "benchmark": "Synthbuster (9 subsets, vs 5000 MSCOCO reals - not the paper's RAISE-1k)", + "metric": "balanced accuracy at 0.5 (mean of real and fake accuracy), mean over subsets (reals: 5000 MSCOCO val2017, different from the paper)", + "paper": "acc=79.1", + "ours": "mAP=85.23 / acc=83.75 / AUROC=95.88 (official wts)", + "ours_synthscope": "", + "ours_official": "mAP=85.23 / acc=83.75 / AUROC=95.88", + "status": "reference", + "note": "83.75 bAcc / 85.23 mAP with DIFFERENT REALS: 5000 MSCOCO val2017 images (EvalGEN/Flux/0_real) instead of the paper's RAISE-1k (registration-gated, not in SynthScope), so this is not a like-for-like comparison and does not reproduce the paper's number. Per subset (diff to the paper): dalle2 52.97 (+4.67); dalle3 94.82 (+4.62); firefly 51.57 (+4.67); glide 62.07 (+4.67); midjourney-v5 97.82\u2026" + }, + { + "benchmark": "SynthWildX (dalle3 / firefly / midjourney_v5)", + "metric": "balanced accuracy at 0.5 (mean of real and fake accuracy), mean over subsets", + "paper": "acc=75.6", + "ours": "mAP=83.88 / acc=75.2 / AUROC=82.8 (official wts)", + "ours_synthscope": "", + "ours_official": "mAP=83.88 / acc=75.2 / AUROC=82.8", + "status": "official", + "note": "75.2 bAcc / 83.88 mAP, -0.40. Per subset (diff): dalle3 89.71 (-0.59); firefly 56.29 (-0.41); midjourney_v5 79.61 (-0.09). Our copy: 413 reals and 392 / 473 / 435 fakes (paper Table 12: 0.5k and 1.5k). The unmodified official code gives the same bAcc on every subset (max |dP| 4.7e-4, 0 flips). Tag probe_resnet_synthwildx, job 66753." + }, + { + "benchmark": "WildRF (facebook / reddit / twitter)", + "metric": "balanced accuracy at 0.5 (mean of real and fake accuracy), mean over subsets", + "paper": "acc=81.3", + "ours": "mAP=89.45 / acc=81.63 / AUROC=85.76 (official wts)", + "ours_synthscope": "", + "ours_official": "mAP=89.45 / acc=81.63 / AUROC=85.76", + "status": "official", + "note": "81.63 bAcc / 89.45 mAP, +0.33. Per subset (diff): facebook 87.81 (+0.01); reddit 72.87 (-0.03); twitter 84.20 (+0.90). 2503 files (the paper lists 1.25k + 1.25k). The official code drops the 262 .jfif files of twitter (.jpg/.jpeg/.png only); on the common files it equals SynthScope (0 flips, max |dP| 1.3e-3). Tag probe_resnet_wildrf, job 66753." + }, + { + "benchmark": "AIGI-Bench (CommunityAI + SocialRF)", + "metric": "balanced accuracy at 0.5 (mean of real and fake accuracy), mean over subsets", + "paper": "acc=70.4", + "ours": "mAP=79.8 / acc=70.44 / AUROC=77.55 (official wts)", + "ours_synthscope": "", + "ours_official": "mAP=79.8 / acc=70.44 / AUROC=77.55", + "status": "official", + "note": "70.44 bAcc / 79.8 mAP, +0.04. Per subset (diff): CommunityAI 70.99 (-0.01); SocialRF 69.88 (-0.02). Only the paper's two subsets were scored: CommunityAI 6000 + 6000, SocialRF 3000 + 3000. Tag probe_resnet_aigibench, job 66790." + }, + { + "benchmark": "Chameleon", + "metric": "balanced accuracy at 0.5 (mean of real and fake accuracy), mean over subsets", + "paper": "acc=74.0", + "ours": "", + "ours_synthscope": "", + "ours_official": "", + "status": "missing", + "note": "Not run: Chameleon is available by request only and has no loader in SynthScope." + }, + { + "benchmark": "AIGI-Quality-Paradox", + "metric": "balanced accuracy at 0.5 (mean of real and fake accuracy), mean over subsets", + "paper": "acc=87.7", + "ours": "", + "ours_synthscope": "", + "ours_official": "", + "status": "missing", + "note": "Not run: no loader in SynthScope." + } + ], "restrav": [ { "benchmark": "A) VidProM vs image-based detectors (Table 2)", @@ -1596,5 +1740,139 @@ "status": "missing", "note": "Not run: no data or loader in SynthScope." } + ], + "waverep": [ + { + "benchmark": "GenVideo-Val, the paper's 8 GenVideo generators (PARTIAL comparison)", + "metric": "balanced accuracy at 0.5 and AUC, mean over the paper's 8 GenVideo columns (full GenVideo-Val: 10,000 reals + all fakes of each generator, 64 frames)", + "paper": "acc=94.83 / auroc=98.03", + "ours": "acc=90.3 / AUROC=95.73 (official wts)", + "ours_synthscope": "", + "ours_official": "acc=90.3 / AUROC=95.73", + "status": "below", + "note": "PARTIAL: the paper's 8 GenVideo columns, scored with GenVideo-Val's own 10,000 reals (the paper does not say which reals it paired). 5 of 8 within ~2 pts; HotShot (60.1 vs 81.4), Show-1 (79.7 vs 92.1) and LaVie (92.1 vs 95.5) NOT reproduced; HotShot fake recall 21%, AUC 75.6 (cause untested)." + }, + { + "benchmark": "GenVideo-Val full, 10 generators (zero-shot reference)", + "metric": "mean over 10 generators: balanced accuracy at 0.5, AP (fake positive), AUROC; 10,000 reals + all fakes", + "paper": "\u2014", + "ours": "mAP=79.85 / acc=86.87 / AUROC=92.13 (official wts)", + "ours_synthscope": "", + "ours_official": "mAP=79.85 / acc=86.87 / AUROC=92.13", + "status": "reference", + "note": "Zero-shot reference, NOT a paper reproduction (the 8 paper columns are in the row above; Sora and WildScrape have no paper cell). mAP (fake positive) is low because of the 10,000 : 56-1400 class imbalance; AUROC is not affected the same way." + }, + { + "benchmark": "GenVideo-Val --limit 1000 (zero-shot reference)", + "metric": "mean over 10 generators; first 1000 reals and first 1000 fakes per generator (the D3 protocol)", + "paper": "\u2014", + "ours": "mAP=89.81 / acc=86.62 / AUROC=92.09 (official wts)", + "ours_synthscope": "", + "ours_official": "mAP=89.81 / acc=86.62 / AUROC=92.09", + "status": "reference", + "note": "Zero-shot reference, NOT a paper reproduction: the first 1000 clips per class (--limit 1000), so up to 1000 fakes and exactly 1000 reals per generator." + }, + { + "benchmark": "VideoPhy --limit 1000 (zero-shot reference)", + "metric": "mean over the 8 generators online; first 1000 reals, up to 1000 fakes per generator", + "paper": "\u2014", + "ours": "mAP=93.21 / acc=90.0 / AUROC=96.54 (official wts)", + "ours_synthscope": "", + "ours_official": "mAP=93.21 / acc=90.0 / AUROC=96.54", + "status": "reference", + "note": "Zero-shot reference, NOT a paper reproduction; first 1000 clips per class (--limit 1000); 8 of the 10 VideoPhy generators (dead links skipped). Weakest: OpenSora and ZeroScope." + }, + { + "benchmark": "VidProM --limit 1000 (zero-shot reference)", + "metric": "mean over 4 generators (ModelScope, Pika, Text2Video-Zero, VideoCrafter2); first 1000 clips per class", + "paper": "\u2014", + "ours": "mAP=98.11 / acc=89.85 / AUROC=98.06 (official wts)", + "ours_synthscope": "", + "ours_official": "mAP=98.11 / acc=89.85 / AUROC=98.06", + "status": "reference", + "note": "Zero-shot reference, NOT a paper reproduction; first 1000 clips per class (--limit 1000); 2 Pika fakes (00642, 00891) are empty 0-byte files in our copy, so OpenCV decodes no frame; excluded (998 scored). VidProM is non-commercial." + }, + { + "benchmark": "EvalCrafter (zero-shot reference)", + "metric": "mean over 14 generators; the fakes of each generator vs the first 1000 GenVideo-Val MSR-VTT reals", + "paper": "\u2014", + "ours": "mAP=96.93 / acc=92.84 / AUROC=97.17 (official wts)", + "ours_synthscope": "", + "ours_official": "mAP=96.93 / acc=92.84 / AUROC=97.17", + "status": "reference", + "note": "Zero-shot reference, NOT a paper reproduction. EvalCrafter has no reals of its own: the reals are the first 1000 GenVideo-Val MSR-VTT videos (--limit 1000), the same for every generator." + }, + { + "benchmark": "The paper's own test set: Allegro, CogVideoX1.5, Open-Sora-Plan, Mochi-1, NOVA, Sora, FLUX vs 300 Panda-70M reals (NOT HELD)", + "metric": "balanced accuracy and AUC", + "paper": "\u2014", + "ours": "", + "ours_synthscope": "", + "ours_official": "", + "status": "missing", + "note": "NOT HELD: the 2,100 fakes are downloadable from grip.unina.it, but the 300 real clips are Panda-70M YouTube videos that need dataset/script_download_real.py with a YouTube downloader and cookies; not scraped. Without the reals there is no AUC or balanced accuracy, so a fakes-only run would not be the paper's benchmark." + } + ], + "waverep_g4": [ + { + "benchmark": "GenVideo-Val, the paper's 8 GenVideo generators (reference only: G4 is not the paper's single-generator model)", + "metric": "balanced accuracy at 0.5 and AUC, mean over the paper's 8 GenVideo columns (full GenVideo-Val, 64 frames)", + "paper": "\u2014", + "ours": "acc=96.3 / AUROC=99.05 (official wts)", + "ours_synthscope": "", + "ours_official": "acc=96.3 / AUROC=99.05", + "status": "reference", + "note": "REFERENCE ONLY: G4 is trained on four generators, not the paper's single-generator setting (the paper's G1 values are in the waverep rows). PARTIAL as for G1: GenVideo-Val's own 10,000 reals (the paper's pairing is unstated). Above the paper's G1 on every column but Gen2 AUC, by up to 4.7 bAcc (Show-1)." + }, + { + "benchmark": "GenVideo-Val full, 10 generators (zero-shot reference)", + "metric": "mean over 10 generators: balanced accuracy at 0.5, AP (fake positive), AUROC; 10,000 reals + all fakes", + "paper": "\u2014", + "ours": "mAP=88.88 / acc=93.28 / AUROC=96.69 (official wts)", + "ours_synthscope": "", + "ours_official": "mAP=88.88 / acc=93.28 / AUROC=96.69", + "status": "reference", + "note": "Zero-shot reference, NOT a paper reproduction (the 8 paper columns are in the row above; Sora and WildScrape have no paper cell). mAP (fake positive) is low because of the 10,000 : 56-1400 class imbalance; AUROC is not affected the same way." + }, + { + "benchmark": "GenVideo-Val --limit 1000 (zero-shot reference)", + "metric": "mean over 10 generators; first 1000 reals and first 1000 fakes per generator (the D3 protocol)", + "paper": "\u2014", + "ours": "mAP=94.47 / acc=92.65 / AUROC=96.53 (official wts)", + "ours_synthscope": "", + "ours_official": "mAP=94.47 / acc=92.65 / AUROC=96.53", + "status": "reference", + "note": "Zero-shot reference, NOT a paper reproduction: the first 1000 clips per class (--limit 1000), so up to 1000 fakes and exactly 1000 reals per generator." + }, + { + "benchmark": "VideoPhy --limit 1000 (zero-shot reference)", + "metric": "mean over the 8 generators online; first 1000 reals, up to 1000 fakes per generator", + "paper": "\u2014", + "ours": "mAP=98.2 / acc=95.73 / AUROC=99.29 (official wts)", + "ours_synthscope": "", + "ours_official": "mAP=98.2 / acc=95.73 / AUROC=99.29", + "status": "reference", + "note": "Zero-shot reference, NOT a paper reproduction; first 1000 clips per class (--limit 1000); 8 of the 10 VideoPhy generators (dead links skipped). Weakest: OpenSora and ZeroScope." + }, + { + "benchmark": "VidProM --limit 1000 (zero-shot reference)", + "metric": "mean over 4 generators (ModelScope, Pika, Text2Video-Zero, VideoCrafter2); first 1000 clips per class", + "paper": "\u2014", + "ours": "mAP=99.29 / acc=95.8 / AUROC=99.25 (official wts)", + "ours_synthscope": "", + "ours_official": "mAP=99.29 / acc=95.8 / AUROC=99.25", + "status": "reference", + "note": "Zero-shot reference, NOT a paper reproduction; first 1000 clips per class (--limit 1000); 2 Pika fakes (00642, 00891) are empty 0-byte files in our copy, so OpenCV decodes no frame; excluded (998 scored). VidProM is non-commercial." + }, + { + "benchmark": "EvalCrafter (zero-shot reference)", + "metric": "mean over 14 generators; the fakes of each generator vs the first 1000 GenVideo-Val MSR-VTT reals", + "paper": "\u2014", + "ours": "mAP=99.19 / acc=96.55 / AUROC=99.29 (official wts)", + "ours_synthscope": "", + "ours_official": "mAP=99.19 / acc=96.55 / AUROC=99.29", + "status": "reference", + "note": "Zero-shot reference, NOT a paper reproduction. EvalCrafter has no reals of its own: the reals are the first 1000 GenVideo-Val MSR-VTT videos (--limit 1000), the same for every generator." + } ] } \ No newline at end of file diff --git a/interface/scripts/collect_checkpoints.py b/interface/scripts/collect_checkpoints.py index 8a5b97fe32941532a45c6a234201492ccc07fe1b..7b627394c33f50d153625fcbe3ec9dd8c84bedf0 100644 --- a/interface/scripts/collect_checkpoints.py +++ b/interface/scripts/collect_checkpoints.py @@ -6,7 +6,7 @@ it was obtained (official weights / trained-from-scratch / training-free). Run: conda run -n SynthScope python interface/scripts/collect_checkpoints.py -Override the destination with SYNTHSCOPE_CKPT_DIR. +Override the destination with SYNTHSCOPE_CKPT_DIR. ``--check`` only verifies that the source files exist. """ import json import os @@ -18,15 +18,27 @@ sys.path.insert(0, str(Path(__file__).resolve().parents[1])) from backend import config # noqa: E402 (sets paths) from backend.registry import list_specs # noqa: E402 -# Known source locations of the official weights on this node. +# Known source locations of the official weights on this node. Every entry must be the file the registry (and the +# public Space) actually serves under that name: +# fat_former.pth official 4-class ProGAN FatFormer release +# aide.pth official SD-v1.4 release (sd14_train.pth), not the ProGAN-trained progan_train.pth +# npr.pth official NPR.pth with the DataParallel ``module.`` prefix stripped (NPR_table1.pth, linked 2026-06-09), +# not the older model_epoch_last_3090.pth REPRO_CKPTS = Path("/hddstore/ssalehi/SynthScope/repro/ckpts") +AIDE_OFFICIAL = Path("/hddstore/ssalehi/SynthScope/repro/official_ckpts/aide/AIDE_checkpoints") OFFICIAL_SOURCES = { "fat_former.pth": REPRO_CKPTS / "fatformer_official.pth", - "aide.pth": REPRO_CKPTS / "aide_progan_train.pth", - "npr.pth": REPRO_CKPTS / "NPR_model_epoch_last_3090.pth", + "aide.pth": AIDE_OFFICIAL / "sd14_train.pth", + "npr.pth": REPRO_CKPTS / "NPR_table1.pth", } +def missing_sources(sources: dict = None) -> list: + """Names whose source file does not exist (on a node without /hddstore this is all of them).""" + sources = OFFICIAL_SOURCES if sources is None else sources + return [name for name, src in sources.items() if not src.exists()] + + def link(dest: Path, src: Path) -> str: if not src.exists(): return f"source missing: {src}" @@ -37,6 +49,15 @@ def link(dest: Path, src: Path) -> str: def main(): + if "--check" in sys.argv[1:]: # only verify that every source exists; link nothing, write nothing + missing = missing_sources() + for name in missing: + print(f"WARNING: source for {name} is missing: {OFFICIAL_SOURCES[name]}", file=sys.stderr) + print(f"{len(OFFICIAL_SOURCES) - len(missing)}/{len(OFFICIAL_SOURCES)} official sources present") + sys.exit(1 if missing else 0) + for name in missing_sources(): + print(f"WARNING: source for {name} is missing: {OFFICIAL_SOURCES[name]} " + f"(an existing {name} link is left unchanged)", file=sys.stderr) dst = config.CHECKPOINTS_DIR dst.mkdir(parents=True, exist_ok=True) print(f"checkpoints dir: {dst}") diff --git a/interface/scripts/verify_model.py b/interface/scripts/verify_model.py index 2e5441cd6ca31aa1792d1e4e8e2377b348248993..a582aab90f990cec9b86cc224ca15ce1f8d5a58f 100644 --- a/interface/scripts/verify_model.py +++ b/interface/scripts/verify_model.py @@ -69,9 +69,10 @@ def main(): random.Random(2).shuffle(items) print(f"{args.key}: scoring {len(items)} images from [{args.gens}] on {engine.device}") + bs = spec.eval_batch_size(args.bs) # native-resolution specs cannot stack variable-size inputs probs, labels = [], [] - for i in range(0, len(items), args.bs): - chunk = items[i:i + args.bs] + for i in range(0, len(items), bs): + chunk = items[i:i + bs] batch = torch.stack([spec.transform(media.open_rgb(p)) for p, _ in chunk]).to(engine.device) probs += engine._fake_prob(model, spec, batch).float().cpu().tolist() labels += [l for _, l in chunk] diff --git a/interface/static/index.html b/interface/static/index.html index fdbe80e33bf9328ce1f78f127f8d292be684e92c..1918ed9fbe316ea93e530800e15df2f4cdf97c59 100644 --- a/interface/static/index.html +++ b/interface/static/index.html @@ -1248,7 +1248,7 @@ pre.cmd { margin: 10px 0 0; padding: 10px 12px; background: rgba(0,0,0,.35); bor
the detector's input
${r.input_note && html`${r.input_note.label}`} - ${r.input_size && r.orig_size && html`${r.input_size[0]}×${r.input_size[1]} px${(r.input_size[0] === r.orig_size[0] && r.input_size[1] === r.orig_size[1]) ? " (your image's own size)" : " (from your " + r.orig_size[0] + "×" + r.orig_size[1] + " image)"}. `} + ${r.input_size && r.orig_size && html`${r.input_size[0]}×${r.input_size[1]} px${(r.input_size[0] === r.orig_size[0] && r.input_size[1] === r.orig_size[1]) ? " (your image's own size)" : " (from your " + r.orig_size[0] + "×" + r.orig_size[1] + " image)"}${r.input_grid ? ", cut into " + r.input_grid[1] + "×" + r.input_grid[0] + " = " + r.input_patches + " patches (as in the official code, padded edges beyond the patch grid are not scored)" : ""}. `} ${r.input_note && r.input_note.explanation}
`} diff --git a/models/image/aide/README.md b/models/image/aide/README.md index 91f9a7d79461eaa44dc30134447793c54457fe59..367d5720daa8a6c8fd2fd95c2f43e4bff17b0710 100644 --- a/models/image/aide/README.md +++ b/models/image/aide/README.md @@ -5,7 +5,7 @@ **AIDE** (ICLR 2025, "A Sanity Check for AI-generated Image Detection") detects generated images by fusing a **semantic** branch and a **low-level artifact** branch: -- **Semantic branch** — a frozen OpenCLIP **ConvNeXt-XXL** trunk, mean-pooled and projected to 256-d. +- **Semantic branch** — a frozen OpenCLIP **ConvNeXt-XXL** trunk, mean-pooled and projected to 256-d by a linear layer that is frozen too (the official forward computes it under `torch.no_grad()`, so it keeps its random initialization; training updates only the two ResNet-50 streams and the MLP head). - **Artifact branch** — the image is resized to 256×256, then 32×32 patches are **DCT-scored** with `K=6` band-pass filters (weighted `2^k` over `log(|DCT|+1)`); the **2 highest- and 2 lowest-energy patches** are each upsampled to 256×256, passed through **30 fixed SRM high-pass kernels** and two ResNet-50 @@ -30,10 +30,34 @@ All benchmarks the paper reports, with our numbers (verified, traced to `repro/b | Benchmark | Paper | SynthScope_official | SynthScope_train | Status | |---|---|---|---|---| | AIGCDetectBenchmark (B1, Setting-I, ProGAN-trained) | acc=92.77 | mAP=97.94 / acc=91.89 (official `progan_train.pth`) | — | official | -| GenImage (B2, Setting-I, SDv1.4-trained) | acc=86.88 | mAP=97.12 / acc=85.91 (served 96.83) | **mAP=96.42 / acc=77.9** | official; trained: mAP matches the official weights, acc below | -| ForenSynths-13 | — | mAP=94.40 / acc=81.8 (official `progan_train.pth`) | mAP=79.62 (cross-domain) | reference | +| GenImage (B2, Setting-I, SDv1.4-trained) | acc=86.88 | mAP=97.12 / acc=85.91 (served 96.83) | **mAP=93.90 / acc=80.73** | official; trained: below the paper (acc -6.15, mAP -3.22 vs the official weights) | +| ForenSynths-13 | — | mAP=94.40 / acc=81.8 (official `progan_train.pth`) | mAP=80.42 / acc=62.5 (cross-domain) | reference | | Chameleon (B3, Setting-II, in-the-wild) | acc=58–66 | — | — | missing | -*(**SynthScope_train = a from-scratch retrain with the faithful native-res 5-view preprocessing** (`checkpoints_retrain/aide_native_v2/model_2`, GenImage SDv1.4): GenImage-8 **96.42 mAP / 97.07 mAUROC**, reproducing the official 97.12 mAP (acc 77.9 vs 85.9 is lower) — up from the old resize-256 run's 92.47. This proves the repo can regenerate the AIDE checkpoint from scratch. ForenSynths-13 is cross-domain for it (a GenImage-trained model on the GAN benchmark); the official number there is the ProGAN-trained `progan_train.pth`, not the served `sd14_train.pth`.)* +*(**SynthScope_train = the official training recipe run in SynthScope** (`bash experiments/image/aide.sh`, train job 281041, `model_best` = epoch 4 of 5, validation accuracy 0.9984), evaluated with `bench_eval --model aide --ckpt model_best.pth`: GenImage-8 on the full test set (tag `aide_trained_genimage8`) **93.90 mAP / 91.66 mAUROC / 80.73 acc**; on the first 300 images per class and generator (the protocol of the served row and of the previous retrain; tag `aide_trained_genimage8_l300`) 92.57 / 89.63 / 80.69. It stays outside the 2-point tolerance of the paper (86.88 acc, -6.15) and below the official weights (97.12 mAP, -3.22): SD v1.4, SD v1.5, Wukong and GLIDE match them (acc 99.97 / 100.0 / 99.93 / 92.00 against 99.76 / 99.80 / 99.13 / 90.83), but ADM (58.63 against 76.60), Midjourney (74.60 against 83.70), VQDM (69.83 against 76.80) and BigGAN (50.87 against 60.63) transfer worse; real accuracy is 99.93-100 on every subset, so the loss is fake recall at the 0.5 threshold. The previous retrain (`aide_native_v2/model_2`; checkpoint deleted 2026-11-10 to free disk space, its result JSONs remain: native-resolution 5-view, but the earlier recipe with lr 1e-4, batch 32, horizontal flip, no perturbations, no label smoothing, DeepSpeed gradient clipping 1.0 and the epoch picked by validation loss; 300 images per class) had 96.42 mAP / 77.87 acc: the faithful recipe gains 2.8 points of accuracy and loses 3.9 mAP on the same images. The cause of the remaining gap is not identified. ForenSynths-13 (tag `aide_trained_forensynths`, 300 per class) is cross-domain for a GenImage-trained model (80.42 mAP / 62.5 acc); the official number there is the ProGAN-trained `progan_train.pth`, not the served `sd14_train.pth`.)* + +**Per-epoch diagnostic (not a reproduction claim; the headline stays `model_best` = epoch 4, chosen by validation accuracy as in the official code).** Each epoch checkpoint `model_0..model_4` of train job 281041 was scored on GenImage-8 (first 300 images per class and generator; epoch 4 is `aide_trained_genimage8_l300`) and, as a transfer probe, on Synthbuster (not an AIDE paper benchmark: the 9 generators' fakes against the 5,000 shared MSCOCO reals, first 300 per class and generator, 5,400 images), DAS6 job 66991, tags `aide_trained_e_genimage8_l300` / `aide_trained_e_synthbuster`: + +| Epoch | val acc | GenImage-8 mAP / acc | GenImage-8 ADM acc | Synthbuster mAP / acc | Synthbuster DALL-E 2 AP | +|---|---:|---:|---:|---:|---:| +| 0 | 0.9913 | 93.20 / 77.83 | 52.67 | **96.16** / 72.20 | 98.90 | +| 1 | 0.9956 | 91.99 / 77.88 | 54.17 | 94.20 / 69.63 | 93.79 | +| 2 | 0.9973 | 92.96 / 79.73 | 54.67 | 93.13 / 70.37 | 86.57 | +| 3 | 0.9979 | 92.50 / 79.73 | 54.33 | 92.56 / 70.24 | 84.96 | +| 4 (best) | 0.9984 | 92.57 / 80.69 | 56.83 | 92.20 / 70.67 | 81.79 | + +Reading: Synthbuster mAP falls monotonically with training (96.16 to 92.20; DALL-E 2 98.9 to 81.8, Firefly 82.8 to 78.6), the signature of over-adapting to SD v1.4 artifacts, while GenImage-8 mAP is flat (92.0-93.2, within single-run noise) and its accuracy creeps up (77.8 to 80.7) as the 0.5 threshold calibrates. No early epoch comes near the official weights' 97.12 mAP on GenImage-8, so an early checkpoint does not explain the gap on the paper's benchmark. One run, one seed, 300 images per class. + +### Training recipe (`experiments/image/aide.sh`) + +The recipe follows the official code (`shilinyan99/AIDE`, `main_finetune.py`, `data/datasets.py`) and the paper's GenImage setting: + +- **Data**: GenImage SD v1.4 train (162,000 ImageNet reals + 162,000 SD v1.4 fakes); validation = the SD v1.4 val split (6,000 + 6,000). +- **Trainable set**: the two ResNet-50 streams and the MLP head (322 tensors, 49,547,778 values). The OpenCLIP ConvNeXt-XXL trunk and its projection stay frozen, the ResNets start from random weights (the official code never loads its ImageNet state dict). +- **Transforms** (native resolution, no flip, no crop): `aide_blur` (Gaussian blur, 3x3 kernel, sigma 0.1-3.0, p 0.1) then `aide_jpeg` (JPEG quality 30-100, p 0.1; kornia 0.7.2, images whose sides are not multiples of 16 are edge-padded for the codec and cropped back), then the 5-view DCT patch selection (`aide_five_view_train`). Validation images get the same perturbations, as in the official run. The one deviation is a 1024-pixel cap on the long side before the DCT (dataloader memory); inference never caps. +- **Optimisation**: AdamW, lr 5e-4, weight decay 0, 5 epochs, per-iteration cosine decay to 1e-6, no warm-up, label smoothing 0.1, fp32, no gradient clipping, no EMA; plain DDP (no DeepSpeed). +- **Batch**: effective batch 256 = 4 GPUs x micro-batch 8 x gradient accumulation 8, with SyncBatchNorm over the 4 GPUs so each BatchNorm layer sees 32 images, as on each of the official 8 GPUs (batch 32 each). +- **Selection**: `model_best.pth` = the epoch with the highest validation accuracy (the official `max_accuracy`); every epoch is kept as `model_.pth`. Validation accuracy rose every epoch (0.9913, 0.9956, 0.9973, 0.9979, 0.9984), so epoch 4 is also the last. +- **Evaluate**: `python benchmark/bench_eval.py --model aide --ckpt /model_best.pth --benchmark pergen --data `. **reproduced** = SynthScope-trained checkpoint matches the paper · **official** = official weights loaded into the SynthScope class match (the SynthScope-trained number is shown alongside where we trained from scratch) · **below** = gap remains · **reference** = paper reports no comparable number · **missing** = not yet evaluated. diff --git a/models/image/aide/official_arch.py b/models/image/aide/official_arch.py index 4000cb1f3ce03453ba33e2ff87c067cf0a3c8416..d9a5ae796fa7cf3bfd2eef5eecdfbb139e10b606 100644 --- a/models/image/aide/official_arch.py +++ b/models/image/aide/official_arch.py @@ -297,6 +297,11 @@ class AIDE_Model(nn.Module): self.convnext_proj = nn.Sequential(nn.Linear(feat_dim, 256)) for param in self.openclip_convnext_xxl.parameters(): param.requires_grad = False + # The official forward computes ``convnext_proj`` inside ``torch.no_grad()`` (models/AIDE.py): the projection never + # receives gradients and keeps its random initialization, so the trained set is the two ResNets and ``fc``. Freeze + # it as well (checkpoints still carry its weights; outputs are unchanged). + for param in self.convnext_proj.parameters(): + param.requires_grad = False # The ResNet ``fc`` heads are unused (the streams stop at avgpool); they exist only so the # official checkpoint loads strict. Freeze them so the optimizer never touches dead params. for stream in (self.model_min, self.model_max): @@ -317,12 +322,12 @@ class AIDE_Model(nn.Module): tokens = x[:, 4] with torch.no_grad(): - # FROZEN trunk only: re-normalize the ImageNet/DINOv2-normalized tokens into CLIP space. + # FROZEN trunk and projection (as the official forward): re-normalize the ImageNet/DINOv2-normalized tokens into CLIP space. local = self.openclip_convnext_xxl( tokens * (self.dinov2_std / self.clip_std) + (self.dinov2_mean - self.clip_mean) / self.clip_std) local = self.avgpool(local).view(tokens.size(0), -1) # [B, feat_dim] - x_0 = self.convnext_proj(local) # trainable projection (outside no_grad so it learns) + x_0 = self.convnext_proj(local) # as the official forward: inside no_grad, a frozen random projection x_1 = (self.model_min(x_minmin) + self.model_max(x_maxmax) + self.model_min(x_minmin1) + self.model_max(x_maxmax1)) / 4 diff --git a/models/image/co_spy/README.md b/models/image/co_spy/README.md index bba8e6041ad674ccfad1c40d5d8480980f3a87fc..dfbd82e6b1e847653a538441a6a319db6aace6dd 100644 --- a/models/image/co_spy/README.md +++ b/models/image/co_spy/README.md @@ -110,6 +110,8 @@ All benchmarks the paper reports, with our numbers (verified, traced to `repro/b | ForenSynths (CNNDetection test) | — | mAP=87.97 | mAP=96.17 | reference | | In-the-wild (Co-Spy-Bench in-the-wild) | map=84.65 / acc=77.41 | — | — | missing | +The ForenSynths row of the official weights (`cospy_official_forensynths`, 13 sets, 87.97 mAP) is a 1000-per-class run (rates are multiples of 0.1; the June job log was not kept). The full ForenSynths-8 run with the same checkpoint and evaluator (`cospy_official_fs8_nov`, DAS6 job 66671, `repro/logs/lbfu_cospyoff_das6_66671.out`) gives 98.85 mAP / 95.12 acc / 99.03 mAUROC and is the leaderboard row. + The served `co_spy.pth` is the SynthScope retrain on GenImage SD v1.4 (`repro/retrain_cospy_full_mgpu.sbatch`, `checkpoints_retrain/cospy_full/model_1.pth`), which gives the Co-Spy-Bench and GenImage SynthScope_train numbers. The AIGCDetect and ForenSynths SynthScope_train numbers are from earlier SynthScope checkpoints and have not been re-run with it. diff --git a/models/image/cure/README.md b/models/image/cure/README.md index 411da157b37ada7c3a17424998de7a3998cdd861..3552f8b84e6d15ee189d01cdb47c02f02000717e 100644 --- a/models/image/cure/README.md +++ b/models/image/cure/README.md @@ -30,7 +30,7 @@ fetched from the Hugging Face Hub on first use (or `ModelConfig.base_checkpoint` | Preprocessing in cv2/PIL (`preprocess.py`), not albumentations | No new dependency. Equal to the official pipeline up to **1 float32 ulp (5.96e-8)** on 104 PNG/JPEG images, 200 px–4256 px, square and non-square (`repro/cure_preproc_equiv.py`). | | **Source-format hint** `img.info["synthscope_src_format"]` | Official PNG sources get an extra JPEG‑q96 round-trip, decided by the file suffix. `bench_eval` and the web decoder now record the original format on the PIL image; without the hint an image is treated as non-PNG. | | fp16 autocast on CUDA inside `forward` | The released results use fp16 AMP; CPU runs in fp32 (scores differ in the 3rd decimal). | -| `compute_loss` = plain cross-entropy | **The paper's two-stage mixing-ratio-regression training recipe is not in the official release.** `compute_loss` only satisfies SynthScope's trainer interface (LoRA + head trainable); it does **not** reproduce the paper's training. The SynthScope-trained row below is therefore empty. | +| Training recipe implemented from the paper | **The official release has inference code only.** SynthScope implements the paper's three stages (see *Training recipe* below); without `training_stage` `compute_loss` stays a plain cross-entropy that only satisfies the trainer interface. | ## Fidelity check (identical to the official model) @@ -43,23 +43,23 @@ images (official preprocessing vs SynthScope preprocessing, each end to end). Lo Summary in the repo's **Paper / SynthScope_official / SynthScope_train** schema (`acc` = mean per-generator balanced accuracy at 0.5): -| Benchmark | Paper | SynthScope_official | SynthScope_train | Status | +| Benchmark | Paper | SynthScope_official | SynthScope_train | Status (official adapter) | |---|---|---|---|---| -| AIGIBench (paper's 20 full-image-synthesis subsets, full test data) | acc=92.8 / AUC=97.5 | mAP=97.00 / acc=92.85 / AUROC=97.48 | — | **reproduced** (every subset within 0.10 pt) | -| UniversalFakeDetect (UFD-8) | acc=82.0 (UnivFD, aggregation unspecified) | mAP=99.19 / acc=93.94 | — | reference | -| ForenSynths (13) | (GAN half of UnivFD) | mAP=94.05 / acc=81.95 | — | reference | -| GenImage-8 (its training set) | — | mAP=97.30 / acc=85.18 | — | reference | -| AIGCDetectBenchmark (17 generators, full data, 76.3k real / 76.3k fake) | acc=89.3 / AUC=98.0 | mAP=98.08 / acc=89.30 / AUROC=98.02 | — | **reproduced** | -| RealChain (7 generators, 7000 real / 7000 fake, full data) | acc=79.7 | mAP=87.39 / acc=79.69 / AUROC=85.47 | — | **reproduced** | -| EvalGEN (5 generators, about 55k fakes, MSCOCO val2017 reals) | acc=98.1 | mAP=99.86 / acc=98.14 / AUROC=99.66 | — | **reproduced** (our real pool; see below) | -| SynthWildX (3 generators; 1713 of 2000 images still online on X) | acc=92.7 | mAP=95.61 / acc=92.69 / AUROC=96.50 | — | **reproduced** (on the images still online) | -| WildRF (Facebook, Reddit, Twitter test sets, 1251 real / 1252 fake) | acc=95.8 | mAP=99.13 / acc=95.89 / AUROC=99.14 | — | **reproduced** | -| BFree-Online (807 of the 1111 listed links still online; the paper had about 1400 images) | acc=90.9 | mAP=99.06 / acc=91.64 / AUROC=98.08 | — | close (about 58% of the paper's images) | -| RRDataset (original / transfer / redigital, public test archive, 25.5k real / 25.5k fake) | acc=81.5 | mAP=90.40 / acc=82.04 / AUROC=88.88 | — | **reproduced** within 0.6 pt (the paper counts 30k/30k) | +| AIGIBench (paper's 20 full-image-synthesis subsets, full test data) | acc=92.8 / AUC=97.5 | mAP=97.00 / acc=92.85 / AUROC=97.48 | mAP=96.72 / acc=91.12 / AUROC=97.10 (**reproduced**) | **reproduced** (every subset within 0.10 pt) | +| UniversalFakeDetect (UFD-8) | acc=82.0 (UnivFD, aggregation unspecified) | mAP=99.19 / acc=93.94 | mAP=98.73 / acc=93.89 / AUROC=98.31 (**reference**) | reference | +| ForenSynths (13) | (GAN half of UnivFD) | mAP=94.05 / acc=81.95 | mAP=97.22 / acc=89.36 / AUROC=96.58 (**reference**) | reference | +| GenImage-8 (its training set) | — | mAP=97.30 / acc=85.18 | mAP=97.56 / acc=86.22 / AUROC=97.59 (**reference**) | reference | +| AIGCDetectBenchmark (17 generators, full data, 76.3k real / 76.3k fake) | acc=89.3 / AUC=98.0 | mAP=98.08 / acc=89.30 / AUROC=98.02 | mAP=98.59 / acc=92.01 / AUROC=98.38 (**reproduced**) | **reproduced** | +| RealChain (7 generators, 7000 real / 7000 fake, full data) | acc=79.7 | mAP=87.39 / acc=79.69 / AUROC=85.47 | mAP=83.67 / acc=72.75 / AUROC=84.70 (**not reproduced, -7.0 acc**) | **reproduced** | +| EvalGEN (5 generators, about 55k fakes, MSCOCO val2017 reals) | acc=98.1 | mAP=99.86 / acc=98.14 / AUROC=99.66 | mAP=99.47 / acc=93.32 / AUROC=98.85 (**not reproduced, -4.8 acc**) | **reproduced** (our real pool; see below) | +| SynthWildX (3 generators; 1713 of 2000 images still online on X) | acc=92.7 | mAP=95.61 / acc=92.69 / AUROC=96.50 | mAP=97.12 / acc=91.76 / AUROC=97.09 (**reproduced**) | **reproduced** (on the images still online) | +| WildRF (Facebook, Reddit, Twitter test sets, 1251 real / 1252 fake) | acc=95.8 | mAP=99.13 / acc=95.89 / AUROC=99.14 | mAP=99.30 / acc=95.58 / AUROC=99.25 (**reproduced**) | **reproduced** | +| BFree-Online (807 of the 1111 listed links still online; the paper had about 1400 images) | acc=90.9 | mAP=99.06 / acc=91.64 / AUROC=98.08 | mAP=89.48 / acc=71.19 / AUROC=79.51 (**not reproduced, -19.7 acc**) | close (about 58% of the paper's images) | +| RRDataset (original / transfer / redigital, public test archive, 25.5k real / 25.5k fake) | acc=81.5 | mAP=90.40 / acc=82.04 / AUROC=88.88 | mAP=84.91 / acc=73.46 / AUROC=85.32 (**not reproduced, -8.0 acc**) | **reproduced** within 0.6 pt (the paper counts 30k/30k) | | Chameleon | 93.8 | — | — | missing (available by request only) | -`SynthScope_train` is empty: the paper's training recipe is not released. Details and per-generator tables below -(official weights through SynthScope; balanced accuracy at 0.5 unless noted). +`SynthScope_train` = **r3e0**, the best checkpoint of SynthScope's training investigation by its pre-registered, non-benchmark selection score (see *Trained checkpoint* below): the paper's recipe, plus DDA-style training augmentation (an assumption, the paper states none), stopped after epoch 0 by the selection rule. It is scored with `bench_eval --ckpt` and the same flags as the official rows (tags `cure_trained_r3e0_`, DAS6 job 67200). By the repo's tolerance (ours >= paper - 2.0 acc, - 2.5 AUROC) it **partially reproduces** the paper: 4 of the 8 comparable benchmarks (AIGIBench, AIGCDetect, SynthWildX, WildRF), mean accuracy 85.15 against the paper's 90.10; BFree-Online, RRDataset, RealChain and EvalGEN stay below. The served `cure` model remains the official adapter. +The tables below are the official weights through SynthScope (balanced accuracy at 0.5 unless noted); the trained checkpoint has its own section after the recipe. Paper: **89.7 avg over ten benchmarks** — AIGCDetect 89.3 · AIGIBench 92.8 · UnivFD 82.0 · EvalGEN 98.1 · SynthWildX 92.7 · WildRF 95.8 · BFree-Online 90.9 · RRDataset 81.5 · RealChain 79.7 · Chameleon 93.8. @@ -147,6 +147,179 @@ biggan 67.80 · adm 60.63 official PNG to JPEG q96 step (the scorers did not pass the source-format hint then). They were rescored with the step on 2026-11-08 (AUROC changes between -2.1 and +0.9, ranks unchanged); see `docs/BENCHMARKS.md`. +## Training recipe (from the paper; no official training code) + +`experiments/image/cure.sh` runs the three stages of the paper (Sec. 3, 4.1-4.2, Appendix A) on GenImage SD v1.4 train +(162,000 ImageNet reals + 162,000 SD v1.4 images) and writes `cure_trained.pth` with exactly the released adapter's 100 +tensors, so it is scored like the official weights: `bench_eval.py --model cure --ckpt /stage23/cure_trained.pth`. + +**Status: recipe provided; it partially reproduces the paper (see *Trained checkpoint* below).** Run as written (last epoch) it over-adapts to SD v1.4 in stage 1 and falls 13 points short; with the pre-registered early-stopping rule below it reproduces 3 of 8 comparable benchmarks (4 of 8 with the DDA-style augmentation option, `DatasetConfig.train_augment=dda`). Stages 2-3 are verified with the released encoder. Stage 1 saves every epoch; to build the adapter from the selected epoch run stages 2-3 with `STAGES="2 3" LORA=/stage1/model_.pth bash experiments/image/cure.sh`, with `` from `repro/cure_stage1/epoch_select.py` (the pre-registered rule; epoch 0 in both runs here). + +| stage | what (paper) | where | +|---|---|---| +| 1 | x_a = (1 - a) x_r + a x_g with independent real / generated endpoints, a ~ U(0, 1) per pair; linear ratio head + sigmoid on the adapted feature, BCE with soft target a; LoRA on Q and V of all 24 layers (rank 64, alpha 128, dropout 0); AdamW lr 1e-5, weight decay 0.1 (LoRA) / 0.01 (head); 5 epochs, per-GPU batch 64, 2 warmup epochs then cosine to 1e-6 | `main.py` with `trainer/image/cure.yaml`, `dataset/image/cure_train.yaml`, `ModelConfig.training_stage=ratio` (`dataset.CuReMixDataset`, `SynthScopeCuReModel.compute_loss`) | +| 2 | frozen encoder; 20,000 endpoint pairs; RF / RR / FF trajectories on {0, .2, .4, .6, .8, 1}; slopes (Eq. 6); C_F, C_M, C_S (Eq. 7-9) trace-normalised; generalised eigenproblem (Eq. 10), top k = 128 -> W, mu = mean RF trajectory feature | `train_stages.py stage2`, `subspace.py` | +| 3 | only Linear(128, 2) on W^T (z - mu): dropout 0.05, CE, AdamW lr 2e-4, weight decay 0.1, batch 256, 5 epochs | `train_stages.py stage3` (features cached once) | + +**Choices the paper leaves open** (each a documented assumption; the released `W` / `mu` allow checking stage 2): + +| open point | SynthScope choice | reason | +|---|---|---| +| training preprocessing | each endpoint goes through the released test pipeline (`cure_eval`: PNG -> JPEG q96, 390 resize / crop, 336, JPEG q70, mean = std = 0.5), then the mixture is formed | the paper re-encodes the PNG fakes as JPEG q96 (the pipeline's first step); the subspace and head are used with this pipeline at test time; no augmentation is mentioned. Check (consistency, not proof): with the released encoder, stage 2 on this preprocessing gives a mu with cosine 0.999998 to the released mu (relative distance 0.19 %, 20,000 pairs per type on the full data, job 66720); the same run without the final JPEG q70 pass (one control) gives cosine 0.982 / distance 19 % and a 17x larger off-diagonal ratio, so the mu match does discriminate that choice, whereas the subspace overlap (0.89 vs 0.86) does not. It is therefore consistent with the release's stage 2 having used this pipeline, but it does not establish it (mixing before q70, and stage 1's own preprocessing, are untested; stage 1 cannot be checked this way). See *Trained checkpoint* | +| where mixing happens | on the preprocessed tensors | normalisation is affine, so this equals the pixel mixture of the preprocessed images | +| pairing / epoch | one item per real image (162k per epoch), its generated partner and a drawn at random per item (with replacement), fresh every epoch | "independently drawn" endpoints, "each training pair receives one independently sampled mixing ratio" | +| warmup / cosine shape | linear from 0 per optimizer step over 2 epochs to 1e-5, then cosine over the remaining 3 epochs to 1e-6 (`timm_cosine.warmup_prefix`) | the usual meaning of "N warmup epochs and cosine decay to a minimum lr" (MAE-style) | +| GPU count / global batch | per-GPU 64 as stated; the global batch is NGPU x 64 (`STEP_MULT` in `cure.sh` accumulates to NGPU x 64 x STEP_MULT) | not stated. Tested: 192 (3 GPUs x 64, or 1 GPU x 64 x 3) and 512 (2 x 64 x 4, as on 8 GPUs); 512 alone does not reproduce the paper | +| training augmentation | none by default; `DatasetConfig.train_augment=dda` applies DDA's training augmentations per endpoint (`models/image/cure/train_augment.py`) | the paper states none ("following the setting of DDA" refers to the JPEG format alignment). The option is the R3 run below: DDA's `create_train_transforms` list unchanged, CuRe's random 390 crop in place of the centre crop, one shared seed per pair | +| precision, clipping, betas, seed | fp16 autocast with loss scaling, no clipping, torch AdamW betas, seed 0 | the released inference is fp16; nothing else stated | +| stage-1 model selection | every epoch is saved (`save_all`); the epoch is chosen by a pre-registered non-benchmark rule (`repro/cure_stage1/epoch_select.py`, see *Trained checkpoint*) | the paper mentions a "model-selection protocol" (Sec. 4.3) but does not describe it. The last epoch over-adapts (see below) | +| ratio-head weight decay | 0.01 on all head parameters (bias too) | "weight decay of 0.1 and 0.01, respectively" | +| pairs per trajectory type | 20,000 for each of RF, RR, FF (360k forwards) | "20,000 sampled endpoint pairs" | +| lambda_s, lambda_m, eps | 1, 1, 1e-3 (`subspace.py` defaults; `--lambda-s/--lambda-m/--eps`) | not stated. Stage 2 with `--reference-adapter` reports the overlap with the released W and fits the (lambda_s, lambda_m, eps) under which the released W is B-orthonormal. With the **released encoder** on 2500 pairs per type of a 2572 + 2572 subset of the training set (job 283104): fit lambda_s 0.90, lambda_m 1.02, eps 1.05e-3 (relative residual 0.09); with 1, 1, 1e-3 the solved W overlaps the released W at 0.74 (random 0.125), its columns have norms 9.0-9.6 (released 6.8-8.8), and the released W is nearly a generalised eigenbasis of our C_F (off-diagonal ratio 0.03). eps 1e-4 gave overlap 0.19 and 6x larger columns (job 283072, 1000 pairs). Final check on the full data (released encoder, 20,000 pairs per type, job 66720): overlap 0.89, fit lambda_s 0.96, lambda_m 1.02, eps 1.00e-3 (residual 0.036), off-diagonal ratio 0.016, so 1, 1, 1e-3 stand | +| eigenvector scale | B-orthonormal (W^T B W = I), as LAPACK / scipy generalised solvers return | the released W is not unit-norm (column norms 6.8-8.8) | +| stage-3 data and schedule | all 324k clean training images, constant lr, last epoch | not stated | + +**Memory.** On a 24 GB A5000, stage 1 at micro-batch 64 needs gradient checkpointing (`ModelConfig.grad_checkpointing`, +6.3 GiB peak, 32 images/s); without it micro-batch 32 takes 14.1 GiB (43 images/s), so a 48 GB GPU can run 64 without +checkpointing, or use `MICRO=32` (gradient accumulation 2, same per-GPU batch of 64). Checkpointing gives the same features and +gradients (`tests/test_cure_recipe.py`). + +**Smoke run** (job 283104, one A5000, log `repro/logs/curesmoke_283104.out`; a 2572 + 2572 subset of the training set, +every 63rd image of each class; not a result). Stage 1, 200 optimizer steps at per-GPU batch 64 with checkpointing: the +validation BCE on 256 fixed mixtures falls 0.738, 0.714, 0.698, 0.683, 0.674 over the 5 epochs (0.5 is the floor for +a ~ U(0, 1)). Stage 2 on 200 pairs per type, stage 3 on the 5144 subset images (eval-mode accuracy real 0.63 / fake 0.66 +after 5 epochs of 21 steps), export: 100 tensors, reloaded logits equal the trained head's (max |diff| 3.6e-6), and +`synthscope.load("cure", checkpoint=...)` loads it with the same status as the released adapter (`loaded 100 tensors, +missing=295` frozen backbone keys, `unexpected=0`). Stage-1 lr (job 283137, `repro/logs/curesmlr_283137.out`): all 45 logged steps equal the intended schedule (linear from 0, 1.000e-05 at the start of epoch 2, cosine to 1.002e-06 at the last step). + +**Tests.** `tests/test_cure_recipe.py` (CPU): the mixing items, the BCE soft-target loss, the trainable set and weight-decay +groups, gradient checkpointing, the trainer's logged lr at every step against the intended schedule, Eq. 6-10 against numpy +/ scipy, and the export format (the released adapter's keys, shapes and dtypes). + +## Trained checkpoint (SynthScope_train): does the recipe reproduce the paper? + +**Partially.** The recipe as written, keeping the last stage-1 epoch, falls 13 points short of the paper. Early stopping chosen by a rule fixed in advance on non-benchmark data recovers more than half of that gap. It does not close the gap on degraded and real-world sets. + +The scripts are in `repro/cure_stage1/` and the JSON outputs in `repro/cure_stage1/results/`. + +**The checkpoints compared:** +- **Original:** the recipe run as written, last epoch. Code 2966f64, DAS6 job 66658 on 3x A6000, global batch 192, sha256 38390ca9... +- **R1:** the recipe unchanged with every epoch saved. Global batch 192, run as 1 GPU x 64 x gradient accumulation 3 (IVI job 284138). The epoch was chosen by the pre-registered rule: epoch 0. + - Its epoch 4 reproduces the original run (LoRA update norm 3.17 vs 3.18, selection score 83.1 vs 82.9). So the 1-GPU accumulation is not a confound and the original result is not seed noise. +- **R2:** as R1 but at global batch 512 (2 GPUs x 64 x accumulation 4), the natural reading of "per-GPU batch 64" on 8 GPUs (IVI job 284137). Its final epoch is used, as decided before the run. +- **R2 e1:** R2's epoch 1. It is the epoch whose weight change matches the release (LoRA update norm 0.94x the released adapter's). It was chosen **after the fact**, so it is a diagnostic only. +- **R3:** R1 plus DDA-style training augmentation (`DatasetConfig.train_augment=dda`), with the same rule; it selects epoch 0 (DAS6 jobs 67199 / 67200). + - **r3e0 is the main SynthScope-trained checkpoint** (sha256 ac70224f...). + - It depends on an augmentation assumption the paper does not state. + - Among the pre-registered checkpoints it has both the best selection score (94.31 vs r1e0 92.84 vs R2 final 86.86) and the best benchmark mean. + - **Disclosure: choosing r3e0 over r1e0 was a run-level decision.** + - The pre-registered rule selects an epoch *within* a run. + - Running R3 at all, and making it the main checkpoint, was decided after the R1 benchmark results were known. + - The cross-run selection scores were computed on different GPUs: R1 on an RTX 6000 Ada, R2 on an RTX A5000, R3 on an RTX A6000. R1's reference rows reuse R2's A5000 features. The released reference scores 95.2 on the A5000 and 95.16 on the A6000. + - **Only the AIGIBench "reproduced" depends on the augmentation.** r1e0 alone, which uses only the paper's settings, already reproduces AIGCDetect, SynthWildX and WildRF. +- **r1e0 is the result that uses only the paper's stated settings** (sha256 60346a37...). + +All checkpoints were scored with the official rows' exact protocol: `bench_eval --ckpt`, `--bs 16`, the same data, AIGIBench `--select` of the paper's 20 subsets on full data, no `--limit`. Tags: `cure_trained_` (original), `cure_trained_r1e0_*`, `cure_trained_r2_*`, `cure_trained_r2e1_*`, `cure_trained_r3e0_*`. Every JSON was checked against its log's RESULT line. + +Each cell is acc / AUROC. R means reproduced (acc >= paper - 2.0, and AUROC >= paper - 2.5 where the paper reports one); x(d) gives the accuracy gap to the paper. Trained weights are never uploaded. + +| Benchmark | Paper | Official adapter | Original (last epoch) | R1 e0 (pre-registered) | R2 final | R2 e1 (post-hoc, diagnostic) | **R3 e0 (pre-registered, main)** | +|---|---|---|---|---|---|---|---| +| AIGIBench-20 | 92.8/97.5 | 92.85/97.48 | 85.05/91.84 x(-7.8) | 88.85/95.86 x(-4.0) | 87.10/93.73 x(-5.7) | 88.81/95.78 x(-4.0) | **91.12/97.10 R** | +| AIGCDetect | 89.3 | 89.30/98.02 | 81.55/92.22 x(-7.8) | 92.25/98.47 R | 82.29/94.40 x(-7.0) | 88.20/97.84 R | **92.01/98.38 R** | +| EvalGEN | 98.1 | 98.14/99.66 | 90.65/95.96 x(-7.4) | 91.57/98.63 x(-6.5) | 92.45/97.90 x(-5.6) | 93.98/99.17 x(-4.1) | 93.32/98.85 x(-4.8) | +| SynthWildX | 92.7/96.6 | 92.69/96.50 | 76.11/86.84 x(-16.6) | 90.99/96.85 R | 81.56/91.85 x(-11.1) | 88.65/95.90 x(-4.0) | **91.76/97.09 R** | +| WildRF | 95.8/99.1 | 95.89/99.14 | 85.80/94.59 x(-10.0) | 95.23/99.06 R | 90.24/96.19 x(-5.6) | 93.91/98.43 R | **95.58/99.25 R** | +| BFree-Online (807 images) | 90.9 | 91.64/98.08 | 66.64/85.77 x(-24.3) | 72.30/81.80 x(-18.6) | 69.52/81.51 x(-21.4) | 74.54/89.90 x(-16.4) | 71.19/79.51 x(-19.7) | +| RRDataset | 81.5 | 82.04/88.88 | 66.36/76.87 x(-15.1) | 72.62/85.25 x(-8.9) | 68.01/78.57 x(-13.5) | 72.65/84.82 x(-8.8) | 73.46/85.32 x(-8.0) | +| RealChain | 79.7 | 79.69/85.47 | 63.33/76.50 x(-16.4) | 70.34/84.87 x(-9.4) | 67.49/82.20 x(-12.2) | 72.28/85.02 x(-7.4) | 72.75/84.70 x(-7.0) | +| UFD-8 (reference) | - | 93.94/98.98 | 82.69/93.85 | 93.99/98.87 | 83.81/94.91 | 92.14/98.52 | 93.89/98.31 | +| ForenSynths-13 (reference) | - | 81.95/95.02 | 75.83/93.56 | 89.79/97.15 | 74.35/95.40 | 84.26/96.16 | 89.36/96.58 | +| GenImage-8 (reference) | - | 85.18/97.00 | 77.70/87.88 | 86.05/97.36 | 79.89/89.99 | 83.48/96.54 | 86.22/97.59 | +| **Mean acc / AUROC, 8 comparable** | 90.10 | 90.28/95.40 | 76.94/87.57 | 84.27/92.60 | 79.83/89.54 | 84.13/93.36 | **85.15/92.53** | +| **Reproduced** | | | 0/8 | 3/8 | 0/8 | 2/8 | **4/8** | + +### What remains, stated plainly (r3e0) +- **Mean accuracy:** 5 points below the paper (85.15 vs 90.10). +- **BFree-Online:** -19.7 accuracy, with AUROC 79.5 against the official adapter's 98.1. + - This is a **ranking failure**, not a threshold problem. + - No variant fixes it; the best is R2 e1 at AUROC 89.9. +- **RRDataset:** -8.0. AUROC is 85.3 vs 88.9, so the gap is partly ranking and partly calibration. +- **RealChain:** -7.0. AUROC is 84.7, about the official adapter's 85.5, so the gap is **threshold calibration** on degraded images. Fake recall is 51% at 0.5. +- **EvalGEN:** -4.8. AUROC is 98.85 vs 99.66, so the gap is **mostly the threshold** (fake recall 87.5%). +- **Real/fake balance:** on the wild sets r3e0 is no longer the conservative detector the original checkpoint was. Real / fake accuracy is 93.0 / 90.5 on SynthWildX and 95.9 / 95.3 on WildRF. +- **Single seed:** every run is one seed; the paper's seed spread is 0.3-0.7 on AIGIBench. + - Differences of about 1 point (r1e0 vs r3e0 on RRDataset and BFree-Online) are within plausible seed noise. + - The AIGIBench gain from augmentation (+2.3 accuracy) and the RealChain gain (+2.4) are larger than that. + +### The over-training finding and the pre-registered early-stopping rule +- **The original checkpoint over-adapts to SD v1.4 in stage 1.** Diagnostics: `repro/cure_stage1/feature_analysis.py`, IVI job 284084. + - Its LoRA update is 1.71x the released adapter's (Frobenius norm of 2·B·A over all 48 adapted projections). The released adapter starts from the same standard init. + - It fits the SD v1.4 mixing ratio about 3x better than the released encoder: excess BCE of a fresh linear head 0.0072 vs 0.0220. + - It encodes JPEG quality more strongly: a q95-vs-q50 probe gives 90.2 bacc vs the release's 83.4. + - A linear probe fitted on SD v1.4 features transfers worse than the **frozen** base: on Synthbuster fakes, 81.0 vs 92.5, against 95.0 for the released encoder. These are balanced accuracies 80.95 / 92.53 / 95.03 from `repro/cure_stage1/results/epoch_select_r1.json` (rows orig / base / released). +- **Ruled out by direct tests:** the stage-2 mixing position (released mu matches mixing after q70: 0.59% vs 3.59% before), the stage-2 solver, the head trainer and the protocol. +- **Selection rule.** It was committed before any epoch was scored (`repro/cure_stage1/epoch_select.py`, commit d73d102), and no CuRe paper benchmark is used. + - **Data:** 1287 Synthbuster fakes (143 per generator; Synthbuster is not a CuRe benchmark) against 2000 SD v1.4 test reals. + - **Score:** the mean of two balanced accuracies on that set: the stage-1 ratio head used directly at 0.5, and a logistic probe fitted on SD v1.4 train features. + - **Choice:** the highest-scoring epoch, with ties within 0.5 going to the earlier epoch. + - **Also logged for every epoch, not used by the rule:** the LoRA update norm against the release's, the SD v1.4 mixing fit, and WildRF as a diagnostic. + +Per-epoch selection score (update norm as a multiple of the released adapter's in brackets; full numbers in `repro/cure_stage1/results/epoch_select_{r1,r2,r3}.json`): + +| Run | epoch 0 | epoch 1 | epoch 2 | epoch 3 | epoch 4 | +|---|---|---|---|---|---| +| R1 (192) | **92.84** (0.66x) | 89.63 (1.23x) | 84.72 (1.53x) | 82.34 (1.67x) | 83.06 (1.71x) | +| R2 (512) | 86.73 (0.37x) | 93.34 (0.94x) | 90.74 (1.26x) | 86.40 (1.38x) | 86.86 (1.42x, used) | +| R3 (192 + augmentation) | **94.31** (0.67x) | 92.55 (1.26x) | 86.10 (1.57x) | 85.26 (1.70x) | 84.51 (1.75x) | + +References on the same score: released adapter 95.2, frozen PE-Core 89.5, original run 82.9. In-distribution accuracy is high at every epoch except R2's warmup epoch 0 (SD v1.4 test 98.9-99.9; R2 epoch 0 82.2), so a held-out split of the training distribution cannot detect the over-adaptation. + +**Interpretation** +- The epoch curve and the R1/R2 comparison show that the paper's numbers are consistent with stopping after about one epoch's worth of updates, which the "model-selection protocol" the paper mentions may have done. +- The 8-GPU reading alone (R2 final) does not get there. +- Matching the release's update size (R2 e1) is not sufficient either: R2 e1 ≈ r1e0. + +### Engineering notes +- **Batch-size-dependent fp16 kernels on RTX 6000 Ada.** + - On the RTX 6000 Ada (IVI cn032), PE-Core fp16 features depend on the batch size: 0.29 max |diff| between batches of 64 and 128 (|z| up to 82). Logits differ by 1.7-2.3e-2. + - At equal batch size the results are bit-identical. On Ampere GPUs (A6000, A5000) the same comparison gives 3.6e-6 to 9.5e-6. + - The stage-3 export check therefore compares at the batch size the features were encoded with (`--encode-batch`, tolerance unchanged), and logs the 64-image difference as information only. + - Benchmark scores can move at the ~1e-2-logit level with batch size on Ada GPUs (`bench_eval` uses `--bs 16`). All trained-checkpoint benchmark numbers above were computed on A6000s. +- **Multi-encoder stages 2/3.** `repro/cure_stage1/multi_stage23.py` runs stages 2/3 for several encoders in one pass over the images, then calls the unchanged `train_stages.py`. Checks: + - Stage-2 trajectories: bit-identical to the single-encoder path (all fields max |diff| 0). + - Stage-3 features: bit-identical at batch 128. + - Exported adapters for R2 e4 / R2 e1: sha256 equal to a full single-path `--recompute`. + +### Earlier diagnostics of the original checkpoint + +**Stage-2 parity check on the full data (review item M2).** Stage 2 run with the **released** encoder (`cure.pth` LoRA), 20,000 pairs per trajectory type on all 162k + 162k training images, once with the recipe's endpoint preprocessing and once with ONE control (the final JPEG q70 pass removed; same seed, same pairs). DAS6 job 66720 (`repro/logs/curepar_std_das6_66720.full.log`, `curepar_noq70_das6_66720.full.log`): + +| | recipe preprocessing | control (no q70) | random | +|---|---|---|---| +| overlap of the solved W with the released W | 0.892 | 0.864 | 0.125 | +| cosine of mu to the released mu | 0.999998 | 0.982 | | +| relative distance of mu | 0.19 % | 19.2 % | | +| off-diagonal ratio of the released `W^T C_F W` | 0.016 | 0.276 | | +| fitted (lambda_s, lambda_m, eps) / residual | 0.96, 1.02, 1.0e-3 / 0.036 | 1.03, 0.80, 1.06e-3 / 0.103 | | + +The subspace overlap barely separates the two pipelines (0.89 vs 0.86, both far above random), so an overlap alone does **not** identify the release's preprocessing. The mu distance (100x) and the off-diagonal ratio (17x) do, and the recipe's pipeline is the one that matches: this is the evidence that the released stage 2 used the endpoint preprocessing assumed here (the earlier subset claim was too strong). Mixing before the q70 step was not tested. With the fitted values the lambdas are 1, 1 and eps 1e-3 as assumed. Even with the released encoder the full-data W overlaps the released one at 0.89, not 1.0: the pair sampling and other unstated details of stage 2 are not pinned down. For the trained encoder stage 2 gave overlap 0.685 with the released W, mu cosine 0.696, and one dominant generalised eigenvalue (2.856, then 0.017) in `curetrain_das6_66658.out`; the released encoder's own spectrum is 2.157, then 0.039. + +**Where the shortfall comes from (diagnostics, same protocol, `bench_eval --ckpt`).** The three parts of the adapter (LoRA, subspace `W` / `mu`, head) are only meaningful together, so swapping parts between the released and the trained adapter is a sanity check, not a decomposition: + +| checkpoint | BFree-Online acc / AUROC | SynthWildX | WildRF | RRDataset | job | +|---|---|---|---|---|---| +| official adapter | 91.64 / 98.08 | 92.69 / 96.50 | 95.89 / 99.14 | 82.04 / 88.88 | (existing rows) | +| **trained** (our stage 1, 2, 3) | 66.64 / 85.77 | 76.11 / 86.84 | 85.80 / 94.59 | 66.36 / 76.87 | 66721 | +| A: trained LoRA + released mu / W / head | 48.61 / 38.67 | 35.00 / 16.34 | 35.05 / 11.72 | 33.17 / 25.55 | 66725 | +| B: released LoRA + trained mu / W / head | 43.68 / 6.53 | 38.44 / 5.17 | 40.50 / 3.35 | 43.15 / 12.87 | 66725 | +| **D: released LoRA + OUR stage 2 + OUR stage 3** | **91.08 / 98.25** | **92.65 / 96.32** | **95.45 / 98.99** | **81.04 / 86.84** | 66726 | + +- A and B collapse (AUROC far below 50, the score is anti-correlated): the released `W` / `mu` / head live in the released encoder's feature space and the trained ones in the trained encoder's, so mixed adapters are meaningless. They cannot localise the problem. +- **D is the informative one.** Run through SynthScope's stage 2 (the parity run, 20,000 pairs per type, `par_std/subspace.pt`) and stage 3 (head on all 324k clean images, 5 epochs), the *released* encoder reproduces the paper and the official adapter: BFree-Online 91.08 (paper 90.9), SynthWildX 92.65 (92.7), WildRF 95.45 (95.8), RRDataset 81.04 (81.5), all within the repo tolerance and within 1.0 pt of the official adapter. So **our stage-2 solver and stage-3 head trainer are sound, and the evaluation protocol is not the cause; the shortfall of the trained checkpoint comes from stage 1** (the LoRA we trained: ratio regression, 5 epochs, last epoch). Its stage-1 validation loss looks fine (0.5099 against a floor of 0.5), so the loss value does not reveal it. +- What stage 1 was missing was then investigated (sections above): mainly over-adaptation (the last epoch), with an early-stopping rule fixed in advance recovering more than half of the gap; augmentation adds a little; the remaining gap (BFree-Online ranking, RealChain / RRDataset / EvalGEN calibration) is not explained. + + ## Usage ```bash diff --git a/models/image/cure/cure.py b/models/image/cure/cure.py index 3b5c8003a224f945bea0e9b53e37154ee51daa17..167fa660b4d2a2b6efba1ba0388f1ffa3ee36d53 100644 --- a/models/image/cure/cure.py +++ b/models/image/cure/cure.py @@ -15,9 +15,20 @@ from ``ModelConfig.base_checkpoint`` / ``$SYNTHSCOPE_PE_CORE_CKPT``), exactly as Input contract: ``forward`` takes the tensor produced by ``CuReTransform`` (``[B, 3, 336, 336]``, mean=std=0.5 normalized, after the official PNG->JPEG96 / 390-crop / JPEG70 pipeline). -Training: the paper's two-stage mixing-ratio-regression recipe is NOT in the official release, so -``compute_loss`` is plain cross-entropy on the 2-way head (LoRA + subspace + head trainable). It -exists to satisfy SynthScope's trainer interface; it does not reproduce the paper's training. +Training: the official release has no training code. SynthScope implements the paper's recipe +(Sec. 3, 4.1-4.2, Appendix A; see README "Training recipe"): + +* Stage 1 (``ModelConfig.training_stage: ratio``, run through SynthScope's trainer): a linear ratio + head ``ratio_head`` (1024 -> 1, sigmoid) on the adapted features of real/generated pixel mixtures + x_a = (1 - a) x_r + a x_g, trained with BCE against the soft target a; only the LoRA tensors and the + ratio head are trainable, with their own weight decays (``optimizer_param_groups``). Optional + gradient checkpointing per transformer block (``grad_checkpointing``) for the per-GPU batch of 64. +* Stages 2 and 3 (``train_stages.py``): the source-response subspace (``mu``, ``W``) from the frozen + stage-1 encoder (``subspace.py``) and the 128 -> 2 head; ``adapter_state_dict`` exports the result + with exactly the released adapter's 100 keys. + +Without ``training_stage`` ``compute_loss`` is plain cross-entropy on the 2-way head (LoRA + head +trainable); it only satisfies the trainer interface and is not the paper's training. """ import os from pathlib import Path @@ -26,7 +37,9 @@ import _synthscope_env # noqa: F401 (maps legacy AGID_* variables to SYNTHSCOP import torch import torch.nn as nn +import torch.nn.functional as F from huggingface_hub import hf_hub_download +from torch.utils.checkpoint import checkpoint from omegaconf import DictConfig from .official_arch import PECore @@ -36,6 +49,8 @@ BASE_FILENAME = "PE-Core-L14-336.pt" FEATURE_DIM = 1024 SUBSPACE_DIM = 128 _VISUAL_PREFIX = "visual." +# The released adapter's tensors (cure_adapter.pt): 24 layers x (lora_A_q, lora_B_q, lora_A_v, lora_B_v), mu, W, head. +ADAPTER_BUFFERS = ("mu", "W", "head.weight", "head.bias") def resolve_base_checkpoint(path=None, repo_id: str = BASE_REPO_ID, filename: str = BASE_FILENAME) -> Path: @@ -67,6 +82,15 @@ class SynthScopeCuReModel(nn.Module): self.register_buffer("mu", torch.zeros(FEATURE_DIM)) self.register_buffer("W", torch.zeros(FEATURE_DIM, SUBSPACE_DIM)) self.head = nn.Linear(SUBSPACE_DIM, 2) + # Stage 1 of the paper's recipe: mixing-ratio regression with a linear ratio head (Appendix A). + self.training_stage = mc.get("training_stage", None) + if self.training_stage not in (None, "ratio"): + raise ValueError(f"CuRe training_stage must be null or 'ratio', got {self.training_stage!r}") + self.grad_checkpointing = bool(mc.get("grad_checkpointing", False)) + self.lora_weight_decay = float(mc.get("lora_weight_decay", 0.1)) + self.head_weight_decay = float(mc.get("head_weight_decay", 0.01)) + if self.training_stage == "ratio": + self.ratio_head = nn.Linear(FEATURE_DIM, 1) # PyTorch default init; discarded after stage 1 if bool(mc.get("load_base_backbone", True)): self._load_base(resolve_base_checkpoint(mc.get("base_checkpoint", None), @@ -76,9 +100,11 @@ class SynthScopeCuReModel(nn.Module): self._init_random_backbone() # architecture-only mode (tests): official params are torch.empty self._init_trainable() - # Everything frozen except the LoRA tensors and the head (the adapter's trainable set). + # Everything frozen except the LoRA tensors and the head (the adapter's trainable set); in stage 1 the ratio + # head replaces the 2-way head (which is trained later, on the frozen subspace, by train_stages.py). + head_prefix = "ratio_head." if self.training_stage == "ratio" else "head." for name, param in self.named_parameters(): - param.requires_grad = "lora_" in name or name.startswith("head.") + param.requires_grad = "lora_" in name or name.startswith(head_prefix) # The frozen PE-Core base is loaded above from its own release (``_load_base``), so the released adapter # (LoRA + subspace + head only) does not contain it: the engine accepts exactly these keys as missing. self.pretrained_prefixes = tuple(n for n, p in self.named_parameters() if not p.requires_grad) @@ -124,7 +150,63 @@ class SynthScopeCuReModel(nn.Module): features = self.backbone(images) return self.head((features - self.mu) @ self.W) + def features(self, images: torch.Tensor) -> torch.Tensor: + """Adapted PE Core features ``[B, 1024]`` (fp16 autocast on CUDA, as ``forward``). With ``grad_checkpointing`` in + training each transformer block is recomputed in the backward pass (same values, less activation memory).""" + with torch.amp.autocast("cuda", enabled=images.is_cuda): + if self.grad_checkpointing and self.training and torch.is_grad_enabled(): + return self._checkpointed_backbone(images) + return self.backbone(images) + + def _checkpointed_backbone(self, images: torch.Tensor) -> torch.Tensor: + """``PECore.forward`` (official_arch.py) step for step, with ``torch.utils.checkpoint`` around every block.""" + bb = self.backbone + if images.ndim != 4 or tuple(images.shape[1:]) != (3, 336, 336): + raise ValueError("Expected image tensors with shape [N, 3, 336, 336]") + batch = images.shape[0] + x = bb.conv1(images).permute(0, 2, 3, 1).reshape(batch, 576, 1024) + cls = bb.class_embedding.view(1, 1, -1).expand(batch, -1, -1) + x = torch.cat([cls, x], dim=1) + x = x + bb.positional_embedding[None] + x = bb.ln_pre(x) + for block in bb.transformer.resblocks: + x = checkpoint(block, x, use_reentrant=False) + return bb.ln_post(x)[:, 1:].mean(dim=1).float() + + def optimizer_param_groups(self): + """Stage 1: AdamW groups with the paper's weight decays (0.1 on the LoRA tensors, 0.01 on the ratio head, all of + its parameters); used by the trainer instead of its single group. ``None`` otherwise (the trainer's default).""" + if self.training_stage != "ratio": + return None + named = [(n, p) for n, p in self.named_parameters() if p.requires_grad] + return [{"params": [p for n, p in named if "lora_" in n], "weight_decay": self.lora_weight_decay}, + {"params": [p for n, p in named if "lora_" not in n], "weight_decay": self.head_weight_decay}] + + @staticmethod + def _require_grad_scaler(images: torch.Tensor) -> None: + """``features`` always runs fp16 autocast on CUDA, so CUDA training needs a gradient scaler; ``accelerate launch + --mixed_precision fp16`` (exported as ACCELERATE_MIXED_PRECISION, which the trainer's Accelerator reads) provides it. + Without it the fp16 gradients would underflow silently, so fail loudly instead.""" + if images.is_cuda and torch.is_grad_enabled() and os.environ.get("ACCELERATE_MIXED_PRECISION", "no") != "fp16": + raise RuntimeError("CuRe stage 1 runs the backbone in fp16 autocast and needs a gradient scaler: launch with " + "`accelerate launch --mixed_precision fp16` (experiments/image/cure.sh does)") + def compute_loss(self, batch): - images, labels, _folder_ids = batch + images, targets, _folder_ids = batch + if self.training_stage == "ratio": + # Eq. 3-4: sigmoid ratio head, BCE with the mixing ratio as the soft target (targets = alpha in [0, 1]). + self._require_grad_scaler(images) + logits = self.ratio_head(self.features(images)).squeeze(-1).float() + loss = F.binary_cross_entropy_with_logits(logits, targets.float()) + return {"loss": loss, "outputs": torch.sigmoid(logits)} outputs = self.forward(images) - return {"loss": self.criterion(outputs, labels), "outputs": outputs} + return {"loss": self.criterion(outputs, targets), "outputs": outputs} + + def adapter_state_dict(self) -> dict: + """The trained parameters in the released adapter's format: exactly its 100 keys (96 LoRA tensors, ``mu``, + ``W`` [1024, 128], ``head.weight``, ``head.bias``), fp32, so the file loads like ``cure_adapter.pt``.""" + state = self.state_dict() + out = {k: v.detach().float().cpu().contiguous() for k, v in state.items() + if "lora_" in k or k in ADAPTER_BUFFERS} + assert len(out) == 100, f"expected the adapter's 100 tensors, got {len(out)}" + return out diff --git a/models/image/cure/preprocess.py b/models/image/cure/preprocess.py index 7504b1f6e9551744bc79f54dc10544816d3de0d3..27746292edca895f31a64c9fe9554fed771ac6d7 100644 --- a/models/image/cure/preprocess.py +++ b/models/image/cure/preprocess.py @@ -37,7 +37,13 @@ def _cubic_resize(arr: np.ndarray, height: int, width: int) -> np.ndarray: class CuReTransform: - """PIL image -> normalized float32 tensor ``[3, 336, 336]`` (picklable, stateless).""" + """PIL image -> normalized float32 tensor ``[3, 336, 336]`` (picklable, stateless). + + ``eval_jpeg_quality`` is the final JPEG pass (official: 70); ``None`` skips it. Only the stage-2 parity control of the + training recipe (``train_stages.py --control no_q70``) changes it; every registered pipeline uses the default.""" + + def __init__(self, eval_jpeg_quality: int | None = EVAL_JPEG_QUALITY): + self.eval_jpeg_quality = eval_jpeg_quality def __call__(self, img: Image.Image) -> torch.Tensor: source_format = img.info.get(SRC_FORMAT_KEY) or img.format @@ -57,7 +63,8 @@ class CuReTransform: left = (arr.shape[1] - RESIZE_SIZE) // 2 arr = np.ascontiguousarray(arr[top:top + RESIZE_SIZE, left:left + RESIZE_SIZE]) arr = _cubic_resize(arr, INPUT_SIZE, INPUT_SIZE) - _, encoded = cv2.imencode(".jpg", arr, (int(cv2.IMWRITE_JPEG_QUALITY), EVAL_JPEG_QUALITY)) - arr = cv2.imdecode(encoded, cv2.IMREAD_UNCHANGED) + if self.eval_jpeg_quality is not None: + _, encoded = cv2.imencode(".jpg", arr, (int(cv2.IMWRITE_JPEG_QUALITY), self.eval_jpeg_quality)) + arr = cv2.imdecode(encoded, cv2.IMREAD_UNCHANGED) arr = (arr.astype(np.float32) - 127.5) / 127.5 return torch.from_numpy(arr).permute(2, 0, 1).contiguous() diff --git a/models/image/cure/subspace.py b/models/image/cure/subspace.py new file mode 100644 index 0000000000000000000000000000000000000000..51fe13130ae1a0f2bd06ce34757b5bc8446de0eb --- /dev/null +++ b/models/image/cure/subspace.py @@ -0,0 +1,100 @@ +"""CuRe stage 2: the interference-suppressed source-response subspace (arXiv 2609.14316, Sec. 3.2, Eq. 5-11). + +The official release has no training code; this follows the paper's equations. For trajectories T in {RF, RR, FF} +(real->generated, real->real, generated->generated) with features z_{i,a} of the mixtures on the grid +A = {0, .2, .4, .6, .8, 1}: + + b_i^T = sum_a (a - a_bar)(z_{i,a} - z_bar_i) / sum_a (a - a_bar)^2 (Eq. 6, the per-trajectory slope) + C_F = E_i[b_i^RF b_i^RF^T] (Eq. 7) + C_M = E_i[b_i^RR b_i^RR^T] + E_i[b_i^FF b_i^FF^T] (Eq. 8) + C_S = Cov_i(z_bar_i^RF) (Eq. 9) + +each divided by its trace, then the generalised eigenproblem + + C_F w = g (lambda_s C_S + lambda_m C_M + eps I) w (Eq. 10) + +whose k = 128 leading eigenvectors are W [1024, 128] (Eq. 11); mu is the mean RF trajectory feature (Sec. 3.3). + +Unspecified in the paper (documented assumptions, see the README "Training recipe"): lambda_s, lambda_m, eps (defaults +below: 1, 1, 1e-3; with the released encoder our statistics make the released W B-orthonormal for about lambda_s 0.9, +lambda_m 1.0, eps 1.05e-3, job 283104); the scale of the eigenvectors (here B-orthonormal, W^T B W = I, the convention of LAPACK's / scipy's generalised +symmetric solver; the released W is not unit-norm, its columns have norms 6.8-8.8); C_S uses the 1/N covariance (the trace +normalisation removes the factor). Everything is computed in float64. +""" +from __future__ import annotations + +import torch + +GRID = (0.0, 0.2, 0.4, 0.6, 0.8, 1.0) +DEFAULT_LAMBDA_S = 1.0 +DEFAULT_LAMBDA_M = 1.0 +DEFAULT_EPS = 1e-3 + + +def slope_weights(grid=GRID) -> torch.Tensor: + """``c_a = (a - a_bar) / sum (a - a_bar)^2`` so that Eq. 6 is ``b_i = sum_a c_a z_{i,a}`` (the ``z_bar`` term vanishes + because ``sum_a (a - a_bar) = 0``).""" + a = torch.tensor(grid, dtype=torch.float64) + centered = a - a.mean() + return centered / (centered ** 2).sum() + + +def trajectory_summary(z: torch.Tensor, grid=GRID) -> tuple[torch.Tensor, torch.Tensor]: + """``z`` [N, len(grid), D] trajectory features -> (slopes b [N, D] (Eq. 6), means z_bar [N, D]), float64.""" + z = z.double() + c = slope_weights(grid).to(z.device) + return torch.einsum("a,nad->nd", c, z), z.mean(dim=1) + + +def second_moment(b: torch.Tensor) -> torch.Tensor: + """``E_i[b_i b_i^T]`` (uncentred), float64.""" + b = b.double() + return b.T @ b / b.shape[0] + + +def covariance(x: torch.Tensor) -> torch.Tensor: + """``Cov_i(x_i)`` with the 1/N normalisation, float64.""" + x = x.double() + x = x - x.mean(dim=0, keepdim=True) + return x.T @ x / x.shape[0] + + +def trace_normalised(c: torch.Tensor) -> torch.Tensor: + return c / torch.trace(c) + + +def statistics(b_rf, b_rr, b_ff, zbar_rf) -> dict: + """Eq. 7-9, each normalised by its trace, plus mu (the mean RF trajectory feature = the mean of the z_bar^RF).""" + return { + "C_F": trace_normalised(second_moment(b_rf)), + "C_M": trace_normalised(second_moment(b_rr) + second_moment(b_ff)), + "C_S": trace_normalised(covariance(zbar_rf)), + "mu": zbar_rf.double().mean(dim=0), + } + + +def solve(c_f, c_m, c_s, k=128, lambda_s=DEFAULT_LAMBDA_S, lambda_m=DEFAULT_LAMBDA_M, eps=DEFAULT_EPS): + """Eq. 10-11: the ``k`` largest generalised eigenpairs of ``C_F w = g B w``, ``B = lambda_s C_S + lambda_m C_M + eps I``. + Cholesky-whitened symmetric problem: ``B = L L^T``, ``M = L^-1 C_F L^-T = V G V^T``, ``w = L^-T v`` (so + ``W^T B W = I``). Returns ``(W [D, k], gammas [k])``, eigenvalues in descending order, float64.""" + c_f, c_m, c_s = c_f.double(), c_m.double(), c_s.double() + d = c_f.shape[0] + b = lambda_s * c_s + lambda_m * c_m + eps * torch.eye(d, dtype=torch.float64, device=c_f.device) + b = (b + b.T) / 2 + chol = torch.linalg.cholesky(b) + eye = torch.eye(d, dtype=torch.float64, device=c_f.device) + l_inv = torch.linalg.solve_triangular(chol, eye, upper=False) + m = l_inv @ ((c_f + c_f.T) / 2) @ l_inv.T + gammas, v = torch.linalg.eigh((m + m.T) / 2) # ascending + order = torch.argsort(gammas, descending=True)[:k] + w = l_inv.T @ v[:, order] + return w, gammas[order] + + +def subspace_overlap(w_a: torch.Tensor, w_b: torch.Tensor) -> float: + """Mean squared cosine of the principal angles between span(w_a) and span(w_b) (1 = same subspace; two random + k-dim subspaces of R^D give about k / D).""" + qa, _ = torch.linalg.qr(w_a.double()) + qb, _ = torch.linalg.qr(w_b.double()) + s = torch.linalg.svdvals(qa.T @ qb) + return float((s ** 2).mean()) diff --git a/models/image/cure/train_augment.py b/models/image/cure/train_augment.py new file mode 100644 index 0000000000000000000000000000000000000000..63ebdd277f3689c6dadbd1051c593320138331c8 --- /dev/null +++ b/models/image/cure/train_augment.py @@ -0,0 +1,96 @@ +"""CuRe stage-1 investigation, R3: DDA-style training augmentation for the stage-1 endpoints (an ASSUMPTION under test, not +part of the paper's stated recipe: CuRe, arXiv 2609.14316, Sec. 4.1, follows "the setting of DDA" for format alignment and +states no augmentation). + +Per endpoint (a real or a generated image), in this order: + 1. format alignment, as the eval pipeline: a PNG source is re-encoded as JPEG q96 (CuRe Appendix A) + 2. DDA's training augmentations, exactly DDA's ``create_train_transforms`` list (vendored in + ``models/image/dda/official_train_data.py``) without its last three steps: RandomJPEG q55-100 p 0.15, horizontal and + vertical flips p 0.5, Gaussian noise (std 55) p 0.1, pepper noise p 0.1, one of {Gaussian blur k3, k5, median 3, + motion 5} p 0.2, sharpen p 0.1, colour jitter (0.4, 0.4, 0.4, 0.175) p 0.2, grayscale p 0.1 + 3. CuRe's fixed geometry with DDA's random crop in place of the centre crop: SmallestMaxSize(390, cubic) -> + RandomCrop(390) (replaces CenterCrop(390); DDA's ``PadRandomCrop`` never pads here because the short side is 390) + -> Resize(336, cubic) -> JPEG q70 -> mean = std = 0.5 +Steps 2-3 draw from one seed per (pair, epoch) that is SHARED by the two endpoints of a pair, as DDA's +``ComposedTransforms`` replays one RNG state for the real and the fake of a pair: both endpoints get the same decisions +(whether each step applies, flips, blur kind, jitter factors, grayscale, JPEG quality, relative crop position), so the +augmentation cannot vary with the mixing ratio. Unlike DDA's pairs (a real and its same-size reconstruction) CuRe's +endpoints differ in size, so the global RNGs are re-seeded before every step (size-dependent draws such as the noise field +would otherwise desynchronise the later decisions); only the noise / pepper realisations differ between the endpoints. Not used: DDA's extra re-scaled +copies (``build_item``'s 0.2-1.0 / 1.0-3.5 resized samples) and its pixel / frequency blending of reconstructions, which are +separate DDA-specific samples rather than per-image augmentations. Validation, stage 2 and stage 3 stay un-augmented. +With ``augment=False`` the output equals the eval pipeline ``CuReTransform`` bit for bit (tests/test_cure_recipe.py). +""" +import io +import random + +import cv2 +import numpy as np +import torch +from PIL import Image + +from models.image.dda.official_train_data import create_train_transforms +from .preprocess import EVAL_JPEG_QUALITY, INPUT_SIZE, PNG_REENCODE_QUALITY, RESIZE_SIZE, SRC_FORMAT_KEY + + +def _dda_augmentations(): + """DDA's train transform list without PadRandomCrop / ToTensor / Normalize (parameters unchanged).""" + steps = create_train_transforms(size=RESIZE_SIZE).transforms + names = [type(t).__name__ for t in steps[-3:]] + assert names == ["PadRandomCrop", "ToTensor", "Normalize"], names + return steps[:-3] + + +class CuReDDAEndpoint: + """PIL image (+ source-format hint) and a seed -> normalized float32 tensor [3, 336, 336].""" + + def __init__(self, augment: bool = True): + self.augment = augment + self.steps = _dda_augmentations() if augment else [] + + def __call__(self, img: Image.Image, seed: int | None = None) -> torch.Tensor: + source_format = img.info.get(SRC_FORMAT_KEY) or img.format + image = img.convert("RGB") + if source_format == "PNG": + buf = io.BytesIO() + image.save(buf, format="JPEG", quality=PNG_REENCODE_QUALITY) + buf.seek(0) + with Image.open(buf) as dec: + image = dec.convert("RGB") + image.load() + crop_rng = None + if self.augment: + # replay one RNG state per pair (DDA's ComposedTransforms); restore the caller's global (CPU) states afterwards; + # the CUDA generators are never touched + states = (random.getstate(), np.random.get_state(), torch.get_rng_state()) + try: + # re-seed before EVERY step: the two endpoints differ in size, so size-dependent draws (noise, pepper + # coordinates) would otherwise desynchronise all later decisions; per-step seeding keeps every decision + # (apply?, which blur, jitter factors, flips, JPEG quality, ...) identical for the pair + for k, step in enumerate(self.steps): + s = (seed * 1_000_003 + k) % 2 ** 31 + # torch: the CPU default generator only (torch.manual_seed would also re-seed every CUDA device) + random.seed(s); np.random.seed(s); torch.default_generator.manual_seed(s) + image = step(image) + image = image.convert("RGB") + finally: + random.setstate(states[0]); np.random.set_state(states[1]); torch.set_rng_state(states[2]) + crop_rng = random.Random(seed + 1) + arr = np.asarray(image) + h, w = arr.shape[:2] + s = RESIZE_SIZE / min(h, w) + nh, nw = max(1, round(h * s)), max(1, round(w * s)) + if (nh, nw) != (h, w): + arr = cv2.resize(arr, (nw, nh), interpolation=cv2.INTER_CUBIC) + if crop_rng is None: + top, left = (arr.shape[0] - RESIZE_SIZE) // 2, (arr.shape[1] - RESIZE_SIZE) // 2 + else: + # the same RELATIVE crop position for both endpoints (their sizes differ) + fy, fx = crop_rng.random(), crop_rng.random() + top, left = round(fy * (arr.shape[0] - RESIZE_SIZE)), round(fx * (arr.shape[1] - RESIZE_SIZE)) + arr = np.ascontiguousarray(arr[top:top + RESIZE_SIZE, left:left + RESIZE_SIZE]) + if arr.shape[:2] != (INPUT_SIZE, INPUT_SIZE): + arr = cv2.resize(arr, (INPUT_SIZE, INPUT_SIZE), interpolation=cv2.INTER_CUBIC) + _, enc = cv2.imencode(".jpg", arr, (int(cv2.IMWRITE_JPEG_QUALITY), EVAL_JPEG_QUALITY)) + arr = cv2.imdecode(enc, cv2.IMREAD_UNCHANGED) + return torch.from_numpy((arr.astype(np.float32) - 127.5) / 127.5).permute(2, 0, 1).contiguous() diff --git a/models/image/cure/train_stages.py b/models/image/cure/train_stages.py new file mode 100644 index 0000000000000000000000000000000000000000..d9e72ba65c867940d373a386479b751f4508ed37 --- /dev/null +++ b/models/image/cure/train_stages.py @@ -0,0 +1,369 @@ +"""CuRe stages 2 and 3 (arXiv 2609.14316, Sec. 3.2-3.3, Appendix A), after stage 1 (experiments/image/cure.sh). + + python -m models.image.cure.train_stages stage2 --lora --data --out + python -m models.image.cure.train_stages stage3 --lora --data --out + +stage2 freezes the stage-1 encoder, draws ``--pairs`` (20,000) endpoint pairs per trajectory type (RF real->generated, + RR real->real, FF generated->generated; independent random endpoints, a same-class pair never uses one image + twice), encodes the six mixtures of each on the grid {0, .2, .4, .6, .8, 1}, keeps the per-trajectory slope and + mean (Eq. 6) in ``/trajectories.pt`` and solves Eq. 7-11 (``subspace.py``) into ``/subspace.pt`` + (W [1024, 128], mu, the generalised eigenvalues). A rerun with other ``--lambda-s/--lambda-m/--eps`` reuses the + cached trajectories. ``--reference-adapter`` (the released cure_adapter.pt) prints the overlap of the solved + subspace with the released W, the distance of mu to the released mu, and the (lambda_s, lambda_m, eps) for which + the released W is B-orthonormal under our C_S / C_M (a least-squares fit; a check of the unspecified choices). +stage3 encodes the training images once (``/head_features.pt``; all 162k + 162k by default, clean endpoints with + the same preprocessing), projects them, ``u = W^T (z - mu)``, and trains only Linear(128, 2) with dropout 0.05 on + u: cross-entropy, AdamW lr 2e-4, weight decay 0.1, batch 256, 5 epochs (constant lr: the paper names no + schedule). The result is written as ``/cure_trained.pth`` with exactly the released adapter's 100 keys + (96 LoRA tensors, mu, W, head), loadable as ``cure.pth`` (``bench_eval --model cure --ckpt``); the export is + checked by reloading it into a fresh model and comparing its logits with the trained head's on cached features. + +Both stages run on one GPU (fp16 autocast inside the model, as the released inference). ``--lora`` takes any state dict +holding the 96 LoRA tensors (a stage-1 trainer checkpoint, or the released adapter for the parity check). +""" +from __future__ import annotations + +import argparse +import json +import sys +import time +from pathlib import Path + +import torch +import torch.nn as nn +import torch.nn.functional as F +from omegaconf import OmegaConf +from torch.utils.data import DataLoader, Dataset + +from dataset import CuReEndpoints, cure_mix +from transformations import AIGITransformations +from .preprocess import CuReTransform +from .cure import FEATURE_DIM, SUBSPACE_DIM, SynthScopeCuReModel +from . import subspace as S + +ROOT = Path(__file__).resolve().parents[3] +MODEL_YAML = ROOT / "conf" / "model" / "image" / "cure.yaml" +TYPES = ("RF", "RR", "FF") + + +def build_model(lora_path: str | None, device: str) -> SynthScopeCuReModel: + """The frozen CuRe encoder (PE Core base + the LoRA tensors of ``lora_path``), eval mode on ``device``.""" + cfg = OmegaConf.create({"ModelConfig": OmegaConf.load(MODEL_YAML), "TrainerConfig": {}}) + model = SynthScopeCuReModel(cfg) + if lora_path: + state = torch.load(lora_path, map_location="cpu", weights_only=True, mmap=True) + state = state.get("model", state) if isinstance(state, dict) else state + lora = {k: v for k, v in state.items() if "lora_" in k} + if len(lora) != 96: + raise RuntimeError(f"{lora_path}: expected 96 LoRA tensors, found {len(lora)}") + missing, unexpected = model.load_state_dict(lora, strict=False) + if unexpected or any("lora_" in k for k in missing): + raise RuntimeError(f"LoRA load mismatch: unexpected={unexpected[:4]}") + model.requires_grad_(False) + return model.to(device).eval() + + +def endpoint_transform(control: str = "none"): + """The stage-1 endpoint preprocessing (the model config's eval list), see ``dataset.CuReEndpoints``. + ``control="no_q70"`` drops the final JPEG q70 pass: a deliberately different pipeline, used only to show whether the + parity check against the released W / mu discriminates preprocessing choices (``--control``).""" + if control == "no_q70": + return CuReTransform(eval_jpeg_quality=None) + if control != "none": + raise ValueError(f"unknown control {control!r}") + return AIGITransformations(list(OmegaConf.load(MODEL_YAML).eval_transform_list)) + + +def _draw_indices(n: int, n_pairs: int, gen: torch.Generator) -> torch.Tensor: + """``n_pairs`` indices into ``n`` images: without replacement while ``n`` is large enough, else with replacement.""" + return torch.randperm(n, generator=gen)[:n_pairs] if n_pairs <= n else torch.randint(n, (n_pairs,), generator=gen) + + +def draw_pairs(n_pairs: int, n_a: int, n_b: int, same_class: bool, gen: torch.Generator) -> torch.Tensor: + """``[n_pairs, 2]`` endpoint indices: independent uniform draws (without replacement while the class is large + enough); for a same-class pair the second index is uniform over the other images of the class.""" + first = _draw_indices(n_a, n_pairs, gen) + if same_class: + second = (first + 1 + torch.randint(n_a - 1, (n_pairs,), generator=gen)) % n_a + else: + second = _draw_indices(n_b, n_pairs, gen) + return torch.stack([first, second], dim=1) + + +class TrajectoryPairs(Dataset): + """Endpoint pairs ``(x_0, x_1, type index, pair index)``; the mixtures are formed on the GPU.""" + + def __init__(self, ep: CuReEndpoints, pairs: dict[str, torch.Tensor]): + self.ep = ep + self.items = [(t, i, int(a), int(b)) for t in TYPES for i, (a, b) in enumerate(pairs[t].tolist())] + + def __len__(self): + return len(self.items) + + def __getitem__(self, idx): + t, i, a, b = self.items[idx] + lists = {"RF": (self.ep.reals, self.ep.fakes), "RR": (self.ep.reals, self.ep.reals), "FF": (self.ep.fakes, self.ep.fakes)}[t] + g = torch.Generator().manual_seed(idx) + x0 = self.ep.load_any(lists[0], a, lambda: int(torch.randint(len(lists[0]), (), generator=g))) + x1 = self.ep.load_any(lists[1], b, lambda: int(torch.randint(len(lists[1]), (), generator=g))) + return x0, x1, TYPES.index(t), i + + +class LabelledImages(Dataset): + """All (or the first ``max_images``) training images with labels 0 = real, 1 = generated.""" + + def __init__(self, ep: CuReEndpoints): + self.ep = ep + self.items = [(p, 0) for p in ep.reals] + [(p, 1) for p in ep.fakes] + + def __len__(self): + return len(self.items) + + def __getitem__(self, idx): + paths = self.ep.reals if self.items[idx][1] == 0 else self.ep.fakes + offset = 0 if self.items[idx][1] == 0 else len(self.ep.reals) + g = torch.Generator().manual_seed(idx) + return self.ep.load_any(paths, idx - offset, lambda: int(torch.randint(len(paths), (), generator=g))), self.items[idx][1] + + +def encode_trajectories(model, loader, n_pairs: int, device: str) -> dict: + """Slopes and means of every trajectory: ``{"b_RF": [N, D], "zbar_RF": [N, D], ...}`` (float32).""" + grid = torch.tensor(S.GRID, device=device).view(1, -1, 1, 1, 1) + out = {f"{k}_{t}": torch.zeros(n_pairs, FEATURE_DIM) for t in TYPES for k in ("b", "zbar")} + done, start = 0, time.time() + with torch.no_grad(): + for step, (x0, x1, types, idx) in enumerate(loader): + x0, x1 = x0.to(device, non_blocking=True), x1.to(device, non_blocking=True) + mixed = cure_mix(x0.unsqueeze(1), x1.unsqueeze(1), grid) # [P, 6, 3, 336, 336] + z = model.features(mixed.flatten(0, 1)).view(x0.shape[0], len(S.GRID), FEATURE_DIM) + b, zbar = S.trajectory_summary(z) + for j in range(x0.shape[0]): + t = TYPES[int(types[j])] + out[f"b_{t}"][int(idx[j])] = b[j].float().cpu() + out[f"zbar_{t}"][int(idx[j])] = zbar[j].float().cpu() + done += x0.shape[0] + if (step + 1) % 50 == 0: + rate = done / (time.time() - start) + print(f" trajectories {done}/{3 * n_pairs} ({rate:.1f} pairs/s, {6 * rate:.0f} images/s)", flush=True) + return out + + +def fit_normalisation(w_ref: torch.Tensor, c_s: torch.Tensor, c_m: torch.Tensor) -> dict: + """Least squares (lambda_s, lambda_m, eps) with ``W_ref^T (lambda_s C_S + lambda_m C_M + eps I) W_ref = I`` over all + entries: if the released W is B-orthonormal (our solver's convention) under statistics like ours, this recovers its + B. ``rel_residual`` = ||fit - I||_F / ||I||_F.""" + w = w_ref.double() + blocks = [w.T @ c_s.double() @ w, w.T @ c_m.double() @ w, w.T @ w] + a = torch.stack([blk.flatten() for blk in blocks], dim=1) + target = torch.eye(w.shape[1], dtype=torch.float64).flatten() + coef = torch.linalg.lstsq(a, target.unsqueeze(1)).solution.squeeze(1) + resid = (a @ coef - target).norm() / target.norm() + return {"lambda_s": float(coef[0]), "lambda_m": float(coef[1]), "eps": float(coef[2]), "rel_residual": float(resid)} + + +def reference_report(stats: dict, w: torch.Tensor, adapter_path: str) -> dict: + ref = torch.load(adapter_path, map_location="cpu", weights_only=True) + w_ref, mu_ref = ref["W"].double(), ref["mu"].double() + mu = stats["mu"] + g = w_ref.T @ stats["C_F"] @ w_ref + report = { + "overlap_with_released_W": S.subspace_overlap(w, w_ref), + "overlap_random_baseline": SUBSPACE_DIM / FEATURE_DIM, + "mu_cosine": float(F.cosine_similarity(mu, mu_ref, dim=0)), + "mu_rel_dist": float((mu - mu_ref).norm() / mu_ref.norm()), + "released_W_col_norms": [float(x) for x in w_ref.norm(dim=0)[:4]], + "solved_W_col_norms": [float(x) for x in w.norm(dim=0)[:4]], + # released W against our C_F: a generalised eigenbasis makes W^T C_F W diagonal + "released_WtCfW_offdiag_ratio": float((g - torch.diag(torch.diag(g))).norm() / torch.diag(g).norm()), + "normalisation_fit": fit_normalisation(w_ref, stats["C_S"], stats["C_M"]), + } + return report + + +def stage2(args) -> None: + out = Path(args.out); out.mkdir(parents=True, exist_ok=True) + traj_path = out / "trajectories.pt" + if traj_path.exists() and not args.recompute: + print(f"[stage2] reusing {traj_path}", flush=True) + traj = torch.load(traj_path, map_location="cpu", weights_only=True) + else: + ep = CuReEndpoints(args.data, "train", endpoint_transform(args.control), args.max_images) + gen = torch.Generator().manual_seed(args.seed) + n_r, n_f = len(ep.reals), len(ep.fakes) + pairs = {"RF": draw_pairs(args.pairs, n_r, n_f, False, gen), "RR": draw_pairs(args.pairs, n_r, n_r, True, gen), + "FF": draw_pairs(args.pairs, n_f, n_f, True, gen)} + print(f"[stage2] {n_r} real / {n_f} generated images, {args.pairs} pairs per type x 6 ratios " + f"= {18 * args.pairs} forwards", flush=True) + model = build_model(args.lora, args.device) + loader = DataLoader(TrajectoryPairs(ep, pairs), batch_size=args.batch_pairs, shuffle=False, + num_workers=args.workers, pin_memory=True) + traj = encode_trajectories(model, loader, args.pairs, args.device) + traj["pairs"] = pairs + traj["meta"] = json.dumps({"lora": args.lora, "data": args.data, "pairs": args.pairs, "seed": args.seed, + "max_images": args.max_images, "control": args.control}) + torch.save(traj, traj_path) + del model + stats = S.statistics(traj["b_RF"], traj["b_RR"], traj["b_FF"], traj["zbar_RF"]) + w, gammas = S.solve(stats["C_F"], stats["C_M"], stats["C_S"], k=args.k, + lambda_s=args.lambda_s, lambda_m=args.lambda_m, eps=args.eps) + result = {"W": w.float(), "mu": stats["mu"].float(), "gammas": gammas, + "config": {"k": args.k, "lambda_s": args.lambda_s, "lambda_m": args.lambda_m, "eps": args.eps}} + print(f"[stage2] solved: k={args.k}, lambda_s={args.lambda_s}, lambda_m={args.lambda_m}, eps={args.eps}; " + f"top eigenvalues {[round(float(x), 3) for x in gammas[:5]]}, k-th {float(gammas[-1]):.4f}", flush=True) + if args.reference_adapter: + report = reference_report(stats, w, args.reference_adapter) + result["reference_report"] = report + print("[stage2] vs released adapter: " + json.dumps(report), flush=True) + torch.save(result, out / args.subspace_name) + print(f"[stage2] wrote {out / args.subspace_name}", flush=True) + + +def encode_images(model, loader, device: str) -> tuple[torch.Tensor, torch.Tensor]: + feats, labels, start = [], [], time.time() + with torch.no_grad(): + for i, (x, y) in enumerate(loader): + feats.append(model.features(x.to(device, non_blocking=True)).float().cpu()) + labels.append(y) + if (i + 1) % 100 == 0: + n = sum(len(f) for f in feats) + print(f" head features {n}/{len(loader.dataset)} ({n / (time.time() - start):.0f} images/s)", flush=True) + return torch.cat(feats), torch.cat(labels) + + +def train_head(u: torch.Tensor, y: torch.Tensor, args) -> nn.Linear: + """Linear(128, 2) on ``u`` with dropout on its input: CE, AdamW, constant lr, shuffled mini-batches.""" + torch.manual_seed(args.seed) + head = nn.Linear(SUBSPACE_DIM, 2).to(u.device) + drop = nn.Dropout(args.dropout) + opt = torch.optim.AdamW(head.parameters(), lr=args.lr, weight_decay=args.weight_decay) + gen = torch.Generator().manual_seed(args.seed) + for epoch in range(args.epochs): + head.train(); drop.train() + order = torch.randperm(len(y), generator=gen).to(u.device) + total, correct = 0.0, 0 + for start in range(0, len(y), args.batch): + idx = order[start:start + args.batch] + logits = head(drop(u[idx])) + loss = F.cross_entropy(logits, y[idx]) + opt.zero_grad(); loss.backward(); opt.step() + total += loss.item() * len(idx) + correct += int((logits.argmax(1) == y[idx]).sum()) + head.eval() + with torch.no_grad(): + pred = head(u).argmax(1) + real_acc = float((pred[y == 0] == 0).float().mean()) + fake_acc = float((pred[y == 1] == 1).float().mean()) + print(f"[stage3] epoch {epoch}: train loss {total / len(y):.4f} (dropout on), train acc {correct / len(y):.4f}; " + f"eval-mode acc real {real_acc:.4f} / fake {fake_acc:.4f}, lr {opt.param_groups[0]['lr']:.1e}", flush=True) + return head.eval() + + +def stage3(args) -> None: + out = Path(args.out); out.mkdir(parents=True, exist_ok=True) + sub = torch.load(args.subspace or out / "subspace.pt", map_location="cpu", weights_only=True) + w, mu = sub["W"].float(), sub["mu"].float() + feat_path = out / "head_features.pt" + ep = CuReEndpoints(args.data, "train", endpoint_transform(), args.max_images) + model = build_model(args.lora, args.device) + if feat_path.exists() and not args.recompute: + print(f"[stage3] reusing {feat_path}", flush=True) + cache = torch.load(feat_path, map_location="cpu", weights_only=True) + z, y = cache["z"], cache["y"] + encode_batch = int(cache["encode_batch"]) if "encode_batch" in cache else None + else: + print(f"[stage3] encoding {len(ep.reals)} real + {len(ep.fakes)} generated images", flush=True) + loader = DataLoader(LabelledImages(ep), batch_size=args.encode_batch, shuffle=False, num_workers=args.workers, + pin_memory=True) + z, y = encode_images(model, loader, args.device) + encode_batch = args.encode_batch + torch.save({"z": z, "y": y, "encode_batch": encode_batch}, feat_path) # the export check matches this batch size + dev = args.device + u = ((z.to(dev) - mu.to(dev)) @ w.to(dev)).float() + head = train_head(u, y.to(dev), args) + + # export in the released adapter's format and check it reproduces the trained head on real inputs + with torch.no_grad(): + model.mu.copy_(mu.to(dev)); model.W.copy_(w.to(dev)) + model.head.weight.copy_(head.weight); model.head.bias.copy_(head.bias) + adapter = model.adapter_state_dict() + torch.save(adapter, out / "cure_trained.pth") + print(f"[stage3] wrote {out / 'cure_trained.pth'} ({len(adapter)} tensors)", flush=True) + check = build_model(None, dev) + missing, unexpected = check.load_state_dict(torch.load(out / "cure_trained.pth", map_location="cpu", weights_only=True), + strict=False) + stray = [k for k in missing if "lora_" in k or k in ("mu", "W", "head.weight", "head.bias")] + # The reloaded model runs at the SAME batch size and precision (fp16 autocast) the cached features were encoded with + # (--encode-batch): fp16 kernels can give batch-size-dependent results (measured on an RTX 6000 Ada, job 285054: + # max |feature diff| 0.29 at |z| <= 82 between batches of 64 and 128, bit-identical at equal batch size), which is a + # GPU property, not an export error. One batch of reals and one of generated images; the tolerance is unchanged. + if encode_batch is None: + print(f"[stage3] WARNING: {feat_path} records no encode batch size; assuming --encode-batch {args.encode_batch}", + flush=True) + encode_batch = args.encode_batch + elif encode_batch != args.encode_batch: + print(f"[stage3] WARNING: cached features were encoded in batches of {encode_batch}, not --encode-batch " + f"{args.encode_batch}; the export check uses {encode_batch}", flush=True) + n_r = len(ep.reals) + nb = max(1, min(encode_batch, n_r, len(ep.fakes))) + logits_export, idx = [], [] + with torch.no_grad(): + for blk in (list(range(nb)), [n_r + i for i in range(nb)]): + xs = torch.stack([ep.load(ep.reals[i]) if i < n_r else ep.load(ep.fakes[i - n_r]) for i in blk]).to(dev) + logits_export.append(check(xs).float().cpu()) + idx += blk + logits_export = torch.cat(logits_export) + logits_cached = head(u[torch.tensor(idx).to(dev)]).float().cpu() + diff = float((logits_export - logits_cached).abs().max()) + print(f"[stage3] export check: missing adapter keys {stray}, unexpected {unexpected}; reloaded-model logits vs trained " + f"head on cached features, max |diff| {diff:.2e} over {len(idx)} images (batches of {nb}, as encoded)", flush=True) + # informational only, not a gate: the same comparison with one batch of 32 + 32 images (the check's former batch) + n = min(64, 2 * nb) + probe = [ep.load(ep.reals[i]) for i in range(n // 2)] + [ep.load(ep.fakes[i]) for i in range(n - n // 2)] + pidx = torch.tensor(list(range(n // 2)) + [n_r + i for i in range(n - n // 2)]) + with torch.no_grad(): + alt = float((check(torch.stack(probe).to(dev)).float().cpu() - head(u[pidx.to(dev)]).float().cpu()).abs().max()) + print(f"[stage3] batch-size sensitivity on this GPU (informational, not a gate): reloaded-model logits in one batch of " + f"{n} vs cached features encoded in batches of {encode_batch}: max |diff| {alt:.2e}", flush=True) + if stray or unexpected or diff > 1e-2: + raise RuntimeError("exported adapter does not reproduce the trained head") + + +def main(argv=None) -> None: + ap = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) + sub = ap.add_subparsers(dest="stage", required=True) + for name in ("stage2", "stage3"): + p = sub.add_parser(name) + p.add_argument("--lora", required=True, help="state dict with the 96 stage-1 LoRA tensors (trainer model_last.pth)") + p.add_argument("--data", required=True, help="GenImage SD v1.4 root (train/real, train/fake)") + p.add_argument("--out", required=True) + p.add_argument("--max-images", type=int, default=None, help="first N reals and N fakes of the split (smoke runs)") + p.add_argument("--workers", type=int, default=8) + p.add_argument("--seed", type=int, default=0) + p.add_argument("--device", default="cuda") + p.add_argument("--recompute", action="store_true", help="re-encode even if the cached features exist") + p2 = sub.choices["stage2"] + p2.add_argument("--pairs", type=int, default=20000, help="endpoint pairs per trajectory type (paper: 20,000)") + p2.add_argument("--batch-pairs", type=int, default=16, help="pairs per forward (x 6 mixtures)") + p2.add_argument("--k", type=int, default=SUBSPACE_DIM) + p2.add_argument("--lambda-s", type=float, default=S.DEFAULT_LAMBDA_S) + p2.add_argument("--lambda-m", type=float, default=S.DEFAULT_LAMBDA_M) + p2.add_argument("--eps", type=float, default=S.DEFAULT_EPS) + p2.add_argument("--reference-adapter", default=None, help="released cure_adapter.pt: compare W / mu with it") + p2.add_argument("--control", choices=["none", "no_q70"], default="none", + help="parity control only: preprocess the endpoints without the final JPEG q70 pass") + p2.add_argument("--subspace-name", default="subspace.pt") + p3 = sub.choices["stage3"] + p3.add_argument("--subspace", default=None, help="default /subspace.pt") + p3.add_argument("--epochs", type=int, default=5) + p3.add_argument("--lr", type=float, default=2e-4) + p3.add_argument("--weight-decay", type=float, default=0.1) + p3.add_argument("--dropout", type=float, default=0.05) + p3.add_argument("--batch", type=int, default=256) + p3.add_argument("--encode-batch", type=int, default=128) + args = ap.parse_args(argv) + print(f"[{args.stage}] args: {vars(args)}", flush=True) + {"stage2": stage2, "stage3": stage3}[args.stage](args) + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/models/image/effort/effort.py b/models/image/effort/effort.py index 7409c4b33c771b4f06341e9e5c35606deffce5a3..9fbb7e5067d9a5884594cf1c28abf25f05ec4087 100644 --- a/models/image/effort/effort.py +++ b/models/image/effort/effort.py @@ -16,7 +16,10 @@ class SynthScopeEffortModel(nn.Module): def __init__(self, config: DictConfig): super().__init__() mc = config.ModelConfig - vision = CLIPVisionModel.from_pretrained(mc.get("clip_name", "openai/clip-vit-large-patch14")).vision_model + clip_vision = CLIPVisionModel.from_pretrained(mc.get("clip_name", "openai/clip-vit-large-patch14")) + # transformers <= 5.5.4 wraps the tower as ``.vision_model``; 5.22.2 made CLIPVisionModel the tower itself (the + # tensor names under it, and the pooled output, are the same either way). + vision = getattr(clip_vision, "vision_model", clip_vision) self.backbone = apply_svd_residual_to_self_attn(vision, r=int(mc.get("svd_rank", 1023))) self.head = nn.Linear(1024, 2) # Training recipe only (conf/model/image/effort_ufd.yaml): the official UniversalFakeDetect trainer re-draws the diff --git a/models/image/pgc/pgc.py b/models/image/pgc/pgc.py index 993387163a5da65f0ffdca2466e462a576231a59..d83fed1843a36f79e67afdbd032cdc2ad3663ec9 100644 --- a/models/image/pgc/pgc.py +++ b/models/image/pgc/pgc.py @@ -39,10 +39,13 @@ from transformers import AutoModel logger = logging.getLogger(__name__) _RESIDUAL_DIM = 256 -# LoRA targets for a Hugging Face DINOv2 ViT (attention q/k/v + output dense + MLP fc1/fc2). +# LoRA targets for a Hugging Face DINOv2 ViT (attention q/k/v + output dense + MLP fc1/fc2); attention modules are +# named attention.attention.{query,key,value} / attention.output.dense up to transformers 5.5.x and +# attention.{q,k,v,o}_proj in later releases (5.22), so both spellings are listed (each matches only on its own release). _DEFAULT_LORA_TARGETS = [ "attention.attention.query", "attention.attention.key", "attention.attention.value", - "attention.output.dense", "mlp.fc1", "mlp.fc2", + "attention.output.dense", "attention.q_proj", "attention.k_proj", "attention.v_proj", "attention.o_proj", + "mlp.fc1", "mlp.fc2", ] _IMAGENET_MEAN = (0.485, 0.456, 0.406) _IMAGENET_STD = (0.229, 0.224, 0.225) diff --git a/models/image/probe/README.md b/models/image/probe/README.md new file mode 100644 index 0000000000000000000000000000000000000000..238135549dc4e7d7e608399f350fa47af56745a9 --- /dev/null +++ b/models/image/probe/README.md @@ -0,0 +1,283 @@ +# PROBE (`probe`, `probe_resnet`) + +**Where Detectors Fail: Probing Generative Space for Generalizable AI-Generated Image Detection** (ICML 2026) — +[paper (arXiv 2605.24906)](https://arxiv.org/abs/2605.24906) · +[official code](https://github.com/Amamiya-C/PROBE-AIGI-Detection) · +[checkpoints](https://modelscope.cn/models/shuinishaojiu/PROBE-AIGI-Detection) + +PROBE (Probing Robustness via Boundary Exploration) is a way to train a detector, not a new architecture. Detectors +fail on generators they have not seen because the training data covers only a small part of what generators can +produce. PROBE uses the detector as a critic: it steers an image generator through small edits of its internal +representations ("manifold-level modifications") towards realistic images that the detector misclassifies, and then +refines the detector on those hard samples. The released detectors are therefore plain classifiers with one logit: + +* **PROBE-DINOv2** (`probe`): DINOv2 ViT-L/14 with registers, fine-tuned, with a linear head on the CLS token; trained + on the paper's *Reconstruction Training Set* (real images reconstructed with SD 2.1) plus PROBE samples. README: + 93.9 average balanced accuracy over 7 benchmarks. +* **PROBE-ResNet50** (`probe_resnet`): a ResNet-50 with a linear head, trained on GenImage SD v1.4 plus PROBE samples + (78.1 average). Both are rows of the paper's Table 1, so both are registered. + +## Pipeline (official, reproduced exactly) + +``` +image ─ Image.open(path).convert('RGB') + ─ pad_image to the crop size S, only if a side is shorter than S: + probe: S = 336, mode 'repeat' (tile the image with copies of itself until both sides reach 336) + probe_resnet: S = 224, mode 'pad' (paste it centered on a black 224×224 square; a longer side is cut) + ─ ToTensor → ImageNet normalization (on the whole image) + ─ non-overlapping S×S patches, row-major (unfold, stride S); the strip at the right / bottom that is narrower + than S is not used → [N, 3, S, S], N depends on the size + → each patch: DINOv2-reg ViT-L/14 → CLS → Linear(1024, 1) | ResNet-50 → avgpool → Linear(2048, 1) + → mean of the N patch logits → P(fake) = sigmoid(mean) (official evaluate_dino.py / evaluate_resnet.py) +``` + +The crop sizes are the official README commands (`evaluate_dino.py --crop_size 336`, `evaluate_resnet.py --crop_size +224`); the pad modes are the scripts' `data_augment_params['pad_mode']`. Every test-time perturbation of the official +`data_augment` (blur, JPEG, noise, resize, cutout) has probability 0 in the README commands, so it is the identity. + +Weights: `DINOv2_best_model_step_34999.pth` (1.22 GB, sha256 `c8caa9ba…450156`) holds the full model (all 440 backbone +tensors + the head) and loads key-for-key as `probe.pth`, so the backbone download (`facebook/dinov2-with-registers- +large`) is not needed for inference; `ResNet50_best_model_step_19343.pth` (94 MB, sha256 `71ef257e…20f0507c`) loads +key-for-key as `probe_resnet.pth`. Both are `{"model_state_dict": ...}` (ModelScope +`shuinishaojiu/PROBE-AIGI-Detection`). Place them under `$SYNTHSCOPE_CKPT_DIR` with those names. + +## SynthScope adaptations + +| choice | reason | +|---|---| +| `official/dino_classifier.py` and `official/resnet50.py` = the official model files | `SynthScopePROBEModel` subclasses the official `dino_classifier`, `SynthScopePROBEResNetModel` the official `ResNet` (as `resnet50(num_classes=1, classifier_type='linear')`), so the checkpoints load strictly (`ckpt_kind="official_probe"`); attribution and licence status in the headers. `resnet50.py` is unchanged. | +| DINOv2 backbone built from its config (`DINOV2_REG_LARGE`), not `AutoModel.from_pretrained(model_name)` | the checkpoint already holds the backbone weights; `backbone_path` still loads a pretrained HF-format backbone (for training). Both give the same `Dinov2WithRegistersModel` with the default (sdpa) attention. | +| transform steps `probe_pad_repeat_336` / `probe_pad_224` (the official `pad_image`, vendored unchanged in `preprocess.py`), `to_dtype`, `normalize_imagenet`, `sliding_patches_336` / `sliding_patches_224` (the official `generate_sliding_patches`) | the official per-image preprocessing as eval-list steps; the transform returns the image's patch bag `[N, 3, S, S]`. | +| the mean over patches is in `forward` (`[B, N, 3, S, S]` → `[B, 1]`); `native_res=True` scores one image at a time | the official `evaluate` averages the patch logits of each image; N varies with the image size, so bags cannot be stacked across images. | +| patches go through the network in chunks of `patch_chunk_size: 32` | bounds memory on very large images; the official code runs all patches of a batch of images in one forward. Chunking does not change the scores here (max \|diff\| 0.0 against the official batch-1 run, including a 40-patch image). `patch_chunk_size: 0` runs all patches at once. | +| `remap_probe` unwraps `model_state_dict` | the official `checkpoint['model_state_dict']` load (no key renaming). | +| an unreadable image is skipped by `bench_eval` (with a "bad image" print) | the official loader scores it as P(fake) = 0.5 (logit 0); no effect on readable data. | +| image files of every format PIL reads | the official loader lists `.jpg`, `.jpeg`, `.png` only; the pixels of those formats are the same. | +| `compute_loss` = BCE with logits on one patch per image, `outputs` = `[-logit, logit]` | the official fine-tuning and boundary-exploration code is not released (README TODO), so there is no training recipe; this is the repo convention for single-logit detectors. | + +## Fidelity check + +The official code (`probe_ref` at commit b145f71, unmodified, in a separate process: `evaluate_dino.EvaluateDataset` +/ `evaluate_resnet.EvaluateDataset`, `collate_fn` and `evaluate`, with the README settings, `fake_equal_real=False` so +every file is scored, the backbone path pointed at a local copy of `facebook/dinov2-with-registers-large` @ e4c89a4, +CPU) against SynthScope's full pipeline: raw file → `bench_eval._open_rgb` → registry transform → engine-built model +with the checkpoint loaded by the engine (`_load_checkpoint`, strict) → `engine._fake_prob`, through `bench_eval.score`. + +Images: 34 files (16 real, 18 fake; PNG and JPEG incl. one RGBA PNG and one grayscale JPEG; 128×128 to 3000×1999; sides +below, at and just under the crop size, e.g. 335×700 and 336×500): 1 to 40 patches per image for `probe` (179 in +all), 1 to 104 for `probe_resnet` (389). + +Results (CPU, torch 2.11, transformers 5.5.4; logs `repro/logs/probepar_cpu_{official_dino,official_resnet}_bs{1,8}.log` +and `probepar_cpu_ours_{dino,resnet}.log`): + +| | `probe` (DINOv2, 336) | `probe_resnet` (ResNet-50, 224) | +|---|---|---| +| state dict (strict engine load) | 442/442 tensors identical to the checkpoint and to the official model (sha256 of the bytes); missing 0, unexpected 0 | 320/320 identical; missing 0, unexpected 0 | +| model inputs (patch bags) | 34/34 identical to the official tensors (sha256) | 34/34 identical | +| P(fake), mean logit vs official batch 1 | **max \|diff\| 0.0 / 0.0**, 0 flips | **max \|diff\| 0.0 / 0.0**, 0 flips | +| P(fake), mean logit vs official batch 8 (README) | 2.6e-8 / 1.9e-6, 0 flips | 1.8e-7 / 5.7e-6, 0 flips | + +The batch-8 differences are the official code's own batch-size effect (it runs the patches of 8 images in one +forward), not a SynthScope difference. A checkpoint with one tensor removed or one extra key makes the engine raise. +The code tested is commit f01b3ee; `patch_chunk_size` 32 and 0 (all patches at once) give identical scores. + +Memory and speed (CPU, fp32, 16 threads on a shared login node, the 34 parity images scored one at a time as the +engine does, second pass timed; logs `repro/logs/probepar_cpu_speed_{probe,probe_resnet,probe_chunk0}.log`): + +| | `probe` | `probe_resnet` | +|---|---|---| +| model time per patch | 507 ms (336×336) | 28 ms (224×224) | +| one-patch image (e.g. 500×375) | 0.90 s | 0.13 s | +| largest image (3000×1999) | 40 patches, 16.5 s | 104 patches, 2.0 s | +| mean per image (incl. preprocessing) | 2.68 s | 0.32 s | +| peak RSS (load + inference) | 2.98 GiB (3.19 GiB with `patch_chunk_size: 0`) | 1.24 GiB | + +The cost grows with the image area: an image is scored on all its patches. + +## Results + +**Verdict: faithful port (SynthScope equals the official code on every file compared: the 34 parity images, WildRF and +SynthWildX); the released checkpoints reproduce the +paper's Table 1 on four of the five benchmarks we can run (GenImage, SynthWildX, WildRF, AIGI-Bench) to within 0.9 +points per benchmark; Synthbuster uses different reals and is not a like-for-like comparison. Chameleon and +AIGI-Quality-Paradox were not run (no loader), so the paper's 7-benchmark averages (93.9 / 78.1) are not comparable +with the means below.** + +Paper = Table 1 of arXiv 2605.24906 (balanced accuracy, %, threshold 0.5, positive = fake; per-benchmark Avg = unweighted +mean of the per-subset bAcc of its Tables 2-4). SynthScope_official = the released checkpoint run through SynthScope +(`benchmark/bench_eval.py --model probe` / `--model probe_resnet`); its `means.acc` is the same quantity (the mean over +subsets of (real accuracy + fake accuracy) / 2). SynthScope_train = "—": the training code (generator probing and +fine-tuning) is not released, so there is no SynthScope-trained model. + +| Benchmark | Paper PROBE-DINOv2 | SynthScope_official `probe` | Paper PROBE-ResNet50 | SynthScope_official `probe_resnet` | SynthScope_train | +|---|---:|---:|---:|---:|:-:| +| GenImage (val100k, fakes JPEG q96) | 96.8 | **97.47** (+0.67) | 78.4 | **78.38** (-0.02) | — | +| Synthbuster (**different reals**: 5000 MSCOCO, not RAISE-1k) | 97.5 | 98.20 (not like-for-like) | 79.1 | 83.75 (not like-for-like) | — | +| SynthWildX | 96.4 | **97.30** (+0.90) | 75.6 | **75.20** (-0.40) | — | +| WildRF | 96.9 | **96.92** (+0.02) | 81.3 | **81.63** (+0.33) | — | +| AIGI-Bench (CommunityAI + SocialRF) | 89.9 | **89.88** (-0.02) | 70.4 | **70.44** (+0.04) | — | +| Chameleon | 86.6 | — (no loader; by request only) | 74.0 | — (no loader) | — | +| AIGI-Quality-Paradox | 92.9 | — (no loader) | 87.7 | — (no loader) | — | +| Mean of the 5 benchmarks we ran | 95.50 | 95.95 | 76.96 | 77.88 | — | +| Mean of the 4 like-for-like benchmarks (no Synthbuster) | 95.00 | 95.39 | 76.43 | 76.41 | — | +| Paper's Avg. over all 7 | 93.9 | not comparable | 78.1 | not comparable | — | + +The SynthScope columns are `means.acc` of `repro/bench_results/probe_.json` and +`probe_resnet_.json` (tags below). Their mean AP / AUROC (the paper does not report them in Table 1): GenImage +99.77 / 99.80 (DINOv2), 86.69 / 84.81 (ResNet-50); Synthbuster 99.64 / 99.93, 85.23 / 95.88; SynthWildX 98.80 / 99.18, +83.88 / 82.80; WildRF 99.36 / 99.26, 89.45 / 85.76; AIGI-Bench 96.46 / 95.88, 79.80 / 77.55. + +### Protocol + +* **Metric**: balanced accuracy at threshold 0.5 (mean of real and fake accuracy), positive class = fake; the per-benchmark + value is the unweighted mean over the paper's subsets. The paper checks out against itself: the mean of its eight + GenImage DINOv2 values is 96.76 (Table 1: 96.8), of its nine Synthbuster values 97.52 (97.5), of its WildRF values 96.93 + (96.9). +* **Inference**: the SynthScope registry transform of Task 1 (exact parity with the official code), batch size 1 (native + resolution), fp32, one RTX A6000 per job. +* **GenImage**: the official val split, 100,000 images, 8 generators, **all fakes JPEG-compressed at quality 96, reals + untouched** (`--jpeg-fakes 96`, the same PIL round trip as the official `util.jpeg_compress`), as the paper does to remove + GenImage's compression bias. These numbers are for that compressed protocol; they are not comparable with GenImage + numbers measured on the uncompressed split. The folders hold + 6000 real + 6000 fake images per generator except SD v1.5 with 8000 + 8000 (the paper's Table 12 lists 48k / 48k). +* **Synthbuster**: 9 generators, 1000 fakes each, paired with **5000 MSCOCO val2017 reals** (the `EvalGEN/Flux/0_real` + folder, the same reals as the MIRROR and B-Free Synthbuster runs). The paper pairs them with the **1000 RAISE-1k reals** + (its Table 12); RAISE is distributed through a personal registration form that was not filled in, so it is not in + SynthScope. These rows are therefore a *different-reals* comparison and are not presented as reproducing the paper. +* **SynthWildX**: dalle3 / firefly / midjourney_v5, 413 reals and 392 / 473 / 435 fakes (1713 unique images: 413 reals scored against each of + the 3 fake subsets; the paper's Table 12 lists 0.5k reals and 1.5k fakes: our copy is the part still online). +* **WildRF**: facebook / reddit / twitter, 2503 files (160 + 160, 750 + 750, 341 + 342); the paper lists 1.25k + 1.25k. +* **AIGI-Bench**: only the two subsets the paper evaluates, **CommunityAI** (6000 real + 6000 fake) and **SocialRF** (3000 + real + 3000 fake), 18,000 files (the paper's 9k / 9k), staged as `aigibench/{CommunityAI,SocialRF}/{0_real,1_fake}`; the + other subsets of the AIGIBench release (about 330 GB) were not scored. +* **Not run**: Chameleon (available by request only) and AIGI-Quality-Paradox have no loader in SynthScope. +* No JPEG alignment on any benchmark other than GenImage (the paper applies it to GenImage only). + +### Per-subset results + +balanced accuracy, % (real accuracy / fake accuracy in brackets); `Paper` = Tables 2-4, `Avg` row = Table 1 for the +paper and `means.acc` for SynthScope. + +**GenImage (val100k, fakes JPEG q96)** + +| subset | Paper DINOv2 | SynthScope_official `probe` (real / fake acc) | Paper ResNet-50 | SynthScope_official `probe_resnet` (real / fake acc) | +|---|---:|---:|---:|---:| +| midjourney | 98.8 | 98.73 (98.57 / 98.9) | 90.7 | 90.73 (98.67 / 82.8) | +| sdv1.4 | 99.4 | 99.41 (98.85 / 99.97) | 99.4 | 99.36 (98.72 / 100.0) | +| sdv1.5 | 99.4 | 99.39 (98.9 / 99.87) | 99.2 | 99.24 (98.6 / 99.89) | +| adm | 91.0 | 93.22 (98.55 / 87.88) | 60.0 | 58.94 (98.52 / 19.37) | +| glide | 92.1 | 93.86 (99.07 / 88.65) | 63.0 | 63.01 (98.78 / 27.23) | +| wukong | 99.5 | 99.33 (98.68 / 99.97) | 99.4 | 99.41 (98.87 / 99.95) | +| vqdm | 98.9 | 98.76 (98.62 / 98.9) | 66.9 | 66.90 (98.72 / 35.08) | +| biggan | 95.0 | 97.07 (98.75 / 95.38) | 49.4 | 49.41 (98.82 / 0.0) | +| **Avg** | **96.8** | **97.47** | **78.4** | **78.38** | + +**Synthbuster (5000 MSCOCO reals, not the paper's RAISE-1k)** + +| subset | Paper DINOv2 | SynthScope_official `probe` (real / fake acc) | Paper ResNet-50 | SynthScope_official `probe_resnet` (real / fake acc) | +|---|---:|---:|---:|---:| +| dalle2 | 94.6 | 93.47 (99.54 / 87.4) | 48.3 | 52.97 (99.14 / 6.8) | +| dalle3 | 99.4 | 99.57 (99.54 / 99.6) | 90.2 | 94.82 (99.14 / 90.5) | +| firefly | 99.5 | 99.77 (99.54 / 100.0) | 46.9 | 51.57 (99.14 / 4.0) | +| glide | 86.7 | 92.22 (99.54 / 84.9) | 57.4 | 62.07 (99.14 / 25.0) | +| midjourney-v5 | 99.5 | 99.77 (99.54 / 100.0) | 93.2 | 97.82 (99.14 / 96.5) | +| stable-diffusion-1-3 | 99.5 | 99.72 (99.54 / 99.9) | 94.9 | 99.57 (99.14 / 100.0) | +| stable-diffusion-1-4 | 99.5 | 99.77 (99.54 / 100.0) | 94.9 | 99.57 (99.14 / 100.0) | +| stable-diffusion-2 | 99.5 | 99.77 (99.54 / 100.0) | 93.1 | 97.72 (99.14 / 96.3) | +| stable-diffusion-xl | 99.5 | 99.72 (99.54 / 99.9) | 93.0 | 97.67 (99.14 / 96.2) | +| **Avg** | **97.5** | **98.20** | **79.1** | **83.75** | + +**SynthWildX** + +| subset | Paper DINOv2 | SynthScope_official `probe` (real / fake acc) | Paper ResNet-50 | SynthScope_official `probe_resnet` (real / fake acc) | +|---|---:|---:|---:|---:| +| dalle3 | 96.5 | 97.44 (95.64 / 99.23) | 90.3 | 89.71 (89.1 / 90.31) | +| firefly | 96.4 | 96.98 (95.64 / 98.31) | 56.7 | 56.29 (89.1 / 23.47) | +| midjourney_v5 | 96.5 | 97.48 (95.64 / 99.31) | 79.7 | 79.61 (89.1 / 70.11) | +| **Avg** | **96.4** | **97.30** | **75.6** | **75.20** | + +**WildRF** + +| subset | Paper DINOv2 | SynthScope_official `probe` (real / fake acc) | Paper ResNet-50 | SynthScope_official `probe_resnet` (real / fake acc) | +|---|---:|---:|---:|---:| +| facebook | 98.4 | 98.75 (98.12 / 99.37) | 87.8 | 87.81 (82.5 / 93.12) | +| reddit | 93.4 | 93.33 (94.4 / 92.27) | 72.9 | 72.87 (89.6 / 56.13) | +| twitter | 99.0 | 98.68 (99.12 / 98.25) | 83.3 | 84.20 (89.74 / 78.65) | +| **Avg** | **96.9** | **96.92** | **81.3** | **81.63** | + +**AIGI-Bench (CommunityAI + SocialRF)** + +| subset | Paper DINOv2 | SynthScope_official `probe` (real / fake acc) | Paper ResNet-50 | SynthScope_official `probe_resnet` (real / fake acc) | +|---|---:|---:|---:|---:| +| CommunityAI | 89.8 | 90.38 (97.17 / 83.6) | 71.0 | 70.99 (87.1 / 54.88) | +| SocialRF | 89.9 | 89.38 (89.87 / 88.9) | 69.9 | 69.88 (84.2 / 55.57) | +| **Avg** | **89.9** | **89.88** | **70.4** | **70.44** | + + +Reading the tables: + +* **ResNet-50 reproduces the paper** on GenImage (7 of 8 generators within 0.1, ADM 58.94 vs 60.0; average 78.38 vs + 78.4), SynthWildX, WildRF and AIGI-Bench (every subset within 0.9, the largest being WildRF twitter 84.2 vs 83.3). Its + weakness is real: it detects almost nothing from ADM, GLIDE, VQDM and BigGAN (fake accuracy 0 - 35 %) because it is + trained on SD v1.4 only. +* **DINOv2**: Stable Diffusion, Wukong, VQDM and Midjourney are within 0.2 of the paper. **ADM, GLIDE and BigGAN are + about 2 points above it** (+2.2, +1.8, +2.1), which makes the GenImage average 97.47 vs 96.8. SynthScope equals the + official code wherever we compared the two (the 34 parity images of the fidelity check, and every WildRF and SynthWildX + file, next section), and the official code was not run on GenImage itself. Since the pipeline is identical, the + difference points to the data or preprocessing on the paper's side (the exact JPEG-q96 implementation and the exact val + subset are not specified); we cannot determine it. +* **Synthbuster**: the real-class accuracy is fixed by the reals, so swapping RAISE for MSCOCO moves every subset by the + same real-accuracy term. Inferred, not measured: for ResNet-50 the paper's bAcc of SD 1.3 / 1.4 (94.9), DALL-E 2 (48.3) + and DALL-E 3 (90.2) is reproduced from our fake accuracies (100.0, 6.8, 90.5) if the RAISE real accuracy is about 89.8 + (ours on MSCOCO: 99.14); for DINOv2 the same reading gives about 99.0 (ours 99.54), and the per-subset differences are + small except GLIDE (+5.5) and DALL-E 2 (-1.1). This is why 98.20 and 83.75 must not be quoted as "reproducing 97.5 and + 79.1". + +### Official code on our data + +To separate port from data, the **unmodified official** `evaluate_dino.py` / `evaluate_resnet.py` code path +(`EvaluateDataset`, `collate_fn`, `evaluate`, README settings, batch size 4; `repro/probe_task2/probe_official_eval.py`) +was run on the same files as SynthScope for WildRF and SynthWildX (job 66753). Per file: **0 flips at 0.5 on every +common file in all four runs; max |dP| = 4.8e-6 (DINOv2) and 1.3e-3 (ResNet-50, GPU convolution algorithms / TF32 at +batch 4 vs 1)**. + +| run | SynthScope `means.acc` | official, bAcc on all files it reads | official "Overall Accuracy" (seed-42 class-balanced subsample) | Paper | +|---|---:|---:|---:|---:| +| `probe` WildRF | 96.92 | 96.88 | 96.78 | 96.9 | +| `probe` SynthWildX | 97.30 | 97.30 | 97.42 | 96.4 | +| `probe_resnet` WildRF | 81.63 | 81.65 | 80.99 | 81.3 | +| `probe_resnet` SynthWildX | 75.20 | 75.20 | 75.09 | 75.6 | + +* The official script's default `fake_equal_real=True` subsamples the larger class to the smaller one (seed 42) and + reports pooled accuracy on that sample; it equals bAcc up to sampling noise (at most 2.0 per subset, ResNet-50 on the unbalanced WildRF + twitter subset: 82.29 vs 84.27; at most 0.66 per benchmark, ResNet-50 WildRF: 80.99 vs 81.65). `means.acc` is the paper's metric. +* **The official file lister keeps `.jpg` / `.jpeg` / `.png` only**, so it silently drops the 262 `.jfif` files of WildRF + twitter (683 files in SynthScope, 421 in the official run). SynthScope scores all of them. On the 421 common files both + give the same number (DINOv2 98.57, ResNet-50 84.27); on all 683 SynthScope gives 98.68 / 84.20. Every other subset is + identical to two decimals. +* An unreadable image is scored P(fake) = 0.5 by the official code and skipped by `bench_eval`; no file in these + benchmarks was unreadable. + +Raw comparison: `repro/probe_task2/official_vs_synthscope.json`, `official_runs_summary.json`, +`paper_vs_synthscope.json`; scripts `repro/probe_task2/`. + +### Tags and jobs + +DAS6, one RTX A6000 per job, code at commit a6ba2c5 (clean checkout in every job; the checkpoints were verified against +`SHA256SUMS` in every job). Logs: `repro/logs/probebench_das6_.out`; every `repro/bench_results/probe_*.json` matches +its `=== RESULT ` log line and its `repro/MASTER_RESULTS.jsonl` line. + +| tags (`probe_`, `probe_resnet_`) | benchmark | job | +|---|---|---| +| `genimage_val100k` | GenImage val100k, fakes JPEG q96 | 66753 (node409) | +| `synthbuster_coco` | Synthbuster vs 5000 MSCOCO reals | 66755 (node412) | +| `synthwildx`, `wildrf` | SynthWildX, WildRF (+ the official-code runs above) | 66753 | +| `aigibench` | CommunityAI + SocialRF | 66790 (node409) | + +(Jobs 66754, 66757 and the IVI job 284282 were cancelled and produced no result used here.) + +## Licence + +The official repository has no LICENSE file and states no licence, and the ModelScope model page has an empty licence +field: the licence is **unclear**. The weights are not redistributed (not in the SynthScope model zoo or on the +Space); download them from ModelScope. See [LICENSES.md](../../../LICENSES.md). diff --git a/models/image/probe/__init__.py b/models/image/probe/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/models/image/probe/official/__init__.py b/models/image/probe/official/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/models/image/probe/official/dino_classifier.py b/models/image/probe/official/dino_classifier.py new file mode 100644 index 0000000000000000000000000000000000000000..bba2da02ff1acb28a328325bd274b529a503df2b --- /dev/null +++ b/models/image/probe/official/dino_classifier.py @@ -0,0 +1,77 @@ +# Vendored from github.com/Amamiya-C/PROBE-AIGI-Detection (commit b145f71), file Detector/model/dino_classifier.py. +# Licence UNCLEAR: the repository has no LICENSE file and states no licence; see LICENSES.md. +# +# The `dino_classifier` below is the official class, so the released DINOv2_best_model_step_34999.pth loads key-for-key +# with strict=True. One forced change, which does not alter the computation: +# 1. The backbone can be built from its config (`DINOV2_REG_LARGE`, the config.json of +# facebook/dinov2-with-registers-large) instead of `AutoModel.from_pretrained(model_name)`: the checkpoint holds +# the full backbone, so inference needs no backbone download. A directory path or hub id (the official +# `model_name`) still uses from_pretrained. Both build the same Dinov2WithRegistersModel with the transformers +# default attention (sdpa). +from collections.abc import Mapping + +import torch +from transformers import AutoModel, Dinov2WithRegistersConfig, Dinov2WithRegistersModel + +# config.json of facebook/dinov2-with-registers-large (revision e4c89a4e05589de9b3e188688a303d0f3c04d0f3), the backbone +# of the official `model_name` ('.../dinov2-l-register'; the commented-out default is the hub id). +DINOV2_REG_LARGE = dict( + apply_layernorm=True, attention_probs_dropout_prob=0.0, drop_path_rate=0.0, hidden_act="gelu", + hidden_dropout_prob=0.0, hidden_size=1024, image_size=518, initializer_range=0.02, interpolate_antialias=True, + interpolate_offset=0.0, layer_norm_eps=1e-06, layerscale_value=1.0, mlp_ratio=4, num_attention_heads=16, + num_channels=3, num_hidden_layers=24, num_register_tokens=4, patch_size=14, qkv_bias=True, use_swiglu_ffn=False, +) + + +def _load_backbone(source): + """`AutoModel.from_pretrained(source)` for a directory / hub id; a config dict builds the same model untrained.""" + if isinstance(source, Mapping): + return Dinov2WithRegistersModel(Dinov2WithRegistersConfig(**source)) + return AutoModel.from_pretrained(source) + + +# --- official Detector/model/dino_classifier.py (unchanged except for the marked line) -------------------------------- +class dino_classifier(torch.nn.Module): + def __init__(self, + # model_name="facebook/dinov2-with-registers-large", + model_name='/data_center/data2/dataset/czj/detector/model/dinov2-l-register', + classifier_type='linear', + mlp_hidden_size=512 + ): + super(dino_classifier, self).__init__() + self.backbone = _load_backbone(model_name) # changed (1) + if classifier_type == 'linear': + self.fc = torch.nn.Linear(self.backbone.config.hidden_size, 1) + elif classifier_type == 'mlp': + self.fc = torch.nn.Sequential( + torch.nn.Linear(self.backbone.config.hidden_size, mlp_hidden_size), + torch.nn.ReLU(inplace=False), + torch.nn.Dropout(0.5), + torch.nn.Linear(mlp_hidden_size, 1) + ) + else: + raise ValueError(f"Unknown classifier_type: {classifier_type}") + + # Freeze backbone + # for param in self.vision_model.parameters(): + # param.requires_grad = False + + def extract_feature(self, input): + outputs = self.backbone(input) + sequence_output = outputs[0] # batch_size, sequence_length, hidden_size + cls_token = sequence_output[:, 0] + return cls_token + + def forward(self, input, return_feature=False): + outputs = self.backbone(input) + sequence_output = outputs[0] # batch_size, sequence_length, hidden_size + cls_token = sequence_output[:, 0] + feature = cls_token + # patch_tokens = sequence_output[:, 1:] + # linear_input = torch.cat([cls_token, patch_tokens.mean(dim=1)], dim=1) + logits = self.fc(cls_token) + if return_feature: + return logits, feature + else: + return logits + diff --git a/models/image/probe/official/resnet50.py b/models/image/probe/official/resnet50.py new file mode 100644 index 0000000000000000000000000000000000000000..712882511be3df3217ad3f5ff076ffdc74522505 --- /dev/null +++ b/models/image/probe/official/resnet50.py @@ -0,0 +1,256 @@ +# Vendored from github.com/Amamiya-C/PROBE-AIGI-Detection (commit b145f71), file Detector/model/resnet50.py. Licence +# UNCLEAR: the repository has no LICENSE file and states no licence; see LICENSES.md. +# Unchanged below this header, so the released ResNet50_best_model_step_19343.pth loads key-for-key with strict=True. +import torch.nn as nn +import torch.utils.model_zoo as model_zoo + +__all__ = ['ResNet', 'resnet18', 'resnet34', 'resnet50', 'resnet101','resnet152'] + + +model_urls = { + 'resnet18': 'https://download.pytorch.org/models/resnet18-5c106cde.pth', + 'resnet34': 'https://download.pytorch.org/models/resnet34-333f7ec4.pth', + 'resnet50': 'https://download.pytorch.org/models/resnet50-19c8e357.pth', + 'resnet101': 'https://download.pytorch.org/models/resnet101-5d3b4d8f.pth', + 'resnet152': 'https://download.pytorch.org/models/resnet152-b121ed2d.pth', +} + + +def conv3x3(in_planes, out_planes, stride=1): + """3x3 convolution with padding""" + return nn.Conv2d(in_planes, out_planes, kernel_size=3, stride=stride, + padding=1, bias=False) + + +def conv1x1(in_planes, out_planes, stride=1): + """1x1 convolution""" + return nn.Conv2d(in_planes, out_planes, kernel_size=1, stride=stride, bias=False) + + +class BasicBlock(nn.Module): + expansion = 1 + + def __init__(self, inplanes, planes, stride=1, downsample=None): + super(BasicBlock, self).__init__() + self.conv1 = conv3x3(inplanes, planes, stride) + self.bn1 = nn.BatchNorm2d(planes) + self.relu = nn.ReLU(inplace=False) + self.conv2 = conv3x3(planes, planes) + self.bn2 = nn.BatchNorm2d(planes) + self.downsample = downsample + self.stride = stride + + def forward(self, x): + identity = x + + out = self.conv1(x) + out = self.bn1(out) + out = self.relu(out) + + out = self.conv2(out) + out = self.bn2(out) + + if self.downsample is not None: + identity = self.downsample(x) + + out += identity + out = self.relu(out) + + return out + + +class Bottleneck(nn.Module): + expansion = 4 + + def __init__(self, inplanes, planes, stride=1, downsample=None): + super(Bottleneck, self).__init__() + self.conv1 = conv1x1(inplanes, planes) + self.bn1 = nn.BatchNorm2d(planes) + self.conv2 = conv3x3(planes, planes, stride) + self.bn2 = nn.BatchNorm2d(planes) + self.conv3 = conv1x1(planes, planes * self.expansion) + self.bn3 = nn.BatchNorm2d(planes * self.expansion) + self.relu = nn.ReLU(inplace=False) + self.downsample = downsample + self.stride = stride + + def forward(self, x): + identity = x + + out = self.conv1(x) + out = self.bn1(out) + out = self.relu(out) + + out = self.conv2(out) + out = self.bn2(out) + out = self.relu(out) + + out = self.conv3(out) + out = self.bn3(out) + + if self.downsample is not None: + identity = self.downsample(x) + + out += identity + out = self.relu(out) + + return out + + +class ResNet(nn.Module): + + def __init__(self, block, layers, num_classes=1000, zero_init_residual=False, classifier_type='linear', mlp_hidden_size=512): + super(ResNet, self).__init__() + self.inplanes = 64 + self.conv1 = nn.Conv2d(3, 64, kernel_size=7, stride=2, padding=3, + bias=False) + self.bn1 = nn.BatchNorm2d(64) + # self.relu = nn.ReLU(inplace=True) + self.relu = nn.ReLU(inplace=False) + self.maxpool = nn.MaxPool2d(kernel_size=3, stride=2, padding=1) + self.layer1 = self._make_layer(block, 64, layers[0]) + self.layer2 = self._make_layer(block, 128, layers[1], stride=2) + self.layer3 = self._make_layer(block, 256, layers[2], stride=2) + self.layer4 = self._make_layer(block, 512, layers[3], stride=2) + self.avgpool = nn.AdaptiveAvgPool2d((1, 1)) + # self.fc = nn.Linear(512 * block.expansion, num_classes) + if classifier_type == 'linear': + self.fc = nn.Linear(512 * block.expansion, num_classes) + elif classifier_type == 'mlp': + self.fc = nn.Sequential( + nn.Linear(512 * block.expansion, mlp_hidden_size), + nn.ReLU(inplace=False), + nn.Dropout(0.5), + nn.Linear(mlp_hidden_size, num_classes) + ) + else: + raise ValueError(f"Unknown classifier_type: {classifier_type}") + # print(num_classes) + for m in self.modules(): + if isinstance(m, nn.Conv2d): + nn.init.kaiming_normal_(m.weight, mode='fan_out', nonlinearity='relu') + elif isinstance(m, nn.BatchNorm2d): + nn.init.constant_(m.weight, 1) + nn.init.constant_(m.bias, 0) + + # Zero-initialize the last BN in each residual branch, + # so that the residual branch starts with zeros, and each residual block behaves like an identity. + # This improves the model by 0.2~0.3% according to https://arxiv.org/abs/1706.02677 + if zero_init_residual: + for m in self.modules(): + if isinstance(m, Bottleneck): + nn.init.constant_(m.bn3.weight, 0) + elif isinstance(m, BasicBlock): + nn.init.constant_(m.bn2.weight, 0) + + def _make_layer(self, block, planes, blocks, stride=1): + downsample = None + if stride != 1 or self.inplanes != planes * block.expansion: + downsample = nn.Sequential( + conv1x1(self.inplanes, planes * block.expansion, stride), + nn.BatchNorm2d(planes * block.expansion), + ) + + layers = [] + layers.append(block(self.inplanes, planes, stride, downsample)) + self.inplanes = planes * block.expansion + for _ in range(1, blocks): + layers.append(block(self.inplanes, planes)) + + return nn.Sequential(*layers) + + def extract_feature(self, x): + + # print("1"+str(x.size())) + x = self.conv1(x) + x = self.bn1(x) + x = self.relu(x) + x = self.maxpool(x) + + x = self.layer1(x) + x = self.layer2(x) + x = self.layer3(x) + x = self.layer4(x) + + x = self.avgpool(x) + x = x.view(x.size(0), -1) + # print("2"+str(x.size())) + return x + + def forward(self, x, return_feature=False): + + # print("1"+str(x.size())) + x = self.conv1(x) + x = self.bn1(x) + x = self.relu(x) + x = self.maxpool(x) + + x = self.layer1(x) + x = self.layer2(x) + x = self.layer3(x) + x = self.layer4(x) + + x = self.avgpool(x) + feature = x.view(x.size(0), -1) + # print("2"+str(x.size())) + x = self.fc(feature) + # print("3"+str(x.size())) + if return_feature is True: + return x, feature + else: + return x + + +def resnet18(pretrained=False, **kwargs): + """Constructs a ResNet-18 model. + Args: + pretrained (bool): If True, returns a model pre-trained on ImageNet + """ + model = ResNet(BasicBlock, [2, 2, 2, 2], **kwargs) + if pretrained: + model.load_state_dict(model_zoo.load_url(model_urls['resnet18'])) + return model + + +def resnet34(pretrained=False, **kwargs): + """Constructs a ResNet-34 model. + Args: + pretrained (bool): If True, returns a model pre-trained on ImageNet + """ + model = ResNet(BasicBlock, [3, 4, 6, 3], **kwargs) + if pretrained: + model.load_state_dict(model_zoo.load_url(model_urls['resnet34'])) + return model + + +def resnet50(pretrained=False, **kwargs): + """Constructs a ResNet-50 model. + Args: + pretrained (bool): If True, returns a model pre-trained on ImageNet + """ + model = ResNet(Bottleneck, [3, 4, 6, 3], **kwargs) + if pretrained: + model.load_state_dict(model_zoo.load_url(model_urls['resnet50'])) + return model + + +def resnet101(pretrained=False, **kwargs): + """Constructs a ResNet-101 model. + Args: + pretrained (bool): If True, returns a model pre-trained on ImageNet + """ + model = ResNet(Bottleneck, [3, 4, 23, 3], **kwargs) + if pretrained: + model.load_state_dict(model_zoo.load_url(model_urls['resnet101'])) + return model + + +def resnet152(pretrained=False, **kwargs): + """Constructs a ResNet-152 model. + Args: + pretrained (bool): If True, returns a model pre-trained on ImageNet + """ + model = ResNet(Bottleneck, [3, 8, 36, 3], **kwargs) + if pretrained: + model.load_state_dict(model_zoo.load_url(model_urls['resnet152'])) + return model diff --git a/models/image/probe/preprocess.py b/models/image/probe/preprocess.py new file mode 100644 index 0000000000000000000000000000000000000000..fd34705b081ebd8658f80aa20c909ff0c4642c11 --- /dev/null +++ b/models/image/probe/preprocess.py @@ -0,0 +1,98 @@ +"""PROBE's test-time preprocessing; ``pad_image`` is vendored unchanged and ``sliding_patches`` is the +``EvaluateDataset.generate_sliding_patches`` of github.com/Amamiya-C/PROBE-AIGI-Detection (commit b145f71, +``Detector/util.py`` and ``Detector/evaluate_dino.py`` / ``evaluate_resnet.py``; licence unclear: no LICENSE file - +see LICENSES.md). + +The official evaluation (``EvaluateDataset.__getitem__`` + ``evaluate``), per image: + 1. ``Image.open(path).convert('RGB')``, + 2. ``data_augment(image, params, mode='fix', crop_size)``: every perturbation probability is 0 at test time (the + README commands set none), so this is ``Image.fromarray(np.array(image))`` (an identity) followed by + ``pad_image(image, size=crop_size, mode=pad_mode)``: an image with a side under ``crop_size`` is tiled with copies + of itself (``'repeat'``, the DINOv2 script) or pasted on a black ``crop_size`` square (``'pad'``, the ResNet-50 + script; a side longer than ``crop_size`` is then cut, offset ``(crop_size - side) // 2``), + 3. ``ToTensor`` + ImageNet ``Normalize`` on the whole image, + 4. non-overlapping ``crop_size`` patches (``unfold`` with stride = size; pixels past the last full patch on the + right / bottom are dropped) -> ``[N, 3, crop_size, crop_size]``, + 5. the model scores every patch; the image's logit is the mean of its patch logits, P(fake) = sigmoid(mean). + +Steps 2 and 4 are the transform steps ``probe_pad_repeat_336`` / ``probe_pad_224`` and ``sliding_patches_336`` / +``sliding_patches_224`` (``transformations.py``); 3 is ``to_dtype`` + ``normalize_imagenet``; 5 is in the model's +``forward``. The patch count depends on the image size, so images are scored one at a time (``native_res``). +""" +from __future__ import annotations + +import torch +from PIL import Image + + +# --- official Detector/util.py, unchanged ---------------------------------------------------------------------------- +def pad_image(img, size=224, mode='pad'): + width, height = img.size + + if width>=size and height>=size: + return img + + if mode == 'repeat': + repeat_times_width = max(1, (size + width - 1) // width) + repeat_times_height = max(1, (size + height - 1) // height) + new_width = width * repeat_times_width + new_height = height * repeat_times_height + new_img = Image.new('RGB', (new_width, new_height)) + + for i in range(repeat_times_height): + for j in range(repeat_times_width): + new_img.paste(img, (j * width, i * height)) + return new_img + if mode == 'pad': + new_img = Image.new('RGB', (size, size), (0,0,0)) + paste_x = (size - width) // 2 + paste_y = (size - height) // 2 + new_img.paste(img, (paste_x, paste_y)) + return new_img +# ---------------------------------------------------------------------------------------------------------------------- + + +def sliding_patches(img_tensor: torch.Tensor, ps: int) -> torch.Tensor: + """The official ``generate_sliding_patches`` after its ``self.transform``: [3, H, W] -> [N, 3, ps, ps], row-major + non-overlapping patches (an image smaller than ``ps`` gives N = 0, as the official code; ``pad_image`` runs first, + so that does not happen in the pipeline).""" + C, H, W = img_tensor.shape + stride = ps + + if H < ps or W < ps: + return torch.zeros(0, 3, ps, ps) + + # unfold on tensor (much faster than PIL crop) + patches = img_tensor.unfold(1, ps, stride).unfold(2, ps, stride) + patches = patches.permute(1, 2, 0, 3, 4).contiguous() + patches = patches.view(-1, C, ps, ps) + + return patches + + +class ProbePad: + """``probe_pad_repeat_`` / ``probe_pad_``: the official ``pad_image`` on an RGB PIL image (PIL out).""" + + def __init__(self, size: int, mode: str): + if mode not in ("repeat", "pad"): + raise ValueError(f"pad mode must be 'repeat' or 'pad', not {mode!r}") + self.size, self.mode = size, mode + + def __call__(self, image: Image.Image) -> Image.Image: + return pad_image(image.convert("RGB"), size=self.size, mode=self.mode) + + def __repr__(self) -> str: + return f"ProbePad({self.size}, {self.mode!r})" + + +class SlidingPatches: + """``sliding_patches_``: a normalized [3, H, W] tensor -> its non-overlapping [N, 3, n, n] patches.""" + + def __init__(self, size: int): + self.size = size + + def __call__(self, image: torch.Tensor) -> torch.Tensor: + return sliding_patches(torch.as_tensor(image), self.size) + + def __repr__(self) -> str: + return f"SlidingPatches({self.size})" diff --git a/models/image/probe/probe.py b/models/image/probe/probe.py new file mode 100644 index 0000000000000000000000000000000000000000..fe70d133444f62d7d19e865f7bee8a0b0e71ad42 --- /dev/null +++ b/models/image/probe/probe.py @@ -0,0 +1,92 @@ +"""PROBE (Where Detectors Fail: Probing Generative Space for Generalizable AI-Generated Image Detection, ICML 2026, +arXiv 2605.24906). + +Official repo: github.com/Amamiya-C/PROBE-AIGI-Detection (licence unclear: no LICENSE file). PROBE is a training +method: the detector steers a generator through manifold-level edits to find realistic samples it misclassifies, and +is then refined on them. The released detectors are plain classifiers with one logit: + + PROBE-DINOv2 = DINOv2 ViT-L/14 with registers (facebook/dinov2-with-registers-large) -> CLS -> Linear(1024, 1) + PROBE-ResNet50 = ResNet-50 -> global average pool -> Linear(2048, 1) + +and the official evaluation scores an image as the mean logit of its non-overlapping crop_size patches at native +resolution (336 for DINOv2, 224 for ResNet-50; ``preprocess.py``), P(fake) = sigmoid(mean logit). + +``SynthScopePROBEModel`` *is* the official ``dino_classifier`` and ``SynthScopePROBEResNetModel`` the official +``resnet50(num_classes=1, classifier_type='linear')`` (vendored in ``official/``); the released +``DINOv2_best_model_step_34999.pth`` / ``ResNet50_best_model_step_19343.pth`` ({"model_state_dict": ...}) load +key-for-key as ``probe.pth`` / ``probe_resnet.pth``. The DINOv2 backbone is built from its config, so inference needs +no backbone download. + +Input contract: ``forward`` takes the patch bag of one image per sample, [B, N, 3, S, S] from the eval transform +(``probe_pad_*``, ``to_dtype``, ``normalize_imagenet``, ``sliding_patches_*``), and returns the mean patch logit [B, 1], +as the official ``evaluate``; a [B, 3, S, S] batch is one patch per sample. Patches go through the network in chunks +of ``patch_chunk_size`` (0 = all at once, as the official code does per batch) to bound memory on large images. + +Training: the official fine-tuning and boundary-exploration code is not released (README TODO), so no recipe is +reproduced; ``compute_loss`` is BCE with logits on one patch per image, outputs [-logit, logit] (the repo convention +for single-logit detectors). +""" +import torch +import torch.nn.functional as F +from omegaconf import DictConfig + +from .official.dino_classifier import DINOV2_REG_LARGE, dino_classifier +from .official.resnet50 import Bottleneck, ResNet + + +def mean_patch_logits(net_forward, images: torch.Tensor, chunk: int) -> torch.Tensor: + """[B, N, 3, S, S] (or [B, 3, S, S] = one patch each) -> the mean logit over each sample's patches, [B, 1].""" + if images.dim() == 4: + images = images.unsqueeze(1) + b, n = images.shape[:2] + patches = images.flatten(0, 1) + step = chunk if chunk > 0 else len(patches) + logits = torch.cat([net_forward(patches[i:i + step]) for i in range(0, len(patches), step)]) # [B*N, 1] + return logits.view(b, n, -1).mean(dim=1) + + +def bce_loss(model, batch): + images, labels = batch[0], batch[1] + logits = model.forward(images)[:, 0] + loss = F.binary_cross_entropy_with_logits(logits, labels.to(logits.dtype)) + # Two-column [-logit, logit] so the trainer's metrics (argmax / softmax[:, 1]) read the single logit right. + return {"loss": loss, "outputs": torch.stack([-logits, logits], dim=1)} + + +class SynthScopePROBEModel(dino_classifier): + """PROBE-DINOv2: the official ``dino_classifier``, configured from SynthScope's ModelConfig.""" + + def __init__(self, config: DictConfig): + mc = config.ModelConfig + # backbone_path null: build DINOv2-reg ViT-L/14 from its config (the weights come from probe.pth); a HF-format + # directory or hub id loads pretrained weights, as the official model_name. + backbone_path = mc.get("backbone_path") + # backbone_config: overrides of the ViT-L config fields (e.g. a tiny backbone for the smoke test). + backbone_config = dict(DINOV2_REG_LARGE, **dict(mc.get("backbone_config") or {})) + super().__init__(model_name=str(backbone_path) if backbone_path else backbone_config, + classifier_type=mc.get("classifier_type", "linear")) + self.patch_chunk_size = int(mc.get("patch_chunk_size", 0) or 0) + + def forward(self, images): + """[B, N, 3, S, S] normalized patches (or [B, 3, S, S]) -> mean patch logit [B, 1].""" + return mean_patch_logits(super().forward, images, self.patch_chunk_size) + + def compute_loss(self, batch): + return bce_loss(self, batch) + + +class SynthScopePROBEResNetModel(ResNet): + """PROBE-ResNet50: the official ``resnet50(num_classes=1, classifier_type='linear')``.""" + + def __init__(self, config: DictConfig): + mc = config.ModelConfig + super().__init__(Bottleneck, [3, 4, 6, 3], num_classes=1, classifier_type=mc.get("classifier_type", "linear")) + self.patch_chunk_size = int(mc.get("patch_chunk_size", 0) or 0) + + def forward(self, images): + """[B, N, 3, S, S] normalized patches (or [B, 3, S, S]) -> mean patch logit [B, 1].""" + return mean_patch_logits(super().forward, images, self.patch_chunk_size) + + def compute_loss(self, batch): + return bce_loss(self, batch) + diff --git a/models/video/waverep/README.md b/models/video/waverep/README.md new file mode 100644 index 0000000000000000000000000000000000000000..0135c1811a31d6c4cbb18c50f90c943bcd124234 --- /dev/null +++ b/models/video/waverep/README.md @@ -0,0 +1,266 @@ +# WaveRep (`waverep`, `waverep_g4`) + +**Seeing What Matters: Generalizable AI-generated Video Detection with Forensic-Oriented Augmentation** (Corvi, +Cozzolino, Prashnani, De Mello, Nagano, Verdoliva; NeurIPS 2025) — +[paper (arXiv 2506.16802)](https://arxiv.org/abs/2506.16802) · +[official code](https://github.com/grip-unina/WaveRep-SyntheticVideoDetection) · +[project page](https://grip-unina.github.io/WaveRep-SyntheticVideoDetection/) + +A video detector built from an image backbone. A DINOv2 ViT-B/14 with registers is fine-tuned end to end on single +video frames. The method's contribution is the training data and an augmentation, not the architecture: in a wavelet +decomposition, a fake frame's low-pass and horizontal / vertical bands are replaced by those of a real frame, which steers +the detector towards the diagonal mid-high frequencies that generators leave behind and that survive compression. The +paper trains on ONE generator (Pyramid Flow) and tests on 15 unseen ones. + +Two released checkpoints, both registered: + +| key | checkpoint | trained on | +|---|---|---| +| `waverep` | `weights_dinov2_G1.ckpt` (`waverep.pth`) | "a single generator" (official demo README); we infer Pyramid Flow, the paper's detector in Tables 1-2 | +| `waverep_g4` | `weights_dinov2_G4.ckpt` (`waverep_g4.pth`) | "four generators" (official demo README; the demo's default); we infer Pyramid Flow, CogVideoX 1.5, Allegro and Open-Sora Plan, the Table 5 set | + +## Pipeline (official, reproduced exactly) + +``` +video ─ OpenCV VideoCapture, every frame in order, BGR -> RGB (official demo/utils.py ReadVideoIteratorCV) + → the first 64 frames (paper, App. D; the demo's --limit 64) + → per frame: CenterCrop(504) on the PIL frame (no resize; a smaller frame is zero-padded), ToTensor, ImageNet norm + → DINOv2 ViT-B/14 + 4 registers (timm vit_base_patch14_reg4_dinov2, img_size 504) → one logit per frame + → video logit = mean of the frame logits; P(fake) = sigmoid(logit) (logit > 0: synthetic) +``` + +Weights: `weights_dinov2_G{1,4}.ckpt` from grip.unina.it (md5 `bc9852a7…` / `8bf19e6f…`, as listed in the demo +README; sha256 `1c7566b2…a897` / `50d63904…5d53`). Each is a flat timm state dict of the full model, loaded strictly. + +## SynthScope adaptations + +| choice | reason | +|---|---| +| `SynthScopeWaveRepModel` holds the timm model as `self.model`; `registry.remap_waverep` prefixes the checkpoint keys with `model.` | The official `create_model` builds exactly this timm model and loads the checkpoint into it strictly. The remap also accepts the Lightning `{"state_dict": {"model.*"}}` form the official loader handles. | +| `pretrained_backbone: false` | The official code first downloads the timm DINOv2 weights, then overwrites every one of them with the checkpoint; building the model empty gives the same tensors without the download. | +| `official_utils.py` = the official `demo/utils.py`, verbatim | Reference for the tests and the parity check (GRIP license: nonprofit use; notices kept). SynthScope's reader `media.cv2_frames` is the same loop as `ReadVideoIteratorCV`, written out so that the package does not import pandas. | +| video sampler `cv2_frames`, `num_frames=64` | The paper scores the first 64 frames (App. D, Fig. 9). The demo scores every frame unless `--limit` is given; `dataclasses.replace(spec, num_frames=0)` reproduces that default. | +| frames scored `frame_batch` (16) at a time; the mean is taken in float64 | The demo scores one frame at a time and averages the float32 logits with pandas (float64). Batching changes the CPU logits by at most ~1e-5 (measured below) and bounds memory on long videos (`Engine.video_frame_logits` streams). | +| new transform step `center_crop_504` | torchvision `CenterCrop(504)` on the PIL frame: bit-exact with the official `CenterCrop((504, 504))`, zero padding included. | +| `compute_loss` = BCE with logits on single frames | The training code is not released (only the augmentation); no training recipe is reproduced. | + +## Fidelity check (identical to the official model) + +The unmodified official demo (`demo/main_avideo.py` @ `0fd6010`, CPU) against SynthScope's full pipeline (raw file -> +`media.cv2_frames` -> registry transform -> engine-built model, strict load -> `Engine.video_frame_logits` / +`predict_video_clip`), both checkpoints, same environment (torch 2.11, timm 1.0.27, OpenCV 4.13), on 15 videos: +GenVideo-Val (MSR-VTT reals 298×224, Sora 1280×720 × 600 frames, WildScrape `.mov` 2160×544 and `.gif`), EvalCrafter +(Hot Shot 672×384 × 8, MoonValley 1184×672 at 50 fps), VideoPhy (Dream Machine 1360×752 × 121), VidProM (ModelScope +256×256 MPEG-4 part 2, Text2Video-Zero 512×512), the demo's own two videos, and three re-encodes (VP9 `.webm`, MJPEG +`.avi`, HEVC `.mkv`); codecs H.264, MPEG-4 part 2, GIF, VP9, MJPEG, HEVC; 8 to 600 frames. + +| check | result | +|---|---| +| state dict | 177/177 tensors identical (sha256), 0 missing / 0 unexpected, no transformers key translation (timm model), both checkpoints | +| model inputs (every frame of every video) | bit-exact: same frame count, every 504×504 input tensor identical (max abs diff 0.0) | +| per-frame logits, every frame (demo default) | max abs diff 4.8e-6 (frames batched 16 at a time; the demo runs one at a time) | +| video logit / P(fake), every frame | max abs diff 6.0e-7 / 2.8e-8 | +| served protocol (first 64 frames) vs the demo with `--limit 64` | max abs logit diff 2.7e-7 | +| `frame_batch=1` (the demo's batch) vs the demo | per-frame max abs diff 1.8e-15: identical; the 4.8e-6 above is CPU batching only | + +Gate check on the demo's own videos (official demo output, logit > 0 = synthetic): `opensoraplan_-J24pksGK64_2.mp4` +4.80 (G1) / 9.33 (G4), `real_-D8sIkdnSkM_0.mp4` -9.03 / -8.49. + +**Frame decoder.** SynthScope reads frames with OpenCV exactly as the demo, so there is no decoder difference. Measured +for reference (first 64 frames, both checkpoints): the demo's alternative PyAV reader (`ReadVideoIteratorAV`) gives the +same logits on all 15 videos (diff 0.0); decord (SynthScope's sampler for image detectors on video) gives the same +logits on 13, fails on the GIF, and on the WildScrape `.mov` returns 58 frames where OpenCV and PyAV decode 52 (OpenCV +reports 58 in its header but stops reading after 52), which moves the G4 logit by 0.26 (P(fake) by 0.064). Protocol +matters too: on the 600-frame Sora clip the G4 logit is -2.61 over the first 64 frames and -1.20 over every frame. + +## Results + +**Verdict: faithful port (exact parity with the official demo, below); the paper's own benchmark is not held, so the only +paper-comparable numbers are the paper's 8 GenVideo columns, a PARTIAL comparison. `waverep` (G1, the paper's model) +reproduces 5 of those 8 cells to within about 2 points and does NOT reproduce HotShot (60.1 vs 81.4 bAcc), Show-1 (79.7 +vs 92.1) or LaVie (92.1 vs 95.5). Every other row is a zero-shot reference on a SynthScope benchmark, not a paper +reproduction.** + +Metrics: balanced accuracy at threshold 0.5 (logit 0; mean of real and fake accuracy) and AUC, the paper's metrics +(Tables 1-2: bAcc, Table 7: AUC). Protocol for every number below: the official OpenCV reader, the first 64 frames +(paper App. D), 504 centre crop, mean frame logit, fp32 (no TF32), `benchmark/bench_eval_video.py --model waverep|waverep_g4`. +SynthScope_train is "-": the paper's training code is not released (only the augmentation), so there is no SynthScope-trained model. + +### What is and is not the paper's benchmark + +| | status | +|---|---| +| The paper's own test set: 7 generators (Allegro, CogVideoX 1.5, Open-Sora Plan, Mochi-1, NOVA, Sora, FLUX), 300 prompts each (2,100 fakes), against 300 Panda-70M YouTube clips | **NOT HELD.** The fakes are downloadable from grip.unina.it, but the reals are YouTube videos that need the authors' downloader script (`yt-dlp`, cookies); we did not scrape YouTube. Without the reals there is no bAcc or AUC, so a fakes-only run would not be the paper's benchmark. | +| The 8 GenVideo generators among the paper's columns in Tables 1-2 and 7 (Crafter, Gen2, HotShot, LaVie, ModelScope, MorphStudio, Show-1, MoonValley) | **PARTIAL comparison**, below. The paper says it uses "the publicly available GenVideo dataset" and does not say which real videos it paired with each generator; SynthScope scores every generator against GenVideo-Val's own 10,000 MSR-VTT reals. | +| GenVideo-Val extras (Sora, WildScrape), VideoPhy, VidProM, EvalCrafter | zero-shot references; the paper reports none of them (its "Sora" column is its own web set, not GenVideo's) | + +### Partial comparison: the paper's 8 GenVideo generators (GenVideo-Val, full data) + +Full GenVideo-Val per generator (10,000 reals + all fakes of that generator), 64 frames. Paper = "Ours" in Table 1 (bAcc) and +Table 7 (AUC), the paper's single-generator detector (Pyramid Flow) = `waverep` (G1; the release says only "a single generator", so this identity is our inference). **G4 has no paper cell in these columns** +(Table 5 trains it on four generators and reports other test sets); its columns are for reference only, and G4 is trained on four +generators, so its numbers are not single-generator generalization. + +| Generator (n fake) | paper bAcc | G1 bAcc | G4 bAcc | paper AUC | G1 AUC | G4 AUC | +|---|---:|---:|---:|---:|---:|---:| +| Crafter (1398) | 98.3 | 98.99 | 98.90 | 99.8 | 99.90 | 99.98 | +| Gen2 (1380) | 98.8 | 99.49 | 98.90 | 100.0 | 99.99 | 99.99 | +| HotShot (700) | 81.4 | 60.10 | 83.40 | 91.0 | 75.60 | 94.15 | +| LaVie (1400) | 95.5 | 92.06 | 97.33 | 97.7 | 97.03 | 99.26 | +| ModelScope (700) | 97.1 | 95.24 | 97.54 | 99.4 | 99.31 | 99.69 | +| MorphStudio (700) | 97.0 | 97.74 | 98.61 | 99.3 | 99.74 | 99.94 | +| Show-1 (700) | 92.1 | 79.67 | 96.83 | 97.1 | 94.27 | 99.43 | +| MoonValley (626) | 98.4 | 99.12 | 98.89 | 99.9 | 99.97 | 99.98 | +| **8-generator mean** | **94.83** | **90.30** | 96.30 | **98.03** | **95.73** | 99.05 | + +Source: `repro/bench_results/waverep_genvideo_full.json` and `waverep_g4_genvideo_full.json` (`per_generator` `acc` = balanced accuracy +at 0.5, `auroc`); the paper's means are the means of its printed values. + +* **Reproduced (within about 2 points of the paper, G1):** Crafter, Gen2, MorphStudio, MoonValley (within 0.75 bAcc and 0.5 AUC), ModelScope (-1.86 bAcc, -0.09 AUC). +* **Not reproduced (G1):** HotShot -21.3 bAcc / -15.4 AUC, Show-1 -12.4 / -2.8, LaVie -3.4 / -0.7. HotShot: real accuracy 99.2, but only + 21.0% of the fakes are called fake at P >= 0.5 (Show-1: 60.1%, LaVie: 84.9%), and the AUC drops too (75.6 vs 91.0), so it is not a + threshold or calibration offset. **The cause is untested.** A different real pool or fake subset in the paper (unstated) is a possible + cause; we cannot check it. SynthScope equals the official demo on every file compared (below), so it is not the code path. +* G4 is above the paper's G1 on all 8 columns in bAcc (+0.1 to +4.7; Show-1 96.83, HotShot 83.4) and above or equal in AUC except Gen2 + (99.99 vs 100.0). +* Sora (56 fakes; G1 67.46 bAcc / 68.54 AUC, G4 76.65 / 83.61) and WildScrape (924; G1 78.87 / 86.92, G4 85.77 / 90.83) are GenVideo-Val extras with no paper cell. + +### Zero-shot reference rows (NOT paper reproductions) + +Benchmarks the paper does not report. Both keys are zero-shot on these sets, but G4 was trained on four generators (Table 5); do not +read the G4 rows as the paper's single-generator generalization. mAP (fake as positive) on full GenVideo-Val is low only because of the +10,000 : 56-1400 class imbalance; AUROC and mAP (real as positive) are not affected the same way. Means over the generators of each set. + +| Set (protocol) | gens | key | bAcc@0.5 | mAP (fake +) | mAP (real +) | mAUROC | +|---|---:|---|---:|---:|---:|---:| +| GenVideo-Val full (10,000 reals + all fakes) | 10 | `waverep` | 86.87 | 79.85 | 99.24 | 92.13 | +| | | `waverep_g4` | 93.28 | 88.88 | 99.69 | 96.69 | +| GenVideo-Val `--limit 1000` | 10 | `waverep` | 86.62 | 89.81 | 93.96 | 92.09 | +| | | `waverep_g4` | 92.65 | 94.47 | 97.33 | 96.53 | +| VideoPhy `--limit 1000` | 8 | `waverep` | 90.00 | 93.21 | 98.44 | 96.54 | +| | | `waverep_g4` | 95.73 | 98.20 | 99.74 | 99.29 | +| VidProM `--limit 1000` | 4 | `waverep` | 89.85 | 98.11 | 97.94 | 98.06 | +| | | `waverep_g4` | 95.80 | 99.29 | 99.19 | 99.25 | +| EvalCrafter (fakes vs the first 1000 GenVideo-Val MSR-VTT reals) | 14 | `waverep` | 92.84 | 96.93 | 97.39 | 97.17 | +| | | `waverep_g4` | 96.55 | 99.19 | 99.35 | 99.29 | + +Caveats: + +* `--limit 1000`: the first 1000 clips per class per generator (the D3 protocol), so exactly 1000 reals and up to 1000 fakes; the full-data GenVideo-Val row has 10,000 reals. +* **EvalCrafter has no reals of its own.** Its fakes (up to 700 per generator, 14 generators) are scored against the first 1000 GenVideo-Val MSR-VTT reals, the same for every generator; its HotShot, ModelScope, Show-1, MorphStudio and MoonValley cells equal the GenVideo `--limit 1000` cells (same videos). +* VideoPhy: 8 of its 10 generators are online (dead links skipped). VidProM: ModelScope, Pika, Text2Video-Zero and VideoCrafter2 (the first 1000 clips each; the full set is terabytes); non-commercial licence. +* **2 empty VidProM fakes are excluded** (Pika `00642_pika-9e93dcfc...`, `00891_pika-e025f9ee...`: 0-byte files in our VidProM copy, so OpenCV decodes no frame; the official demo would write NaN for them), so Pika has 998 fakes. All other sets: 0 decode failures. Per key the four per-set caches hold 37,859 entries (GenVideo-Val 18,584, VideoPhy 3,674, VidProM 5,000, EvalCrafter 10,601), i.e. 37,857 scored videos plus the 2 undecodable ones; this is a sum over sets, not a unique count (the 1000 EvalCrafter reals are the first 1000 GenVideo-Val reals). +* Weakest cells (G1): VideoPhy OpenSora 62.15 and ZeroScope 63.75 bAcc, VidProM ModelScope 71.55, GenVideo HotShot 60.10 and Sora 67.46. G4 is better on every one of these. + +Per generator (bAcc at 0.5 with real / fake accuracy in brackets; AUC): + +**GenVideo-Val full (10,000 reals + all fakes)** + +| Generator | n real / n fake | G1 bAcc (real / fake acc) | G1 AUC | G4 bAcc (real / fake acc) | G4 AUC | +|---|---|---:|---:|---:|---:| +| Crafter | 10000 / 1398 | 98.99 (99.2 / 98.8) | 99.90 | 98.90 (97.9 / 99.9) | 99.98 | +| Gen2 | 10000 / 1380 | 99.49 (99.2 / 99.8) | 99.99 | 98.90 (97.9 / 99.9) | 99.99 | +| HotShot | 10000 / 700 | 60.10 (99.2 / 21.0) | 75.60 | 83.40 (97.9 / 68.9) | 94.15 | +| LaVie | 10000 / 1400 | 92.06 (99.2 / 84.9) | 97.03 | 97.33 (97.9 / 96.7) | 99.26 | +| ModelScope | 10000 / 700 | 95.24 (99.2 / 91.3) | 99.31 | 97.54 (97.9 / 97.1) | 99.69 | +| MoonValley | 10000 / 626 | 99.12 (99.2 / 99.0) | 99.97 | 98.89 (97.9 / 99.8) | 99.98 | +| MorphStudio | 10000 / 700 | 97.74 (99.2 / 96.3) | 99.74 | 98.61 (97.9 / 99.3) | 99.94 | +| Show-1 | 10000 / 700 | 79.67 (99.2 / 60.1) | 94.27 | 96.83 (97.9 / 95.7) | 99.43 | +| Sora | 10000 / 56 | 67.46 (99.2 / 35.7) | 68.54 | 76.65 (97.9 / 55.4) | 83.61 | +| WildScrape | 10000 / 924 | 78.87 (99.2 / 58.5) | 86.92 | 85.77 (97.9 / 73.6) | 90.83 | +| **mean** | | **86.87** | 92.13 | **93.28** | 96.69 | + +**VideoPhy `--limit 1000`** + +| Generator | n real / n fake | G1 bAcc (real / fake acc) | G1 AUC | G4 bAcc (real / fake acc) | G4 AUC | +|---|---|---:|---:|---:|---:| +| Dream-Machine | 1000 / 339 | 99.50 (99.3 / 99.7) | 99.98 | 98.40 (96.8 / 100.0) | 100.00 | +| Gen-2 | 1000 / 312 | 99.65 (99.3 / 100.0) | 99.99 | 98.40 (96.8 / 100.0) | 100.00 | +| LaVie | 1000 / 343 | 98.48 (99.3 / 97.7) | 99.88 | 98.40 (96.8 / 100.0) | 99.96 | +| OpenSora | 1000 / 344 | 62.15 (99.3 / 25.0) | 88.55 | 83.43 (96.8 / 70.1) | 96.20 | +| Pika | 1000 / 304 | 99.32 (99.3 / 99.3) | 99.94 | 98.40 (96.8 / 100.0) | 99.99 | +| SVD | 1000 / 344 | 98.34 (99.3 / 97.4) | 99.67 | 98.40 (96.8 / 100.0) | 99.99 | +| VideoCrafter2 | 1000 / 344 | 98.78 (99.3 / 98.3) | 99.91 | 98.25 (96.8 / 99.7) | 99.96 | +| ZeroScope | 1000 / 344 | 63.75 (99.3 / 28.2) | 84.42 | 92.15 (96.8 / 87.5) | 98.22 | +| **mean** | | **90.00** | 96.54 | **95.73** | 99.29 | + +**VidProM `--limit 1000`** + +| Generator | n real / n fake | G1 bAcc (real / fake acc) | G1 AUC | G4 bAcc (real / fake acc) | G4 AUC | +|---|---|---:|---:|---:|---:| +| ModelScope | 1000 / 1000 | 71.55 (99.3 / 43.8) | 94.52 | 89.40 (96.8 / 82.0) | 97.59 | +| Pika | 1000 / 998 | 99.35 (99.3 / 99.4) | 99.97 | 98.35 (96.8 / 99.9) | 99.98 | +| Text2Video-Zero | 1000 / 1000 | 91.55 (99.3 / 83.8) | 98.10 | 97.35 (96.8 / 97.9) | 99.53 | +| VideoCrafter2 | 1000 / 1000 | 96.95 (99.3 / 94.6) | 99.66 | 98.10 (96.8 / 99.4) | 99.91 | +| **mean** | | **89.85** | 98.06 | **95.80** | 99.25 | + +**EvalCrafter (reals: the first 1000 GenVideo-Val MSR-VTT)** + +| Generator | n real / n fake | G1 bAcc (real / fake acc) | G1 AUC | G4 bAcc (real / fake acc) | G4 AUC | +|---|---|---:|---:|---:|---:| +| MoonValley | 1000 / 626 | 99.17 (99.3 / 99.0) | 99.97 | 98.32 (96.8 / 99.8) | 99.98 | +| floor33 | 1000 / 700 | 97.79 (99.3 / 96.3) | 99.74 | 98.04 (96.8 / 99.3) | 99.93 | +| gen2 | 1000 / 681 | 99.50 (99.3 / 99.7) | 99.99 | 98.25 (96.8 / 99.7) | 99.99 | +| gen2_december | 1000 / 699 | 99.58 (99.3 / 99.9) | 99.99 | 98.40 (96.8 / 100.0) | 100.00 | +| hotshot | 1000 / 700 | 60.15 (99.3 / 21.0) | 75.95 | 82.83 (96.8 / 68.9) | 93.75 | +| lavie-base | 1000 / 700 | 98.58 (99.3 / 97.9) | 99.83 | 98.26 (96.8 / 99.7) | 99.94 | +| lavie-interpolation | 1000 / 700 | 85.65 (99.3 / 72.0) | 94.30 | 95.26 (96.8 / 93.7) | 98.46 | +| mix-sr | 1000 / 700 | 99.58 (99.3 / 99.9) | 99.99 | 98.40 (96.8 / 100.0) | 100.00 | +| modelscope | 1000 / 700 | 95.29 (99.3 / 91.3) | 99.31 | 96.97 (96.8 / 97.1) | 99.61 | +| pika | 1000 / 697 | 96.57 (99.3 / 93.8) | 99.11 | 97.97 (96.8 / 99.1) | 99.92 | +| pika_v1_december_1 | 1000 / 700 | 97.58 (99.3 / 95.9) | 99.42 | 98.19 (96.8 / 99.6) | 99.91 | +| show_1 | 1000 / 700 | 79.72 (99.3 / 60.1) | 94.35 | 96.26 (96.8 / 95.7) | 99.35 | +| videocrafter-v1.0 | 1000 / 700 | 98.51 (99.3 / 97.7) | 99.81 | 98.26 (96.8 / 99.7) | 99.96 | +| zeroscope | 1000 / 598 | 92.12 (99.3 / 85.0) | 98.68 | 96.31 (96.8 / 95.8) | 99.32 | +| **mean** | | **92.84** | 97.17 | **96.55** | 99.29 | + +The `--limit 1000` GenVideo-Val per-generator values are in `repro/bench_results/waverep_genvideo.json` / `waverep_g4_genvideo.json`. + +### Official-demo parity on benchmark files + +The unmodified official `demo/main_directory.py` (`--limit 64`, GPU) against the SynthScope scores of the benchmark run, both +checkpoints, 180 GenVideo-Val files (the first 60 Crafter reals and the first 12 fakes of each of the 10 generators). Ours = the cached +scores of the benchmark run (RTX A5000 / RTX 6000, rounded to 6 decimals); official = DAS6 A6000. The differences are cross-device +fp32 noise, not a protocol difference. File: `repro/waverep_official_parity_genvideo180.json`. + +| checkpoint | files compared | NaN | max abs logit diff | mean abs logit diff | max abs P(fake) diff | sign agreement | +|---|---:|---:|---:|---:|---:|---:| +| G1 | 180/180 | 0 | 1.02e-05 | 1.7e-06 | 2.1e-06 | 180/180 | +| G4 | 180/180 | 0 | 1.05e-05 | 1.4e-06 | 1.0e-06 | 180/180 | + +Together with the 15-video, 6-codec check above (model inputs bit-exact, video logit max diff 6.0e-7), SynthScope's scores are the +official demo's scores, so a difference from the paper is not a difference of this port; its cause (the unstated real pairing, the +fake subset, or the paper's evaluation details) is untested. + +### Jobs and files + +Scores come from a resumable per-video cache (`bench_eval_video.py --cache-dir`, with `cache_meta.json` recording the checkpoint +sha256 `1c7566b2...a897` (G1) / `50d63904...5d53` (G4) and the preprocessing; the cache refuses a run whose setup differs). Four +sets x two keys, scored in shards: IVI 285376_0 (cn027), 285390_3 and 285390_4 (cn031), 285389_2 and its remainder 285886_2, DAS6 +67328 and its remainder 67404 (node409); full GenVideo-Val took about a day over three IVI GPUs and one DAS6 node. Aggregation: IVI +286053, re-run as 286059 after the cache-identity fix with identical means (CPU, `--cache-only`). Official-demo parity: DAS6 67291. +Task 1 parity: IVI 285339 (official side) and 285342. Logs: `repro/logs/waverep_*`. Result JSONs: `repro/bench_results/waverep[_g4]_{genvideo_full,genvideo,videophy,vidprom,evalcrafter}.json`; +website data: `repro/benchmark_specs/waverep.json`, `waverep_g4.json`. + +## Availability + +Space: pending user approval. It requires uploading `weights_dinov2_G{1,4}.ckpt` to the hub repo (a decision for the maintainer, +under the GRIP non-profit licence below), and a clip costs about 30 s on the Space's CPU (up to 64 ViT-B/14 forwards at 504 px). +For that reason the keys are not in `deploy/hf-space/fetch_weights.py`. +Not in the model zoo: place the checkpoints under `$SYNTHSCOPE_CKPT_DIR` as `waverep.pth` / `waverep_g4.pth`. + +## License + +GRIP-UNINA license (`LICENSE.md` of the official repository): free for informational and nonprofit purposes only, +original notices kept, and the authors credited whenever results are made public. The checkpoints (distributed by GRIP +alongside the code) are treated as covered by the same terms, as for B-Free. Citation (official, from the project page): + +``` +@InProceedings{corvi2025seeing, + title = {Seeing What Matters: Generalizable AI-generated Video Detection with Forensic-Oriented Augmentation}, + author = {Riccardo Corvi and Davide Cozzolino and Ekta Prashnani and Shalini De Mello and Koki Nagano and Luisa Verdoliva}, + booktitle = {The Thirty-ninth Annual Conference on Neural Information Processing Systems}, + year = {2025}, + url = {https://openreview.net/forum?id=dOGXKBL7IE} +} +``` diff --git a/models/video/waverep/__init__.py b/models/video/waverep/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/models/video/waverep/official_utils.py b/models/video/waverep/official_utils.py new file mode 100644 index 0000000000000000000000000000000000000000..cb13f642ccd9ee930a870d629f5b32b4e81153ac --- /dev/null +++ b/models/video/waverep/official_utils.py @@ -0,0 +1,199 @@ +# Vendored from github.com/grip-unina/WaveRep-SyntheticVideoDetection @ 0fd6010 (GRIP-UNINA license: informational and +# nonprofit use only; reproduction must keep the original notices and credit the authors, see the repository's +# LICENSE.md and https://www.grip.unina.it/download/LICENSE_OPEN.txt), file demo/utils.py. Unchanged below this header. +# SynthScope uses ReadVideoIteratorCV (the demo's frame reader) for the `waverep` video protocol (interface/backend/ +# media.py) and create_transform / evaluate as the reference in tests; the model itself is the timm ViT built in +# waverep.py, which is what create_model builds. +# +# Copyright (c) 2025 Image Processing Research Group of University Federico II of Naples ('GRIP-UNINA'). +# All rights reserved. +# This work should only be used for nonprofit purposes. + +import torch # torch>=2.0.1 +import timm # timm>=1.0.12 +import pandas +import numpy as np +from PIL import Image +import tqdm + +def create_transform(cropping): + import torchvision.transforms as transforms + t = transforms.Compose([ + transforms.CenterCrop((cropping, cropping)), + transforms.ToTensor(), + transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]), + ]) + return t + + +def create_model(weights, arc, cropping, device): + # create model + model = timm.create_model(arc, num_classes=1, pretrained=True, img_size=cropping) + model = model.to(device) + + # load weights + print('loading the model from %s' % weights) + dat = torch.load(weights, map_location=device) + if 'state_dict' in dat: + dat = {k[6:]: dat['state_dict'][k] for k in dat['state_dict'] if k.startswith('model')} + model.load_state_dict(dat) + del dat + + return model + + +class ReadVideoIteratorCV: + def __init__(self, video_path, transform=None, limit=None): + """ + Args: + video_path (str): Path to video file. + transform (callable, optional): Transform to apply to each frame. + """ + self.video_path = video_path + self.transform = transform + self.limit = limit + + def __len__(self): + import cv2 + cap = cv2.VideoCapture(self.video_path) + total_frames = int(cap.get(cv2.CAP_PROP_FRAME_COUNT)) + cap.release() + if self.limit: + total_frames = min(total_frames, self.limit) + return total_frames + + def __iter__(self): + import cv2 + cap = cv2.VideoCapture(self.video_path) + idx = 0 + while cap.isOpened(): + ret, frame = cap.read() + if not ret: + break + frame = Image.fromarray(cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)) + if self.transform: + frame = self.transform(frame) + yield idx, frame + idx = idx + 1 + if self.limit: + if idx>=self.limit: + break + cap.release() + + +class ReadVideoIteratorAV: + def __init__(self, video_fid, transform=None, limit=None): + """ + Args: + video_fid (file id): video id file. + transform (callable, optional): Transform to apply to each frame. + """ + self.video_fid = video_fid + self.transform = transform + self.limit = limit + + def __len__(self): + import av + self.video_fid.seek(0) + container = av.open(self.video_fid) + total_frames = container.streams.video[0].frames + container.close() + if self.limit: + total_frames = min(total_frames, self.limit) + return total_frames + + def __iter__(self): + import av + self.video_fid.seek(0) + container = av.open(self.video_fid) + for idx, frame in enumerate(container.decode(video=0)): + if self.limit: + if idx>=self.limit: + break + frame = frame.to_image().convert('RGB') + if self.transform: + frame = self.transform(frame) + yield idx, frame + container.close() + + +class BatchIterator: + def __init__(self, source, batch_size): + self.source = source + self.batch_size = max(batch_size, 1) + + def __len__(self): + len_source = len(self.source) + if (len_source % self.batch_size) == 0: + return len_source // self.batch_size + else: + return len_source // self.batch_size + 1 + + def __iter__(self): + list_dat = list() + list_idx = list() + for idx, dat in self.source: + list_dat.append(dat) + list_idx.append(idx) + if len(list_dat)>=self.batch_size: + yield list_idx, torch.stack(list_dat, 0) + list_dat = list() + list_idx = list() + if len(list_dat)>0: + yield list_idx, torch.stack(list_dat, 0) + + +class ClipIterator: + def __init__(self, reader, num_frames, stride=None): + """ + Args: + reader: reader video. + num_frames (int): number of frames in a clip + stride (int): stride between clips + """ + self.reader = reader + self.num_frames = max(num_frames, 1) + self.stride = max(stride, 1) if stride else self.num_frames + assert self.stride<=self.num_frames + + def __len__(self): + len_video = len(self.reader) + if len_video < self.num_frames: + return 0 + else: + return (len_video - self.num_frames) // self.stride + 1 + + def __iter__(self): + list_frame = list() + list_idx = list() + for idx, frame in self.reader: + list_frame.append(frame) + list_idx.append(idx) + if len(list_frame)>=self.num_frames: + yield list_idx[len(list_idx)//2], torch.stack(list_frame, 1) + list_frame = list_frame[self.stride:] + list_idx = list_idx[self.stride:] + + +def evaluate(model, data_loader, device): + list_out = list() + with torch.no_grad(): + model = model.eval() + pbar = tqdm.tqdm(data_loader) + for idx, frame in pbar: + pred = model(frame[None, ...].to(device))[0, -1].item() + list_out.append({'index': idx, 'logit': pred}) + pbar.set_description('logit=%f' % pred) + return pandas.DataFrame(list_out) + + +def evaluate_batch(model, data_loader, device): + list_out = list() + with torch.no_grad(): + model = model.eval() + for idxs, frames in data_loader: + preds = model(frames.to(device))[:, -1].cpu().numpy() + for idx, pred in zip(idxs, preds): + list_out.append({'index': idx, 'logit': pred}) + return pandas.DataFrame(list_out) + diff --git a/models/video/waverep/waverep.py b/models/video/waverep/waverep.py new file mode 100644 index 0000000000000000000000000000000000000000..c64dcdc3df1e5b736d0bf9eabca6b03213d6cc94 --- /dev/null +++ b/models/video/waverep/waverep.py @@ -0,0 +1,68 @@ +"""WaveRep (Corvi et al., "Seeing What Matters: Generalizable AI-generated Video Detection with Forensic-Oriented +Augmentation", NeurIPS 2025). + +Official repo: github.com/grip-unina/WaveRep-SyntheticVideoDetection (GRIP-UNINA license: informational and nonprofit +use only). The detector is a DINOv2 ViT-B/14 with four registers (timm ``vit_base_patch14_reg4_dinov2.lvd142m``) at a +504x504 input, fine-tuned end to end frame by frame with one output logit; the method's contribution is the training +data and a wavelet-band augmentation, not the architecture. A video is scored frame by frame (official demo/utils.py): + + x_t = CenterCrop(504)(frame_t) -> ToTensor -> ImageNet Normalize # no resize; smaller frames are zero-padded + logit = vit(x_t)[:, -1] # one logit per frame + score = mean over the frames of the video; P(fake) = sigmoid(score) + +``SynthScopeWaveRepModel`` holds the timm model exactly as the official ``create_model`` builds it +(``timm.create_model(arc, num_classes=1, img_size=504)``) as ``self.model``; the released ``weights_dinov2_G{1,4}.ckpt`` +are flat timm state dicts that the official code loads strictly, and ``registry.remap_waverep`` puts them under +``model.``. ``pretrained_backbone`` (default false) only matters for training: the official code starts from the timm +DINOv2 weights, which every checkpoint key then overwrites. + +Input contract: ``forward`` takes ImageNet-normalized [B, 3, 504, 504] frames (the registry transform: +``center_crop_504``, ``to_dtype``, ``normalize_imagenet``) -> [B] logits, or [B, T, 3, 504, 504] clips -> the mean of +their T frame logits, computed ``frame_batch`` frames at a time. + +Training: the official training code is not released (only the augmentation, augmentation/pytorch_wt.py); +``compute_loss`` is binary cross-entropy with logits on single frames, and its ``outputs`` are the two columns +[-logit, logit], the repo convention for single-logit detectors. No training recipe is reproduced here. +""" +import timm +import torch +import torch.nn as nn +from omegaconf import DictConfig + +# The official demo's arch string (demo/main_avideo.py: arc, cropping). +TIMM_ARCH = "vit_base_patch14_reg4_dinov2.lvd142m" +CROP_SIZE = 504 + + +class SynthScopeWaveRepModel(nn.Module): + """WaveRep's frame-level detector, configured from SynthScope's ModelConfig.""" + + def __init__(self, config: DictConfig): + super().__init__() + mc = config.ModelConfig + self.model = timm.create_model(mc.get("timm_arch", TIMM_ARCH), num_classes=1, + pretrained=bool(mc.get("pretrained_backbone", False)), + img_size=int(mc.get("crop_size", CROP_SIZE))) + self.frame_batch = int(mc.get("frame_batch", 16)) # frames per forward pass when scoring a clip + self.criterion = nn.BCEWithLogitsLoss() + + def frame_logits(self, frames: torch.Tensor) -> torch.Tensor: + """[N, 3, H, W] normalized frames -> [N] logits: the official ``model(x)[:, -1]``.""" + return self.model(frames)[:, -1] + + def forward(self, images: torch.Tensor) -> torch.Tensor: + """[B, 3, H, W] -> [B] frame logits, or [B, T, 3, H, W] -> [B] mean frame logit per clip (official evaluate + + ``tab['logit'].mean()``).""" + if images.dim() == 4: + return self.frame_logits(images) + b, t = images.shape[:2] + frames = images.flatten(0, 1) + logits = torch.cat([self.frame_logits(chunk) for chunk in frames.split(self.frame_batch)]) + return logits.view(b, t).double().mean(dim=1).to(logits.dtype) + + def compute_loss(self, batch): + images, labels = batch[0], batch[1] + logits = self.forward(images) + loss = self.criterion(logits, labels.to(logits.dtype)) + # Two-column [-logit, logit] so the trainer's metrics (argmax / softmax[:, 1]) read the single logit right. + return {"loss": loss, "outputs": torch.stack([-logits, logits], dim=1)} diff --git a/pyproject.toml b/pyproject.toml index 7274639c6150ac64dac0af9ef0efed3454c08fdf..7294acd08229e6aafbe432dab2f0b107be6f415b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -54,14 +54,17 @@ dependencies = [ # FastAPI + React web demo (interface/). Not imported by `import synthscope`. web = ["fastapi>=0.110", "uvicorn[standard]>=0.27", "python-multipart>=0.0.9"] # Training + dataset auto-download stack. -train = ["wandb>=0.16", "gdown>=5", "albumentations==1.4.14", "albucore==0.0.16"] # albumentations: SPAI's official augmentations +train = ["wandb>=0.16", "gdown>=5", "albumentations==1.4.14", "albucore==0.0.16", "kornia==0.7.2"] # albumentations: SPAI's official augmentations; kornia: AIDE's (aide_blur, aide_jpeg) +# Benchmark scripts (benchmark/bench_eval_video.py, benchmark/generator_bench.py): exact AUROC / AP on float64 logits. +bench = ["scikit-learn>=1.0"] # Gradio demo (demo/app.py, Hugging Face Spaces). demo = ["gradio>=4"] # Tooling for contributors / CI. dev = ["ruff>=0.4", "pytest>=7", "build>=1", "twine>=5"] all = [ "fastapi>=0.110", "uvicorn[standard]>=0.27", "python-multipart>=0.0.9", - "wandb>=0.16", "gdown>=5", "albumentations==1.4.14", "albucore==0.0.16", "gradio>=4", + "wandb>=0.16", "gdown>=5", "albumentations==1.4.14", "albucore==0.0.16", "kornia==0.7.2", "gradio>=4", + "scikit-learn>=1.0", ] [project.urls] diff --git a/repro/AGGREGATED_BENCHMARK.md b/repro/AGGREGATED_BENCHMARK.md index 7ea29d820e0fefea3a932ae5388e7b19a0691cad..fe5ce6115cd2783d70c2f858870eaea6bbadd45d 100644 --- a/repro/AGGREGATED_BENCHMARK.md +++ b/repro/AGGREGATED_BENCHMARK.md @@ -27,7 +27,7 @@ Values are `mAP (acc)` or AUROC as noted. **Status:** reproduced = SynthScope_tr | NPR | Table 4 — UniversalFakeDetect / Ojha | acc=95.2 | mAP=97.16 / acc=94.57 | — | official | | NPR | Table 5 — Diffusion1kStep | acc=80.1 | mAP=83.47 / acc=79.13 | — | official | | AIDE | AIGCDetectBenchmark (B1, ProGAN-trained) | acc=92.77 | mAP=97.94 / acc=91.89 | — | official | -| AIDE | GenImage (B2, SDv1.4-trained) | acc=86.88 | mAP=97.12 / acc=85.91 | mAP=96.42 / acc=77.9 | official | +| AIDE | GenImage (B2, SDv1.4-trained) | acc=86.88 | mAP=97.12 / acc=85.91 | mAP=93.90 / acc=80.73 | official (trained: below the paper) | | AIDE | Chameleon (B3, in-the-wild) | acc=58–66 | — | — | missing | | SAFE | ForenSynths-8 (Table 1, intra-arch GANs) | map=98.8 / acc=96.2 | mAP=98.78 / acc=96.2 | mAP=97.79 / acc=95.1 | reproduced | | SAFE | Self-Synthesis / GANGen (Table 2) | map=99.8 / acc=99.0 | mAP=99.85 / acc=99.0 | not re-run (data offline) | official | diff --git a/repro/MASTER_RESULTS.jsonl b/repro/MASTER_RESULTS.jsonl index 292438a78c2cb5b645bc061cb3a82988be0e1a99..0ca6724f523f0a0dd63f109ae8c0a8eaec61125b 100644 --- a/repro/MASTER_RESULTS.jsonl +++ b/repro/MASTER_RESULTS.jsonl @@ -467,6 +467,83 @@ {"date": "2026-11-08T19:48:14", "tag": "vina_rrdataset_offmetric", "model": "vina", "ckpt": "registry-default", "benchmark": "official-metrics:rrdataset", "data_root": "/ssdstore/ssalehi/SynthScope/RRDataset/test", "n_generators": 3, "means": {"acc": 82.89, "map": 92.77, "bacc": 82.9, "mauroc": 91.69}} {"date": "2026-11-08T19:48:22", "tag": "vina_arforensics_offmetric", "model": "vina", "ckpt": "registry-default", "benchmark": "official-metrics:arforensics", "data_root": "/local/ssalehid/cache/data029/ARForensics/test", "n_generators": 6, "means": {"acc": 96.36, "map": 99.54, "bacc": 96.36, "mauroc": 99.38}} {"date": "2026-11-08T19:48:24", "tag": "vina_genimage_val100k_offmetric", "model": "vina", "ckpt": "registry-default", "benchmark": "official-metrics:genimage", "data_root": "/local/ssalehid/cache/data029/GenImage_val_full/test", "n_generators": 8, "means": {"acc": 94.74, "map": 99.05, "bacc": 94.74, "mauroc": 98.72}} +{"date": "2026-11-09T05:48:29", "tag": "cure_trained_aigibench20_full", "model": "cure", "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_trained/cure_trained.pth", "benchmark": "pergen", "data_root": "/local/ssalehid/cache/data023/AIGIBench/test", "n_generators": 20, "means": {"acc": 85.05, "map": 92.69, "mauroc": 91.84}} +{"date": "2026-11-09T04:26:18", "tag": "cure_trained_aigcdetect", "model": "cure", "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_trained/cure_trained.pth", "benchmark": "pergen", "data_root": "/local/ssalehid/cache/data029/AIGCDetect/test", "n_generators": 17, "means": {"acc": 81.55, "map": 93.52, "mauroc": 92.22}} +{"date": "2026-11-09T03:45:31", "tag": "cure_trained_evalgen", "model": "cure", "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_trained/cure_trained.pth", "benchmark": "pergen", "data_root": "/local/ssalehid/cache/data029/EvalGEN/test", "n_generators": 5, "means": {"acc": 90.65, "map": 98.3, "mauroc": 95.96}} +{"date": "2026-11-09T04:02:07", "tag": "cure_trained_realchain", "model": "cure", "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_trained/cure_trained.pth", "benchmark": "pergen", "data_root": "/local/ssalehid/cache/data029/RealChain/test", "n_generators": 7, "means": {"acc": 63.33, "map": 79.6, "mauroc": 76.5}} +{"date": "2026-11-09T03:41:15", "tag": "cure_trained_rrdataset", "model": "cure", "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_trained/cure_trained.pth", "benchmark": "pergen", "data_root": "/local/ssalehid/cache/data029/RRDataset/test", "n_generators": 3, "means": {"acc": 66.36, "map": 80.4, "mauroc": 76.87}} +{"date": "2026-11-09T02:41:43", "tag": "cure_trained_synthwildx", "model": "cure", "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_trained/cure_trained.pth", "benchmark": "pergen", "data_root": "/local/ssalehid/cache/data029/SynthWildX/test", "n_generators": 3, "means": {"acc": 76.11, "map": 88.83, "mauroc": 86.84}} +{"date": "2026-11-09T02:49:08", "tag": "cure_trained_wildrf", "model": "cure", "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_trained/cure_trained.pth", "benchmark": "pergen", "data_root": "/local/ssalehid/cache/data029/WildRF/test", "n_generators": 3, "means": {"acc": 85.8, "map": 95.0, "mauroc": 94.59}} +{"date": "2026-11-09T02:50:24", "tag": "cure_trained_bfree_online", "model": "cure", "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_trained/cure_trained.pth", "benchmark": "pergen", "data_root": "/local/ssalehid/cache/data029/BFreeOnline/test", "n_generators": 1, "means": {"acc": 66.64, "map": 93.37, "mauroc": 85.77}} +{"date": "2026-11-09T02:44:02", "tag": "cure_trained_ufd", "model": "cure", "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_trained/cure_trained.pth", "benchmark": "ufd", "data_root": "/local/ssalehid/cache/data023/universialfakedetection/test", "n_generators": 8, "means": {"acc": 82.69, "map": 95.26, "mauroc": 93.85}} +{"date": "2026-11-09T03:02:45", "tag": "cure_trained_genimage8", "model": "cure", "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_trained/cure_trained.pth", "benchmark": "pergen", "data_root": "/local/ssalehid/cache/data023/GenImage_full/test", "n_generators": 8, "means": {"acc": 77.7, "map": 89.41, "mauroc": 87.88}} +{"date": "2026-11-09T03:55:50", "tag": "cure_trained_forensynths", "model": "cure", "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_trained/cure_trained.pth", "benchmark": "forensynths", "data_root": "/local/ssalehid/cache/data023/CNNDetection/test", "n_generators": 13, "means": {"acc": 75.83, "map": 94.24, "mauroc": 93.56}} +{"date": "2026-11-09T06:36:39", "tag": "cure_hybA_bfree_online", "model": "cure", "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_trained/hybrid/A_trainedLoRA_releasedSubspaceHead.pth", "benchmark": "pergen", "data_root": "/local/ssalehid/cache/data029/BFreeOnline/test", "n_generators": 1, "means": {"acc": 48.61, "map": 66.62, "mauroc": 38.67}} +{"date": "2026-11-09T06:40:23", "tag": "cure_hybA_synthwildx", "model": "cure", "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_trained/hybrid/A_trainedLoRA_releasedSubspaceHead.pth", "benchmark": "pergen", "data_root": "/local/ssalehid/cache/data029/SynthWildX/test", "n_generators": 3, "means": {"acc": 35.0, "map": 35.29, "mauroc": 16.34}} +{"date": "2026-11-09T06:45:21", "tag": "cure_hybA_wildrf", "model": "cure", "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_trained/hybrid/A_trainedLoRA_releasedSubspaceHead.pth", "benchmark": "pergen", "data_root": "/local/ssalehid/cache/data029/WildRF/test", "n_generators": 3, "means": {"acc": 35.05, "map": 33.37, "mauroc": 11.72}} +{"date": "2026-11-09T07:14:21", "tag": "cure_hybA_rrdataset", "model": "cure", "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_trained/hybrid/A_trainedLoRA_releasedSubspaceHead.pth", "benchmark": "pergen", "data_root": "/local/ssalehid/cache/data029/RRDataset/test", "n_generators": 3, "means": {"acc": 33.17, "map": 39.18, "mauroc": 25.55}} +{"date": "2026-11-09T06:36:41", "tag": "cure_hybB_bfree_online", "model": "cure", "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_trained/hybrid/B_releasedLoRA_trainedSubspaceHead.pth", "benchmark": "pergen", "data_root": "/local/ssalehid/cache/data029/BFreeOnline/test", "n_generators": 1, "means": {"acc": 43.68, "map": 46.21, "mauroc": 6.53}} +{"date": "2026-11-09T06:40:24", "tag": "cure_hybB_synthwildx", "model": "cure", "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_trained/hybrid/B_releasedLoRA_trainedSubspaceHead.pth", "benchmark": "pergen", "data_root": "/local/ssalehid/cache/data029/SynthWildX/test", "n_generators": 3, "means": {"acc": 38.44, "map": 32.36, "mauroc": 5.17}} +{"date": "2026-11-09T06:45:21", "tag": "cure_hybB_wildrf", "model": "cure", "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_trained/hybrid/B_releasedLoRA_trainedSubspaceHead.pth", "benchmark": "pergen", "data_root": "/local/ssalehid/cache/data029/WildRF/test", "n_generators": 3, "means": {"acc": 40.5, "map": 31.25, "mauroc": 3.35}} +{"date": "2026-11-09T07:14:20", "tag": "cure_hybB_rrdataset", "model": "cure", "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_trained/hybrid/B_releasedLoRA_trainedSubspaceHead.pth", "benchmark": "pergen", "data_root": "/local/ssalehid/cache/data029/RRDataset/test", "n_generators": 3, "means": {"acc": 43.15, "map": 33.0, "mauroc": 12.87}} +{"date": "2026-11-09T07:29:13", "tag": "cure_relS23_bfree_online", "model": "cure", "ckpt": "/local/ssalehid/66726/relS23/cure_trained.pth", "benchmark": "pergen", "data_root": "/local/ssalehid/cache/data029/BFreeOnline/test", "n_generators": 1, "means": {"acc": 91.08, "map": 99.11, "mauroc": 98.25}} +{"date": "2026-11-09T07:32:03", "tag": "cure_relS23_synthwildx", "model": "cure", "ckpt": "/local/ssalehid/66726/relS23/cure_trained.pth", "benchmark": "pergen", "data_root": "/local/ssalehid/cache/data029/SynthWildX/test", "n_generators": 3, "means": {"acc": 92.65, "map": 95.41, "mauroc": 96.32}} +{"date": "2026-11-09T07:36:08", "tag": "cure_relS23_wildrf", "model": "cure", "ckpt": "/local/ssalehid/66726/relS23/cure_trained.pth", "benchmark": "pergen", "data_root": "/local/ssalehid/cache/data029/WildRF/test", "n_generators": 3, "means": {"acc": 95.45, "map": 98.94, "mauroc": 98.99}} +{"date": "2026-11-09T08:01:04", "tag": "cure_relS23_rrdataset", "model": "cure", "ckpt": "/local/ssalehid/66726/relS23/cure_trained.pth", "benchmark": "pergen", "data_root": "/local/ssalehid/cache/data029/RRDataset/test", "n_generators": 3, "means": {"acc": 81.04, "map": 88.46, "mauroc": 86.84}} +{"date": "2026-11-10T11:43:34", "tag": "cure_trained_r1e0_aigibench20_full", "model": "cure", "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_s1inv/s23_r1e0/cure_trained.pth", "benchmark": "pergen", "data_root": "/local/ssalehid/cache/data023/AIGIBench/test", "n_generators": 20, "means": {"acc": 88.85, "map": 95.17, "mauroc": 95.86}} +{"date": "2026-11-10T11:43:34", "tag": "cure_trained_r2e1_aigibench20_full", "model": "cure", "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_s1inv/s23mc_r2e1/cure_trained.pth", "benchmark": "pergen", "data_root": "/local/ssalehid/cache/data023/AIGIBench/test", "n_generators": 20, "means": {"acc": 88.81, "map": 95.3, "mauroc": 95.78}} +{"date": "2026-11-10T11:43:26", "tag": "cure_trained_r2_aigibench20_full", "model": "cure", "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_s1inv/s23mc_r2e4/cure_trained.pth", "benchmark": "pergen", "data_root": "/local/ssalehid/cache/data023/AIGIBench/test", "n_generators": 20, "means": {"acc": 87.1, "map": 93.72, "mauroc": 93.73}} +{"date": "2026-11-10T09:54:09", "tag": "cure_trained_r1e0_aigcdetect", "model": "cure", "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_s1inv/s23_r1e0/cure_trained.pth", "benchmark": "pergen", "data_root": "/local/ssalehid/cache/data029/AIGCDetect/test", "n_generators": 17, "means": {"acc": 92.25, "map": 98.61, "mauroc": 98.47}} +{"date": "2026-11-10T09:54:09", "tag": "cure_trained_r2e1_aigcdetect", "model": "cure", "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_s1inv/s23mc_r2e1/cure_trained.pth", "benchmark": "pergen", "data_root": "/local/ssalehid/cache/data029/AIGCDetect/test", "n_generators": 17, "means": {"acc": 88.2, "map": 97.99, "mauroc": 97.84}} +{"date": "2026-11-10T09:54:09", "tag": "cure_trained_r2_aigcdetect", "model": "cure", "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_s1inv/s23mc_r2e4/cure_trained.pth", "benchmark": "pergen", "data_root": "/local/ssalehid/cache/data029/AIGCDetect/test", "n_generators": 17, "means": {"acc": 82.29, "map": 95.21, "mauroc": 94.4}} +{"date": "2026-11-10T08:36:00", "tag": "cure_trained_r1e0_forensynths", "model": "cure", "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_s1inv/s23_r1e0/cure_trained.pth", "benchmark": "forensynths", "data_root": "/local/ssalehid/cache/data023/CNNDetection/test", "n_generators": 13, "means": {"acc": 89.79, "map": 97.6, "mauroc": 97.15}} +{"date": "2026-11-10T08:36:00", "tag": "cure_trained_r2e1_forensynths", "model": "cure", "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_s1inv/s23mc_r2e1/cure_trained.pth", "benchmark": "forensynths", "data_root": "/local/ssalehid/cache/data023/CNNDetection/test", "n_generators": 13, "means": {"acc": 84.26, "map": 96.41, "mauroc": 96.16}} +{"date": "2026-11-10T08:36:04", "tag": "cure_trained_r2_forensynths", "model": "cure", "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_s1inv/s23mc_r2e4/cure_trained.pth", "benchmark": "forensynths", "data_root": "/local/ssalehid/cache/data023/CNNDetection/test", "n_generators": 13, "means": {"acc": 74.35, "map": 95.43, "mauroc": 95.4}} +{"date": "2026-11-10T10:22:42", "tag": "cure_trained_r1e0_evalgen", "model": "cure", "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_s1inv/s23_r1e0/cure_trained.pth", "benchmark": "pergen", "data_root": "/local/ssalehid/cache/data029/EvalGEN/test", "n_generators": 5, "means": {"acc": 91.57, "map": 99.34, "mauroc": 98.63}} +{"date": "2026-11-10T10:22:41", "tag": "cure_trained_r2e1_evalgen", "model": "cure", "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_s1inv/s23mc_r2e1/cure_trained.pth", "benchmark": "pergen", "data_root": "/local/ssalehid/cache/data029/EvalGEN/test", "n_generators": 5, "means": {"acc": 93.98, "map": 99.63, "mauroc": 99.17}} +{"date": "2026-11-10T10:22:42", "tag": "cure_trained_r2_evalgen", "model": "cure", "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_s1inv/s23mc_r2e4/cure_trained.pth", "benchmark": "pergen", "data_root": "/local/ssalehid/cache/data029/EvalGEN/test", "n_generators": 5, "means": {"acc": 92.45, "map": 99.08, "mauroc": 97.9}} +{"date": "2026-11-10T11:01:39", "tag": "cure_trained_r1e0_rrdataset", "model": "cure", "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_s1inv/s23_r1e0/cure_trained.pth", "benchmark": "pergen", "data_root": "/local/ssalehid/cache/data029/RRDataset/test", "n_generators": 3, "means": {"acc": 72.62, "map": 85.87, "mauroc": 85.25}} +{"date": "2026-11-10T11:01:38", "tag": "cure_trained_r2e1_rrdataset", "model": "cure", "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_s1inv/s23mc_r2e1/cure_trained.pth", "benchmark": "pergen", "data_root": "/local/ssalehid/cache/data029/RRDataset/test", "n_generators": 3, "means": {"acc": 72.65, "map": 86.06, "mauroc": 84.82}} +{"date": "2026-11-10T11:01:38", "tag": "cure_trained_r2_rrdataset", "model": "cure", "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_s1inv/s23mc_r2e4/cure_trained.pth", "benchmark": "pergen", "data_root": "/local/ssalehid/cache/data029/RRDataset/test", "n_generators": 3, "means": {"acc": 68.01, "map": 81.7, "mauroc": 78.57}} +{"date": "2026-11-10T10:51:09", "tag": "cure_trained_r1e0_realchain", "model": "cure", "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_s1inv/s23_r1e0/cure_trained.pth", "benchmark": "pergen", "data_root": "/local/ssalehid/cache/data029/RealChain/test", "n_generators": 7, "means": {"acc": 70.34, "map": 85.0, "mauroc": 84.87}} +{"date": "2026-11-10T10:51:09", "tag": "cure_trained_r2e1_realchain", "model": "cure", "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_s1inv/s23mc_r2e1/cure_trained.pth", "benchmark": "pergen", "data_root": "/local/ssalehid/cache/data029/RealChain/test", "n_generators": 7, "means": {"acc": 72.28, "map": 85.86, "mauroc": 85.02}} +{"date": "2026-11-10T10:51:09", "tag": "cure_trained_r2_realchain", "model": "cure", "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_s1inv/s23mc_r2e4/cure_trained.pth", "benchmark": "pergen", "data_root": "/local/ssalehid/cache/data029/RealChain/test", "n_generators": 7, "means": {"acc": 67.49, "map": 83.59, "mauroc": 82.2}} +{"date": "2026-11-10T11:22:15", "tag": "cure_trained_r1e0_genimage8", "model": "cure", "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_s1inv/s23_r1e0/cure_trained.pth", "benchmark": "pergen", "data_root": "/local/ssalehid/cache/data023/GenImage_full/test", "n_generators": 8, "means": {"acc": 86.05, "map": 97.47, "mauroc": 97.36}} +{"date": "2026-11-10T11:22:15", "tag": "cure_trained_r2e1_genimage8", "model": "cure", "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_s1inv/s23mc_r2e1/cure_trained.pth", "benchmark": "pergen", "data_root": "/local/ssalehid/cache/data023/GenImage_full/test", "n_generators": 8, "means": {"acc": 83.48, "map": 96.89, "mauroc": 96.54}} +{"date": "2026-11-10T11:22:15", "tag": "cure_trained_r2_genimage8", "model": "cure", "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_s1inv/s23mc_r2e4/cure_trained.pth", "benchmark": "pergen", "data_root": "/local/ssalehid/cache/data023/GenImage_full/test", "n_generators": 8, "means": {"acc": 79.89, "map": 91.78, "mauroc": 89.99}} +{"date": "2026-11-10T11:20:54", "tag": "cure_trained_r1e0_ufd", "model": "cure", "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_s1inv/s23_r1e0/cure_trained.pth", "benchmark": "ufd", "data_root": "/local/ssalehid/cache/data023/universialfakedetection/test", "n_generators": 8, "means": {"acc": 93.99, "map": 99.13, "mauroc": 98.87}} +{"date": "2026-11-10T11:20:53", "tag": "cure_trained_r2e1_ufd", "model": "cure", "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_s1inv/s23mc_r2e1/cure_trained.pth", "benchmark": "ufd", "data_root": "/local/ssalehid/cache/data023/universialfakedetection/test", "n_generators": 8, "means": {"acc": 92.14, "map": 98.86, "mauroc": 98.52}} +{"date": "2026-11-10T11:20:53", "tag": "cure_trained_r2_ufd", "model": "cure", "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_s1inv/s23mc_r2e4/cure_trained.pth", "benchmark": "ufd", "data_root": "/local/ssalehid/cache/data023/universialfakedetection/test", "n_generators": 8, "means": {"acc": 83.81, "map": 96.29, "mauroc": 94.91}} +{"date": "2026-11-10T11:27:25", "tag": "cure_trained_r1e0_wildrf", "model": "cure", "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_s1inv/s23_r1e0/cure_trained.pth", "benchmark": "pergen", "data_root": "/local/ssalehid/cache/data029/WildRF/test", "n_generators": 3, "means": {"acc": 95.23, "map": 99.14, "mauroc": 99.06}} +{"date": "2026-11-10T11:27:21", "tag": "cure_trained_r2e1_wildrf", "model": "cure", "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_s1inv/s23mc_r2e1/cure_trained.pth", "benchmark": "pergen", "data_root": "/local/ssalehid/cache/data029/WildRF/test", "n_generators": 3, "means": {"acc": 93.91, "map": 98.48, "mauroc": 98.43}} +{"date": "2026-11-10T11:27:30", "tag": "cure_trained_r2_wildrf", "model": "cure", "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_s1inv/s23mc_r2e4/cure_trained.pth", "benchmark": "pergen", "data_root": "/local/ssalehid/cache/data029/WildRF/test", "n_generators": 3, "means": {"acc": 90.24, "map": 96.22, "mauroc": 96.19}} +{"date": "2026-11-10T11:27:04", "tag": "cure_trained_r1e0_synthwildx", "model": "cure", "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_s1inv/s23_r1e0/cure_trained.pth", "benchmark": "pergen", "data_root": "/local/ssalehid/cache/data029/SynthWildX/test", "n_generators": 3, "means": {"acc": 90.99, "map": 96.88, "mauroc": 96.85}} +{"date": "2026-11-10T11:27:01", "tag": "cure_trained_r2e1_synthwildx", "model": "cure", "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_s1inv/s23mc_r2e1/cure_trained.pth", "benchmark": "pergen", "data_root": "/local/ssalehid/cache/data029/SynthWildX/test", "n_generators": 3, "means": {"acc": 88.65, "map": 95.9, "mauroc": 95.9}} +{"date": "2026-11-10T11:27:00", "tag": "cure_trained_r2_synthwildx", "model": "cure", "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_s1inv/s23mc_r2e4/cure_trained.pth", "benchmark": "pergen", "data_root": "/local/ssalehid/cache/data029/SynthWildX/test", "n_generators": 3, "means": {"acc": 81.56, "map": 92.53, "mauroc": 91.85}} +{"date": "2026-11-10T11:28:10", "tag": "cure_trained_r1e0_bfree_online", "model": "cure", "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_s1inv/s23_r1e0/cure_trained.pth", "benchmark": "pergen", "data_root": "/local/ssalehid/cache/data029/BFreeOnline/test", "n_generators": 1, "means": {"acc": 72.3, "map": 90.78, "mauroc": 81.8}} +{"date": "2026-11-10T11:28:11", "tag": "cure_trained_r2e1_bfree_online", "model": "cure", "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_s1inv/s23mc_r2e1/cure_trained.pth", "benchmark": "pergen", "data_root": "/local/ssalehid/cache/data029/BFreeOnline/test", "n_generators": 1, "means": {"acc": 74.54, "map": 94.85, "mauroc": 89.9}} +{"date": "2026-11-10T11:28:13", "tag": "cure_trained_r2_bfree_online", "model": "cure", "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_s1inv/s23mc_r2e4/cure_trained.pth", "benchmark": "pergen", "data_root": "/local/ssalehid/cache/data029/BFreeOnline/test", "n_generators": 1, "means": {"acc": 69.52, "map": 91.31, "mauroc": 81.51}} +{"date": "2026-11-10T23:28:30", "tag": "cure_trained_r3e0_aigibench20_full", "model": "cure", "ckpt": "/local/ssalehid/67200/s23_r3e0/cure_trained.pth", "benchmark": "pergen", "data_root": "/local/ssalehid/cache/data023/AIGIBench/test", "n_generators": 20, "means": {"acc": 91.12, "map": 96.72, "mauroc": 97.1}} +{"date": "2026-11-10T22:07:09", "tag": "cure_trained_r3e0_aigcdetect", "model": "cure", "ckpt": "/local/ssalehid/67200/s23_r3e0/cure_trained.pth", "benchmark": "pergen", "data_root": "/local/ssalehid/cache/data029/AIGCDetect/test", "n_generators": 17, "means": {"acc": 92.01, "map": 98.59, "mauroc": 98.38}} +{"date": "2026-11-10T21:40:42", "tag": "cure_trained_r3e0_forensynths", "model": "cure", "ckpt": "/local/ssalehid/67200/s23_r3e0/cure_trained.pth", "benchmark": "forensynths", "data_root": "/local/ssalehid/cache/data023/CNNDetection/test", "n_generators": 13, "means": {"acc": 89.36, "map": 97.22, "mauroc": 96.58}} +{"date": "2026-11-10T21:38:37", "tag": "cure_trained_r3e0_evalgen", "model": "cure", "ckpt": "/local/ssalehid/67200/s23_r3e0/cure_trained.pth", "benchmark": "pergen", "data_root": "/local/ssalehid/cache/data029/EvalGEN/test", "n_generators": 5, "means": {"acc": 93.32, "map": 99.47, "mauroc": 98.85}} +{"date": "2026-11-10T21:24:22", "tag": "cure_trained_r3e0_rrdataset", "model": "cure", "ckpt": "/local/ssalehid/67200/s23_r3e0/cure_trained.pth", "benchmark": "pergen", "data_root": "/local/ssalehid/cache/data029/RRDataset/test", "n_generators": 3, "means": {"acc": 73.46, "map": 84.91, "mauroc": 85.32}} +{"date": "2026-11-10T20:53:39", "tag": "cure_trained_r3e0_realchain", "model": "cure", "ckpt": "/local/ssalehid/67200/s23_r3e0/cure_trained.pth", "benchmark": "pergen", "data_root": "/local/ssalehid/cache/data029/RealChain/test", "n_generators": 7, "means": {"acc": 72.75, "map": 83.67, "mauroc": 84.7}} +{"date": "2026-11-10T20:53:04", "tag": "cure_trained_r3e0_genimage8", "model": "cure", "ckpt": "/local/ssalehid/67200/s23_r3e0/cure_trained.pth", "benchmark": "pergen", "data_root": "/local/ssalehid/cache/data023/GenImage_full/test", "n_generators": 8, "means": {"acc": 86.22, "map": 97.56, "mauroc": 97.59}} +{"date": "2026-11-10T20:42:48", "tag": "cure_trained_r3e0_ufd", "model": "cure", "ckpt": "/local/ssalehid/67200/s23_r3e0/cure_trained.pth", "benchmark": "ufd", "data_root": "/local/ssalehid/cache/data023/universialfakedetection/test", "n_generators": 8, "means": {"acc": 93.89, "map": 98.73, "mauroc": 98.31}} +{"date": "2026-11-10T20:32:41", "tag": "cure_trained_r3e0_wildrf", "model": "cure", "ckpt": "/local/ssalehid/67200/s23_r3e0/cure_trained.pth", "benchmark": "pergen", "data_root": "/local/ssalehid/cache/data029/WildRF/test", "n_generators": 3, "means": {"acc": 95.58, "map": 99.3, "mauroc": 99.25}} +{"date": "2026-11-10T20:31:06", "tag": "cure_trained_r3e0_synthwildx", "model": "cure", "ckpt": "/local/ssalehid/67200/s23_r3e0/cure_trained.pth", "benchmark": "pergen", "data_root": "/local/ssalehid/cache/data029/SynthWildX/test", "n_generators": 3, "means": {"acc": 91.76, "map": 97.12, "mauroc": 97.09}} +{"date": "2026-11-10T20:32:49", "tag": "cure_trained_r3e0_bfree_online", "model": "cure", "ckpt": "/local/ssalehid/67200/s23_r3e0/cure_trained.pth", "benchmark": "pergen", "data_root": "/local/ssalehid/cache/data029/BFreeOnline/test", "n_generators": 1, "means": {"acc": 71.19, "map": 89.48, "mauroc": 79.51}} +{"date": "2026-11-09T10:03:08", "tag": "probe_synthwildx", "model": "probe", "ckpt": "registry-default", "benchmark": "pergen", "data_root": "/local/ssalehid/cache/data029/SynthWildX/test", "n_generators": 3, "means": {"acc": 97.3, "map": 98.8, "mauroc": 99.18}} +{"date": "2026-11-09T10:07:16", "tag": "probe_resnet_synthwildx", "model": "probe_resnet", "ckpt": "registry-default", "benchmark": "pergen", "data_root": "/local/ssalehid/cache/data029/SynthWildX/test", "n_generators": 3, "means": {"acc": 75.2, "map": 83.88, "mauroc": 82.8}} +{"date": "2026-11-09T10:44:52", "tag": "probe_wildrf", "model": "probe", "ckpt": "registry-default", "benchmark": "pergen", "data_root": "/local/ssalehid/cache/data029/WildRF/test", "n_generators": 3, "means": {"acc": 96.92, "map": 99.36, "mauroc": 99.26}} +{"date": "2026-11-09T10:51:44", "tag": "probe_resnet_wildrf", "model": "probe_resnet", "ckpt": "registry-default", "benchmark": "pergen", "data_root": "/local/ssalehid/cache/data029/WildRF/test", "n_generators": 3, "means": {"acc": 81.63, "map": 89.45, "mauroc": 85.76}} +{"date": "2026-11-09T10:58:05", "tag": "probe_synthbuster_coco", "model": "probe", "ckpt": "registry-default", "benchmark": "pergen", "data_root": "/local/ssalehid/66755/tmp/layouts/Synthbuster_coco", "n_generators": 9, "means": {"acc": 98.2, "map": 99.64, "mauroc": 99.93}} +{"date": "2026-11-09T11:19:41", "tag": "probe_resnet_synthbuster_coco", "model": "probe_resnet", "ckpt": "registry-default", "benchmark": "pergen", "data_root": "/local/ssalehid/66755/tmp/layouts/Synthbuster_coco", "n_generators": 9, "means": {"acc": 83.75, "map": 85.23, "mauroc": 95.88}} +{"date": "2026-11-09T13:39:04", "tag": "probe_genimage_val100k", "model": "probe", "ckpt": "registry-default", "benchmark": "pergen", "data_root": "/local/ssalehid/cache/data029/GenImage_val_full/test", "n_generators": 8, "means": {"acc": 97.47, "map": 99.77, "mauroc": 99.8}} +{"date": "2026-11-09T14:14:14", "tag": "probe_resnet_genimage_val100k", "model": "probe_resnet", "ckpt": "registry-default", "benchmark": "pergen", "data_root": "/local/ssalehid/cache/data029/GenImage_val_full/test", "n_generators": 8, "means": {"acc": 78.38, "map": 86.69, "mauroc": 84.81}} +{"date": "2026-11-09T16:13:43", "tag": "probe_aigibench", "model": "probe", "ckpt": "registry-default", "benchmark": "pergen", "data_root": "/local/ssalehid/66790/tmp/layouts/aigibench", "n_generators": 2, "means": {"acc": 89.88, "map": 96.46, "mauroc": 95.88}} +{"date": "2026-11-09T16:45:46", "tag": "probe_resnet_aigibench", "model": "probe_resnet", "ckpt": "registry-default", "benchmark": "pergen", "data_root": "/local/ssalehid/66790/tmp/layouts/aigibench", "n_generators": 2, "means": {"acc": 70.44, "map": 79.8, "mauroc": 77.55}} {"date": "2026-11-09T05:47:21", "tag": "pgc_official_ufd8_fixed", "model": "pgc", "ckpt": "registry-default", "benchmark": "ufd", "data_root": "/local/ssalehid/cache/data023/universialfakedetection/test", "n_generators": 8, "means": {"acc": 94.19, "map": 99.35, "mauroc": 99.31}} {"date": "2026-11-09T06:18:18", "tag": "pgc_official_forensynths13_fixed", "model": "pgc", "ckpt": "registry-default", "benchmark": "forensynths", "data_root": "/local/ssalehid/cache/data023/CNNDetection/test", "n_generators": 13, "means": {"acc": 83.76, "map": 96.25, "mauroc": 96.64}} {"date": "2026-11-09T06:49:08", "tag": "pgc_official_deploycheck_fixed", "model": "pgc", "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/pgc_official_eval/PGC_train_progan_ckpt.pth", "benchmark": "forensynths", "data_root": "/local/ssalehid/cache/data023/CNNDetection/test", "n_generators": 13, "means": {"acc": 83.76, "map": 96.25, "mauroc": 96.64}} @@ -488,3 +565,25 @@ {"date": "2026-11-08T21:27:57", "tag": "spai_ep8_sdv14_full_nov", "model": "spai", "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/spai_v1/model_8.pth", "benchmark": "pergen", "data_root": "/local/ssalehid/cache/data023/GenImage_full/test", "n_generators": 1, "means": {"acc": 96.32, "map": 99.49, "mauroc": 99.71}} {"date": "2026-11-08T22:41:09", "tag": "cospy_served_fs8_nov", "model": "co_spy", "ckpt": "/local/ssalehid/cache/data023/zoo_ckpts/co_spy.pth", "benchmark": "forensynths", "data_root": "/local/ssalehid/cache/data023/CNNDetection/test", "n_generators": 8, "means": {"acc": 64.5, "map": 76.45, "mauroc": 80.17}} {"date": "2026-11-08T23:37:27", "tag": "cospy_official_fs8_nov", "model": "co_spy", "ckpt": "/local/ssalehid/cache/data023/repro/ckpts/progan", "benchmark": "forensynths", "data_root": "/local/ssalehid/cache/data023/CNNDetection/test", "n_generators": 8, "means": {"acc": 95.12, "map": 98.85, "mauroc": 99.03}} +{"date": "2026-11-10T00:05:18", "tag": "aide_trained_genimage8_l300", "model": "aide", "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/aide_train/model_best.pth", "benchmark": "pergen", "data_root": "/local/ssalehid/cache/data023/GenImage_full/test", "n_generators": 8, "means": {"acc": 80.69, "map": 92.57, "mauroc": 89.63}} +{"date": "2026-11-10T00:49:12", "tag": "aide_trained_forensynths", "model": "aide", "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/aide_train/model_best.pth", "benchmark": "forensynths", "data_root": "/local/ssalehid/cache/data023/CNNDetection/test", "n_generators": 13, "means": {"acc": 62.5, "map": 80.42, "mauroc": 80.41}} +{"date": "2026-11-10T02:00:21", "tag": "aide_trained_genimage8", "model": "aide", "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/aide_train/model_best.pth", "benchmark": "pergen", "data_root": "/local/ssalehid/cache/data023/GenImage_full/test", "n_generators": 8, "means": {"acc": 80.73, "map": 93.9, "mauroc": 91.66}} +{"date": "2026-11-10T02:31:21", "tag": "aide_trained_e0_synthbuster", "model": "aide", "ckpt": "/local/ssalehid/cache/data023/models/aide_full/model_0.pth", "benchmark": "pergen", "data_root": "/local/ssalehid/66991/layouts/Synthbuster_coco", "n_generators": 9, "means": {"acc": 72.2, "map": 96.16, "mauroc": 96.57}} +{"date": "2026-11-10T02:41:48", "tag": "aide_trained_e0_genimage8_l300", "model": "aide", "ckpt": "/local/ssalehid/cache/data023/models/aide_full/model_0.pth", "benchmark": "pergen", "data_root": "/local/ssalehid/cache/data023/GenImage_full/test", "n_generators": 8, "means": {"acc": 77.83, "map": 93.2, "mauroc": 91.25}} +{"date": "2026-11-10T03:04:30", "tag": "aide_trained_e1_synthbuster", "model": "aide", "ckpt": "/local/ssalehid/cache/data023/models/aide_full/model_1.pth", "benchmark": "pergen", "data_root": "/local/ssalehid/66991/layouts/Synthbuster_coco", "n_generators": 9, "means": {"acc": 69.63, "map": 94.2, "mauroc": 93.47}} +{"date": "2026-11-10T03:15:30", "tag": "aide_trained_e1_genimage8_l300", "model": "aide", "ckpt": "/local/ssalehid/cache/data023/models/aide_full/model_1.pth", "benchmark": "pergen", "data_root": "/local/ssalehid/cache/data023/GenImage_full/test", "n_generators": 8, "means": {"acc": 77.88, "map": 91.99, "mauroc": 89.24}} +{"date": "2026-11-10T03:37:52", "tag": "aide_trained_e2_synthbuster", "model": "aide", "ckpt": "/local/ssalehid/cache/data023/models/aide_full/model_2.pth", "benchmark": "pergen", "data_root": "/local/ssalehid/66991/layouts/Synthbuster_coco", "n_generators": 9, "means": {"acc": 70.37, "map": 93.13, "mauroc": 91.7}} +{"date": "2026-11-10T03:48:40", "tag": "aide_trained_e2_genimage8_l300", "model": "aide", "ckpt": "/local/ssalehid/cache/data023/models/aide_full/model_2.pth", "benchmark": "pergen", "data_root": "/local/ssalehid/cache/data023/GenImage_full/test", "n_generators": 8, "means": {"acc": 79.73, "map": 92.96, "mauroc": 90.11}} +{"date": "2026-11-10T04:11:37", "tag": "aide_trained_e3_synthbuster", "model": "aide", "ckpt": "/local/ssalehid/cache/data023/models/aide_full/model_3.pth", "benchmark": "pergen", "data_root": "/local/ssalehid/66991/layouts/Synthbuster_coco", "n_generators": 9, "means": {"acc": 70.24, "map": 92.56, "mauroc": 90.77}} +{"date": "2026-11-10T04:22:21", "tag": "aide_trained_e3_genimage8_l300", "model": "aide", "ckpt": "/local/ssalehid/cache/data023/models/aide_full/model_3.pth", "benchmark": "pergen", "data_root": "/local/ssalehid/cache/data023/GenImage_full/test", "n_generators": 8, "means": {"acc": 79.73, "map": 92.5, "mauroc": 89.53}} +{"date": "2026-11-10T04:45:50", "tag": "aide_trained_e4_synthbuster", "model": "aide", "ckpt": "/local/ssalehid/cache/data023/models/aide_full/model_4.pth", "benchmark": "pergen", "data_root": "/local/ssalehid/66991/layouts/Synthbuster_coco", "n_generators": 9, "means": {"acc": 70.67, "map": 92.2, "mauroc": 90.38}} +{"date": "2026-11-11T00:31:37", "tag": "waverep_genvideo_full", "model": "waverep", "ckpt": "registry-default", "benchmark": "video:pergen", "data_root": "/ssdstore/ssalehi/SynthScope/GenVideo/test", "n_generators": 10, "means": {"acc": 86.87, "map": 79.85, "map_real": 99.24, "mauroc": 92.13}} +{"date": "2026-11-11T00:31:48", "tag": "waverep_genvideo", "model": "waverep", "ckpt": "registry-default", "benchmark": "video:pergen", "data_root": "/ssdstore/ssalehi/SynthScope/GenVideo/test", "n_generators": 10, "means": {"acc": 86.62, "map": 89.81, "map_real": 93.96, "mauroc": 92.09}} +{"date": "2026-11-11T00:32:00", "tag": "waverep_videophy", "model": "waverep", "ckpt": "registry-default", "benchmark": "video:pergen", "data_root": "/ssdstore/ssalehi/SynthScope/VideoPhy/test", "n_generators": 8, "means": {"acc": 90.0, "map": 93.21, "map_real": 98.44, "mauroc": 96.54}} +{"date": "2026-11-11T00:32:11", "tag": "waverep_vidprom", "model": "waverep", "ckpt": "registry-default", "benchmark": "video:pergen", "data_root": "/ssdstore/ssalehi/SynthScope/VidProM/test", "n_generators": 4, "means": {"acc": 89.85, "map": 98.11, "map_real": 97.94, "mauroc": 98.06}} +{"date": "2026-11-11T00:32:24", "tag": "waverep_evalcrafter", "model": "waverep", "ckpt": "registry-default", "benchmark": "video:fakeonly", "data_root": "/ssdstore/ssalehi/SynthScope/EvalCrafter/test/1_fake", "n_generators": 14, "means": {"acc": 92.84, "map": 96.93, "map_real": 97.39, "mauroc": 97.17}} +{"date": "2026-11-11T00:32:51", "tag": "waverep_g4_genvideo_full", "model": "waverep_g4", "ckpt": "registry-default", "benchmark": "video:pergen", "data_root": "/ssdstore/ssalehi/SynthScope/GenVideo/test", "n_generators": 10, "means": {"acc": 93.28, "map": 88.88, "map_real": 99.69, "mauroc": 96.69}} +{"date": "2026-11-11T00:33:02", "tag": "waverep_g4_genvideo", "model": "waverep_g4", "ckpt": "registry-default", "benchmark": "video:pergen", "data_root": "/ssdstore/ssalehi/SynthScope/GenVideo/test", "n_generators": 10, "means": {"acc": 92.65, "map": 94.47, "map_real": 97.33, "mauroc": 96.53}} +{"date": "2026-11-11T00:33:14", "tag": "waverep_g4_videophy", "model": "waverep_g4", "ckpt": "registry-default", "benchmark": "video:pergen", "data_root": "/ssdstore/ssalehi/SynthScope/VideoPhy/test", "n_generators": 8, "means": {"acc": 95.73, "map": 98.2, "map_real": 99.74, "mauroc": 99.29}} +{"date": "2026-11-11T00:33:26", "tag": "waverep_g4_vidprom", "model": "waverep_g4", "ckpt": "registry-default", "benchmark": "video:pergen", "data_root": "/ssdstore/ssalehi/SynthScope/VidProM/test", "n_generators": 4, "means": {"acc": 95.8, "map": 99.29, "map_real": 99.19, "mauroc": 99.25}} +{"date": "2026-11-11T00:33:38", "tag": "waverep_g4_evalcrafter", "model": "waverep_g4", "ckpt": "registry-default", "benchmark": "video:fakeonly", "data_root": "/ssdstore/ssalehi/SynthScope/EvalCrafter/test/1_fake", "n_generators": 14, "means": {"acc": 96.55, "map": 99.19, "map_real": 99.35, "mauroc": 99.29}} diff --git a/repro/RESULTS_SUMMARY.md b/repro/RESULTS_SUMMARY.md index 671a4a7a73bb667f8a5804c0f6fc851a0293750f..0a70e6ec66bc252648c9d55b2b724ccca5d52740 100644 --- a/repro/RESULTS_SUMMARY.md +++ b/repro/RESULTS_SUMMARY.md @@ -1,6 +1,6 @@ # SynthScope Full-Benchmark Reproduction & Gap-Closing — Results Summary -*Updated 2026-11-09. Numbers trace to `repro/bench_results/*.json` and `repro/MASTER_RESULTS.jsonl`. Format: **mAP** (acc@0.5), % — unless noted.* +*Updated 2026-11-11. Numbers trace to `repro/bench_results/*.json` and `repro/MASTER_RESULTS.jsonl`. Format: **mAP** (acc@0.5), % — unless noted.* ## Three number columns (consistent everywhere) - **Paper** — figure reported in the paper. @@ -15,7 +15,7 @@ | CLIP/UnivFD | ForenSynths-13 | — | 93.14 | 92.99 | ✅ match | | CNNDetection | ForenSynths-11 (the paper's set) | 90.8 | 90.77 | 90.44 | ✅ match | | SAFE | GenImage | 99.3 | 99.32 | 99.51 | ✅ retrain reproduces | -| AIDE | GenImage (SD-v1.4) | 86.9 acc | 85.91 acc (97.12 mAP) | 77.87 acc (96.42 mAP) | ✅ official match on acc; the native-res retrain matches the official weights' mAP, its acc is 9 pt lower | +| AIDE | GenImage (SD-v1.4) | 86.9 acc | 85.91 acc (97.12 mAP) | 80.73 acc (93.90 mAP) | ⚠️ official weights match on acc; **trained in SynthScope with the official recipe: 6.2 pt below the paper on acc, 3.2 mAP below the official weights** (in-domain SD-v1.4/v1.5/Wukong/GLIDE match, ADM / Midjourney / VQDM transfer is weaker) | | SPAI | GenImage | ~91 AUC | 94.22 | 94.67 | ✅ served native-res (beats vendored 91.33); official-recipe retrain reproduces the official weights (+0.45 mAP; Synthbuster -0.99) | | PGC | GenImage / ForenSynths-8 / UFD | 100 / — / 98.0 AP | 100.0 / 97.83 / 99.35 | 97.62 / 97.41 / **98.99** | ✅ UFD reproduced by the official recipe in SynthScope (step 500); ForenSynths (not in the paper) slightly below the official checkpoint (corrected 2026-11-09, see the PGC section) | | VIB-Net | 15 generators (7 GenImage + 8 GANs), SD-v1.4-trained | 95.53 AP / 85.83 acc | *not available* | **94.08 / 85.22** | ✅ reproduced by the reconstructed recipe (native-resolution training) | @@ -27,10 +27,12 @@ | LTF | GenImage (8 subsets, full val, 100,000 images) | 98.4 acc (Table 4: AUC 99.89 / AP 99.86) | 98.36 acc / 99.88 AUROC / 99.86 AP | — | ✅ official match (every subset within 0.10 pt; the official code equals SynthScope exactly on a 33k subset) | | MIRROR | AIGCDetect / GenImage / UnivFakeDetect / Synthbuster / EvalGEN / SynthWildX / WildRF / AIGIBench / BFree-Online / RRDataset | 97.3 / 99.8 / 92.4 / 99.2 / 99.8 / 95.1 / 97.8 / 94.9 / 97.6 / 88.3 B.Acc (README, DINOv3-H+) | 97.39 / 99.78 / 92.44 / 99.28 / 99.85 / 95.08 / 97.88 / 94.98 / 97.40 / 86.91 B.Acc | — | ✅ official match on 9 of 10 held (RRDataset 1.4 short); DRCT-2M, Chameleon, CO-SPY in-the-wild, Human-AIGI not run | | VINA | ForenSynths / UniversalFakeDetect / DiTFake / ARForensics (6 shared subsets) / GenImage (full val) / GenVideo-Val | 86.99 / 94.84 / 97.98 / 96.36 / 94.74 / 96.9 acc (ARForensics: mean of the paper's six per-subset values) | 86.93 / 94.84 / 97.98 / 96.36 / 94.74 / 96.86 acc (pooled accuracy per subset, the paper's metric) | — | ✅ official match on these 6 (every subset; ForenSynths 10 of 11). SynthWildX and WildRF are **below the paper** (91.82 vs 92.8 and 96.12 vs 97.13, the means of the paper's printed per-subset values) and AIGIBench differs (SocialRF -1.18, CommunityAI +1.83), but the unmodified official `eval.py` gives the same per-file scores on our files (max diff <= 5.8e-05, 0 flips), so the gap is the data, not the code; RRDataset 82.89 vs 82.7; Chameleon, Magic Videos, GenBuster++, DeepTraceReward not run | +| PROBE (DINOv2 `probe` / ResNet-50 `probe_resnet`) | GenImage (val100k, fakes JPEG q96) / SynthWildX / WildRF / AIGI-Bench (CommunityAI + SocialRF); Synthbuster with different reals | DINOv2 96.8 / 96.4 / 96.9 / 89.9; ResNet-50 78.4 / 75.6 / 81.3 / 70.4 bAcc (Synthbuster 97.5 / 79.1) | DINOv2 97.47 / 97.30 / 96.92 / 89.88; ResNet-50 78.38 / 75.20 / 81.63 / 70.44 bAcc (Synthbuster, 5000 MSCOCO reals not RAISE-1k: 98.20 / 83.75) | — (training code not released) | ✅ official match on the 4 like-for-like benchmarks (DINOv2 within 0.9, ResNet-50 within 0.4 per benchmark; DINOv2 ADM / GLIDE / BigGAN about 2 points above the paper). Synthbuster is a different-reals comparison, not a reproduction claim. Chameleon and AIGI-Quality-Paradox not run (no loader), so the paper's 7-benchmark averages (93.9 / 78.1) are not comparable with our 5-benchmark means (95.95 / 77.88; paper's same 5: 95.50 / 76.96). Licence unclear: not redistributed | | D3 (video) | GenVideo-Val | 98.5 AP | 97.93 (official code) | 98.95 (training-free; AP with real as positive) | ✅ reproduced (D3 protocol; preprocessing matched to the official code) | | ReStraV (video) | GenVidBench (Main task: 4 test generators) | 93.01 acc | — | 93.33 acc on those 4; 92.70 mAP / 86.87 acc on all 8 | ✅ close on acc on the paper's 4 generators (not the paper's train/test split) | | STALL (video) | GenVideo-Val | ~80 AUC | — | 83.5 AUROC (training-free) | ✅ match | | SPLIT (video) | GenVideo-Val, fake recall at FPR 0.1 / 1 / 5% | 82.1 / 91.7 / 97.2 | 82.22 / 90.17 / 96.89 (official code) | 98.87 / 99.86 / 99.98 (training-free) | ✅ the official code reproduces the paper; SynthScope's SPLIT skips the official JPEG frame round trip, so it scores higher (see `models/video/split/README.md`) | +| WaveRep (video; `waverep` = G1, the paper's model) | The 8 GenVideo generators of the paper's Tables 1 and 7, on GenVideo-Val (PARTIAL: the paper's own 7-generator test set is not held) | 94.83 bAcc / 98.03 AUC (means of the printed per-generator values) | 90.30 bAcc / 95.73 AUC (official G1 weights; G4, trained on four generators, 96.30 / 99.05, reference only) | — (no training code) | ⚠️ **partial**: faithful port (the unmodified official demo agrees on 180 of 180 benchmark files, max logit diff 1.05e-5, and on 15 videos / 6 codecs with bit-exact inputs); 5 of the 8 generators within about 2 points, but HotShot (60.10 vs 81.4 bAcc), Show-1 (79.67 vs 92.1) and LaVie (92.06 vs 95.5) are **not reproduced** (HotShot fake recall 21%, AUC 75.6 vs 91.0, so not a threshold offset; cause untested; the paper does not say which reals it paired, we use GenVideo-Val's 10,000). Zero-shot reference rows only for VideoPhy / VidProM / EvalCrafter. GRIP non-profit licence: not redistributed | | B-Free | SynthWildX / WildRF | 95.6 / 95.6 · 86.2 · 97.3 bAcc | 95.64 / 95.31 · 86.47 · 97.66 bAcc | — | ✅ official match (details in `models/image/bfree/README.md`) | | MoE-JEPA | SID-Set (3-way) | 95.54 acc | 96.37 acc | — | ✅ official match (details in `models/image/moejepa/README.md`) | @@ -39,12 +41,26 @@ ### AIDE | Benchmark | Paper | SynthScope_official | SynthScope_train | |---|---:|---:|---:| -| GenImage-8 | 86.9 acc | 97.12 (85.9) | **96.42 (77.9)** (native-res 5-view retrain, model_2) | -| ForenSynths-13 | — | 94.40 (81.8) | 79.62 (59.0) (native-res retrain, cross-domain) | +| GenImage-8 | 86.9 acc | 97.12 (85.9) | **93.90 (80.73)** (official recipe, `experiments/image/aide.sh`, model_best = epoch 4; full test set) | +| ForenSynths-13 | — | 94.40 (81.8) | 80.42 (62.5) (same checkpoint, cross-domain, 300 images per class) | | AIGCDetect-17 | 92.8 acc | 97.94 (91.9) | — (not trained in this setting) | +SynthScope_train (GenImage-8, ForenSynths-13) = the official AIDE recipe in SynthScope (`bash experiments/image/aide.sh`, train job 281041: 4 x A6000, effective batch 256 = 4 GPUs x micro-batch 8 x accumulation 8 with SyncBatchNorm over 32 images as on each official GPU, AdamW lr 5e-4, weight decay 0, 5 epochs, per-iteration cosine to 1e-6, label smoothing 0.1, fp32, no clipping; training images get the official Gaussian blur and JPEG perturbations (p 0.1 each) at native resolution before the 5-view DCT selection, no flip; the long side is capped at 1024 before the DCT, the only deviation). `model_best` = epoch 4 (validation accuracy 0.9984; every epoch was still improving). Evaluated by DAS6 job 66956 through `bench_eval --model aide --ckpt`: tags `aide_trained_genimage8` (all 1500 + 1500 images per generator, 6000 + 6000 for sdv1.4: 93.90 mAP / 91.66 mAUROC / 80.73 acc), `aide_trained_genimage8_l300` (first 300 per class, the protocol of the previous retrain and the served row: 92.57 / 89.63 / 80.69), `aide_trained_forensynths` (300 per class: 80.42 / 80.41 / 62.5). Accuracy per generator (full): ADM 58.63, BigGAN 50.87, GLIDE 92.00, Midjourney 74.60, SD v1.4 99.97, SD v1.5 100.0, VQDM 69.83, Wukong 99.93 (official weights: 76.60, 60.63, 90.83, 83.70, 99.76, 99.80, 76.80, 99.13). Real accuracy is 99.93-100 everywhere: the loss is fake recall at threshold 0.5 on generators other than SD v1.4. The previous retrain (`aide_native_v2/model_2`; checkpoint deleted 2026-11-10 to free disk space, its result JSONs remain: native-resolution 5-view, but the earlier recipe with lr 1e-4, batch 32, horizontal flip, no perturbations, no label smoothing, DeepSpeed gradient clipping 1.0 and the epoch picked by validation loss; 300 per class) scored 96.42 mAP / 77.87 acc, so the faithful recipe gains 2.8 pt accuracy (80.69 on the same 300 images per class) and loses 3.9 mAP (92.57); neither reaches the paper's 86.88 accuracy within the 2-point tolerance. + SynthScope_official is `sd14_train.pth` (the served `aide.pth`) on GenImage and the ProGAN-trained `progan_train.pth` on ForenSynths and AIGCDetect. The earlier 72.25 (61.6) AIGCDetect entry was `progan_train.pth` under the old resize-before-DCT eval, not a SynthScope-trained model. +**Per-epoch diagnostic (not a reproduction claim; the headline stays `model_best` = epoch 4, chosen by validation accuracy as in the official code).** Each epoch checkpoint `model_0..model_4` of train job 281041 was scored on GenImage-8 (first 300 images per class and generator; epoch 4 is `aide_trained_genimage8_l300`) and, as a transfer probe, on Synthbuster (not an AIDE paper benchmark: the 9 generators' fakes against the 5,000 shared MSCOCO reals, first 300 per class and generator, 5,400 images), DAS6 job 66991, tags `aide_trained_e_genimage8_l300` / `aide_trained_e_synthbuster`: + +| Epoch | val acc | GenImage-8 mAP / acc | GenImage-8 ADM acc | Synthbuster mAP / acc | Synthbuster DALL-E 2 AP | +|---|---:|---:|---:|---:|---:| +| 0 | 0.9913 | 93.20 / 77.83 | 52.67 | **96.16** / 72.20 | 98.90 | +| 1 | 0.9956 | 91.99 / 77.88 | 54.17 | 94.20 / 69.63 | 93.79 | +| 2 | 0.9973 | 92.96 / 79.73 | 54.67 | 93.13 / 70.37 | 86.57 | +| 3 | 0.9979 | 92.50 / 79.73 | 54.33 | 92.56 / 70.24 | 84.96 | +| 4 (best) | 0.9984 | 92.57 / 80.69 | 56.83 | 92.20 / 70.67 | 81.79 | + +Reading: Synthbuster mAP falls monotonically with training (96.16 to 92.20; DALL-E 2 98.9 to 81.8, Firefly 82.8 to 78.6), the signature of over-adapting to SD v1.4 artifacts, while GenImage-8 mAP is flat (92.0-93.2, within single-run noise) and its accuracy creeps up (77.8 to 80.7) as the 0.5 threshold calibrates. No early epoch comes near the official weights' 97.12 mAP on GenImage-8, so an early checkpoint does not explain the gap on the paper's benchmark. One run, one seed, 300 images per class. + ### SPAI SPAI SERVES official weights remapped into the SynthScope class at NATIVE resolution (any-res spectral path). `SynthScope_official` = that served number; `SynthScope_train` = the official-recipe retrain in SynthScope (35 epochs, job 267192), epoch 8 chosen by validation loss (epoch 17 as a note). It reproduces the official weights within about 1 point; the earlier from-scratch fixed-448 retrain (88.80) is superseded. Protocol: native resolution, GenImage-8 300 per class per generator, Synthbuster 200 with GenImage-nature proxy reals; eval jobs 273444-273446, 273597. | Benchmark | Paper | SynthScope_official (served, native-res) | SynthScope_train (epoch 8) | Epoch 17 | @@ -77,6 +93,8 @@ SynthScope_official uses the release matching each benchmark's training setting: SynthScope_train on Co-Spy-Bench and GenImage is the served `co_spy.pth` (`checkpoints_retrain/cospy_full/model_1.pth`, GenImage SD v1.4; `cospy_full_cospybench` also has rows for model_0 96.12 and model_2 96.60). The ForenSynths and AIGCDetect SynthScope_train entries are from earlier SynthScope checkpoints and have not been re-run with it. SynthScope_official is the official SD v1.4 checkpoint on Co-Spy-Bench and GenImage and the official ProGAN one on ForenSynths and AIGCDetect. +The ForenSynths-13 SynthScope_official entry (`cospy_official_forensynths`, 87.97 mAP / 83.42 acc, 2026-06-04) is a **1000-per-class** run (`--limit 1000` on the sorted path list: every per-class rate is a multiple of 0.1, and the June job log was not kept), not the full test sets. The full ForenSynths-8 run with the same checkpoint and evaluator (`cospy_official_fs8_nov`, DAS6 job 66671, `repro/logs/lbfu_cospyoff_das6_66671.out`) gives 98.85 mAP / 95.12 acc / 99.03 mAUROC; that is the leaderboard's CO-SPY (official weights) row (it previously used the 8 ForenSynths-8 sets of the 1000-per-class file: 98.50 / 94.64). + ### SAFE `SynthScope_train` = retrained SAFE v2 (full 40-epoch crop recipe, `safe_full_v2/model_38`); supersedes the earlier resize-era column. | Benchmark | Paper | SynthScope_official | SynthScope_train (retrain v2) | @@ -132,7 +150,7 @@ transform (`vib_net_official`: fp32 CLIP, no feature norm, 224 center crop witho differ only in that resize (82.98 -> 94.08 AP). The earlier 83.9 / 77.6 model also differed from the official one (fp16 CLIP, an added feature BatchNorm); their separate effect was not measured. -### CuRe (official adapter) +### CuRe (official adapter and trained in SynthScope) Fidelity: SynthScope's class == the official model (395/395 state-dict tensors identical, logit diff 4.8e-6, 0 verdict flips; `repro/cure_verify_load.py`). Paper: 89.7 avg balanced acc over 10 benchmarks (trained on GenImage SD-v1.4 only). | Benchmark (SynthScope protocol) | acc (mean per-gen balanced) | mAP | Paper | Note | @@ -151,6 +169,55 @@ Fidelity: SynthScope's class == the official model (395/395 state-dict tensors i **Verdict: faithful port (identical to the official model); 7 of the paper's 10 benchmarks reproduced** — AIGIBench (92.85 vs 92.8), AIGCDetectBenchmark (89.30 vs 89.3), RealChain (79.69 vs 79.7), EvalGEN (98.14 vs 98.1), SynthWildX (92.69 vs 92.7), WildRF (95.89 vs 95.8), RRDataset (82.04 vs 81.5). BFree-Online is close (91.64 vs 90.9) but only 807 of about 1400 images are still online. Not confirmed: UnivFD (the paper's aggregation is unspecified) and Chameleon (released by email request only). +**SynthScope_train (the paper's 3-stage recipe, `experiments/image/cure.sh`; investigation scripts and results in `repro/cure_stage1/`; all scored with `bench_eval --ckpt` and the official rows' flags; `models/image/cure/README.md` "Trained checkpoint")** + +Columns: +- **Original:** the recipe as written, last epoch (job 66658). +- **R1 e0:** the recipe, every epoch saved, epoch chosen by a pre-registered non-benchmark rule (Synthbuster fakes vs SD1.4 test reals). +- **R2 final:** global batch 512. +- **R2 e1:** chosen after the fact by its weight-norm match to the release; diagnostic only. +- **R3 e0:** R1 + DDA-style training augmentation (an assumption, not in the paper), same rule. **This is the main trained checkpoint.** + +Each cell is acc / AUROC; R means reproduced. + +| Benchmark | Paper | Official | Original | R1 e0 | R2 final | R2 e1 (diag) | **R3 e0** | +|---|---|---|---|---|---|---|---| +| AIGIBench-20 | 92.8/97.5 | 92.85/97.48 | 85.05/91.84 | 88.85/95.86 | 87.10/93.73 | 88.81/95.78 | **91.12/97.10 R** | +| AIGCDetect | 89.3 | 89.30/98.02 | 81.55/92.22 | 92.25/98.47 R | 82.29/94.40 | 88.20/97.84 R | **92.01/98.38 R** | +| EvalGEN | 98.1 | 98.14/99.66 | 90.65/95.96 | 91.57/98.63 | 92.45/97.90 | 93.98/99.17 | 93.32/98.85 (-4.8) | +| SynthWildX | 92.7/96.6 | 92.69/96.50 | 76.11/86.84 | 90.99/96.85 R | 81.56/91.85 | 88.65/95.90 | **91.76/97.09 R** | +| WildRF | 95.8/99.1 | 95.89/99.14 | 85.80/94.59 | 95.23/99.06 R | 90.24/96.19 | 93.91/98.43 R | **95.58/99.25 R** | +| BFree-Online (807 imgs) | 90.9 | 91.64/98.08 | 66.64/85.77 | 72.30/81.80 | 69.52/81.51 | 74.54/89.90 | 71.19/79.51 (-19.7) | +| RRDataset | 81.5 | 82.04/88.88 | 66.36/76.87 | 72.62/85.25 | 68.01/78.57 | 72.65/84.82 | 73.46/85.32 (-8.0) | +| RealChain | 79.7 | 79.69/85.47 | 63.33/76.50 | 70.34/84.87 | 67.49/82.20 | 72.28/85.02 | 72.75/84.70 (-7.0) | +| UFD-8 / ForenSynths-13 / GenImage-8 (ref) | - | 93.94 / 81.95 / 85.18 | 82.69 / 75.83 / 77.70 | 93.99 / 89.79 / 86.05 | 83.81 / 74.35 / 79.89 | 92.14 / 84.26 / 83.48 | 93.89 / 89.36 / 86.22 | +| Mean acc (8 comparable) | 90.10 | 90.28 | 76.94 | 84.27 | 79.83 | 84.13 | **85.15** | +| Reproduced | | | 0/8 | 3/8 | 0/8 | 2/8 | **4/8** | + +**Verdict: the recipe is provided and partially reproduces the paper.** The repo tolerance is acc >= paper - 2.0 and AUROC >= paper - 2.5. +- **Last epoch, as written:** 13 points short. Stage 1 over-adapts to SD v1.4: + - LoRA update 1.71x the release's; + - a 3x tighter fit of the SD1.4 mixing ratio; + - a SD1.4-fitted probe transfers to Synthbuster worse than the frozen base (81.0 vs 92.5; release 95.0; `repro/cure_stage1/results/epoch_select_r1.json`). +- **Early stopping by the pre-registered rule (epoch 0):** recovers more than half of the gap. +- **Augmentation:** adds AIGIBench. +- **What remains with R3 e0:** + - mean -5; + - BFree-Online -19.7 with AUROC 79.5 against the official adapter's 98.1, a ranking failure; + - RRDataset -8 (AUROC 85.3 vs 88.9); + - RealChain -7, which is calibration (AUROC 84.7 vs the official 85.5); + - EvalGEN -5, mostly the threshold (AUROC 98.85 vs 99.66). +- **Disclosure:** the pre-registered rule selects an epoch within a run. + - Choosing r3e0 over r1e0 as the main checkpoint was decided after R1's benchmark results were known. + - Cross-run selection scores come from different GPUs: R1 RTX 6000 Ada, R2 A5000, R3 A6000. The released reference scores 95.2 on the A5000 and 95.16 on the A6000. + - Only the AIGIBench "reproduced" depends on the augmentation; r1e0 alone reproduces AIGCDetect, SynthWildX and WildRF. +- **Seed and global batch:** single seed (paper std 0.3-0.7). Global batch 512 alone (R2) does not reproduce the paper. +- **Stages 2-3:** verified. The released encoder through our stage 2 + 3 reproduces the paper (jobs 66720 / 66726). +- **Engineering notes:** + - On RTX 6000 Ada GPUs, PE-Core fp16 features depend on the batch size (logits differ by about 2e-2 between batches of 64 and 128; Ampere 1e-5). The stage-3 export check now compares at the encoding batch size. + - The multi-encoder stage-2/3 driver is bit-identical to the single path. +- **Serving:** the served `cure` model stays the official adapter. + ### DDA (official checkpoint and trained in SynthScope) Fidelity: SynthScope's class == the official `DINOv2ModelWithLoRA` (537/537 state-dict tensors identical, transform and logits identical on 40 images, 0 verdict flips; job 264307). Paper: 90.7 avg accuracy over 11 benchmarks (trained on DDA-aligned MSCOCO only). Accuracy = mean per-subset balanced accuracy at 0.5, ± = sample std over subsets. @@ -269,6 +336,52 @@ Fidelity: SynthScope's class == the official `DINOv3` model (417/417 state-dict **Verdict: faithful port (identical to the official model); the released checkpoint reproduces the paper on the six benchmarks whose data is the paper's, in every subset (ForenSynths: 10 of 11, SAN differs by 0.7 on the .bmp question).** Three in-the-wild sets are up to 2 points from the paper and the official code agrees with SynthScope on our files to 6e-05, so the cause is the dataset version or file list. The official `eval.py` was run on SynthWildX, WildRF, AIGIBench, UniversalFakeDetect and GenVideo-Val (not on the others); its per-file CSVs are kept outside the repo (the comparison JSONs are in `repro/bench_results/vina_official_code/`). Jobs: CPU 281654-281656 and 281831 (cn023), GPU 281657 (A5000), DAS6 66630 and 66627 (A6000), 281662 (A5000). Licence unclear (no LICENSE file): not redistributed, not on the Space. Details and per-subset tables: `models/image/vina/README.md`. +### PROBE (official checkpoints, DINOv2 and ResNet-50) +Fidelity: SynthScope's classes equal the official `dino_classifier` / `ResNet` (442 and 320 state-dict tensors identical, strict load; patch tensors identical; P(fake) and mean logit equal the official batch-1 run with max |diff| 0.0 and 0 flips on 34 images of varied sizes, CPU). The released checkpoints are the paper's PROBE-DINOv2 and PROBE-ResNet50 rows; the generator-probing and fine-tuning code is not released, so there is no SynthScope-trained number. Protocol: balanced accuracy at 0.5 (positive = fake), mean over the paper's subsets, the paper's metric (`means.acc`); official inference (pad to the crop size, mean logit of non-overlapping 336 / 224 patches), batch size 1, GPU. GenImage = the full val split (100,000 images) with all fakes JPEG q96 as in the paper (sdv1.5 has 8000 per class here, 6000 in the paper's 48k). + +| Benchmark | `probe` bAcc | `probe_resnet` bAcc | Paper DINOv2 / ResNet-50 (Table 1) | Note | +|---|---:|---:|---|---| +| GenImage (8 subsets, val100k, fakes JPEG q96) | **97.47** | **78.38** | 96.8 / 78.4 | ResNet-50 equal (7 of 8 subsets within 0.1, ADM 58.94 vs 60.0). DINOv2 +0.67: ADM +2.2, GLIDE +1.8, BigGAN +2.1, the other five within 0.2; the official code equals SynthScope wherever compared (34 parity images, WildRF, SynthWildX; not run on GenImage), so the difference is on the paper's data / preprocessing side, undetermined | +| Synthbuster (9 subsets) vs **5000 MSCOCO reals** | 98.20 | 83.75 | 97.5 / 79.1 | **different reals** from the paper's RAISE-1k (registration-gated, not in SynthScope): not like-for-like; real accuracy 99.54 / 99.14. ResNet-50: the paper's SD 1.3 / 1.4, DALL-E 2 and DALL-E 3 values follow from our fake accuracies if the RAISE real accuracy is about 89.8 (inferred, not measured) | +| SynthWildX | **97.30** | **75.20** | 96.4 / 75.6 | +0.90 / -0.40; the unmodified official code gives the same bAcc on every subset (413 reals, 392 / 473 / 435 fakes; paper 0.5k + 1.5k) | +| WildRF | **96.92** | **81.63** | 96.9 / 81.3 | +0.02 / +0.33; 2503 files. The official code drops the 262 `.jfif` files of twitter (421 of 683 files read); on the common files it equals SynthScope | +| AIGI-Bench (CommunityAI + SocialRF only, 9k + 9k) | **89.88** | **70.44** | 89.9 / 70.4 | equal; the other AIGIBench subsets were not scored | +| Chameleon · AIGI-Quality-Paradox | — | — | 86.6 / 74.0 · 92.9 / 87.7 | not run (no loader; Chameleon by request only) | +| Mean of the 5 run (4 like-for-like) | 95.95 (95.39) | 77.88 (76.41) | 95.50 (95.00) / 76.96 (76.43) | the paper's Avg over all 7 (93.9 / 78.1) is not comparable | + +**Official code on our data** (unmodified `evaluate_dino.py` / `evaluate_resnet.py`, job 66753, WildRF and SynthWildX): **0 flips at 0.5 over every common file in all four runs; max |dP| 4.8e-6 (DINOv2), 1.3e-3 (ResNet-50, GPU convolution algorithms / TF32 at batch 4 vs 1)**. Its own "Overall Accuracy" is pooled accuracy on a seed-42 class-balanced subsample, which equals bAcc up to sampling noise (at most 2.0 per subset, ResNet-50 on WildRF twitter: 82.29 vs 84.27; at most 0.66 per benchmark, ResNet-50 WildRF: 80.99 vs 81.65). **Verdict: faithful port; the released checkpoints reproduce the paper on GenImage (JPEG q96), SynthWildX, WildRF and AIGI-Bench; Synthbuster is not a like-for-like comparison and Chameleon / AIGI-Quality-Paradox were not run.** Jobs (DAS6, A6000): 66753 (SynthWildX, WildRF, official runs, GenImage), 66755 (Synthbuster), 66790 (AIGI-Bench); tags `probe_`, `probe_resnet_` in `repro/bench_results/`; per-subset tables, protocol and scripts: `models/image/probe/README.md`, `repro/probe_task2/`. Licence unclear (no LICENSE file): not redistributed, not on the Space. + +### WaveRep (official checkpoints G1 and G4; PARTIAL paper comparison) +Fidelity: SynthScope's class == the official timm `vit_base_patch14_reg4_dinov2` model (177/177 state-dict tensors identical, strict load, both checkpoints). The unmodified official demo (`main_avideo.py` / `main_directory.py` @ `0fd6010`) and SynthScope agree: 15 videos in 6 codecs (model inputs bit-exact; video logit max diff 6.0e-7; CPU) and 180 GenVideo-Val files per checkpoint (max |logit diff| 1.02e-5 G1 / 1.05e-5 G4, 0 sign flips, 0 NaN; GPU-vs-GPU; `repro/waverep_official_parity_genvideo180.json`, DAS6 67291). Protocol: official OpenCV reader, the first 64 frames (paper App. D; the demo's default is every frame, `num_frames=0`), 504 centre crop, mean frame logit, balanced accuracy at 0.5 and AUC (the paper's metrics). Two released checkpoints: `waverep` = G1 ("a single generator" per the official demo README; we infer Pyramid Flow, the paper's detector), `waverep_g4` = G4 ("four generators", the demo's default; we infer the Table 5 set). No training code is released, so there is no SynthScope-trained number. + +**What is held.** The paper's own test set (7 generators vs 300 Panda-70M YouTube reals) is **NOT held**: the reals need a YouTube downloader and were not scraped. The comparison below uses the 8 GenVideo generators that are among the paper's columns, scored on full GenVideo-Val with its own 10,000 reals; the paper does not say which reals it paired, so this is a **PARTIAL** comparison. + +| Generator (n fake) | Paper bAcc (Table 1) | G1 `waverep` bAcc | G4 `waverep_g4` bAcc (reference only) | Paper AUC (Table 7) | G1 AUC | G4 AUC | +|---|---:|---:|---:|---:|---:|---:| +| Crafter (1398) | 98.3 | 98.99 | 98.90 | 99.8 | 99.90 | 99.98 | +| Gen2 (1380) | 98.8 | 99.49 | 98.90 | 100.0 | 99.99 | 99.99 | +| HotShot (700) | 81.4 | **60.10** | 83.40 | 91.0 | **75.60** | 94.15 | +| LaVie (1400) | 95.5 | **92.06** | 97.33 | 97.7 | 97.03 | 99.26 | +| ModelScope (700) | 97.1 | 95.24 | 97.54 | 99.4 | 99.31 | 99.69 | +| MorphStudio (700) | 97.0 | 97.74 | 98.61 | 99.3 | 99.74 | 99.94 | +| Show-1 (700) | 92.1 | **79.67** | 96.83 | 97.1 | 94.27 | 99.43 | +| MoonValley (626) | 98.4 | 99.12 | 98.89 | 99.9 | 99.97 | 99.98 | +| 8-generator mean | 94.83 | 90.30 | 96.30 | 98.03 | 95.73 | 99.05 | + +Reading: 5 of 8 G1 cells are within about 2 points (Crafter, Gen2, MorphStudio, MoonValley, ModelScope -1.86); **HotShot (-21.3 bAcc / -15.4 AUC), Show-1 (-12.4 / -2.8) and LaVie (-3.4 / -0.7) are NOT reproduced.** HotShot: G1 real accuracy 99.2 but fake recall 21.0% at P >= 0.5 (Show-1 60.1%, LaVie 84.9%); AUC falls too, so it is not a calibration or threshold offset. The cause is untested (a different real pool or fake subset in the paper is a possibility; we cannot check it). G4 is trained on four generators, so its higher numbers are not single-generator generalization. Source: `repro/bench_results/waverep_genvideo_full.json`, `waverep_g4_genvideo_full.json` (`per_generator` `acc`, `auroc`); paper values from arXiv 2506.16802 Tables 1 and 7. Sora (56 fakes: G1 67.46 / 68.54, G4 76.65 / 83.61) and WildScrape (924: 78.87 / 86.92, 85.77 / 90.83) are GenVideo-Val extras with no paper cell. + +**Zero-shot reference rows (NOT paper reproductions; the paper reports none of these sets).** Means over the generators; bAcc at 0.5 / mAP (fake positive) / mAUROC. + +| Set | gens | G1 `waverep` | G4 `waverep_g4` | +|---|---:|---|---| +| GenVideo-Val full (10,000 reals + all fakes) | 10 | 86.87 / 79.85 / 92.13 | 93.28 / 88.88 / 96.69 | +| GenVideo-Val `--limit 1000` (D3 protocol) | 10 | 86.62 / 89.81 / 92.09 | 92.65 / 94.47 / 96.53 | +| VideoPhy `--limit 1000` | 8 | 90.00 / 93.21 / 96.54 | 95.73 / 98.20 / 99.29 | +| VidProM `--limit 1000` | 4 | 89.85 / 98.11 / 98.06 | 95.80 / 99.29 / 99.25 | +| EvalCrafter (fakes vs the **first 1000 GenVideo-Val MSR-VTT reals**; EvalCrafter has none of its own) | 14 | 92.84 / 96.93 / 97.17 | 96.55 / 99.19 / 99.29 | + +`--limit 1000` = the first 1000 clips per class per generator. Two VidProM Pika fakes (`00642_pika-9e93dcfc...`, `00891_pika-e025f9ee...`) are empty (0-byte) files in our copy, so OpenCV decodes no frame; they are excluded (998 scored); every other set decodes fully. Weakest G1 cells: VideoPhy OpenSora 62.15 / ZeroScope 63.75, VidProM ModelScope 71.55, GenVideo Sora 67.46; G4 is better on all of them. Full GenVideo-Val mAP (fake positive) is low only through the 10,000 : 56-1400 class imbalance. Jobs: IVI 285376_0, 285390_3-4, 285389_2 / 285886_2, DAS6 67328 / 67404 (scoring), IVI 286053 / 286059 (aggregation), DAS6 67291 (official demo); logs `repro/logs/waverep_*`. Licence: GRIP-UNINA, free for informational / non-profit use only, so the weights are not redistributed, not in the model zoo, and not on the Space (pending user approval: needs uploading the checkpoints to the hub; about 30 s per clip on CPU). Details: `models/video/waverep/README.md`. + ### Video detectors (D3, SPLIT and STALL are training-free; ReStraV is trained in SynthScope; no official weights) | Method · Benchmark | Paper | SynthScope | |---|---:|---:| diff --git a/repro/bench_results/aide_trained_e0_genimage8_l300.json b/repro/bench_results/aide_trained_e0_genimage8_l300.json new file mode 100644 index 0000000000000000000000000000000000000000..276945057de1fbdb396c8a1f0f05b0eb21790b3e --- /dev/null +++ b/repro/bench_results/aide_trained_e0_genimage8_l300.json @@ -0,0 +1,76 @@ +{ + "tag": "aide_trained_e0_genimage8_l300", + "model": "aide", + "ckpt": "/local/ssalehid/cache/data023/models/aide_full/model_0.pth", + "model_config": null, + "benchmark": "pergen", + "data_root": "/local/ssalehid/cache/data023/GenImage_full/test", + "jpeg_fakes": null, + "n_generators": 8, + "means": { + "acc": 77.83, + "map": 93.2, + "mauroc": 91.25 + }, + "per_generator": { + "adm": { + "ap": 66.22, + "auroc": 54.63, + "real_acc": 100.0, + "fake_acc": 5.33, + "acc": 52.67 + }, + "biggan": { + "ap": 87.71, + "auroc": 85.57, + "real_acc": 100.0, + "fake_acc": 3.33, + "acc": 51.67 + }, + "glide": { + "ap": 98.83, + "auroc": 98.32, + "real_acc": 99.67, + "fake_acc": 65.33, + "acc": 82.5 + }, + "midjourney": { + "ap": 97.84, + "auroc": 97.61, + "real_acc": 100.0, + "fake_acc": 48.33, + "acc": 74.17 + }, + "sdv1.4": { + "ap": 100.0, + "auroc": 100.0, + "real_acc": 100.0, + "fake_acc": 99.67, + "acc": 99.83 + }, + "sdv1.5": { + "ap": 100.0, + "auroc": 100.0, + "real_acc": 99.67, + "fake_acc": 100.0, + "acc": 99.83 + }, + "vqdm": { + "ap": 95.03, + "auroc": 93.9, + "real_acc": 100.0, + "fake_acc": 26.33, + "acc": 63.17 + }, + "wukong": { + "ap": 99.99, + "auroc": 99.99, + "real_acc": 100.0, + "fake_acc": 97.67, + "acc": 98.83 + } + }, + "date": "2026-11-10T02:41:48", + "synthscope_version": "0.1.0", + "ckpt_ivi": "/hddstore/ssalehi/SynthScope/models/aide_full/model_0.pth on ivi-cn023 (the ckpt field above is the DAS6 node-cache copy); DIAGNOSTIC per-epoch run, --limit 300" +} \ No newline at end of file diff --git a/repro/bench_results/aide_trained_e0_synthbuster.json b/repro/bench_results/aide_trained_e0_synthbuster.json new file mode 100644 index 0000000000000000000000000000000000000000..89f5def53e21a41ff0393b7c2d7769468b7fb88f --- /dev/null +++ b/repro/bench_results/aide_trained_e0_synthbuster.json @@ -0,0 +1,83 @@ +{ + "tag": "aide_trained_e0_synthbuster", + "model": "aide", + "ckpt": "/local/ssalehid/cache/data023/models/aide_full/model_0.pth", + "model_config": null, + "benchmark": "pergen", + "data_root": "/local/ssalehid/66991/layouts/Synthbuster_coco", + "jpeg_fakes": null, + "n_generators": 9, + "means": { + "acc": 72.2, + "map": 96.16, + "mauroc": 96.57 + }, + "per_generator": { + "dalle2": { + "ap": 98.9, + "auroc": 98.87, + "real_acc": 100.0, + "fake_acc": 30.33, + "acc": 65.17 + }, + "dalle3": { + "ap": 93.46, + "auroc": 94.0, + "real_acc": 100.0, + "fake_acc": 5.0, + "acc": 52.5 + }, + "firefly": { + "ap": 82.76, + "auroc": 87.55, + "real_acc": 100.0, + "fake_acc": 0.33, + "acc": 50.17 + }, + "glide": { + "ap": 98.8, + "auroc": 98.28, + "real_acc": 100.0, + "fake_acc": 73.0, + "acc": 86.5 + }, + "midjourney-v5": { + "ap": 95.43, + "auroc": 95.25, + "real_acc": 100.0, + "fake_acc": 14.33, + "acc": 57.17 + }, + "stable-diffusion-1-3": { + "ap": 100.0, + "auroc": 100.0, + "real_acc": 100.0, + "fake_acc": 99.67, + "acc": 99.83 + }, + "stable-diffusion-1-4": { + "ap": 100.0, + "auroc": 100.0, + "real_acc": 100.0, + "fake_acc": 99.33, + "acc": 99.67 + }, + "stable-diffusion-2": { + "ap": 97.12, + "auroc": 96.56, + "real_acc": 100.0, + "fake_acc": 24.67, + "acc": 62.33 + }, + "stable-diffusion-xl": { + "ap": 98.97, + "auroc": 98.58, + "real_acc": 100.0, + "fake_acc": 53.0, + "acc": 76.5 + } + }, + "date": "2026-11-10T02:31:21", + "synthscope_version": "0.1.0", + "ckpt_ivi": "/hddstore/ssalehi/SynthScope/models/aide_full/model_0.pth on ivi-cn023 (the ckpt field above is the DAS6 node-cache copy); DIAGNOSTIC per-epoch run, --limit 300" +} \ No newline at end of file diff --git a/repro/bench_results/aide_trained_e1_genimage8_l300.json b/repro/bench_results/aide_trained_e1_genimage8_l300.json new file mode 100644 index 0000000000000000000000000000000000000000..a5973041e1cd55989ccc19b59f88a51450933839 --- /dev/null +++ b/repro/bench_results/aide_trained_e1_genimage8_l300.json @@ -0,0 +1,76 @@ +{ + "tag": "aide_trained_e1_genimage8_l300", + "model": "aide", + "ckpt": "/local/ssalehid/cache/data023/models/aide_full/model_1.pth", + "model_config": null, + "benchmark": "pergen", + "data_root": "/local/ssalehid/cache/data023/GenImage_full/test", + "jpeg_fakes": null, + "n_generators": 8, + "means": { + "acc": 77.88, + "map": 91.99, + "mauroc": 89.24 + }, + "per_generator": { + "adm": { + "ap": 60.09, + "auroc": 45.28, + "real_acc": 100.0, + "fake_acc": 8.33, + "acc": 54.17 + }, + "biggan": { + "ap": 86.74, + "auroc": 83.11, + "real_acc": 100.0, + "fake_acc": 1.33, + "acc": 50.67 + }, + "glide": { + "ap": 99.18, + "auroc": 98.73, + "real_acc": 100.0, + "fake_acc": 71.33, + "acc": 85.67 + }, + "midjourney": { + "ap": 96.15, + "auroc": 95.2, + "real_acc": 100.0, + "fake_acc": 46.67, + "acc": 73.33 + }, + "sdv1.4": { + "ap": 100.0, + "auroc": 100.0, + "real_acc": 100.0, + "fake_acc": 99.67, + "acc": 99.83 + }, + "sdv1.5": { + "ap": 100.0, + "auroc": 100.0, + "real_acc": 100.0, + "fake_acc": 100.0, + "acc": 100.0 + }, + "vqdm": { + "ap": 93.79, + "auroc": 91.58, + "real_acc": 100.0, + "fake_acc": 20.33, + "acc": 60.17 + }, + "wukong": { + "ap": 100.0, + "auroc": 100.0, + "real_acc": 100.0, + "fake_acc": 98.33, + "acc": 99.17 + } + }, + "date": "2026-11-10T03:15:30", + "synthscope_version": "0.1.0", + "ckpt_ivi": "/hddstore/ssalehi/SynthScope/models/aide_full/model_1.pth on ivi-cn023 (the ckpt field above is the DAS6 node-cache copy); DIAGNOSTIC per-epoch run, --limit 300" +} \ No newline at end of file diff --git a/repro/bench_results/aide_trained_e1_synthbuster.json b/repro/bench_results/aide_trained_e1_synthbuster.json new file mode 100644 index 0000000000000000000000000000000000000000..4b0ec59f4ec5ffb4872bc509ca186c3cfddc04bd --- /dev/null +++ b/repro/bench_results/aide_trained_e1_synthbuster.json @@ -0,0 +1,83 @@ +{ + "tag": "aide_trained_e1_synthbuster", + "model": "aide", + "ckpt": "/local/ssalehid/cache/data023/models/aide_full/model_1.pth", + "model_config": null, + "benchmark": "pergen", + "data_root": "/local/ssalehid/66991/layouts/Synthbuster_coco", + "jpeg_fakes": null, + "n_generators": 9, + "means": { + "acc": 69.63, + "map": 94.2, + "mauroc": 93.47 + }, + "per_generator": { + "dalle2": { + "ap": 93.79, + "auroc": 92.73, + "real_acc": 100.0, + "fake_acc": 8.0, + "acc": 54.0 + }, + "dalle3": { + "ap": 88.7, + "auroc": 87.84, + "real_acc": 100.0, + "fake_acc": 2.33, + "acc": 51.17 + }, + "firefly": { + "ap": 82.96, + "auroc": 83.7, + "real_acc": 100.0, + "fake_acc": 0.0, + "acc": 50.0 + }, + "glide": { + "ap": 98.92, + "auroc": 98.34, + "real_acc": 100.0, + "fake_acc": 69.0, + "acc": 84.5 + }, + "midjourney-v5": { + "ap": 93.08, + "auroc": 91.14, + "real_acc": 100.0, + "fake_acc": 24.67, + "acc": 62.33 + }, + "stable-diffusion-1-3": { + "ap": 100.0, + "auroc": 100.0, + "real_acc": 100.0, + "fake_acc": 98.33, + "acc": 99.17 + }, + "stable-diffusion-1-4": { + "ap": 100.0, + "auroc": 100.0, + "real_acc": 100.0, + "fake_acc": 99.0, + "acc": 99.5 + }, + "stable-diffusion-2": { + "ap": 93.57, + "auroc": 91.56, + "real_acc": 100.0, + "fake_acc": 20.33, + "acc": 60.17 + }, + "stable-diffusion-xl": { + "ap": 96.79, + "auroc": 95.95, + "real_acc": 100.0, + "fake_acc": 31.67, + "acc": 65.83 + } + }, + "date": "2026-11-10T03:04:30", + "synthscope_version": "0.1.0", + "ckpt_ivi": "/hddstore/ssalehi/SynthScope/models/aide_full/model_1.pth on ivi-cn023 (the ckpt field above is the DAS6 node-cache copy); DIAGNOSTIC per-epoch run, --limit 300" +} \ No newline at end of file diff --git a/repro/bench_results/aide_trained_e2_genimage8_l300.json b/repro/bench_results/aide_trained_e2_genimage8_l300.json new file mode 100644 index 0000000000000000000000000000000000000000..dddee2ce90def85c47e2ccdb982905b3cab2781d --- /dev/null +++ b/repro/bench_results/aide_trained_e2_genimage8_l300.json @@ -0,0 +1,76 @@ +{ + "tag": "aide_trained_e2_genimage8_l300", + "model": "aide", + "ckpt": "/local/ssalehid/cache/data023/models/aide_full/model_2.pth", + "model_config": null, + "benchmark": "pergen", + "data_root": "/local/ssalehid/cache/data023/GenImage_full/test", + "jpeg_fakes": null, + "n_generators": 8, + "means": { + "acc": 79.73, + "map": 92.96, + "mauroc": 90.11 + }, + "per_generator": { + "adm": { + "ap": 71.94, + "auroc": 58.42, + "real_acc": 100.0, + "fake_acc": 9.33, + "acc": 54.67 + }, + "biggan": { + "ap": 84.58, + "auroc": 80.73, + "real_acc": 100.0, + "fake_acc": 2.67, + "acc": 51.33 + }, + "glide": { + "ap": 99.44, + "auroc": 99.11, + "real_acc": 100.0, + "fake_acc": 87.0, + "acc": 93.5 + }, + "midjourney": { + "ap": 93.86, + "auroc": 91.3, + "real_acc": 99.67, + "fake_acc": 46.67, + "acc": 73.17 + }, + "sdv1.4": { + "ap": 100.0, + "auroc": 100.0, + "real_acc": 100.0, + "fake_acc": 100.0, + "acc": 100.0 + }, + "sdv1.5": { + "ap": 100.0, + "auroc": 100.0, + "real_acc": 100.0, + "fake_acc": 100.0, + "acc": 100.0 + }, + "vqdm": { + "ap": 93.87, + "auroc": 91.35, + "real_acc": 100.0, + "fake_acc": 30.33, + "acc": 65.17 + }, + "wukong": { + "ap": 100.0, + "auroc": 100.0, + "real_acc": 100.0, + "fake_acc": 100.0, + "acc": 100.0 + } + }, + "date": "2026-11-10T03:48:40", + "synthscope_version": "0.1.0", + "ckpt_ivi": "/hddstore/ssalehi/SynthScope/models/aide_full/model_2.pth on ivi-cn023 (the ckpt field above is the DAS6 node-cache copy); DIAGNOSTIC per-epoch run, --limit 300" +} \ No newline at end of file diff --git a/repro/bench_results/aide_trained_e2_synthbuster.json b/repro/bench_results/aide_trained_e2_synthbuster.json new file mode 100644 index 0000000000000000000000000000000000000000..759991669218ead98452e2610b1b21c0cf556589 --- /dev/null +++ b/repro/bench_results/aide_trained_e2_synthbuster.json @@ -0,0 +1,83 @@ +{ + "tag": "aide_trained_e2_synthbuster", + "model": "aide", + "ckpt": "/local/ssalehid/cache/data023/models/aide_full/model_2.pth", + "model_config": null, + "benchmark": "pergen", + "data_root": "/local/ssalehid/66991/layouts/Synthbuster_coco", + "jpeg_fakes": null, + "n_generators": 9, + "means": { + "acc": 70.37, + "map": 93.13, + "mauroc": 91.7 + }, + "per_generator": { + "dalle2": { + "ap": 86.57, + "auroc": 82.66, + "real_acc": 100.0, + "fake_acc": 3.33, + "acc": 51.67 + }, + "dalle3": { + "ap": 87.66, + "auroc": 86.01, + "real_acc": 100.0, + "fake_acc": 0.67, + "acc": 50.33 + }, + "firefly": { + "ap": 82.18, + "auroc": 83.14, + "real_acc": 100.0, + "fake_acc": 0.0, + "acc": 50.0 + }, + "glide": { + "ap": 98.53, + "auroc": 97.64, + "real_acc": 100.0, + "fake_acc": 78.0, + "acc": 89.0 + }, + "midjourney-v5": { + "ap": 92.97, + "auroc": 90.03, + "real_acc": 100.0, + "fake_acc": 26.33, + "acc": 63.17 + }, + "stable-diffusion-1-3": { + "ap": 100.0, + "auroc": 100.0, + "real_acc": 100.0, + "fake_acc": 100.0, + "acc": 100.0 + }, + "stable-diffusion-1-4": { + "ap": 100.0, + "auroc": 100.0, + "real_acc": 100.0, + "fake_acc": 99.33, + "acc": 99.67 + }, + "stable-diffusion-2": { + "ap": 93.69, + "auroc": 90.89, + "real_acc": 100.0, + "fake_acc": 24.0, + "acc": 62.0 + }, + "stable-diffusion-xl": { + "ap": 96.56, + "auroc": 94.93, + "real_acc": 100.0, + "fake_acc": 35.0, + "acc": 67.5 + } + }, + "date": "2026-11-10T03:37:52", + "synthscope_version": "0.1.0", + "ckpt_ivi": "/hddstore/ssalehi/SynthScope/models/aide_full/model_2.pth on ivi-cn023 (the ckpt field above is the DAS6 node-cache copy); DIAGNOSTIC per-epoch run, --limit 300" +} \ No newline at end of file diff --git a/repro/bench_results/aide_trained_e3_genimage8_l300.json b/repro/bench_results/aide_trained_e3_genimage8_l300.json new file mode 100644 index 0000000000000000000000000000000000000000..0336b909d026949ef5e60a0b472431a486c3d51e --- /dev/null +++ b/repro/bench_results/aide_trained_e3_genimage8_l300.json @@ -0,0 +1,76 @@ +{ + "tag": "aide_trained_e3_genimage8_l300", + "model": "aide", + "ckpt": "/local/ssalehid/cache/data023/models/aide_full/model_3.pth", + "model_config": null, + "benchmark": "pergen", + "data_root": "/local/ssalehid/cache/data023/GenImage_full/test", + "jpeg_fakes": null, + "n_generators": 8, + "means": { + "acc": 79.73, + "map": 92.5, + "mauroc": 89.53 + }, + "per_generator": { + "adm": { + "ap": 64.85, + "auroc": 49.18, + "real_acc": 100.0, + "fake_acc": 8.67, + "acc": 54.33 + }, + "biggan": { + "ap": 85.71, + "auroc": 82.15, + "real_acc": 100.0, + "fake_acc": 1.33, + "acc": 50.67 + }, + "glide": { + "ap": 99.39, + "auroc": 99.05, + "real_acc": 100.0, + "fake_acc": 84.33, + "acc": 92.17 + }, + "midjourney": { + "ap": 96.43, + "auroc": 94.99, + "real_acc": 100.0, + "fake_acc": 51.0, + "acc": 75.5 + }, + "sdv1.4": { + "ap": 100.0, + "auroc": 100.0, + "real_acc": 100.0, + "fake_acc": 100.0, + "acc": 100.0 + }, + "sdv1.5": { + "ap": 100.0, + "auroc": 100.0, + "real_acc": 100.0, + "fake_acc": 100.0, + "acc": 100.0 + }, + "vqdm": { + "ap": 93.6, + "auroc": 90.86, + "real_acc": 100.0, + "fake_acc": 30.67, + "acc": 65.33 + }, + "wukong": { + "ap": 100.0, + "auroc": 100.0, + "real_acc": 100.0, + "fake_acc": 99.67, + "acc": 99.83 + } + }, + "date": "2026-11-10T04:22:21", + "synthscope_version": "0.1.0", + "ckpt_ivi": "/hddstore/ssalehi/SynthScope/models/aide_full/model_3.pth on ivi-cn023 (the ckpt field above is the DAS6 node-cache copy); DIAGNOSTIC per-epoch run, --limit 300" +} \ No newline at end of file diff --git a/repro/bench_results/aide_trained_e3_synthbuster.json b/repro/bench_results/aide_trained_e3_synthbuster.json new file mode 100644 index 0000000000000000000000000000000000000000..6a4aace08260784da57ba9dd2e7c96959a8c0e3d --- /dev/null +++ b/repro/bench_results/aide_trained_e3_synthbuster.json @@ -0,0 +1,83 @@ +{ + "tag": "aide_trained_e3_synthbuster", + "model": "aide", + "ckpt": "/local/ssalehid/cache/data023/models/aide_full/model_3.pth", + "model_config": null, + "benchmark": "pergen", + "data_root": "/local/ssalehid/66991/layouts/Synthbuster_coco", + "jpeg_fakes": null, + "n_generators": 9, + "means": { + "acc": 70.24, + "map": 92.56, + "mauroc": 90.77 + }, + "per_generator": { + "dalle2": { + "ap": 84.96, + "auroc": 81.45, + "real_acc": 100.0, + "fake_acc": 2.0, + "acc": 51.0 + }, + "dalle3": { + "ap": 88.17, + "auroc": 86.08, + "real_acc": 100.0, + "fake_acc": 1.0, + "acc": 50.5 + }, + "firefly": { + "ap": 82.22, + "auroc": 81.28, + "real_acc": 100.0, + "fake_acc": 0.33, + "acc": 50.17 + }, + "glide": { + "ap": 98.21, + "auroc": 97.03, + "real_acc": 100.0, + "fake_acc": 74.67, + "acc": 87.33 + }, + "midjourney-v5": { + "ap": 92.57, + "auroc": 90.24, + "real_acc": 100.0, + "fake_acc": 29.0, + "acc": 64.5 + }, + "stable-diffusion-1-3": { + "ap": 100.0, + "auroc": 100.0, + "real_acc": 100.0, + "fake_acc": 100.0, + "acc": 100.0 + }, + "stable-diffusion-1-4": { + "ap": 100.0, + "auroc": 100.0, + "real_acc": 100.0, + "fake_acc": 100.0, + "acc": 100.0 + }, + "stable-diffusion-2": { + "ap": 90.88, + "auroc": 86.64, + "real_acc": 100.0, + "fake_acc": 23.33, + "acc": 61.67 + }, + "stable-diffusion-xl": { + "ap": 96.02, + "auroc": 94.21, + "real_acc": 100.0, + "fake_acc": 34.0, + "acc": 67.0 + } + }, + "date": "2026-11-10T04:11:37", + "synthscope_version": "0.1.0", + "ckpt_ivi": "/hddstore/ssalehi/SynthScope/models/aide_full/model_3.pth on ivi-cn023 (the ckpt field above is the DAS6 node-cache copy); DIAGNOSTIC per-epoch run, --limit 300" +} \ No newline at end of file diff --git a/repro/bench_results/aide_trained_e4_synthbuster.json b/repro/bench_results/aide_trained_e4_synthbuster.json new file mode 100644 index 0000000000000000000000000000000000000000..8d517e230b4b699229ff3809093804edcef65ca9 --- /dev/null +++ b/repro/bench_results/aide_trained_e4_synthbuster.json @@ -0,0 +1,83 @@ +{ + "tag": "aide_trained_e4_synthbuster", + "model": "aide", + "ckpt": "/local/ssalehid/cache/data023/models/aide_full/model_4.pth", + "model_config": null, + "benchmark": "pergen", + "data_root": "/local/ssalehid/66991/layouts/Synthbuster_coco", + "jpeg_fakes": null, + "n_generators": 9, + "means": { + "acc": 70.67, + "map": 92.2, + "mauroc": 90.38 + }, + "per_generator": { + "dalle2": { + "ap": 81.79, + "auroc": 77.76, + "real_acc": 100.0, + "fake_acc": 1.33, + "acc": 50.67 + }, + "dalle3": { + "ap": 88.95, + "auroc": 86.92, + "real_acc": 100.0, + "fake_acc": 1.0, + "acc": 50.5 + }, + "firefly": { + "ap": 78.59, + "auroc": 77.68, + "real_acc": 100.0, + "fake_acc": 0.0, + "acc": 50.0 + }, + "glide": { + "ap": 97.91, + "auroc": 96.4, + "real_acc": 100.0, + "fake_acc": 74.0, + "acc": 87.0 + }, + "midjourney-v5": { + "ap": 93.78, + "auroc": 91.31, + "real_acc": 100.0, + "fake_acc": 34.67, + "acc": 67.33 + }, + "stable-diffusion-1-3": { + "ap": 100.0, + "auroc": 100.0, + "real_acc": 100.0, + "fake_acc": 100.0, + "acc": 100.0 + }, + "stable-diffusion-1-4": { + "ap": 100.0, + "auroc": 100.0, + "real_acc": 100.0, + "fake_acc": 100.0, + "acc": 100.0 + }, + "stable-diffusion-2": { + "ap": 92.31, + "auroc": 88.61, + "real_acc": 100.0, + "fake_acc": 23.67, + "acc": 61.83 + }, + "stable-diffusion-xl": { + "ap": 96.45, + "auroc": 94.73, + "real_acc": 100.0, + "fake_acc": 37.33, + "acc": 68.67 + } + }, + "date": "2026-11-10T04:45:50", + "synthscope_version": "0.1.0", + "ckpt_ivi": "/hddstore/ssalehi/SynthScope/models/aide_full/model_4.pth on ivi-cn023 (the ckpt field above is the DAS6 node-cache copy); DIAGNOSTIC per-epoch run, --limit 300" +} \ No newline at end of file diff --git a/repro/bench_results/aide_trained_forensynths.json b/repro/bench_results/aide_trained_forensynths.json new file mode 100644 index 0000000000000000000000000000000000000000..6217ce19655c8d7bdc0ceba313fa94dbad3bebd6 --- /dev/null +++ b/repro/bench_results/aide_trained_forensynths.json @@ -0,0 +1,111 @@ +{ + "tag": "aide_trained_forensynths", + "model": "aide", + "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/aide_train/model_best.pth", + "model_config": null, + "benchmark": "forensynths", + "data_root": "/local/ssalehid/cache/data023/CNNDetection/test", + "jpeg_fakes": null, + "n_generators": 13, + "means": { + "acc": 62.5, + "map": 80.42, + "mauroc": 80.41 + }, + "per_generator": { + "biggan": { + "ap": 94.93, + "auroc": 94.27, + "real_acc": 99.67, + "fake_acc": 39.33, + "acc": 69.5 + }, + "crn": { + "ap": 59.21, + "auroc": 65.5, + "real_acc": 67.33, + "fake_acc": 57.67, + "acc": 62.5 + }, + "cyclegan": { + "ap": 88.68, + "auroc": 87.17, + "real_acc": 100.0, + "fake_acc": 8.33, + "acc": 54.17 + }, + "deepfake": { + "ap": 75.17, + "auroc": 74.77, + "real_acc": 99.0, + "fake_acc": 11.67, + "acc": 55.33 + }, + "gaugan": { + "ap": 75.5, + "auroc": 79.3, + "real_acc": 99.67, + "fake_acc": 2.0, + "acc": 50.83 + }, + "imle": { + "ap": 76.75, + "auroc": 78.14, + "real_acc": 67.33, + "fake_acc": 77.33, + "acc": 72.33 + }, + "progan": { + "ap": 91.15, + "auroc": 89.79, + "real_acc": 100.0, + "fake_acc": 22.33, + "acc": 61.17 + }, + "san": { + "ap": 71.81, + "auroc": 65.45, + "real_acc": 99.54, + "fake_acc": 14.61, + "acc": 57.08 + }, + "seeingdark": { + "ap": 81.66, + "auroc": 90.88, + "real_acc": 82.22, + "fake_acc": 91.67, + "acc": 86.94 + }, + "stargan": { + "ap": 93.97, + "auroc": 92.34, + "real_acc": 99.67, + "fake_acc": 56.33, + "acc": 78.0 + }, + "stylegan": { + "ap": 90.88, + "auroc": 87.27, + "real_acc": 100.0, + "fake_acc": 24.33, + "acc": 62.17 + }, + "stylegan2": { + "ap": 70.8, + "auroc": 66.27, + "real_acc": 100.0, + "fake_acc": 0.67, + "acc": 50.33 + }, + "whichfaceisreal": { + "ap": 74.95, + "auroc": 74.17, + "real_acc": 100.0, + "fake_acc": 4.33, + "acc": 52.17 + } + }, + "date": "2026-11-10T00:49:12", + "synthscope_version": "0.1.0", + "ckpt_ivi": "/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/aide_train/model_best.pth (= /hddstore/ssalehi/SynthScope/models/aide_full/model_best.pth on ivi-cn023); the ckpt field above is the DAS6 node-cache copy" +} diff --git a/repro/bench_results/aide_trained_genimage8.json b/repro/bench_results/aide_trained_genimage8.json new file mode 100644 index 0000000000000000000000000000000000000000..b886c557b7bb8870033770ffe755d67d3170d5d0 --- /dev/null +++ b/repro/bench_results/aide_trained_genimage8.json @@ -0,0 +1,76 @@ +{ + "tag": "aide_trained_genimage8", + "model": "aide", + "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/aide_train/model_best.pth", + "model_config": null, + "benchmark": "pergen", + "data_root": "/local/ssalehid/cache/data023/GenImage_full/test", + "jpeg_fakes": null, + "n_generators": 8, + "means": { + "acc": 80.73, + "map": 93.9, + "mauroc": 91.66 + }, + "per_generator": { + "adm": { + "ap": 75.72, + "auroc": 64.57, + "real_acc": 100.0, + "fake_acc": 17.27, + "acc": 58.63 + }, + "biggan": { + "ap": 86.0, + "auroc": 83.94, + "real_acc": 100.0, + "fake_acc": 1.73, + "acc": 50.87 + }, + "glide": { + "ap": 99.29, + "auroc": 98.87, + "real_acc": 99.93, + "fake_acc": 84.07, + "acc": 92.0 + }, + "midjourney": { + "ap": 94.76, + "auroc": 92.67, + "real_acc": 99.93, + "fake_acc": 49.27, + "acc": 74.6 + }, + "sdv1.4": { + "ap": 100.0, + "auroc": 100.0, + "real_acc": 100.0, + "fake_acc": 99.95, + "acc": 99.97 + }, + "sdv1.5": { + "ap": 100.0, + "auroc": 100.0, + "real_acc": 100.0, + "fake_acc": 100.0, + "acc": 100.0 + }, + "vqdm": { + "ap": 95.42, + "auroc": 93.26, + "real_acc": 100.0, + "fake_acc": 39.67, + "acc": 69.83 + }, + "wukong": { + "ap": 100.0, + "auroc": 100.0, + "real_acc": 100.0, + "fake_acc": 99.87, + "acc": 99.93 + } + }, + "date": "2026-11-10T02:00:21", + "synthscope_version": "0.1.0", + "ckpt_ivi": "/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/aide_train/model_best.pth (= /hddstore/ssalehi/SynthScope/models/aide_full/model_best.pth on ivi-cn023); the ckpt field above is the DAS6 node-cache copy" +} diff --git a/repro/bench_results/aide_trained_genimage8_l300.json b/repro/bench_results/aide_trained_genimage8_l300.json new file mode 100644 index 0000000000000000000000000000000000000000..485811040a21d928c6cc1a349c299a2dda46ffa2 --- /dev/null +++ b/repro/bench_results/aide_trained_genimage8_l300.json @@ -0,0 +1,76 @@ +{ + "tag": "aide_trained_genimage8_l300", + "model": "aide", + "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/aide_train/model_best.pth", + "model_config": null, + "benchmark": "pergen", + "data_root": "/local/ssalehid/cache/data023/GenImage_full/test", + "jpeg_fakes": null, + "n_generators": 8, + "means": { + "acc": 80.69, + "map": 92.57, + "mauroc": 89.63 + }, + "per_generator": { + "adm": { + "ap": 66.62, + "auroc": 51.31, + "real_acc": 100.0, + "fake_acc": 13.67, + "acc": 56.83 + }, + "biggan": { + "ap": 84.31, + "auroc": 80.9, + "real_acc": 100.0, + "fake_acc": 1.67, + "acc": 50.83 + }, + "glide": { + "ap": 99.41, + "auroc": 99.0, + "real_acc": 100.0, + "fake_acc": 84.67, + "acc": 92.33 + }, + "midjourney": { + "ap": 95.77, + "auroc": 94.08, + "real_acc": 100.0, + "fake_acc": 52.67, + "acc": 76.33 + }, + "sdv1.4": { + "ap": 100.0, + "auroc": 100.0, + "real_acc": 100.0, + "fake_acc": 100.0, + "acc": 100.0 + }, + "sdv1.5": { + "ap": 100.0, + "auroc": 100.0, + "real_acc": 100.0, + "fake_acc": 100.0, + "acc": 100.0 + }, + "vqdm": { + "ap": 94.47, + "auroc": 91.72, + "real_acc": 100.0, + "fake_acc": 38.67, + "acc": 69.33 + }, + "wukong": { + "ap": 100.0, + "auroc": 100.0, + "real_acc": 100.0, + "fake_acc": 99.67, + "acc": 99.83 + } + }, + "date": "2026-11-10T00:05:18", + "synthscope_version": "0.1.0", + "ckpt_ivi": "/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/aide_train/model_best.pth (= /hddstore/ssalehi/SynthScope/models/aide_full/model_best.pth on ivi-cn023); the ckpt field above is the DAS6 node-cache copy" +} diff --git a/repro/bench_results/cure_hybA_bfree_online.json b/repro/bench_results/cure_hybA_bfree_online.json new file mode 100644 index 0000000000000000000000000000000000000000..e12646bebad128b4727ebc6ea731c027501585a0 --- /dev/null +++ b/repro/bench_results/cure_hybA_bfree_online.json @@ -0,0 +1,26 @@ +{ + "tag": "cure_hybA_bfree_online", + "model": "cure", + "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_trained/hybrid/A_trainedLoRA_releasedSubspaceHead.pth", + "model_config": null, + "benchmark": "pergen", + "data_root": "/local/ssalehid/cache/data029/BFreeOnline/test", + "jpeg_fakes": null, + "n_generators": 1, + "means": { + "acc": 48.61, + "map": 66.62, + "mauroc": 38.67 + }, + "per_generator": { + "viral": { + "ap": 66.62, + "auroc": 38.67, + "real_acc": 67.29, + "fake_acc": 29.93, + "acc": 48.61 + } + }, + "date": "2026-11-09T06:36:39", + "synthscope_version": "0.1.0" +} diff --git a/repro/bench_results/cure_hybA_rrdataset.json b/repro/bench_results/cure_hybA_rrdataset.json new file mode 100644 index 0000000000000000000000000000000000000000..fd6532074a3280f9cf02b8ad2e0581f0cc091e16 --- /dev/null +++ b/repro/bench_results/cure_hybA_rrdataset.json @@ -0,0 +1,40 @@ +{ + "tag": "cure_hybA_rrdataset", + "model": "cure", + "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_trained/hybrid/A_trainedLoRA_releasedSubspaceHead.pth", + "model_config": null, + "benchmark": "pergen", + "data_root": "/local/ssalehid/cache/data029/RRDataset/test", + "jpeg_fakes": null, + "n_generators": 3, + "means": { + "acc": 33.17, + "map": 39.18, + "mauroc": 25.55 + }, + "per_generator": { + "original": { + "ap": 35.51, + "auroc": 15.52, + "real_acc": 44.41, + "fake_acc": 15.4, + "acc": 29.91 + }, + "redigital": { + "ap": 43.38, + "auroc": 36.53, + "real_acc": 22.91, + "fake_acc": 55.59, + "acc": 39.25 + }, + "transfer": { + "ap": 38.66, + "auroc": 24.6, + "real_acc": 28.18, + "fake_acc": 32.52, + "acc": 30.35 + } + }, + "date": "2026-11-09T07:14:21", + "synthscope_version": "0.1.0" +} diff --git a/repro/bench_results/cure_hybA_synthwildx.json b/repro/bench_results/cure_hybA_synthwildx.json new file mode 100644 index 0000000000000000000000000000000000000000..0c8fe606999b2dadbc573952fa45bca3f56b59d6 --- /dev/null +++ b/repro/bench_results/cure_hybA_synthwildx.json @@ -0,0 +1,40 @@ +{ + "tag": "cure_hybA_synthwildx", + "model": "cure", + "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_trained/hybrid/A_trainedLoRA_releasedSubspaceHead.pth", + "model_config": null, + "benchmark": "pergen", + "data_root": "/local/ssalehid/cache/data029/SynthWildX/test", + "jpeg_fakes": null, + "n_generators": 3, + "means": { + "acc": 35.0, + "map": 35.29, + "mauroc": 16.34 + }, + "per_generator": { + "dalle3": { + "ap": 31.75, + "auroc": 13.02, + "real_acc": 56.66, + "fake_acc": 9.18, + "acc": 32.92 + }, + "firefly": { + "ap": 38.19, + "auroc": 18.15, + "real_acc": 56.66, + "fake_acc": 15.43, + "acc": 36.05 + }, + "midjourney_v5": { + "ap": 35.93, + "auroc": 17.86, + "real_acc": 56.66, + "fake_acc": 15.4, + "acc": 36.03 + } + }, + "date": "2026-11-09T06:40:23", + "synthscope_version": "0.1.0" +} diff --git a/repro/bench_results/cure_hybA_wildrf.json b/repro/bench_results/cure_hybA_wildrf.json new file mode 100644 index 0000000000000000000000000000000000000000..d88fba385830bca63d4037dc27bd9cf4a6a51c29 --- /dev/null +++ b/repro/bench_results/cure_hybA_wildrf.json @@ -0,0 +1,40 @@ +{ + "tag": "cure_hybA_wildrf", + "model": "cure", + "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_trained/hybrid/A_trainedLoRA_releasedSubspaceHead.pth", + "model_config": null, + "benchmark": "pergen", + "data_root": "/local/ssalehid/cache/data029/WildRF/test", + "jpeg_fakes": null, + "n_generators": 3, + "means": { + "acc": 35.05, + "map": 33.37, + "mauroc": 11.72 + }, + "per_generator": { + "facebook": { + "ap": 33.38, + "auroc": 12.52, + "real_acc": 63.75, + "fake_acc": 9.38, + "acc": 36.56 + }, + "reddit": { + "ap": 32.81, + "auroc": 9.37, + "real_acc": 52.4, + "fake_acc": 8.27, + "acc": 30.33 + }, + "twitter": { + "ap": 33.91, + "auroc": 13.26, + "real_acc": 67.74, + "fake_acc": 8.77, + "acc": 38.26 + } + }, + "date": "2026-11-09T06:45:21", + "synthscope_version": "0.1.0" +} diff --git a/repro/bench_results/cure_hybB_bfree_online.json b/repro/bench_results/cure_hybB_bfree_online.json new file mode 100644 index 0000000000000000000000000000000000000000..f3e89e3e129f94108c60d4275619f5ed2a59914a --- /dev/null +++ b/repro/bench_results/cure_hybB_bfree_online.json @@ -0,0 +1,26 @@ +{ + "tag": "cure_hybB_bfree_online", + "model": "cure", + "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_trained/hybrid/B_releasedLoRA_trainedSubspaceHead.pth", + "model_config": null, + "benchmark": "pergen", + "data_root": "/local/ssalehid/cache/data029/BFreeOnline/test", + "jpeg_fakes": null, + "n_generators": 1, + "means": { + "acc": 43.68, + "map": 46.21, + "mauroc": 6.53 + }, + "per_generator": { + "viral": { + "ap": 46.21, + "auroc": 6.53, + "real_acc": 87.36, + "fake_acc": 0.0, + "acc": 43.68 + } + }, + "date": "2026-11-09T06:36:41", + "synthscope_version": "0.1.0" +} diff --git a/repro/bench_results/cure_hybB_rrdataset.json b/repro/bench_results/cure_hybB_rrdataset.json new file mode 100644 index 0000000000000000000000000000000000000000..a068406675c4f543a53521a0545737abe6dba12f --- /dev/null +++ b/repro/bench_results/cure_hybB_rrdataset.json @@ -0,0 +1,40 @@ +{ + "tag": "cure_hybB_rrdataset", + "model": "cure", + "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_trained/hybrid/B_releasedLoRA_trainedSubspaceHead.pth", + "model_config": null, + "benchmark": "pergen", + "data_root": "/local/ssalehid/cache/data029/RRDataset/test", + "jpeg_fakes": null, + "n_generators": 3, + "means": { + "acc": 43.15, + "map": 33.0, + "mauroc": 12.87 + }, + "per_generator": { + "original": { + "ap": 31.41, + "auroc": 6.35, + "real_acc": 81.49, + "fake_acc": 0.69, + "acc": 41.09 + }, + "redigital": { + "ap": 35.55, + "auroc": 22.28, + "real_acc": 92.34, + "fake_acc": 1.72, + "acc": 47.03 + }, + "transfer": { + "ap": 32.03, + "auroc": 9.99, + "real_acc": 79.95, + "fake_acc": 2.73, + "acc": 41.34 + } + }, + "date": "2026-11-09T07:14:20", + "synthscope_version": "0.1.0" +} diff --git a/repro/bench_results/cure_hybB_synthwildx.json b/repro/bench_results/cure_hybB_synthwildx.json new file mode 100644 index 0000000000000000000000000000000000000000..5f3f064d2b618b66c0818e166ea9a5454aa9f0ce --- /dev/null +++ b/repro/bench_results/cure_hybB_synthwildx.json @@ -0,0 +1,40 @@ +{ + "tag": "cure_hybB_synthwildx", + "model": "cure", + "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_trained/hybrid/B_releasedLoRA_trainedSubspaceHead.pth", + "model_config": null, + "benchmark": "pergen", + "data_root": "/local/ssalehid/cache/data029/SynthWildX/test", + "jpeg_fakes": null, + "n_generators": 3, + "means": { + "acc": 38.44, + "map": 32.36, + "mauroc": 5.17 + }, + "per_generator": { + "dalle3": { + "ap": 30.29, + "auroc": 4.05, + "real_acc": 76.51, + "fake_acc": 0.0, + "acc": 38.26 + }, + "firefly": { + "ap": 34.6, + "auroc": 8.08, + "real_acc": 76.51, + "fake_acc": 1.06, + "acc": 38.79 + }, + "midjourney_v5": { + "ap": 32.2, + "auroc": 3.39, + "real_acc": 76.51, + "fake_acc": 0.0, + "acc": 38.26 + } + }, + "date": "2026-11-09T06:40:24", + "synthscope_version": "0.1.0" +} diff --git a/repro/bench_results/cure_hybB_wildrf.json b/repro/bench_results/cure_hybB_wildrf.json new file mode 100644 index 0000000000000000000000000000000000000000..3eb521ce7bf4fddec866e5b8efc33288d5e2a060 --- /dev/null +++ b/repro/bench_results/cure_hybB_wildrf.json @@ -0,0 +1,40 @@ +{ + "tag": "cure_hybB_wildrf", + "model": "cure", + "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_trained/hybrid/B_releasedLoRA_trainedSubspaceHead.pth", + "model_config": null, + "benchmark": "pergen", + "data_root": "/local/ssalehid/cache/data029/WildRF/test", + "jpeg_fakes": null, + "n_generators": 3, + "means": { + "acc": 40.5, + "map": 31.25, + "mauroc": 3.35 + }, + "per_generator": { + "facebook": { + "ap": 31.34, + "auroc": 3.55, + "real_acc": 85.0, + "fake_acc": 0.0, + "acc": 42.5 + }, + "reddit": { + "ap": 31.14, + "auroc": 3.15, + "real_acc": 84.4, + "fake_acc": 0.27, + "acc": 42.33 + }, + "twitter": { + "ap": 31.28, + "auroc": 3.35, + "real_acc": 73.31, + "fake_acc": 0.0, + "acc": 36.66 + } + }, + "date": "2026-11-09T06:45:21", + "synthscope_version": "0.1.0" +} diff --git a/repro/bench_results/cure_relS23_bfree_online.json b/repro/bench_results/cure_relS23_bfree_online.json new file mode 100644 index 0000000000000000000000000000000000000000..fd0418c87e27abc985c29c0e357e6cc287977fe5 --- /dev/null +++ b/repro/bench_results/cure_relS23_bfree_online.json @@ -0,0 +1,26 @@ +{ + "tag": "cure_relS23_bfree_online", + "model": "cure", + "ckpt": "/local/ssalehid/66726/relS23/cure_trained.pth", + "model_config": null, + "benchmark": "pergen", + "data_root": "/local/ssalehid/cache/data029/BFreeOnline/test", + "jpeg_fakes": null, + "n_generators": 1, + "means": { + "acc": 91.08, + "map": 99.11, + "mauroc": 98.25 + }, + "per_generator": { + "viral": { + "ap": 99.11, + "auroc": 98.25, + "real_acc": 97.03, + "fake_acc": 85.13, + "acc": 91.08 + } + }, + "date": "2026-11-09T07:29:13", + "synthscope_version": "0.1.0" +} diff --git a/repro/bench_results/cure_relS23_rrdataset.json b/repro/bench_results/cure_relS23_rrdataset.json new file mode 100644 index 0000000000000000000000000000000000000000..9f2e66ce1ac27457e54bec5f380f241a1c8cd2a2 --- /dev/null +++ b/repro/bench_results/cure_relS23_rrdataset.json @@ -0,0 +1,40 @@ +{ + "tag": "cure_relS23_rrdataset", + "model": "cure", + "ckpt": "/local/ssalehid/66726/relS23/cure_trained.pth", + "model_config": null, + "benchmark": "pergen", + "data_root": "/local/ssalehid/cache/data029/RRDataset/test", + "jpeg_fakes": null, + "n_generators": 3, + "means": { + "acc": 81.04, + "map": 88.46, + "mauroc": 86.84 + }, + "per_generator": { + "original": { + "ap": 95.3, + "auroc": 95.17, + "real_acc": 93.62, + "fake_acc": 87.02, + "acc": 90.32 + }, + "redigital": { + "ap": 78.75, + "auroc": 76.25, + "real_acc": 92.92, + "fake_acc": 43.21, + "acc": 68.06 + }, + "transfer": { + "ap": 91.34, + "auroc": 89.1, + "real_acc": 94.4, + "fake_acc": 75.09, + "acc": 84.75 + } + }, + "date": "2026-11-09T08:01:04", + "synthscope_version": "0.1.0" +} diff --git a/repro/bench_results/cure_relS23_synthwildx.json b/repro/bench_results/cure_relS23_synthwildx.json new file mode 100644 index 0000000000000000000000000000000000000000..3180049f2f7b136c999830cea0ff107e112f20d8 --- /dev/null +++ b/repro/bench_results/cure_relS23_synthwildx.json @@ -0,0 +1,40 @@ +{ + "tag": "cure_relS23_synthwildx", + "model": "cure", + "ckpt": "/local/ssalehid/66726/relS23/cure_trained.pth", + "model_config": null, + "benchmark": "pergen", + "data_root": "/local/ssalehid/cache/data029/SynthWildX/test", + "jpeg_fakes": null, + "n_generators": 3, + "means": { + "acc": 92.65, + "map": 95.41, + "mauroc": 96.32 + }, + "per_generator": { + "dalle3": { + "ap": 95.58, + "auroc": 97.27, + "real_acc": 92.25, + "fake_acc": 96.68, + "acc": 94.47 + }, + "firefly": { + "ap": 94.06, + "auroc": 94.19, + "real_acc": 92.25, + "fake_acc": 84.99, + "acc": 88.62 + }, + "midjourney_v5": { + "ap": 96.58, + "auroc": 97.5, + "real_acc": 92.25, + "fake_acc": 97.47, + "acc": 94.86 + } + }, + "date": "2026-11-09T07:32:03", + "synthscope_version": "0.1.0" +} diff --git a/repro/bench_results/cure_relS23_wildrf.json b/repro/bench_results/cure_relS23_wildrf.json new file mode 100644 index 0000000000000000000000000000000000000000..ed7c0c8f7106e8e208ecea1be731d0baec7c56ea --- /dev/null +++ b/repro/bench_results/cure_relS23_wildrf.json @@ -0,0 +1,40 @@ +{ + "tag": "cure_relS23_wildrf", + "model": "cure", + "ckpt": "/local/ssalehid/66726/relS23/cure_trained.pth", + "model_config": null, + "benchmark": "pergen", + "data_root": "/local/ssalehid/cache/data029/WildRF/test", + "jpeg_fakes": null, + "n_generators": 3, + "means": { + "acc": 95.45, + "map": 98.94, + "mauroc": 98.99 + }, + "per_generator": { + "facebook": { + "ap": 98.49, + "auroc": 98.65, + "real_acc": 90.62, + "fake_acc": 99.37, + "acc": 95.0 + }, + "reddit": { + "ap": 99.28, + "auroc": 99.22, + "real_acc": 94.67, + "fake_acc": 97.73, + "acc": 96.2 + }, + "twitter": { + "ap": 99.04, + "auroc": 99.1, + "real_acc": 92.67, + "fake_acc": 97.66, + "acc": 95.16 + } + }, + "date": "2026-11-09T07:36:08", + "synthscope_version": "0.1.0" +} diff --git a/repro/bench_results/cure_trained_aigcdetect.json b/repro/bench_results/cure_trained_aigcdetect.json new file mode 100644 index 0000000000000000000000000000000000000000..90b603a1ad522a41126a2616baafbedee5674df7 --- /dev/null +++ b/repro/bench_results/cure_trained_aigcdetect.json @@ -0,0 +1,138 @@ +{ + "tag": "cure_trained_aigcdetect", + "model": "cure", + "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_trained/cure_trained.pth", + "model_config": null, + "benchmark": "pergen", + "data_root": "/local/ssalehid/cache/data029/AIGCDetect/test", + "jpeg_fakes": null, + "n_generators": 17, + "means": { + "acc": 81.55, + "map": 93.52, + "mauroc": 92.22 + }, + "per_generator": { + "ADM": { + "ap": 64.48, + "auroc": 59.19, + "real_acc": 99.92, + "fake_acc": 6.3, + "acc": 53.11 + }, + "DALLE2": { + "ap": 80.96, + "auroc": 73.98, + "real_acc": 100.0, + "fake_acc": 35.8, + "acc": 67.9 + }, + "Glide": { + "ap": 90.55, + "auroc": 87.63, + "real_acc": 99.82, + "fake_acc": 44.35, + "acc": 72.08 + }, + "Midjourney": { + "ap": 83.72, + "auroc": 77.64, + "real_acc": 99.85, + "fake_acc": 41.08, + "acc": 70.47 + }, + "VQDM": { + "ap": 94.16, + "auroc": 92.2, + "real_acc": 99.88, + "fake_acc": 59.92, + "acc": 79.9 + }, + "biggan": { + "ap": 98.22, + "auroc": 98.59, + "real_acc": 99.7, + "fake_acc": 66.7, + "acc": 83.2 + }, + "cyclegan": { + "ap": 97.41, + "auroc": 97.35, + "real_acc": 99.77, + "fake_acc": 26.57, + "acc": 63.17 + }, + "gaugan": { + "ap": 99.4, + "auroc": 99.64, + "real_acc": 99.82, + "fake_acc": 75.78, + "acc": 87.8 + }, + "progan": { + "ap": 99.81, + "auroc": 99.76, + "real_acc": 100.0, + "fake_acc": 83.0, + "acc": 91.5 + }, + "sd_xl": { + "ap": 98.84, + "auroc": 98.38, + "real_acc": 99.9, + "fake_acc": 88.9, + "acc": 94.4 + }, + "stable_diffusion_v_1_4": { + "ap": 99.99, + "auroc": 99.99, + "real_acc": 99.87, + "fake_acc": 99.95, + "acc": 99.91 + }, + "stable_diffusion_v_1_5": { + "ap": 99.94, + "auroc": 99.9, + "real_acc": 99.86, + "fake_acc": 99.84, + "acc": 99.85 + }, + "stargan": { + "ap": 96.45, + "auroc": 98.74, + "real_acc": 99.0, + "fake_acc": 73.69, + "acc": 86.34 + }, + "stylegan": { + "ap": 97.63, + "auroc": 97.2, + "real_acc": 99.88, + "fake_acc": 59.62, + "acc": 79.75 + }, + "stylegan2": { + "ap": 91.03, + "auroc": 89.22, + "real_acc": 99.9, + "fake_acc": 23.3, + "acc": 61.6 + }, + "whichfaceisreal": { + "ap": 97.27, + "auroc": 98.37, + "real_acc": 96.1, + "fake_acc": 95.4, + "acc": 95.75 + }, + "wukong": { + "ap": 99.96, + "auroc": 99.94, + "real_acc": 99.87, + "fake_acc": 99.52, + "acc": 99.69 + } + }, + "date": "2026-11-09T04:26:18", + "synthscope_version": "0.1.0" +} diff --git a/repro/bench_results/cure_trained_aigibench20_full.json b/repro/bench_results/cure_trained_aigibench20_full.json new file mode 100644 index 0000000000000000000000000000000000000000..a88c4e2701f65423b60012dc54ce50b09f514bf7 --- /dev/null +++ b/repro/bench_results/cure_trained_aigibench20_full.json @@ -0,0 +1,159 @@ +{ + "tag": "cure_trained_aigibench20_full", + "model": "cure", + "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_trained/cure_trained.pth", + "model_config": null, + "benchmark": "pergen", + "data_root": "/local/ssalehid/cache/data023/AIGIBench/test", + "jpeg_fakes": null, + "n_generators": 20, + "means": { + "acc": 85.05, + "map": 92.69, + "mauroc": 91.84 + }, + "per_generator": { + "BLIP": { + "ap": 99.86, + "auroc": 99.92, + "real_acc": 98.89, + "fake_acc": 99.96, + "acc": 99.42 + }, + "CommunityAI": { + "ap": 91.29, + "auroc": 89.61, + "real_acc": 96.97, + "fake_acc": 66.28, + "acc": 81.62 + }, + "DALLE-3": { + "ap": 98.02, + "auroc": 97.97, + "real_acc": 97.95, + "fake_acc": 90.38, + "acc": 94.16 + }, + "FLUX1-dev": { + "ap": 85.61, + "auroc": 82.15, + "real_acc": 98.31, + "fake_acc": 46.04, + "acc": 72.18 + }, + "GLIDE": { + "ap": 86.43, + "auroc": 84.15, + "real_acc": 98.4, + "fake_acc": 46.87, + "acc": 72.63 + }, + "IP_Adapter": { + "ap": 86.98, + "auroc": 85.62, + "real_acc": 98.36, + "fake_acc": 38.36, + "acc": 68.36 + }, + "Imagen3": { + "ap": 73.29, + "auroc": 69.46, + "real_acc": 98.24, + "fake_acc": 19.53, + "acc": 58.89 + }, + "Infinite_ID": { + "ap": 98.01, + "auroc": 98.56, + "real_acc": 98.18, + "fake_acc": 89.11, + "acc": 93.64 + }, + "InstantID": { + "ap": 99.36, + "auroc": 99.55, + "real_acc": 98.22, + "fake_acc": 98.76, + "acc": 98.49 + }, + "Midjourney": { + "ap": 82.77, + "auroc": 80.24, + "real_acc": 96.37, + "fake_acc": 43.1, + "acc": 69.73 + }, + "PhotoMaker": { + "ap": 83.37, + "auroc": 76.44, + "real_acc": 98.56, + "fake_acc": 46.62, + "acc": 72.59 + }, + "ProGAN": { + "ap": 99.81, + "auroc": 99.76, + "real_acc": 100.0, + "fake_acc": 83.0, + "acc": 91.5 + }, + "R3GAN": { + "ap": 97.35, + "auroc": 98.18, + "real_acc": 98.09, + "fake_acc": 83.44, + "acc": 90.77 + }, + "SD3": { + "ap": 95.99, + "auroc": 95.65, + "real_acc": 98.64, + "fake_acc": 76.71, + "acc": 87.68 + }, + "SDXL": { + "ap": 99.41, + "auroc": 99.57, + "real_acc": 98.64, + "fake_acc": 98.47, + "acc": 98.56 + }, + "SocialRF": { + "ap": 87.35, + "auroc": 87.85, + "real_acc": 95.13, + "fake_acc": 62.57, + "acc": 78.85 + }, + "StyleGAN-XL": { + "ap": 98.2, + "auroc": 99.23, + "real_acc": 98.16, + "fake_acc": 98.2, + "acc": 98.18 + }, + "StyleGAN3": { + "ap": 95.26, + "auroc": 95.49, + "real_acc": 98.33, + "fake_acc": 68.33, + "acc": 83.33 + }, + "StyleSwim": { + "ap": 98.22, + "auroc": 98.95, + "real_acc": 98.31, + "fake_acc": 91.13, + "acc": 94.72 + }, + "WFIR": { + "ap": 97.27, + "auroc": 98.37, + "real_acc": 96.1, + "fake_acc": 95.4, + "acc": 95.75 + } + }, + "date": "2026-11-09T05:48:29", + "synthscope_version": "0.1.0" +} diff --git a/repro/bench_results/cure_trained_bfree_online.json b/repro/bench_results/cure_trained_bfree_online.json new file mode 100644 index 0000000000000000000000000000000000000000..58a883ae72541d91ae191b604a92b523d466a2cf --- /dev/null +++ b/repro/bench_results/cure_trained_bfree_online.json @@ -0,0 +1,26 @@ +{ + "tag": "cure_trained_bfree_online", + "model": "cure", + "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_trained/cure_trained.pth", + "model_config": null, + "benchmark": "pergen", + "data_root": "/local/ssalehid/cache/data029/BFreeOnline/test", + "jpeg_fakes": null, + "n_generators": 1, + "means": { + "acc": 66.64, + "map": 93.37, + "mauroc": 85.77 + }, + "per_generator": { + "viral": { + "ap": 93.37, + "auroc": 85.77, + "real_acc": 98.88, + "fake_acc": 34.39, + "acc": 66.64 + } + }, + "date": "2026-11-09T02:50:24", + "synthscope_version": "0.1.0" +} diff --git a/repro/bench_results/cure_trained_evalgen.json b/repro/bench_results/cure_trained_evalgen.json new file mode 100644 index 0000000000000000000000000000000000000000..b1d0b20e0ab9c98450eeaabfb165265dd5c00593 --- /dev/null +++ b/repro/bench_results/cure_trained_evalgen.json @@ -0,0 +1,54 @@ +{ + "tag": "cure_trained_evalgen", + "model": "cure", + "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_trained/cure_trained.pth", + "model_config": null, + "benchmark": "pergen", + "data_root": "/local/ssalehid/cache/data029/EvalGEN/test", + "jpeg_fakes": null, + "n_generators": 5, + "means": { + "acc": 90.65, + "map": 98.3, + "mauroc": 95.96 + }, + "per_generator": { + "Flux": { + "ap": 93.44, + "auroc": 84.58, + "real_acc": 99.78, + "fake_acc": 39.96, + "acc": 69.87 + }, + "GoT": { + "ap": 99.69, + "auroc": 99.24, + "real_acc": 99.78, + "fake_acc": 93.98, + "acc": 96.88 + }, + "Infinity": { + "ap": 98.72, + "auroc": 96.83, + "real_acc": 99.78, + "fake_acc": 80.22, + "acc": 90.0 + }, + "NOVA": { + "ap": 99.77, + "auroc": 99.41, + "real_acc": 99.78, + "fake_acc": 96.26, + "acc": 98.02 + }, + "OmniGen": { + "ap": 99.88, + "auroc": 99.72, + "real_acc": 99.78, + "fake_acc": 97.14, + "acc": 98.46 + } + }, + "date": "2026-11-09T03:45:31", + "synthscope_version": "0.1.0" +} diff --git a/repro/bench_results/cure_trained_forensynths.json b/repro/bench_results/cure_trained_forensynths.json new file mode 100644 index 0000000000000000000000000000000000000000..f799422b8f581ad6e0c724b704f043156181542e --- /dev/null +++ b/repro/bench_results/cure_trained_forensynths.json @@ -0,0 +1,110 @@ +{ + "tag": "cure_trained_forensynths", + "model": "cure", + "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_trained/cure_trained.pth", + "model_config": null, + "benchmark": "forensynths", + "data_root": "/local/ssalehid/cache/data023/CNNDetection/test", + "jpeg_fakes": null, + "n_generators": 13, + "means": { + "acc": 75.83, + "map": 94.24, + "mauroc": 93.56 + }, + "per_generator": { + "biggan": { + "ap": 98.22, + "auroc": 98.59, + "real_acc": 99.7, + "fake_acc": 66.7, + "acc": 83.2 + }, + "crn": { + "ap": 98.99, + "auroc": 98.96, + "real_acc": 99.98, + "fake_acc": 38.67, + "acc": 69.33 + }, + "cyclegan": { + "ap": 97.41, + "auroc": 97.35, + "real_acc": 99.77, + "fake_acc": 26.57, + "acc": 63.17 + }, + "deepfake": { + "ap": 80.92, + "auroc": 80.52, + "real_acc": 99.34, + "fake_acc": 3.56, + "acc": 51.45 + }, + "gaugan": { + "ap": 99.4, + "auroc": 99.64, + "real_acc": 99.82, + "fake_acc": 75.78, + "acc": 87.8 + }, + "imle": { + "ap": 99.28, + "auroc": 99.22, + "real_acc": 99.98, + "fake_acc": 54.72, + "acc": 77.35 + }, + "progan": { + "ap": 99.81, + "auroc": 99.76, + "real_acc": 100.0, + "fake_acc": 83.0, + "acc": 91.5 + }, + "san": { + "ap": 88.32, + "auroc": 82.02, + "real_acc": 100.0, + "fake_acc": 54.79, + "acc": 77.4 + }, + "seeingdark": { + "ap": 80.37, + "auroc": 76.7, + "real_acc": 100.0, + "fake_acc": 22.22, + "acc": 61.11 + }, + "stargan": { + "ap": 96.45, + "auroc": 98.74, + "real_acc": 99.0, + "fake_acc": 73.69, + "acc": 86.34 + }, + "stylegan": { + "ap": 97.63, + "auroc": 97.2, + "real_acc": 99.88, + "fake_acc": 59.62, + "acc": 79.75 + }, + "stylegan2": { + "ap": 91.03, + "auroc": 89.22, + "real_acc": 99.9, + "fake_acc": 23.3, + "acc": 61.6 + }, + "whichfaceisreal": { + "ap": 97.27, + "auroc": 98.37, + "real_acc": 96.1, + "fake_acc": 95.4, + "acc": 95.75 + } + }, + "date": "2026-11-09T03:55:50", + "synthscope_version": "0.1.0" +} diff --git a/repro/bench_results/cure_trained_genimage8.json b/repro/bench_results/cure_trained_genimage8.json new file mode 100644 index 0000000000000000000000000000000000000000..6f57aa93691114db72f634e001f0e9fae1f772cd --- /dev/null +++ b/repro/bench_results/cure_trained_genimage8.json @@ -0,0 +1,75 @@ +{ + "tag": "cure_trained_genimage8", + "model": "cure", + "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_trained/cure_trained.pth", + "model_config": null, + "benchmark": "pergen", + "data_root": "/local/ssalehid/cache/data023/GenImage_full/test", + "jpeg_fakes": null, + "n_generators": 8, + "means": { + "acc": 77.7, + "map": 89.41, + "mauroc": 87.88 + }, + "per_generator": { + "adm": { + "ap": 57.03, + "auroc": 54.2, + "real_acc": 99.87, + "fake_acc": 3.0, + "acc": 51.43 + }, + "biggan": { + "ap": 90.64, + "auroc": 90.74, + "real_acc": 99.93, + "fake_acc": 9.07, + "acc": 54.5 + }, + "glide": { + "ap": 89.69, + "auroc": 87.41, + "real_acc": 99.8, + "fake_acc": 40.07, + "acc": 69.93 + }, + "midjourney": { + "ap": 86.64, + "auroc": 81.59, + "real_acc": 99.87, + "fake_acc": 48.6, + "acc": 74.23 + }, + "sdv1.4": { + "ap": 100.0, + "auroc": 100.0, + "real_acc": 99.93, + "fake_acc": 100.0, + "acc": 99.97 + }, + "sdv1.5": { + "ap": 100.0, + "auroc": 100.0, + "real_acc": 99.93, + "fake_acc": 99.93, + "acc": 99.93 + }, + "vqdm": { + "ap": 91.27, + "auroc": 89.12, + "real_acc": 99.8, + "fake_acc": 43.53, + "acc": 71.67 + }, + "wukong": { + "ap": 100.0, + "auroc": 100.0, + "real_acc": 99.93, + "fake_acc": 99.93, + "acc": 99.93 + } + }, + "date": "2026-11-09T03:02:45", + "synthscope_version": "0.1.0" +} diff --git a/repro/bench_results/cure_trained_r1e0_aigcdetect.json b/repro/bench_results/cure_trained_r1e0_aigcdetect.json new file mode 100644 index 0000000000000000000000000000000000000000..af3719b2659b2239cfa34d2f22cb50875a9fab15 --- /dev/null +++ b/repro/bench_results/cure_trained_r1e0_aigcdetect.json @@ -0,0 +1,138 @@ +{ + "tag": "cure_trained_r1e0_aigcdetect", + "model": "cure", + "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_s1inv/s23_r1e0/cure_trained.pth", + "model_config": null, + "benchmark": "pergen", + "data_root": "/local/ssalehid/cache/data029/AIGCDetect/test", + "jpeg_fakes": null, + "n_generators": 17, + "means": { + "acc": 92.25, + "map": 98.61, + "mauroc": 98.47 + }, + "per_generator": { + "ADM": { + "ap": 93.68, + "auroc": 92.85, + "real_acc": 99.27, + "fake_acc": 48.18, + "acc": 73.73 + }, + "DALLE2": { + "ap": 97.45, + "auroc": 96.91, + "real_acc": 99.3, + "fake_acc": 72.9, + "acc": 86.1 + }, + "Glide": { + "ap": 97.92, + "auroc": 97.86, + "real_acc": 99.35, + "fake_acc": 64.9, + "acc": 82.12 + }, + "Midjourney": { + "ap": 93.45, + "auroc": 91.79, + "real_acc": 99.18, + "fake_acc": 50.05, + "acc": 74.62 + }, + "VQDM": { + "ap": 99.16, + "auroc": 99.03, + "real_acc": 99.42, + "fake_acc": 86.73, + "acc": 93.08 + }, + "biggan": { + "ap": 99.62, + "auroc": 99.69, + "real_acc": 99.25, + "fake_acc": 95.55, + "acc": 97.4 + }, + "cyclegan": { + "ap": 99.18, + "auroc": 99.43, + "real_acc": 98.86, + "fake_acc": 86.22, + "acc": 92.54 + }, + "gaugan": { + "ap": 99.78, + "auroc": 99.82, + "real_acc": 98.88, + "fake_acc": 98.08, + "acc": 98.48 + }, + "progan": { + "ap": 99.86, + "auroc": 99.9, + "real_acc": 99.4, + "fake_acc": 98.55, + "acc": 98.97 + }, + "sd_xl": { + "ap": 99.92, + "auroc": 99.91, + "real_acc": 99.4, + "fake_acc": 97.8, + "acc": 98.6 + }, + "stable_diffusion_v_1_4": { + "ap": 99.98, + "auroc": 99.98, + "real_acc": 99.27, + "fake_acc": 99.82, + "acc": 99.54 + }, + "stable_diffusion_v_1_5": { + "ap": 99.98, + "auroc": 99.97, + "real_acc": 99.33, + "fake_acc": 99.66, + "acc": 99.49 + }, + "stargan": { + "ap": 99.28, + "auroc": 99.51, + "real_acc": 98.2, + "fake_acc": 97.15, + "acc": 97.67 + }, + "stylegan": { + "ap": 99.23, + "auroc": 99.29, + "real_acc": 99.2, + "fake_acc": 87.33, + "acc": 93.26 + }, + "stylegan2": { + "ap": 98.59, + "auroc": 98.59, + "real_acc": 99.04, + "fake_acc": 77.49, + "acc": 88.26 + }, + "whichfaceisreal": { + "ap": 99.24, + "auroc": 99.41, + "real_acc": 90.0, + "fake_acc": 99.8, + "acc": 94.9 + }, + "wukong": { + "ap": 99.98, + "auroc": 99.98, + "real_acc": 99.3, + "fake_acc": 99.73, + "acc": 99.52 + } + }, + "date": "2026-11-10T09:54:09", + "synthscope_version": "0.1.0" +} diff --git a/repro/bench_results/cure_trained_r1e0_aigibench20_full.json b/repro/bench_results/cure_trained_r1e0_aigibench20_full.json new file mode 100644 index 0000000000000000000000000000000000000000..501ef60d1dedc4e72337754bc353e8b7d44bc7ae --- /dev/null +++ b/repro/bench_results/cure_trained_r1e0_aigibench20_full.json @@ -0,0 +1,159 @@ +{ + "tag": "cure_trained_r1e0_aigibench20_full", + "model": "cure", + "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_s1inv/s23_r1e0/cure_trained.pth", + "model_config": null, + "benchmark": "pergen", + "data_root": "/local/ssalehid/cache/data023/AIGIBench/test", + "jpeg_fakes": null, + "n_generators": 20, + "means": { + "acc": 88.85, + "map": 95.17, + "mauroc": 95.86 + }, + "per_generator": { + "BLIP": { + "ap": 99.86, + "auroc": 99.87, + "real_acc": 92.76, + "fake_acc": 100.0, + "acc": 96.38 + }, + "CommunityAI": { + "ap": 93.17, + "auroc": 93.58, + "real_acc": 93.4, + "fake_acc": 74.38, + "acc": 83.89 + }, + "DALLE-3": { + "ap": 98.81, + "auroc": 98.89, + "real_acc": 92.9, + "fake_acc": 96.88, + "acc": 94.89 + }, + "FLUX1-dev": { + "ap": 83.59, + "auroc": 86.71, + "real_acc": 92.87, + "fake_acc": 46.51, + "acc": 69.69 + }, + "GLIDE": { + "ap": 89.83, + "auroc": 91.46, + "real_acc": 92.71, + "fake_acc": 67.82, + "acc": 80.27 + }, + "IP_Adapter": { + "ap": 91.14, + "auroc": 92.04, + "real_acc": 92.91, + "fake_acc": 69.38, + "acc": 81.14 + }, + "Imagen3": { + "ap": 75.65, + "auroc": 79.78, + "real_acc": 92.44, + "fake_acc": 26.76, + "acc": 59.6 + }, + "Infinite_ID": { + "ap": 99.44, + "auroc": 99.54, + "real_acc": 92.53, + "fake_acc": 99.8, + "acc": 96.17 + }, + "InstantID": { + "ap": 99.83, + "auroc": 99.84, + "real_acc": 93.02, + "fake_acc": 99.84, + "acc": 96.43 + }, + "Midjourney": { + "ap": 89.76, + "auroc": 90.97, + "real_acc": 92.47, + "fake_acc": 63.23, + "acc": 77.85 + }, + "PhotoMaker": { + "ap": 94.41, + "auroc": 93.96, + "real_acc": 92.49, + "fake_acc": 78.98, + "acc": 85.73 + }, + "ProGAN": { + "ap": 99.86, + "auroc": 99.9, + "real_acc": 99.4, + "fake_acc": 98.55, + "acc": 98.97 + }, + "R3GAN": { + "ap": 99.38, + "auroc": 99.59, + "real_acc": 92.58, + "fake_acc": 99.82, + "acc": 96.2 + }, + "SD3": { + "ap": 98.72, + "auroc": 98.85, + "real_acc": 94.2, + "fake_acc": 96.18, + "acc": 95.19 + }, + "SDXL": { + "ap": 99.91, + "auroc": 99.92, + "real_acc": 94.2, + "fake_acc": 100.0, + "acc": 97.1 + }, + "SocialRF": { + "ap": 95.03, + "auroc": 95.78, + "real_acc": 91.6, + "fake_acc": 85.47, + "acc": 88.53 + }, + "StyleGAN-XL": { + "ap": 99.41, + "auroc": 99.61, + "real_acc": 92.67, + "fake_acc": 99.89, + "acc": 96.28 + }, + "StyleGAN3": { + "ap": 97.07, + "auroc": 97.95, + "real_acc": 95.09, + "fake_acc": 88.96, + "acc": 92.02 + }, + "StyleSwim": { + "ap": 99.25, + "auroc": 99.46, + "real_acc": 91.67, + "fake_acc": 99.98, + "acc": 95.82 + }, + "WFIR": { + "ap": 99.24, + "auroc": 99.41, + "real_acc": 90.0, + "fake_acc": 99.8, + "acc": 94.9 + } + }, + "date": "2026-11-10T11:43:34", + "synthscope_version": "0.1.0" +} diff --git a/repro/bench_results/cure_trained_r1e0_bfree_online.json b/repro/bench_results/cure_trained_r1e0_bfree_online.json new file mode 100644 index 0000000000000000000000000000000000000000..3e4717a75e69bed377fdb2167854994672873373 --- /dev/null +++ b/repro/bench_results/cure_trained_r1e0_bfree_online.json @@ -0,0 +1,26 @@ +{ + "tag": "cure_trained_r1e0_bfree_online", + "model": "cure", + "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_s1inv/s23_r1e0/cure_trained.pth", + "model_config": null, + "benchmark": "pergen", + "data_root": "/local/ssalehid/cache/data029/BFreeOnline/test", + "jpeg_fakes": null, + "n_generators": 1, + "means": { + "acc": 72.3, + "map": 90.78, + "mauroc": 81.8 + }, + "per_generator": { + "viral": { + "ap": 90.78, + "auroc": 81.8, + "real_acc": 92.57, + "fake_acc": 52.04, + "acc": 72.3 + } + }, + "date": "2026-11-10T11:28:10", + "synthscope_version": "0.1.0" +} diff --git a/repro/bench_results/cure_trained_r1e0_evalgen.json b/repro/bench_results/cure_trained_r1e0_evalgen.json new file mode 100644 index 0000000000000000000000000000000000000000..88a545d4226d3cc70f1a9daf9f39a6b01ddb8dae --- /dev/null +++ b/repro/bench_results/cure_trained_r1e0_evalgen.json @@ -0,0 +1,54 @@ +{ + "tag": "cure_trained_r1e0_evalgen", + "model": "cure", + "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_s1inv/s23_r1e0/cure_trained.pth", + "model_config": null, + "benchmark": "pergen", + "data_root": "/local/ssalehid/cache/data029/EvalGEN/test", + "jpeg_fakes": null, + "n_generators": 5, + "means": { + "acc": 91.57, + "map": 99.34, + "mauroc": 98.63 + }, + "per_generator": { + "Flux": { + "ap": 97.2, + "auroc": 94.24, + "real_acc": 99.1, + "fake_acc": 39.35, + "acc": 69.22 + }, + "GoT": { + "ap": 99.84, + "auroc": 99.64, + "real_acc": 99.1, + "fake_acc": 94.04, + "acc": 96.57 + }, + "Infinity": { + "ap": 99.74, + "auroc": 99.43, + "real_acc": 99.1, + "fake_acc": 89.66, + "acc": 94.38 + }, + "NOVA": { + "ap": 99.97, + "auroc": 99.93, + "real_acc": 99.1, + "fake_acc": 98.99, + "acc": 99.04 + }, + "OmniGen": { + "ap": 99.95, + "auroc": 99.89, + "real_acc": 99.1, + "fake_acc": 98.16, + "acc": 98.63 + } + }, + "date": "2026-11-10T10:22:42", + "synthscope_version": "0.1.0" +} diff --git a/repro/bench_results/cure_trained_r1e0_forensynths.json b/repro/bench_results/cure_trained_r1e0_forensynths.json new file mode 100644 index 0000000000000000000000000000000000000000..77d3363cb75440d94e0f2270e4244131e56e426e --- /dev/null +++ b/repro/bench_results/cure_trained_r1e0_forensynths.json @@ -0,0 +1,110 @@ +{ + "tag": "cure_trained_r1e0_forensynths", + "model": "cure", + "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_s1inv/s23_r1e0/cure_trained.pth", + "model_config": null, + "benchmark": "forensynths", + "data_root": "/local/ssalehid/cache/data023/CNNDetection/test", + "jpeg_fakes": null, + "n_generators": 13, + "means": { + "acc": 89.79, + "map": 97.6, + "mauroc": 97.15 + }, + "per_generator": { + "biggan": { + "ap": 99.62, + "auroc": 99.69, + "real_acc": 99.25, + "fake_acc": 95.55, + "acc": 97.4 + }, + "crn": { + "ap": 99.85, + "auroc": 99.88, + "real_acc": 99.2, + "fake_acc": 99.11, + "acc": 99.15 + }, + "cyclegan": { + "ap": 99.18, + "auroc": 99.43, + "real_acc": 98.86, + "fake_acc": 86.22, + "acc": 92.54 + }, + "deepfake": { + "ap": 87.94, + "auroc": 86.18, + "real_acc": 99.59, + "fake_acc": 18.53, + "acc": 59.06 + }, + "gaugan": { + "ap": 99.78, + "auroc": 99.82, + "real_acc": 98.88, + "fake_acc": 98.08, + "acc": 98.48 + }, + "imle": { + "ap": 99.77, + "auroc": 99.81, + "real_acc": 99.2, + "fake_acc": 97.59, + "acc": 98.39 + }, + "progan": { + "ap": 99.86, + "auroc": 99.9, + "real_acc": 99.4, + "fake_acc": 98.55, + "acc": 98.97 + }, + "san": { + "ap": 92.12, + "auroc": 89.1, + "real_acc": 99.09, + "fake_acc": 49.77, + "acc": 74.43 + }, + "seeingdark": { + "ap": 94.34, + "auroc": 92.39, + "real_acc": 100.0, + "fake_acc": 49.44, + "acc": 74.72 + }, + "stargan": { + "ap": 99.28, + "auroc": 99.51, + "real_acc": 98.2, + "fake_acc": 97.15, + "acc": 97.67 + }, + "stylegan": { + "ap": 99.23, + "auroc": 99.29, + "real_acc": 99.2, + "fake_acc": 87.33, + "acc": 93.26 + }, + "stylegan2": { + "ap": 98.59, + "auroc": 98.59, + "real_acc": 99.04, + "fake_acc": 77.49, + "acc": 88.26 + }, + "whichfaceisreal": { + "ap": 99.24, + "auroc": 99.41, + "real_acc": 90.0, + "fake_acc": 99.8, + "acc": 94.9 + } + }, + "date": "2026-11-10T08:36:00", + "synthscope_version": "0.1.0" +} diff --git a/repro/bench_results/cure_trained_r1e0_genimage8.json b/repro/bench_results/cure_trained_r1e0_genimage8.json new file mode 100644 index 0000000000000000000000000000000000000000..04cc2bf6c2223631348e6c521200db002742d77b --- /dev/null +++ b/repro/bench_results/cure_trained_r1e0_genimage8.json @@ -0,0 +1,75 @@ +{ + "tag": "cure_trained_r1e0_genimage8", + "model": "cure", + "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_s1inv/s23_r1e0/cure_trained.pth", + "model_config": null, + "benchmark": "pergen", + "data_root": "/local/ssalehid/cache/data023/GenImage_full/test", + "jpeg_fakes": null, + "n_generators": 8, + "means": { + "acc": 86.05, + "map": 97.47, + "mauroc": 97.36 + }, + "per_generator": { + "adm": { + "ap": 89.12, + "auroc": 89.01, + "real_acc": 99.2, + "fake_acc": 25.0, + "acc": 62.1 + }, + "biggan": { + "ap": 98.1, + "auroc": 98.56, + "real_acc": 99.13, + "fake_acc": 60.53, + "acc": 79.83 + }, + "glide": { + "ap": 97.97, + "auroc": 97.95, + "real_acc": 99.47, + "fake_acc": 59.2, + "acc": 79.33 + }, + "midjourney": { + "ap": 95.76, + "auroc": 94.63, + "real_acc": 99.47, + "fake_acc": 58.8, + "acc": 79.13 + }, + "sdv1.4": { + "ap": 99.99, + "auroc": 99.99, + "real_acc": 99.33, + "fake_acc": 99.8, + "acc": 99.57 + }, + "sdv1.5": { + "ap": 99.99, + "auroc": 99.99, + "real_acc": 99.47, + "fake_acc": 99.8, + "acc": 99.63 + }, + "vqdm": { + "ap": 98.81, + "auroc": 98.73, + "real_acc": 99.27, + "fake_acc": 79.33, + "acc": 89.3 + }, + "wukong": { + "ap": 99.99, + "auroc": 99.99, + "real_acc": 99.2, + "fake_acc": 99.8, + "acc": 99.5 + } + }, + "date": "2026-11-10T11:22:15", + "synthscope_version": "0.1.0" +} diff --git a/repro/bench_results/cure_trained_r1e0_realchain.json b/repro/bench_results/cure_trained_r1e0_realchain.json new file mode 100644 index 0000000000000000000000000000000000000000..0b8207d1e4e185a8d89964427f59c0257d133456 --- /dev/null +++ b/repro/bench_results/cure_trained_r1e0_realchain.json @@ -0,0 +1,68 @@ +{ + "tag": "cure_trained_r1e0_realchain", + "model": "cure", + "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_s1inv/s23_r1e0/cure_trained.pth", + "model_config": null, + "benchmark": "pergen", + "data_root": "/local/ssalehid/cache/data029/RealChain/test", + "jpeg_fakes": null, + "n_generators": 7, + "means": { + "acc": 70.34, + "map": 85.0, + "mauroc": 84.87 + }, + "per_generator": { + "Flux1": { + "ap": 90.8, + "auroc": 90.93, + "real_acc": 97.3, + "fake_acc": 45.3, + "acc": 71.3 + }, + "Hunyuan3": { + "ap": 95.68, + "auroc": 95.19, + "real_acc": 98.6, + "fake_acc": 64.7, + "acc": 81.65 + }, + "NanoBanana": { + "ap": 85.11, + "auroc": 85.65, + "real_acc": 97.4, + "fake_acc": 31.3, + "acc": 64.35 + }, + "QwenImage": { + "ap": 95.63, + "auroc": 95.59, + "real_acc": 97.3, + "fake_acc": 70.2, + "acc": 83.75 + }, + "SDv3.5": { + "ap": 90.46, + "auroc": 89.98, + "real_acc": 95.3, + "fake_acc": 55.7, + "acc": 75.5 + }, + "Seedream4": { + "ap": 65.41, + "auroc": 67.03, + "real_acc": 93.1, + "fake_acc": 18.4, + "acc": 55.75 + }, + "i2i": { + "ap": 71.94, + "auroc": 69.72, + "real_acc": 95.8, + "fake_acc": 24.3, + "acc": 60.05 + } + }, + "date": "2026-11-10T10:51:09", + "synthscope_version": "0.1.0" +} diff --git a/repro/bench_results/cure_trained_r1e0_rrdataset.json b/repro/bench_results/cure_trained_r1e0_rrdataset.json new file mode 100644 index 0000000000000000000000000000000000000000..d934f15aa81850caa5cf758e93838b22297db70a --- /dev/null +++ b/repro/bench_results/cure_trained_r1e0_rrdataset.json @@ -0,0 +1,40 @@ +{ + "tag": "cure_trained_r1e0_rrdataset", + "model": "cure", + "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_s1inv/s23_r1e0/cure_trained.pth", + "model_config": null, + "benchmark": "pergen", + "data_root": "/local/ssalehid/cache/data029/RRDataset/test", + "jpeg_fakes": null, + "n_generators": 3, + "means": { + "acc": 72.62, + "map": 85.87, + "mauroc": 85.25 + }, + "per_generator": { + "original": { + "ap": 92.05, + "auroc": 92.4, + "real_acc": 93.62, + "fake_acc": 66.6, + "acc": 80.11 + }, + "redigital": { + "ap": 77.82, + "auroc": 76.17, + "real_acc": 95.52, + "fake_acc": 32.13, + "acc": 63.82 + }, + "transfer": { + "ap": 87.75, + "auroc": 87.17, + "real_acc": 94.61, + "fake_acc": 53.27, + "acc": 73.94 + } + }, + "date": "2026-11-10T11:01:39", + "synthscope_version": "0.1.0" +} diff --git a/repro/bench_results/cure_trained_r1e0_synthwildx.json b/repro/bench_results/cure_trained_r1e0_synthwildx.json new file mode 100644 index 0000000000000000000000000000000000000000..1691744b58ba48863e52c07a651a507c68e6abc2 --- /dev/null +++ b/repro/bench_results/cure_trained_r1e0_synthwildx.json @@ -0,0 +1,40 @@ +{ + "tag": "cure_trained_r1e0_synthwildx", + "model": "cure", + "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_s1inv/s23_r1e0/cure_trained.pth", + "model_config": null, + "benchmark": "pergen", + "data_root": "/local/ssalehid/cache/data029/SynthWildX/test", + "jpeg_fakes": null, + "n_generators": 3, + "means": { + "acc": 90.99, + "map": 96.88, + "mauroc": 96.85 + }, + "per_generator": { + "dalle3": { + "ap": 97.62, + "auroc": 98.15, + "real_acc": 94.43, + "fake_acc": 92.86, + "acc": 93.64 + }, + "firefly": { + "ap": 96.57, + "auroc": 95.62, + "real_acc": 94.43, + "fake_acc": 84.78, + "acc": 89.6 + }, + "midjourney_v5": { + "ap": 96.46, + "auroc": 96.79, + "real_acc": 94.43, + "fake_acc": 85.06, + "acc": 89.74 + } + }, + "date": "2026-11-10T11:27:04", + "synthscope_version": "0.1.0" +} diff --git a/repro/bench_results/cure_trained_r1e0_ufd.json b/repro/bench_results/cure_trained_r1e0_ufd.json new file mode 100644 index 0000000000000000000000000000000000000000..7d1d795c22e4a943dceda60eff9a4979bb8bbe12 --- /dev/null +++ b/repro/bench_results/cure_trained_r1e0_ufd.json @@ -0,0 +1,75 @@ +{ + "tag": "cure_trained_r1e0_ufd", + "model": "cure", + "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_s1inv/s23_r1e0/cure_trained.pth", + "model_config": null, + "benchmark": "ufd", + "data_root": "/local/ssalehid/cache/data023/universialfakedetection/test", + "jpeg_fakes": null, + "n_generators": 8, + "means": { + "acc": 93.99, + "map": 99.13, + "mauroc": 98.87 + }, + "per_generator": { + "dalle": { + "ap": 99.84, + "auroc": 99.79, + "real_acc": 99.9, + "fake_acc": 97.1, + "acc": 98.5 + }, + "glide_100_10": { + "ap": 99.18, + "auroc": 98.96, + "real_acc": 99.9, + "fake_acc": 85.0, + "acc": 92.45 + }, + "glide_100_27": { + "ap": 98.85, + "auroc": 98.52, + "real_acc": 99.9, + "fake_acc": 80.7, + "acc": 90.3 + }, + "glide_50_27": { + "ap": 98.63, + "auroc": 98.21, + "real_acc": 99.9, + "fake_acc": 78.9, + "acc": 89.4 + }, + "guided": { + "ap": 96.65, + "auroc": 95.61, + "real_acc": 99.7, + "fake_acc": 65.5, + "acc": 82.6 + }, + "ldm_100": { + "ap": 99.99, + "auroc": 99.99, + "real_acc": 99.9, + "fake_acc": 99.5, + "acc": 99.7 + }, + "ldm_200": { + "ap": 100.0, + "auroc": 100.0, + "real_acc": 99.9, + "fake_acc": 99.4, + "acc": 99.65 + }, + "ldm_200_cfg": { + "ap": 99.94, + "auroc": 99.92, + "real_acc": 99.9, + "fake_acc": 98.7, + "acc": 99.3 + } + }, + "date": "2026-11-10T11:20:54", + "synthscope_version": "0.1.0" +} diff --git a/repro/bench_results/cure_trained_r1e0_wildrf.json b/repro/bench_results/cure_trained_r1e0_wildrf.json new file mode 100644 index 0000000000000000000000000000000000000000..082a6e594112e98d3668ba9c86823fc1851009f4 --- /dev/null +++ b/repro/bench_results/cure_trained_r1e0_wildrf.json @@ -0,0 +1,40 @@ +{ + "tag": "cure_trained_r1e0_wildrf", + "model": "cure", + "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_s1inv/s23_r1e0/cure_trained.pth", + "model_config": null, + "benchmark": "pergen", + "data_root": "/local/ssalehid/cache/data029/WildRF/test", + "jpeg_fakes": null, + "n_generators": 3, + "means": { + "acc": 95.23, + "map": 99.14, + "mauroc": 99.06 + }, + "per_generator": { + "facebook": { + "ap": 98.68, + "auroc": 98.52, + "real_acc": 96.88, + "fake_acc": 90.62, + "acc": 93.75 + }, + "reddit": { + "ap": 99.5, + "auroc": 99.47, + "real_acc": 97.73, + "fake_acc": 96.13, + "acc": 96.93 + }, + "twitter": { + "ap": 99.23, + "auroc": 99.19, + "real_acc": 96.77, + "fake_acc": 93.27, + "acc": 95.02 + } + }, + "date": "2026-11-10T11:27:25", + "synthscope_version": "0.1.0" +} diff --git a/repro/bench_results/cure_trained_r2_aigcdetect.json b/repro/bench_results/cure_trained_r2_aigcdetect.json new file mode 100644 index 0000000000000000000000000000000000000000..b1418a88ea6ccacb713b79d81f380753398594d1 --- /dev/null +++ b/repro/bench_results/cure_trained_r2_aigcdetect.json @@ -0,0 +1,138 @@ +{ + "tag": "cure_trained_r2_aigcdetect", + "model": "cure", + "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_s1inv/s23mc_r2e4/cure_trained.pth", + "model_config": null, + "benchmark": "pergen", + "data_root": "/local/ssalehid/cache/data029/AIGCDetect/test", + "jpeg_fakes": null, + "n_generators": 17, + "means": { + "acc": 82.29, + "map": 95.21, + "mauroc": 94.4 + }, + "per_generator": { + "ADM": { + "ap": 72.39, + "auroc": 64.84, + "real_acc": 99.8, + "fake_acc": 11.23, + "acc": 55.52 + }, + "DALLE2": { + "ap": 90.03, + "auroc": 86.72, + "real_acc": 100.0, + "fake_acc": 46.8, + "acc": 73.4 + }, + "Glide": { + "ap": 93.53, + "auroc": 91.52, + "real_acc": 99.75, + "fake_acc": 52.78, + "acc": 76.27 + }, + "Midjourney": { + "ap": 87.08, + "auroc": 82.32, + "real_acc": 99.78, + "fake_acc": 44.78, + "acc": 72.28 + }, + "VQDM": { + "ap": 95.98, + "auroc": 94.55, + "real_acc": 99.8, + "fake_acc": 64.88, + "acc": 82.34 + }, + "biggan": { + "ap": 97.98, + "auroc": 98.9, + "real_acc": 99.4, + "fake_acc": 63.35, + "acc": 81.37 + }, + "cyclegan": { + "ap": 98.61, + "auroc": 98.57, + "real_acc": 99.85, + "fake_acc": 26.42, + "acc": 63.13 + }, + "gaugan": { + "ap": 99.11, + "auroc": 99.55, + "real_acc": 99.72, + "fake_acc": 53.72, + "acc": 76.72 + }, + "progan": { + "ap": 99.76, + "auroc": 99.82, + "real_acc": 99.85, + "fake_acc": 69.13, + "acc": 84.49 + }, + "sd_xl": { + "ap": 99.52, + "auroc": 99.34, + "real_acc": 99.9, + "fake_acc": 93.3, + "acc": 96.6 + }, + "stable_diffusion_v_1_4": { + "ap": 99.99, + "auroc": 99.99, + "real_acc": 99.65, + "fake_acc": 99.87, + "acc": 99.76 + }, + "stable_diffusion_v_1_5": { + "ap": 99.94, + "auroc": 99.9, + "real_acc": 99.79, + "fake_acc": 99.8, + "acc": 99.79 + }, + "stargan": { + "ap": 95.25, + "auroc": 98.49, + "real_acc": 98.45, + "fake_acc": 76.44, + "acc": 87.44 + }, + "stylegan": { + "ap": 98.53, + "auroc": 98.78, + "real_acc": 99.63, + "fake_acc": 71.96, + "acc": 85.8 + }, + "stylegan2": { + "ap": 94.44, + "auroc": 93.65, + "real_acc": 99.66, + "fake_acc": 36.91, + "acc": 68.28 + }, + "whichfaceisreal": { + "ap": 96.39, + "auroc": 97.99, + "real_acc": 94.5, + "fake_acc": 97.7, + "acc": 96.1 + }, + "wukong": { + "ap": 99.96, + "auroc": 99.94, + "real_acc": 99.7, + "fake_acc": 99.45, + "acc": 99.57 + } + }, + "date": "2026-11-10T09:54:09", + "synthscope_version": "0.1.0" +} diff --git a/repro/bench_results/cure_trained_r2_aigibench20_full.json b/repro/bench_results/cure_trained_r2_aigibench20_full.json new file mode 100644 index 0000000000000000000000000000000000000000..133f49b8348523291036490b69c098dfe4e72e34 --- /dev/null +++ b/repro/bench_results/cure_trained_r2_aigibench20_full.json @@ -0,0 +1,159 @@ +{ + "tag": "cure_trained_r2_aigibench20_full", + "model": "cure", + "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_s1inv/s23mc_r2e4/cure_trained.pth", + "model_config": null, + "benchmark": "pergen", + "data_root": "/local/ssalehid/cache/data023/AIGIBench/test", + "jpeg_fakes": null, + "n_generators": 20, + "means": { + "acc": 87.1, + "map": 93.72, + "mauroc": 93.73 + }, + "per_generator": { + "BLIP": { + "ap": 99.77, + "auroc": 99.88, + "real_acc": 98.29, + "fake_acc": 99.96, + "acc": 99.12 + }, + "CommunityAI": { + "ap": 93.65, + "auroc": 92.77, + "real_acc": 96.78, + "fake_acc": 73.17, + "acc": 84.98 + }, + "DALLE-3": { + "ap": 98.21, + "auroc": 98.65, + "real_acc": 96.98, + "fake_acc": 94.82, + "acc": 95.9 + }, + "FLUX1-dev": { + "ap": 86.83, + "auroc": 86.23, + "real_acc": 97.29, + "fake_acc": 50.96, + "acc": 74.12 + }, + "GLIDE": { + "ap": 87.8, + "auroc": 87.71, + "real_acc": 97.44, + "fake_acc": 55.33, + "acc": 76.39 + }, + "IP_Adapter": { + "ap": 87.01, + "auroc": 85.84, + "real_acc": 96.96, + "fake_acc": 44.78, + "acc": 70.87 + }, + "Imagen3": { + "ap": 75.72, + "auroc": 73.11, + "real_acc": 97.02, + "fake_acc": 24.56, + "acc": 60.79 + }, + "Infinite_ID": { + "ap": 97.84, + "auroc": 98.69, + "real_acc": 97.11, + "fake_acc": 93.56, + "acc": 95.33 + }, + "InstantID": { + "ap": 99.42, + "auroc": 99.61, + "real_acc": 97.18, + "fake_acc": 99.13, + "acc": 98.16 + }, + "Midjourney": { + "ap": 85.79, + "auroc": 85.72, + "real_acc": 94.6, + "fake_acc": 53.87, + "acc": 74.23 + }, + "PhotoMaker": { + "ap": 89.45, + "auroc": 85.06, + "real_acc": 97.53, + "fake_acc": 61.09, + "acc": 79.31 + }, + "ProGAN": { + "ap": 99.76, + "auroc": 99.82, + "real_acc": 99.85, + "fake_acc": 69.13, + "acc": 84.49 + }, + "R3GAN": { + "ap": 96.69, + "auroc": 98.23, + "real_acc": 97.22, + "fake_acc": 90.2, + "acc": 93.71 + }, + "SD3": { + "ap": 97.27, + "auroc": 97.78, + "real_acc": 97.62, + "fake_acc": 87.76, + "acc": 92.69 + }, + "SDXL": { + "ap": 99.3, + "auroc": 99.61, + "real_acc": 97.62, + "fake_acc": 99.53, + "acc": 98.58 + }, + "SocialRF": { + "ap": 90.76, + "auroc": 91.94, + "real_acc": 93.33, + "fake_acc": 74.13, + "acc": 83.73 + }, + "StyleGAN-XL": { + "ap": 98.15, + "auroc": 99.15, + "real_acc": 97.22, + "fake_acc": 99.36, + "acc": 98.29 + }, + "StyleGAN3": { + "ap": 96.87, + "auroc": 97.99, + "real_acc": 97.64, + "fake_acc": 79.53, + "acc": 88.59 + }, + "StyleSwim": { + "ap": 97.68, + "auroc": 98.86, + "real_acc": 97.13, + "fake_acc": 96.2, + "acc": 96.67 + }, + "WFIR": { + "ap": 96.39, + "auroc": 97.99, + "real_acc": 94.5, + "fake_acc": 97.7, + "acc": 96.1 + } + }, + "date": "2026-11-10T11:43:26", + "synthscope_version": "0.1.0" +} diff --git a/repro/bench_results/cure_trained_r2_bfree_online.json b/repro/bench_results/cure_trained_r2_bfree_online.json new file mode 100644 index 0000000000000000000000000000000000000000..97d9ed977a5fbedbf0aa4958415b60b4bd57753f --- /dev/null +++ b/repro/bench_results/cure_trained_r2_bfree_online.json @@ -0,0 +1,26 @@ +{ + "tag": "cure_trained_r2_bfree_online", + "model": "cure", + "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_s1inv/s23mc_r2e4/cure_trained.pth", + "model_config": null, + "benchmark": "pergen", + "data_root": "/local/ssalehid/cache/data029/BFreeOnline/test", + "jpeg_fakes": null, + "n_generators": 1, + "means": { + "acc": 69.52, + "map": 91.31, + "mauroc": 81.51 + }, + "per_generator": { + "viral": { + "ap": 91.31, + "auroc": 81.51, + "real_acc": 99.26, + "fake_acc": 39.78, + "acc": 69.52 + } + }, + "date": "2026-11-10T11:28:13", + "synthscope_version": "0.1.0" +} diff --git a/repro/bench_results/cure_trained_r2_evalgen.json b/repro/bench_results/cure_trained_r2_evalgen.json new file mode 100644 index 0000000000000000000000000000000000000000..1875ae8ebd23c6d47c7cea7a63133dd39c5ea2aa --- /dev/null +++ b/repro/bench_results/cure_trained_r2_evalgen.json @@ -0,0 +1,54 @@ +{ + "tag": "cure_trained_r2_evalgen", + "model": "cure", + "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_s1inv/s23mc_r2e4/cure_trained.pth", + "model_config": null, + "benchmark": "pergen", + "data_root": "/local/ssalehid/cache/data029/EvalGEN/test", + "jpeg_fakes": null, + "n_generators": 5, + "means": { + "acc": 92.45, + "map": 99.08, + "mauroc": 97.9 + }, + "per_generator": { + "Flux": { + "ap": 96.4, + "auroc": 91.68, + "real_acc": 99.66, + "fake_acc": 48.37, + "acc": 74.02 + }, + "GoT": { + "ap": 99.86, + "auroc": 99.73, + "real_acc": 99.66, + "fake_acc": 96.5, + "acc": 98.08 + }, + "Infinity": { + "ap": 99.32, + "auroc": 98.41, + "real_acc": 99.66, + "fake_acc": 85.07, + "acc": 92.37 + }, + "NOVA": { + "ap": 99.88, + "auroc": 99.76, + "real_acc": 99.66, + "fake_acc": 97.73, + "acc": 98.7 + }, + "OmniGen": { + "ap": 99.94, + "auroc": 99.91, + "real_acc": 99.66, + "fake_acc": 98.54, + "acc": 99.1 + } + }, + "date": "2026-11-10T10:22:42", + "synthscope_version": "0.1.0" +} diff --git a/repro/bench_results/cure_trained_r2_forensynths.json b/repro/bench_results/cure_trained_r2_forensynths.json new file mode 100644 index 0000000000000000000000000000000000000000..ca689047f6d5b1175890a7b20898493b523d9aec --- /dev/null +++ b/repro/bench_results/cure_trained_r2_forensynths.json @@ -0,0 +1,110 @@ +{ + "tag": "cure_trained_r2_forensynths", + "model": "cure", + "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_s1inv/s23mc_r2e4/cure_trained.pth", + "model_config": null, + "benchmark": "forensynths", + "data_root": "/local/ssalehid/cache/data023/CNNDetection/test", + "jpeg_fakes": null, + "n_generators": 13, + "means": { + "acc": 74.35, + "map": 95.43, + "mauroc": 95.4 + }, + "per_generator": { + "biggan": { + "ap": 97.98, + "auroc": 98.9, + "real_acc": 99.4, + "fake_acc": 63.35, + "acc": 81.37 + }, + "crn": { + "ap": 99.51, + "auroc": 99.67, + "real_acc": 99.95, + "fake_acc": 34.66, + "acc": 67.31 + }, + "cyclegan": { + "ap": 98.61, + "auroc": 98.57, + "real_acc": 99.85, + "fake_acc": 26.42, + "acc": 63.13 + }, + "deepfake": { + "ap": 83.38, + "auroc": 84.46, + "real_acc": 99.0, + "fake_acc": 3.34, + "acc": 51.17 + }, + "gaugan": { + "ap": 99.11, + "auroc": 99.55, + "real_acc": 99.72, + "fake_acc": 53.72, + "acc": 76.72 + }, + "imle": { + "ap": 99.45, + "auroc": 99.58, + "real_acc": 99.95, + "fake_acc": 35.1, + "acc": 67.53 + }, + "progan": { + "ap": 99.76, + "auroc": 99.82, + "real_acc": 99.85, + "fake_acc": 69.13, + "acc": 84.49 + }, + "san": { + "ap": 89.18, + "auroc": 83.56, + "real_acc": 100.0, + "fake_acc": 46.12, + "acc": 73.06 + }, + "seeingdark": { + "ap": 88.97, + "auroc": 87.16, + "real_acc": 100.0, + "fake_acc": 28.33, + "acc": 64.17 + }, + "stargan": { + "ap": 95.25, + "auroc": 98.49, + "real_acc": 98.45, + "fake_acc": 76.44, + "acc": 87.44 + }, + "stylegan": { + "ap": 98.53, + "auroc": 98.78, + "real_acc": 99.63, + "fake_acc": 71.96, + "acc": 85.8 + }, + "stylegan2": { + "ap": 94.44, + "auroc": 93.65, + "real_acc": 99.66, + "fake_acc": 36.91, + "acc": 68.28 + }, + "whichfaceisreal": { + "ap": 96.39, + "auroc": 97.99, + "real_acc": 94.5, + "fake_acc": 97.7, + "acc": 96.1 + } + }, + "date": "2026-11-10T08:36:04", + "synthscope_version": "0.1.0" +} diff --git a/repro/bench_results/cure_trained_r2_genimage8.json b/repro/bench_results/cure_trained_r2_genimage8.json new file mode 100644 index 0000000000000000000000000000000000000000..1278f1df12cb38bfb97997452aaefb42a8a736e9 --- /dev/null +++ b/repro/bench_results/cure_trained_r2_genimage8.json @@ -0,0 +1,75 @@ +{ + "tag": "cure_trained_r2_genimage8", + "model": "cure", + "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_s1inv/s23mc_r2e4/cure_trained.pth", + "model_config": null, + "benchmark": "pergen", + "data_root": "/local/ssalehid/cache/data023/GenImage_full/test", + "jpeg_fakes": null, + "n_generators": 8, + "means": { + "acc": 79.89, + "map": 91.78, + "mauroc": 89.99 + }, + "per_generator": { + "adm": { + "ap": 63.09, + "auroc": 56.85, + "real_acc": 99.67, + "fake_acc": 6.07, + "acc": 52.87 + }, + "biggan": { + "ap": 94.05, + "auroc": 93.07, + "real_acc": 100.0, + "fake_acc": 18.73, + "acc": 59.37 + }, + "glide": { + "ap": 93.05, + "auroc": 91.47, + "real_acc": 99.67, + "fake_acc": 51.53, + "acc": 75.6 + }, + "midjourney": { + "ap": 89.2, + "auroc": 85.2, + "real_acc": 99.8, + "fake_acc": 51.0, + "acc": 75.4 + }, + "sdv1.4": { + "ap": 100.0, + "auroc": 100.0, + "real_acc": 99.67, + "fake_acc": 99.87, + "acc": 99.77 + }, + "sdv1.5": { + "ap": 99.99, + "auroc": 99.98, + "real_acc": 99.87, + "fake_acc": 99.87, + "acc": 99.87 + }, + "vqdm": { + "ap": 94.9, + "auroc": 93.35, + "real_acc": 99.87, + "fake_acc": 52.8, + "acc": 76.33 + }, + "wukong": { + "ap": 100.0, + "auroc": 100.0, + "real_acc": 100.0, + "fake_acc": 99.87, + "acc": 99.93 + } + }, + "date": "2026-11-10T11:22:15", + "synthscope_version": "0.1.0" +} diff --git a/repro/bench_results/cure_trained_r2_realchain.json b/repro/bench_results/cure_trained_r2_realchain.json new file mode 100644 index 0000000000000000000000000000000000000000..aca52f96a293cf8a1661b21907483df2830f0e94 --- /dev/null +++ b/repro/bench_results/cure_trained_r2_realchain.json @@ -0,0 +1,68 @@ +{ + "tag": "cure_trained_r2_realchain", + "model": "cure", + "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_s1inv/s23mc_r2e4/cure_trained.pth", + "model_config": null, + "benchmark": "pergen", + "data_root": "/local/ssalehid/cache/data029/RealChain/test", + "jpeg_fakes": null, + "n_generators": 7, + "means": { + "acc": 67.49, + "map": 83.59, + "mauroc": 82.2 + }, + "per_generator": { + "Flux1": { + "ap": 90.22, + "auroc": 89.26, + "real_acc": 99.1, + "fake_acc": 39.8, + "acc": 69.45 + }, + "Hunyuan3": { + "ap": 94.84, + "auroc": 93.39, + "real_acc": 99.4, + "fake_acc": 62.2, + "acc": 80.8 + }, + "NanoBanana": { + "ap": 84.24, + "auroc": 82.62, + "real_acc": 98.3, + "fake_acc": 32.2, + "acc": 65.25 + }, + "QwenImage": { + "ap": 91.2, + "auroc": 91.19, + "real_acc": 97.9, + "fake_acc": 49.9, + "acc": 73.9 + }, + "SDv3.5": { + "ap": 86.48, + "auroc": 84.81, + "real_acc": 99.0, + "fake_acc": 37.2, + "acc": 68.1 + }, + "Seedream4": { + "ap": 70.39, + "auroc": 68.93, + "real_acc": 95.3, + "fake_acc": 20.7, + "acc": 58.0 + }, + "i2i": { + "ap": 67.77, + "auroc": 65.17, + "real_acc": 96.8, + "fake_acc": 17.1, + "acc": 56.95 + } + }, + "date": "2026-11-10T10:51:09", + "synthscope_version": "0.1.0" +} diff --git a/repro/bench_results/cure_trained_r2_rrdataset.json b/repro/bench_results/cure_trained_r2_rrdataset.json new file mode 100644 index 0000000000000000000000000000000000000000..a00269995210b3ffe102a59913023e9ec75c4587 --- /dev/null +++ b/repro/bench_results/cure_trained_r2_rrdataset.json @@ -0,0 +1,40 @@ +{ + "tag": "cure_trained_r2_rrdataset", + "model": "cure", + "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_s1inv/s23mc_r2e4/cure_trained.pth", + "model_config": null, + "benchmark": "pergen", + "data_root": "/local/ssalehid/cache/data029/RRDataset/test", + "jpeg_fakes": null, + "n_generators": 3, + "means": { + "acc": 68.01, + "map": 81.7, + "mauroc": 78.57 + }, + "per_generator": { + "original": { + "ap": 91.13, + "auroc": 88.86, + "real_acc": 98.06, + "fake_acc": 58.32, + "acc": 78.19 + }, + "redigital": { + "ap": 70.01, + "auroc": 66.87, + "real_acc": 98.62, + "fake_acc": 16.34, + "acc": 57.48 + }, + "transfer": { + "ap": 83.95, + "auroc": 79.97, + "real_acc": 98.51, + "fake_acc": 38.24, + "acc": 68.37 + } + }, + "date": "2026-11-10T11:01:38", + "synthscope_version": "0.1.0" +} diff --git a/repro/bench_results/cure_trained_r2_synthwildx.json b/repro/bench_results/cure_trained_r2_synthwildx.json new file mode 100644 index 0000000000000000000000000000000000000000..46ac23cca689eb2aae2ab36596fe3722cccaedd3 --- /dev/null +++ b/repro/bench_results/cure_trained_r2_synthwildx.json @@ -0,0 +1,40 @@ +{ + "tag": "cure_trained_r2_synthwildx", + "model": "cure", + "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_s1inv/s23mc_r2e4/cure_trained.pth", + "model_config": null, + "benchmark": "pergen", + "data_root": "/local/ssalehid/cache/data029/SynthWildX/test", + "jpeg_fakes": null, + "n_generators": 3, + "means": { + "acc": 81.56, + "map": 92.53, + "mauroc": 91.85 + }, + "per_generator": { + "dalle3": { + "ap": 93.05, + "auroc": 93.44, + "real_acc": 95.88, + "fake_acc": 71.68, + "acc": 83.78 + }, + "firefly": { + "ap": 93.54, + "auroc": 92.17, + "real_acc": 95.88, + "fake_acc": 69.56, + "acc": 82.72 + }, + "midjourney_v5": { + "ap": 90.99, + "auroc": 89.95, + "real_acc": 95.88, + "fake_acc": 60.46, + "acc": 78.17 + } + }, + "date": "2026-11-10T11:27:00", + "synthscope_version": "0.1.0" +} diff --git a/repro/bench_results/cure_trained_r2_ufd.json b/repro/bench_results/cure_trained_r2_ufd.json new file mode 100644 index 0000000000000000000000000000000000000000..73655d7c9096a06170aefeb6e4d6b5bdf87a32ee --- /dev/null +++ b/repro/bench_results/cure_trained_r2_ufd.json @@ -0,0 +1,75 @@ +{ + "tag": "cure_trained_r2_ufd", + "model": "cure", + "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_s1inv/s23mc_r2e4/cure_trained.pth", + "model_config": null, + "benchmark": "ufd", + "data_root": "/local/ssalehid/cache/data023/universialfakedetection/test", + "jpeg_fakes": null, + "n_generators": 8, + "means": { + "acc": 83.81, + "map": 96.29, + "mauroc": 94.91 + }, + "per_generator": { + "dalle": { + "ap": 99.45, + "auroc": 99.22, + "real_acc": 99.9, + "fake_acc": 90.3, + "acc": 95.1 + }, + "glide_100_10": { + "ap": 97.12, + "auroc": 96.09, + "real_acc": 99.9, + "fake_acc": 62.3, + "acc": 81.1 + }, + "glide_100_27": { + "ap": 93.65, + "auroc": 91.15, + "real_acc": 99.9, + "fake_acc": 49.2, + "acc": 74.55 + }, + "glide_50_27": { + "ap": 94.14, + "auroc": 91.79, + "real_acc": 99.9, + "fake_acc": 49.0, + "acc": 74.45 + }, + "guided": { + "ap": 87.01, + "auroc": 82.52, + "real_acc": 99.9, + "fake_acc": 24.4, + "acc": 62.15 + }, + "ldm_100": { + "ap": 99.66, + "auroc": 99.48, + "real_acc": 99.9, + "fake_acc": 87.0, + "acc": 93.45 + }, + "ldm_200": { + "ap": 99.71, + "auroc": 99.63, + "real_acc": 99.9, + "fake_acc": 86.8, + "acc": 93.35 + }, + "ldm_200_cfg": { + "ap": 99.58, + "auroc": 99.42, + "real_acc": 99.9, + "fake_acc": 92.8, + "acc": 96.35 + } + }, + "date": "2026-11-10T11:20:53", + "synthscope_version": "0.1.0" +} diff --git a/repro/bench_results/cure_trained_r2_wildrf.json b/repro/bench_results/cure_trained_r2_wildrf.json new file mode 100644 index 0000000000000000000000000000000000000000..1cc68f9cbe6fdba698a2356841af965121e54b80 --- /dev/null +++ b/repro/bench_results/cure_trained_r2_wildrf.json @@ -0,0 +1,40 @@ +{ + "tag": "cure_trained_r2_wildrf", + "model": "cure", + "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_s1inv/s23mc_r2e4/cure_trained.pth", + "model_config": null, + "benchmark": "pergen", + "data_root": "/local/ssalehid/cache/data029/WildRF/test", + "jpeg_fakes": null, + "n_generators": 3, + "means": { + "acc": 90.24, + "map": 96.22, + "mauroc": 96.19 + }, + "per_generator": { + "facebook": { + "ap": 93.06, + "auroc": 93.86, + "real_acc": 96.88, + "fake_acc": 78.12, + "acc": 87.5 + }, + "reddit": { + "ap": 98.36, + "auroc": 98.1, + "real_acc": 97.6, + "fake_acc": 89.6, + "acc": 93.6 + }, + "twitter": { + "ap": 97.24, + "auroc": 96.61, + "real_acc": 98.83, + "fake_acc": 80.41, + "acc": 89.62 + } + }, + "date": "2026-11-10T11:27:30", + "synthscope_version": "0.1.0" +} diff --git a/repro/bench_results/cure_trained_r2e1_aigcdetect.json b/repro/bench_results/cure_trained_r2e1_aigcdetect.json new file mode 100644 index 0000000000000000000000000000000000000000..a5fef1cd6addb8c781a1c77add2fcae8653ea970 --- /dev/null +++ b/repro/bench_results/cure_trained_r2e1_aigcdetect.json @@ -0,0 +1,138 @@ +{ + "tag": "cure_trained_r2e1_aigcdetect", + "model": "cure", + "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_s1inv/s23mc_r2e1/cure_trained.pth", + "model_config": null, + "benchmark": "pergen", + "data_root": "/local/ssalehid/cache/data029/AIGCDetect/test", + "jpeg_fakes": null, + "n_generators": 17, + "means": { + "acc": 88.2, + "map": 97.99, + "mauroc": 97.84 + }, + "per_generator": { + "ADM": { + "ap": 91.14, + "auroc": 89.54, + "real_acc": 99.67, + "fake_acc": 34.18, + "acc": 66.92 + }, + "DALLE2": { + "ap": 96.95, + "auroc": 95.99, + "real_acc": 99.9, + "fake_acc": 69.4, + "acc": 84.65 + }, + "Glide": { + "ap": 98.13, + "auroc": 97.93, + "real_acc": 99.58, + "fake_acc": 65.18, + "acc": 82.38 + }, + "Midjourney": { + "ap": 92.97, + "auroc": 90.35, + "real_acc": 99.53, + "fake_acc": 52.03, + "acc": 75.78 + }, + "VQDM": { + "ap": 99.0, + "auroc": 98.86, + "real_acc": 99.68, + "fake_acc": 79.7, + "acc": 89.69 + }, + "biggan": { + "ap": 98.59, + "auroc": 99.27, + "real_acc": 99.35, + "fake_acc": 80.0, + "acc": 89.68 + }, + "cyclegan": { + "ap": 99.26, + "auroc": 99.4, + "real_acc": 99.62, + "fake_acc": 49.66, + "acc": 74.64 + }, + "gaugan": { + "ap": 99.05, + "auroc": 99.44, + "real_acc": 99.22, + "fake_acc": 75.34, + "acc": 87.28 + }, + "progan": { + "ap": 99.39, + "auroc": 99.69, + "real_acc": 99.5, + "fake_acc": 81.55, + "acc": 90.53 + }, + "sd_xl": { + "ap": 99.96, + "auroc": 99.96, + "real_acc": 99.75, + "fake_acc": 98.2, + "acc": 98.97 + }, + "stable_diffusion_v_1_4": { + "ap": 99.98, + "auroc": 99.98, + "real_acc": 99.55, + "fake_acc": 99.85, + "acc": 99.7 + }, + "stable_diffusion_v_1_5": { + "ap": 99.97, + "auroc": 99.97, + "real_acc": 99.69, + "fake_acc": 99.71, + "acc": 99.7 + }, + "stargan": { + "ap": 97.83, + "auroc": 98.93, + "real_acc": 97.7, + "fake_acc": 91.9, + "acc": 94.8 + }, + "stylegan": { + "ap": 98.95, + "auroc": 99.23, + "real_acc": 99.28, + "fake_acc": 80.92, + "acc": 90.1 + }, + "stylegan2": { + "ap": 96.48, + "auroc": 96.0, + "real_acc": 99.26, + "fake_acc": 60.08, + "acc": 79.67 + }, + "whichfaceisreal": { + "ap": 98.16, + "auroc": 98.77, + "real_acc": 91.6, + "fake_acc": 99.1, + "acc": 95.35 + }, + "wukong": { + "ap": 99.97, + "auroc": 99.97, + "real_acc": 99.62, + "fake_acc": 99.62, + "acc": 99.62 + } + }, + "date": "2026-11-10T09:54:09", + "synthscope_version": "0.1.0" +} diff --git a/repro/bench_results/cure_trained_r2e1_aigibench20_full.json b/repro/bench_results/cure_trained_r2e1_aigibench20_full.json new file mode 100644 index 0000000000000000000000000000000000000000..33436298ee2d23f22f8f59f6917e3fbe385d2878 --- /dev/null +++ b/repro/bench_results/cure_trained_r2e1_aigibench20_full.json @@ -0,0 +1,159 @@ +{ + "tag": "cure_trained_r2e1_aigibench20_full", + "model": "cure", + "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_s1inv/s23mc_r2e1/cure_trained.pth", + "model_config": null, + "benchmark": "pergen", + "data_root": "/local/ssalehid/cache/data023/AIGIBench/test", + "jpeg_fakes": null, + "n_generators": 20, + "means": { + "acc": 88.81, + "map": 95.3, + "mauroc": 95.78 + }, + "per_generator": { + "BLIP": { + "ap": 99.93, + "auroc": 99.93, + "real_acc": 96.47, + "fake_acc": 100.0, + "acc": 98.23 + }, + "CommunityAI": { + "ap": 95.13, + "auroc": 95.12, + "real_acc": 95.47, + "fake_acc": 77.88, + "acc": 86.68 + }, + "DALLE-3": { + "ap": 98.83, + "auroc": 98.95, + "real_acc": 95.15, + "fake_acc": 96.17, + "acc": 95.66 + }, + "FLUX1-dev": { + "ap": 88.14, + "auroc": 89.59, + "real_acc": 95.18, + "fake_acc": 52.02, + "acc": 73.6 + }, + "GLIDE": { + "ap": 91.51, + "auroc": 92.71, + "real_acc": 95.22, + "fake_acc": 67.98, + "acc": 81.6 + }, + "IP_Adapter": { + "ap": 90.56, + "auroc": 90.48, + "real_acc": 94.8, + "fake_acc": 63.84, + "acc": 79.32 + }, + "Imagen3": { + "ap": 77.45, + "auroc": 79.36, + "real_acc": 95.04, + "fake_acc": 25.29, + "acc": 60.17 + }, + "Infinite_ID": { + "ap": 98.48, + "auroc": 98.89, + "real_acc": 95.04, + "fake_acc": 96.76, + "acc": 95.9 + }, + "InstantID": { + "ap": 99.82, + "auroc": 99.84, + "real_acc": 94.91, + "fake_acc": 99.82, + "acc": 97.37 + }, + "Midjourney": { + "ap": 89.24, + "auroc": 90.27, + "real_acc": 93.6, + "fake_acc": 59.33, + "acc": 76.47 + }, + "PhotoMaker": { + "ap": 94.62, + "auroc": 93.37, + "real_acc": 95.36, + "fake_acc": 76.09, + "acc": 85.72 + }, + "ProGAN": { + "ap": 99.39, + "auroc": 99.69, + "real_acc": 99.5, + "fake_acc": 81.55, + "acc": 90.53 + }, + "R3GAN": { + "ap": 98.48, + "auroc": 99.08, + "real_acc": 95.22, + "fake_acc": 98.47, + "acc": 96.84 + }, + "SD3": { + "ap": 98.6, + "auroc": 98.79, + "real_acc": 96.13, + "fake_acc": 93.96, + "acc": 95.04 + }, + "SDXL": { + "ap": 99.86, + "auroc": 99.88, + "real_acc": 96.13, + "fake_acc": 99.87, + "acc": 98.0 + }, + "SocialRF": { + "ap": 93.46, + "auroc": 94.74, + "real_acc": 92.03, + "fake_acc": 81.47, + "acc": 86.75 + }, + "StyleGAN-XL": { + "ap": 99.08, + "auroc": 99.47, + "real_acc": 95.18, + "fake_acc": 99.8, + "acc": 97.49 + }, + "StyleGAN3": { + "ap": 96.45, + "auroc": 97.59, + "real_acc": 96.56, + "fake_acc": 80.36, + "acc": 88.46 + }, + "StyleSwim": { + "ap": 98.8, + "auroc": 99.17, + "real_acc": 94.58, + "fake_acc": 99.36, + "acc": 96.97 + }, + "WFIR": { + "ap": 98.16, + "auroc": 98.77, + "real_acc": 91.6, + "fake_acc": 99.1, + "acc": 95.35 + } + }, + "date": "2026-11-10T11:43:34", + "synthscope_version": "0.1.0" +} diff --git a/repro/bench_results/cure_trained_r2e1_bfree_online.json b/repro/bench_results/cure_trained_r2e1_bfree_online.json new file mode 100644 index 0000000000000000000000000000000000000000..b5d95bf8b3a1b53d3410ca7b0f2df66c2fab9894 --- /dev/null +++ b/repro/bench_results/cure_trained_r2e1_bfree_online.json @@ -0,0 +1,26 @@ +{ + "tag": "cure_trained_r2e1_bfree_online", + "model": "cure", + "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_s1inv/s23mc_r2e1/cure_trained.pth", + "model_config": null, + "benchmark": "pergen", + "data_root": "/local/ssalehid/cache/data029/BFreeOnline/test", + "jpeg_fakes": null, + "n_generators": 1, + "means": { + "acc": 74.54, + "map": 94.85, + "mauroc": 89.9 + }, + "per_generator": { + "viral": { + "ap": 94.85, + "auroc": 89.9, + "real_acc": 95.91, + "fake_acc": 53.16, + "acc": 74.54 + } + }, + "date": "2026-11-10T11:28:11", + "synthscope_version": "0.1.0" +} diff --git a/repro/bench_results/cure_trained_r2e1_evalgen.json b/repro/bench_results/cure_trained_r2e1_evalgen.json new file mode 100644 index 0000000000000000000000000000000000000000..213eac9d2c5c65f487fdcbabcf0b3b7614f2cd3e --- /dev/null +++ b/repro/bench_results/cure_trained_r2e1_evalgen.json @@ -0,0 +1,54 @@ +{ + "tag": "cure_trained_r2e1_evalgen", + "model": "cure", + "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_s1inv/s23mc_r2e1/cure_trained.pth", + "model_config": null, + "benchmark": "pergen", + "data_root": "/local/ssalehid/cache/data029/EvalGEN/test", + "jpeg_fakes": null, + "n_generators": 5, + "means": { + "acc": 93.98, + "map": 99.63, + "mauroc": 99.17 + }, + "per_generator": { + "Flux": { + "ap": 98.4, + "auroc": 96.38, + "real_acc": 99.52, + "fake_acc": 52.87, + "acc": 76.19 + }, + "GoT": { + "ap": 99.95, + "auroc": 99.88, + "real_acc": 99.52, + "fake_acc": 97.75, + "acc": 98.63 + }, + "Infinity": { + "ap": 99.87, + "auroc": 99.7, + "real_acc": 99.52, + "fake_acc": 93.44, + "acc": 96.48 + }, + "NOVA": { + "ap": 99.96, + "auroc": 99.92, + "real_acc": 99.52, + "fake_acc": 98.69, + "acc": 99.1 + }, + "OmniGen": { + "ap": 99.98, + "auroc": 99.96, + "real_acc": 99.52, + "fake_acc": 99.53, + "acc": 99.52 + } + }, + "date": "2026-11-10T10:22:41", + "synthscope_version": "0.1.0" +} diff --git a/repro/bench_results/cure_trained_r2e1_forensynths.json b/repro/bench_results/cure_trained_r2e1_forensynths.json new file mode 100644 index 0000000000000000000000000000000000000000..2834d73fcae8e3760d40679db8c0ad5541b0aa17 --- /dev/null +++ b/repro/bench_results/cure_trained_r2e1_forensynths.json @@ -0,0 +1,110 @@ +{ + "tag": "cure_trained_r2e1_forensynths", + "model": "cure", + "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_s1inv/s23mc_r2e1/cure_trained.pth", + "model_config": null, + "benchmark": "forensynths", + "data_root": "/local/ssalehid/cache/data023/CNNDetection/test", + "jpeg_fakes": null, + "n_generators": 13, + "means": { + "acc": 84.26, + "map": 96.41, + "mauroc": 96.16 + }, + "per_generator": { + "biggan": { + "ap": 98.59, + "auroc": 99.27, + "real_acc": 99.35, + "fake_acc": 80.0, + "acc": 89.68 + }, + "crn": { + "ap": 99.74, + "auroc": 99.86, + "real_acc": 99.73, + "fake_acc": 95.14, + "acc": 97.44 + }, + "cyclegan": { + "ap": 99.26, + "auroc": 99.4, + "real_acc": 99.62, + "fake_acc": 49.66, + "acc": 74.64 + }, + "deepfake": { + "ap": 80.41, + "auroc": 79.67, + "real_acc": 98.71, + "fake_acc": 23.72, + "acc": 61.21 + }, + "gaugan": { + "ap": 99.05, + "auroc": 99.44, + "real_acc": 99.22, + "fake_acc": 75.34, + "acc": 87.28 + }, + "imle": { + "ap": 99.53, + "auroc": 99.69, + "real_acc": 99.73, + "fake_acc": 83.61, + "acc": 91.67 + }, + "progan": { + "ap": 99.39, + "auroc": 99.69, + "real_acc": 99.5, + "fake_acc": 81.55, + "acc": 90.53 + }, + "san": { + "ap": 91.08, + "auroc": 87.18, + "real_acc": 98.63, + "fake_acc": 47.95, + "acc": 73.29 + }, + "seeingdark": { + "ap": 94.92, + "auroc": 92.92, + "real_acc": 100.0, + "fake_acc": 39.44, + "acc": 69.72 + }, + "stargan": { + "ap": 97.83, + "auroc": 98.93, + "real_acc": 97.7, + "fake_acc": 91.9, + "acc": 94.8 + }, + "stylegan": { + "ap": 98.95, + "auroc": 99.23, + "real_acc": 99.28, + "fake_acc": 80.92, + "acc": 90.1 + }, + "stylegan2": { + "ap": 96.48, + "auroc": 96.0, + "real_acc": 99.26, + "fake_acc": 60.08, + "acc": 79.67 + }, + "whichfaceisreal": { + "ap": 98.16, + "auroc": 98.77, + "real_acc": 91.6, + "fake_acc": 99.1, + "acc": 95.35 + } + }, + "date": "2026-11-10T08:36:00", + "synthscope_version": "0.1.0" +} diff --git a/repro/bench_results/cure_trained_r2e1_genimage8.json b/repro/bench_results/cure_trained_r2e1_genimage8.json new file mode 100644 index 0000000000000000000000000000000000000000..06a59748003d55effd2bebdd0f9736cca4b4fe8a --- /dev/null +++ b/repro/bench_results/cure_trained_r2e1_genimage8.json @@ -0,0 +1,75 @@ +{ + "tag": "cure_trained_r2e1_genimage8", + "model": "cure", + "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_s1inv/s23mc_r2e1/cure_trained.pth", + "model_config": null, + "benchmark": "pergen", + "data_root": "/local/ssalehid/cache/data023/GenImage_full/test", + "jpeg_fakes": null, + "n_generators": 8, + "means": { + "acc": 83.48, + "map": 96.89, + "mauroc": 96.54 + }, + "per_generator": { + "adm": { + "ap": 86.2, + "auroc": 85.36, + "real_acc": 99.73, + "fake_acc": 14.67, + "acc": 57.2 + }, + "biggan": { + "ap": 98.05, + "auroc": 98.45, + "real_acc": 99.73, + "fake_acc": 38.8, + "acc": 69.27 + }, + "glide": { + "ap": 97.91, + "auroc": 97.76, + "real_acc": 99.6, + "fake_acc": 58.87, + "acc": 79.23 + }, + "midjourney": { + "ap": 94.38, + "auroc": 92.31, + "real_acc": 99.67, + "fake_acc": 56.67, + "acc": 78.17 + }, + "sdv1.4": { + "ap": 99.99, + "auroc": 99.99, + "real_acc": 99.53, + "fake_acc": 99.87, + "acc": 99.7 + }, + "sdv1.5": { + "ap": 99.99, + "auroc": 99.99, + "real_acc": 99.8, + "fake_acc": 99.73, + "acc": 99.77 + }, + "vqdm": { + "ap": 98.58, + "auroc": 98.44, + "real_acc": 99.73, + "fake_acc": 69.8, + "acc": 84.77 + }, + "wukong": { + "ap": 100.0, + "auroc": 100.0, + "real_acc": 99.73, + "fake_acc": 99.8, + "acc": 99.77 + } + }, + "date": "2026-11-10T11:22:15", + "synthscope_version": "0.1.0" +} diff --git a/repro/bench_results/cure_trained_r2e1_realchain.json b/repro/bench_results/cure_trained_r2e1_realchain.json new file mode 100644 index 0000000000000000000000000000000000000000..873e9f854a3c841a96d7decc5d031620f74ba45d --- /dev/null +++ b/repro/bench_results/cure_trained_r2e1_realchain.json @@ -0,0 +1,68 @@ +{ + "tag": "cure_trained_r2e1_realchain", + "model": "cure", + "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_s1inv/s23mc_r2e1/cure_trained.pth", + "model_config": null, + "benchmark": "pergen", + "data_root": "/local/ssalehid/cache/data029/RealChain/test", + "jpeg_fakes": null, + "n_generators": 7, + "means": { + "acc": 72.28, + "map": 85.86, + "mauroc": 85.02 + }, + "per_generator": { + "Flux1": { + "ap": 92.81, + "auroc": 92.17, + "real_acc": 98.1, + "fake_acc": 52.8, + "acc": 75.45 + }, + "Hunyuan3": { + "ap": 96.48, + "auroc": 95.76, + "real_acc": 99.1, + "fake_acc": 72.1, + "acc": 85.6 + }, + "NanoBanana": { + "ap": 87.98, + "auroc": 88.16, + "real_acc": 98.0, + "fake_acc": 37.6, + "acc": 67.8 + }, + "QwenImage": { + "ap": 95.39, + "auroc": 95.31, + "real_acc": 97.5, + "fake_acc": 73.3, + "acc": 85.4 + }, + "SDv3.5": { + "ap": 91.11, + "auroc": 89.73, + "real_acc": 97.5, + "fake_acc": 53.9, + "acc": 75.7 + }, + "Seedream4": { + "ap": 68.06, + "auroc": 67.37, + "real_acc": 94.0, + "fake_acc": 22.7, + "acc": 58.35 + }, + "i2i": { + "ap": 69.17, + "auroc": 66.67, + "real_acc": 94.9, + "fake_acc": 20.4, + "acc": 57.65 + } + }, + "date": "2026-11-10T10:51:09", + "synthscope_version": "0.1.0" +} diff --git a/repro/bench_results/cure_trained_r2e1_rrdataset.json b/repro/bench_results/cure_trained_r2e1_rrdataset.json new file mode 100644 index 0000000000000000000000000000000000000000..04a3ea2b9782dad8b3e939884d62e34d936b30ed --- /dev/null +++ b/repro/bench_results/cure_trained_r2e1_rrdataset.json @@ -0,0 +1,40 @@ +{ + "tag": "cure_trained_r2e1_rrdataset", + "model": "cure", + "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_s1inv/s23mc_r2e1/cure_trained.pth", + "model_config": null, + "benchmark": "pergen", + "data_root": "/local/ssalehid/cache/data029/RRDataset/test", + "jpeg_fakes": null, + "n_generators": 3, + "means": { + "acc": 72.65, + "map": 86.06, + "mauroc": 84.82 + }, + "per_generator": { + "original": { + "ap": 93.12, + "auroc": 93.12, + "real_acc": 95.58, + "fake_acc": 69.08, + "acc": 82.33 + }, + "redigital": { + "ap": 76.5, + "auroc": 74.11, + "real_acc": 96.91, + "fake_acc": 25.94, + "acc": 61.42 + }, + "transfer": { + "ap": 88.56, + "auroc": 87.23, + "real_acc": 96.51, + "fake_acc": 51.89, + "acc": 74.2 + } + }, + "date": "2026-11-10T11:01:38", + "synthscope_version": "0.1.0" +} diff --git a/repro/bench_results/cure_trained_r2e1_synthwildx.json b/repro/bench_results/cure_trained_r2e1_synthwildx.json new file mode 100644 index 0000000000000000000000000000000000000000..3bc085a40a38875afc86a2213d6d1b9c1a9c724e --- /dev/null +++ b/repro/bench_results/cure_trained_r2e1_synthwildx.json @@ -0,0 +1,40 @@ +{ + "tag": "cure_trained_r2e1_synthwildx", + "model": "cure", + "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_s1inv/s23mc_r2e1/cure_trained.pth", + "model_config": null, + "benchmark": "pergen", + "data_root": "/local/ssalehid/cache/data029/SynthWildX/test", + "jpeg_fakes": null, + "n_generators": 3, + "means": { + "acc": 88.65, + "map": 95.9, + "mauroc": 95.9 + }, + "per_generator": { + "dalle3": { + "ap": 96.5, + "auroc": 97.25, + "real_acc": 95.16, + "fake_acc": 88.52, + "acc": 91.84 + }, + "firefly": { + "ap": 95.51, + "auroc": 94.21, + "real_acc": 95.16, + "fake_acc": 79.28, + "acc": 87.22 + }, + "midjourney_v5": { + "ap": 95.69, + "auroc": 96.25, + "real_acc": 95.16, + "fake_acc": 78.62, + "acc": 86.89 + } + }, + "date": "2026-11-10T11:27:01", + "synthscope_version": "0.1.0" +} diff --git a/repro/bench_results/cure_trained_r2e1_ufd.json b/repro/bench_results/cure_trained_r2e1_ufd.json new file mode 100644 index 0000000000000000000000000000000000000000..b0165550ac8a4ee81b8bb518790bc1215e952284 --- /dev/null +++ b/repro/bench_results/cure_trained_r2e1_ufd.json @@ -0,0 +1,75 @@ +{ + "tag": "cure_trained_r2e1_ufd", + "model": "cure", + "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_s1inv/s23mc_r2e1/cure_trained.pth", + "model_config": null, + "benchmark": "ufd", + "data_root": "/local/ssalehid/cache/data023/universialfakedetection/test", + "jpeg_fakes": null, + "n_generators": 8, + "means": { + "acc": 92.14, + "map": 98.86, + "mauroc": 98.52 + }, + "per_generator": { + "dalle": { + "ap": 99.88, + "auroc": 99.87, + "real_acc": 99.9, + "fake_acc": 93.8, + "acc": 96.85 + }, + "glide_100_10": { + "ap": 99.13, + "auroc": 98.92, + "real_acc": 99.9, + "fake_acc": 82.5, + "acc": 91.2 + }, + "glide_100_27": { + "ap": 98.56, + "auroc": 98.11, + "real_acc": 99.9, + "fake_acc": 77.7, + "acc": 88.8 + }, + "glide_50_27": { + "ap": 98.48, + "auroc": 98.0, + "real_acc": 99.9, + "fake_acc": 75.8, + "acc": 87.85 + }, + "guided": { + "ap": 95.0, + "auroc": 93.44, + "real_acc": 99.9, + "fake_acc": 51.2, + "acc": 75.55 + }, + "ldm_100": { + "ap": 99.95, + "auroc": 99.95, + "real_acc": 99.9, + "fake_acc": 97.8, + "acc": 98.85 + }, + "ldm_200": { + "ap": 99.97, + "auroc": 99.97, + "real_acc": 99.9, + "fake_acc": 97.9, + "acc": 98.9 + }, + "ldm_200_cfg": { + "ap": 99.91, + "auroc": 99.88, + "real_acc": 99.9, + "fake_acc": 98.4, + "acc": 99.15 + } + }, + "date": "2026-11-10T11:20:53", + "synthscope_version": "0.1.0" +} diff --git a/repro/bench_results/cure_trained_r2e1_wildrf.json b/repro/bench_results/cure_trained_r2e1_wildrf.json new file mode 100644 index 0000000000000000000000000000000000000000..aaf45ea8f59ddf0cc92855d8d1e5b74ca139a46a --- /dev/null +++ b/repro/bench_results/cure_trained_r2e1_wildrf.json @@ -0,0 +1,40 @@ +{ + "tag": "cure_trained_r2e1_wildrf", + "model": "cure", + "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_s1inv/s23mc_r2e1/cure_trained.pth", + "model_config": null, + "benchmark": "pergen", + "data_root": "/local/ssalehid/cache/data029/WildRF/test", + "jpeg_fakes": null, + "n_generators": 3, + "means": { + "acc": 93.91, + "map": 98.48, + "mauroc": 98.43 + }, + "per_generator": { + "facebook": { + "ap": 97.74, + "auroc": 97.71, + "real_acc": 94.38, + "fake_acc": 90.0, + "acc": 92.19 + }, + "reddit": { + "ap": 99.11, + "auroc": 99.07, + "real_acc": 97.47, + "fake_acc": 93.87, + "acc": 95.67 + }, + "twitter": { + "ap": 98.58, + "auroc": 98.5, + "real_acc": 97.36, + "fake_acc": 90.35, + "acc": 93.86 + } + }, + "date": "2026-11-10T11:27:21", + "synthscope_version": "0.1.0" +} diff --git a/repro/bench_results/cure_trained_r3e0_aigcdetect.json b/repro/bench_results/cure_trained_r3e0_aigcdetect.json new file mode 100644 index 0000000000000000000000000000000000000000..58dfc4c0aeb72954b952caaecdeb2754910aab29 --- /dev/null +++ b/repro/bench_results/cure_trained_r3e0_aigcdetect.json @@ -0,0 +1,138 @@ +{ + "tag": "cure_trained_r3e0_aigcdetect", + "model": "cure", + "ckpt": "/local/ssalehid/67200/s23_r3e0/cure_trained.pth", + "model_config": null, + "benchmark": "pergen", + "data_root": "/local/ssalehid/cache/data029/AIGCDetect/test", + "jpeg_fakes": null, + "n_generators": 17, + "means": { + "acc": 92.01, + "map": 98.59, + "mauroc": 98.38 + }, + "per_generator": { + "ADM": { + "ap": 93.47, + "auroc": 93.07, + "real_acc": 99.22, + "fake_acc": 42.82, + "acc": 71.02 + }, + "DALLE2": { + "ap": 96.64, + "auroc": 95.88, + "real_acc": 98.9, + "fake_acc": 71.0, + "acc": 84.95 + }, + "Glide": { + "ap": 97.85, + "auroc": 97.53, + "real_acc": 99.5, + "fake_acc": 70.37, + "acc": 84.93 + }, + "Midjourney": { + "ap": 94.87, + "auroc": 93.42, + "real_acc": 99.22, + "fake_acc": 58.78, + "acc": 79.0 + }, + "VQDM": { + "ap": 98.87, + "auroc": 98.6, + "real_acc": 99.35, + "fake_acc": 85.4, + "acc": 92.37 + }, + "biggan": { + "ap": 99.68, + "auroc": 99.63, + "real_acc": 99.5, + "fake_acc": 94.4, + "acc": 96.95 + }, + "cyclegan": { + "ap": 99.53, + "auroc": 99.53, + "real_acc": 99.62, + "fake_acc": 78.8, + "acc": 89.21 + }, + "gaugan": { + "ap": 99.91, + "auroc": 99.9, + "real_acc": 99.36, + "fake_acc": 97.66, + "acc": 98.51 + }, + "progan": { + "ap": 99.97, + "auroc": 99.98, + "real_acc": 99.7, + "fake_acc": 99.0, + "acc": 99.35 + }, + "sd_xl": { + "ap": 99.94, + "auroc": 99.93, + "real_acc": 99.4, + "fake_acc": 99.0, + "acc": 99.2 + }, + "stable_diffusion_v_1_4": { + "ap": 99.97, + "auroc": 99.97, + "real_acc": 99.37, + "fake_acc": 99.8, + "acc": 99.58 + }, + "stable_diffusion_v_1_5": { + "ap": 99.97, + "auroc": 99.97, + "real_acc": 99.39, + "fake_acc": 99.67, + "acc": 99.53 + }, + "stargan": { + "ap": 99.29, + "auroc": 99.45, + "real_acc": 97.65, + "fake_acc": 96.85, + "acc": 97.25 + }, + "stylegan": { + "ap": 98.99, + "auroc": 98.81, + "real_acc": 99.22, + "fake_acc": 87.18, + "acc": 93.2 + }, + "stylegan2": { + "ap": 97.7, + "auroc": 97.34, + "real_acc": 99.32, + "fake_acc": 70.22, + "acc": 84.77 + }, + "whichfaceisreal": { + "ap": 99.41, + "auroc": 99.54, + "real_acc": 90.3, + "fake_acc": 99.6, + "acc": 94.95 + }, + "wukong": { + "ap": 99.98, + "auroc": 99.98, + "real_acc": 99.2, + "fake_acc": 99.75, + "acc": 99.47 + } + }, + "date": "2026-11-10T22:07:09", + "synthscope_version": "0.1.0" +} diff --git a/repro/bench_results/cure_trained_r3e0_aigibench20_full.json b/repro/bench_results/cure_trained_r3e0_aigibench20_full.json new file mode 100644 index 0000000000000000000000000000000000000000..f4352468388c4d480ce575950d0ffc91109ef025 --- /dev/null +++ b/repro/bench_results/cure_trained_r3e0_aigibench20_full.json @@ -0,0 +1,159 @@ +{ + "tag": "cure_trained_r3e0_aigibench20_full", + "model": "cure", + "ckpt": "/local/ssalehid/67200/s23_r3e0/cure_trained.pth", + "model_config": null, + "benchmark": "pergen", + "data_root": "/local/ssalehid/cache/data023/AIGIBench/test", + "jpeg_fakes": null, + "n_generators": 20, + "means": { + "acc": 91.12, + "map": 96.72, + "mauroc": 97.1 + }, + "per_generator": { + "BLIP": { + "ap": 99.87, + "auroc": 99.89, + "real_acc": 95.02, + "fake_acc": 99.96, + "acc": 97.49 + }, + "CommunityAI": { + "ap": 94.24, + "auroc": 95.22, + "real_acc": 93.72, + "fake_acc": 79.58, + "acc": 86.65 + }, + "DALLE-3": { + "ap": 99.4, + "auroc": 99.43, + "real_acc": 94.48, + "fake_acc": 98.58, + "acc": 96.53 + }, + "FLUX1-dev": { + "ap": 90.12, + "auroc": 91.75, + "real_acc": 94.31, + "fake_acc": 63.49, + "acc": 78.9 + }, + "GLIDE": { + "ap": 93.2, + "auroc": 93.21, + "real_acc": 94.36, + "fake_acc": 73.18, + "acc": 83.77 + }, + "IP_Adapter": { + "ap": 91.81, + "auroc": 92.39, + "real_acc": 93.76, + "fake_acc": 67.6, + "acc": 80.68 + }, + "Imagen3": { + "ap": 85.04, + "auroc": 87.2, + "real_acc": 93.93, + "fake_acc": 43.67, + "acc": 68.8 + }, + "Infinite_ID": { + "ap": 99.61, + "auroc": 99.64, + "real_acc": 93.67, + "fake_acc": 99.51, + "acc": 96.59 + }, + "InstantID": { + "ap": 99.88, + "auroc": 99.88, + "real_acc": 94.07, + "fake_acc": 99.78, + "acc": 96.92 + }, + "Midjourney": { + "ap": 93.94, + "auroc": 94.66, + "real_acc": 92.9, + "fake_acc": 76.87, + "acc": 84.88 + }, + "PhotoMaker": { + "ap": 96.67, + "auroc": 96.51, + "real_acc": 93.87, + "fake_acc": 85.07, + "acc": 89.47 + }, + "ProGAN": { + "ap": 99.97, + "auroc": 99.98, + "real_acc": 99.7, + "fake_acc": 99.0, + "acc": 99.35 + }, + "R3GAN": { + "ap": 99.39, + "auroc": 99.48, + "real_acc": 94.02, + "fake_acc": 98.91, + "acc": 96.47 + }, + "SD3": { + "ap": 99.42, + "auroc": 99.46, + "real_acc": 95.16, + "fake_acc": 98.29, + "acc": 96.72 + }, + "SDXL": { + "ap": 99.97, + "auroc": 99.97, + "real_acc": 95.16, + "fake_acc": 100.0, + "acc": 97.58 + }, + "SocialRF": { + "ap": 95.76, + "auroc": 96.41, + "real_acc": 89.8, + "fake_acc": 90.5, + "acc": 90.15 + }, + "StyleGAN-XL": { + "ap": 99.48, + "auroc": 99.66, + "real_acc": 94.11, + "fake_acc": 99.87, + "acc": 96.99 + }, + "StyleGAN3": { + "ap": 97.65, + "auroc": 98.2, + "real_acc": 95.6, + "fake_acc": 90.07, + "acc": 92.83 + }, + "StyleSwim": { + "ap": 99.47, + "auroc": 99.6, + "real_acc": 93.42, + "fake_acc": 99.76, + "acc": 96.59 + }, + "WFIR": { + "ap": 99.41, + "auroc": 99.54, + "real_acc": 90.3, + "fake_acc": 99.6, + "acc": 94.95 + } + }, + "date": "2026-11-10T23:28:30", + "synthscope_version": "0.1.0" +} diff --git a/repro/bench_results/cure_trained_r3e0_bfree_online.json b/repro/bench_results/cure_trained_r3e0_bfree_online.json new file mode 100644 index 0000000000000000000000000000000000000000..472bcc40a5da889de2110cd49060081c2fca2ac7 --- /dev/null +++ b/repro/bench_results/cure_trained_r3e0_bfree_online.json @@ -0,0 +1,26 @@ +{ + "tag": "cure_trained_r3e0_bfree_online", + "model": "cure", + "ckpt": "/local/ssalehid/67200/s23_r3e0/cure_trained.pth", + "model_config": null, + "benchmark": "pergen", + "data_root": "/local/ssalehid/cache/data029/BFreeOnline/test", + "jpeg_fakes": null, + "n_generators": 1, + "means": { + "acc": 71.19, + "map": 89.48, + "mauroc": 79.51 + }, + "per_generator": { + "viral": { + "ap": 89.48, + "auroc": 79.51, + "real_acc": 91.45, + "fake_acc": 50.93, + "acc": 71.19 + } + }, + "date": "2026-11-10T20:32:49", + "synthscope_version": "0.1.0" +} diff --git a/repro/bench_results/cure_trained_r3e0_evalgen.json b/repro/bench_results/cure_trained_r3e0_evalgen.json new file mode 100644 index 0000000000000000000000000000000000000000..136c649c7ae54bbe91f424021f40519e2e20e505 --- /dev/null +++ b/repro/bench_results/cure_trained_r3e0_evalgen.json @@ -0,0 +1,54 @@ +{ + "tag": "cure_trained_r3e0_evalgen", + "model": "cure", + "ckpt": "/local/ssalehid/67200/s23_r3e0/cure_trained.pth", + "model_config": null, + "benchmark": "pergen", + "data_root": "/local/ssalehid/cache/data029/EvalGEN/test", + "jpeg_fakes": null, + "n_generators": 5, + "means": { + "acc": 93.32, + "map": 99.47, + "mauroc": 98.85 + }, + "per_generator": { + "Flux": { + "ap": 97.73, + "auroc": 95.04, + "real_acc": 99.1, + "fake_acc": 50.83, + "acc": 74.97 + }, + "GoT": { + "ap": 99.88, + "auroc": 99.73, + "real_acc": 99.1, + "fake_acc": 96.2, + "acc": 97.65 + }, + "Infinity": { + "ap": 99.82, + "auroc": 99.63, + "real_acc": 99.1, + "fake_acc": 92.73, + "acc": 95.92 + }, + "NOVA": { + "ap": 99.97, + "auroc": 99.93, + "real_acc": 99.1, + "fake_acc": 99.24, + "acc": 99.17 + }, + "OmniGen": { + "ap": 99.95, + "auroc": 99.91, + "real_acc": 99.1, + "fake_acc": 98.71, + "acc": 98.9 + } + }, + "date": "2026-11-10T21:38:37", + "synthscope_version": "0.1.0" +} diff --git a/repro/bench_results/cure_trained_r3e0_forensynths.json b/repro/bench_results/cure_trained_r3e0_forensynths.json new file mode 100644 index 0000000000000000000000000000000000000000..45cfe45e65c34e3ba8784a8ef9f2afdb5fa172a5 --- /dev/null +++ b/repro/bench_results/cure_trained_r3e0_forensynths.json @@ -0,0 +1,110 @@ +{ + "tag": "cure_trained_r3e0_forensynths", + "model": "cure", + "ckpt": "/local/ssalehid/67200/s23_r3e0/cure_trained.pth", + "model_config": null, + "benchmark": "forensynths", + "data_root": "/local/ssalehid/cache/data023/CNNDetection/test", + "jpeg_fakes": null, + "n_generators": 13, + "means": { + "acc": 89.36, + "map": 97.22, + "mauroc": 96.58 + }, + "per_generator": { + "biggan": { + "ap": 99.68, + "auroc": 99.63, + "real_acc": 99.5, + "fake_acc": 94.4, + "acc": 96.95 + }, + "crn": { + "ap": 99.82, + "auroc": 99.8, + "real_acc": 97.68, + "fake_acc": 99.4, + "acc": 98.54 + }, + "cyclegan": { + "ap": 99.53, + "auroc": 99.53, + "real_acc": 99.62, + "fake_acc": 78.8, + "acc": 89.21 + }, + "deepfake": { + "ap": 85.83, + "auroc": 83.74, + "real_acc": 99.48, + "fake_acc": 19.76, + "acc": 59.62 + }, + "gaugan": { + "ap": 99.91, + "auroc": 99.9, + "real_acc": 99.36, + "fake_acc": 97.66, + "acc": 98.51 + }, + "imle": { + "ap": 99.74, + "auroc": 99.73, + "real_acc": 97.68, + "fake_acc": 98.7, + "acc": 98.19 + }, + "progan": { + "ap": 99.97, + "auroc": 99.98, + "real_acc": 99.7, + "fake_acc": 99.0, + "acc": 99.35 + }, + "san": { + "ap": 90.63, + "auroc": 87.23, + "real_acc": 99.09, + "fake_acc": 49.77, + "acc": 74.43 + }, + "seeingdark": { + "ap": 93.38, + "auroc": 90.81, + "real_acc": 100.0, + "fake_acc": 53.33, + "acc": 76.67 + }, + "stargan": { + "ap": 99.29, + "auroc": 99.45, + "real_acc": 97.65, + "fake_acc": 96.85, + "acc": 97.25 + }, + "stylegan": { + "ap": 98.99, + "auroc": 98.81, + "real_acc": 99.22, + "fake_acc": 87.18, + "acc": 93.2 + }, + "stylegan2": { + "ap": 97.7, + "auroc": 97.34, + "real_acc": 99.32, + "fake_acc": 70.22, + "acc": 84.77 + }, + "whichfaceisreal": { + "ap": 99.41, + "auroc": 99.54, + "real_acc": 90.3, + "fake_acc": 99.6, + "acc": 94.95 + } + }, + "date": "2026-11-10T21:40:42", + "synthscope_version": "0.1.0" +} diff --git a/repro/bench_results/cure_trained_r3e0_genimage8.json b/repro/bench_results/cure_trained_r3e0_genimage8.json new file mode 100644 index 0000000000000000000000000000000000000000..9c84ed6aa145111d38e44009b90fb40843cf087f --- /dev/null +++ b/repro/bench_results/cure_trained_r3e0_genimage8.json @@ -0,0 +1,75 @@ +{ + "tag": "cure_trained_r3e0_genimage8", + "model": "cure", + "ckpt": "/local/ssalehid/67200/s23_r3e0/cure_trained.pth", + "model_config": null, + "benchmark": "pergen", + "data_root": "/local/ssalehid/cache/data023/GenImage_full/test", + "jpeg_fakes": null, + "n_generators": 8, + "means": { + "acc": 86.22, + "map": 97.56, + "mauroc": 97.59 + }, + "per_generator": { + "adm": { + "ap": 89.39, + "auroc": 90.73, + "real_acc": 99.07, + "fake_acc": 19.33, + "acc": 59.2 + }, + "biggan": { + "ap": 97.76, + "auroc": 97.72, + "real_acc": 99.2, + "fake_acc": 60.13, + "acc": 79.67 + }, + "glide": { + "ap": 97.99, + "auroc": 97.8, + "real_acc": 99.6, + "fake_acc": 64.33, + "acc": 81.97 + }, + "midjourney": { + "ap": 97.13, + "auroc": 96.48, + "real_acc": 99.53, + "fake_acc": 65.27, + "acc": 82.4 + }, + "sdv1.4": { + "ap": 99.99, + "auroc": 99.99, + "real_acc": 99.47, + "fake_acc": 99.8, + "acc": 99.63 + }, + "sdv1.5": { + "ap": 100.0, + "auroc": 100.0, + "real_acc": 99.47, + "fake_acc": 99.8, + "acc": 99.63 + }, + "vqdm": { + "ap": 98.25, + "auroc": 98.04, + "real_acc": 99.2, + "fake_acc": 76.07, + "acc": 87.63 + }, + "wukong": { + "ap": 99.98, + "auroc": 99.98, + "real_acc": 99.27, + "fake_acc": 99.93, + "acc": 99.6 + } + }, + "date": "2026-11-10T20:53:04", + "synthscope_version": "0.1.0" +} diff --git a/repro/bench_results/cure_trained_r3e0_realchain.json b/repro/bench_results/cure_trained_r3e0_realchain.json new file mode 100644 index 0000000000000000000000000000000000000000..2490f2b7eda3c6c09dd7473d1f0c259be98e85ae --- /dev/null +++ b/repro/bench_results/cure_trained_r3e0_realchain.json @@ -0,0 +1,68 @@ +{ + "tag": "cure_trained_r3e0_realchain", + "model": "cure", + "ckpt": "/local/ssalehid/67200/s23_r3e0/cure_trained.pth", + "model_config": null, + "benchmark": "pergen", + "data_root": "/local/ssalehid/cache/data029/RealChain/test", + "jpeg_fakes": null, + "n_generators": 7, + "means": { + "acc": 72.75, + "map": 83.67, + "mauroc": 84.7 + }, + "per_generator": { + "Flux1": { + "ap": 91.58, + "auroc": 92.06, + "real_acc": 96.2, + "fake_acc": 55.7, + "acc": 75.95 + }, + "Hunyuan3": { + "ap": 96.11, + "auroc": 96.23, + "real_acc": 97.9, + "fake_acc": 71.7, + "acc": 84.8 + }, + "NanoBanana": { + "ap": 84.33, + "auroc": 86.9, + "real_acc": 94.0, + "fake_acc": 44.9, + "acc": 69.45 + }, + "QwenImage": { + "ap": 96.14, + "auroc": 96.35, + "real_acc": 96.3, + "fake_acc": 80.3, + "acc": 88.3 + }, + "SDv3.5": { + "ap": 92.04, + "auroc": 91.48, + "real_acc": 95.2, + "fake_acc": 64.9, + "acc": 80.05 + }, + "Seedream4": { + "ap": 58.73, + "auroc": 62.53, + "real_acc": 88.3, + "fake_acc": 17.7, + "acc": 53.0 + }, + "i2i": { + "ap": 66.76, + "auroc": 67.32, + "real_acc": 92.1, + "fake_acc": 23.3, + "acc": 57.7 + } + }, + "date": "2026-11-10T20:53:39", + "synthscope_version": "0.1.0" +} diff --git a/repro/bench_results/cure_trained_r3e0_rrdataset.json b/repro/bench_results/cure_trained_r3e0_rrdataset.json new file mode 100644 index 0000000000000000000000000000000000000000..76055122bc48c2e0a49b7f0ec81c59b3eb6a2d80 --- /dev/null +++ b/repro/bench_results/cure_trained_r3e0_rrdataset.json @@ -0,0 +1,40 @@ +{ + "tag": "cure_trained_r3e0_rrdataset", + "model": "cure", + "ckpt": "/local/ssalehid/67200/s23_r3e0/cure_trained.pth", + "model_config": null, + "benchmark": "pergen", + "data_root": "/local/ssalehid/cache/data029/RRDataset/test", + "jpeg_fakes": null, + "n_generators": 3, + "means": { + "acc": 73.46, + "map": 84.91, + "mauroc": 85.32 + }, + "per_generator": { + "original": { + "ap": 89.23, + "auroc": 90.3, + "real_acc": 88.52, + "fake_acc": 70.86, + "acc": 79.69 + }, + "redigital": { + "ap": 79.2, + "auroc": 79.12, + "real_acc": 94.15, + "fake_acc": 36.02, + "acc": 65.09 + }, + "transfer": { + "ap": 86.3, + "auroc": 86.53, + "real_acc": 90.01, + "fake_acc": 61.2, + "acc": 75.61 + } + }, + "date": "2026-11-10T21:24:22", + "synthscope_version": "0.1.0" +} diff --git a/repro/bench_results/cure_trained_r3e0_synthwildx.json b/repro/bench_results/cure_trained_r3e0_synthwildx.json new file mode 100644 index 0000000000000000000000000000000000000000..1196e7fb66a4c24c480447af82d1e0186d782499 --- /dev/null +++ b/repro/bench_results/cure_trained_r3e0_synthwildx.json @@ -0,0 +1,40 @@ +{ + "tag": "cure_trained_r3e0_synthwildx", + "model": "cure", + "ckpt": "/local/ssalehid/67200/s23_r3e0/cure_trained.pth", + "model_config": null, + "benchmark": "pergen", + "data_root": "/local/ssalehid/cache/data029/SynthWildX/test", + "jpeg_fakes": null, + "n_generators": 3, + "means": { + "acc": 91.76, + "map": 97.12, + "mauroc": 97.09 + }, + "per_generator": { + "dalle3": { + "ap": 98.0, + "auroc": 98.47, + "real_acc": 92.98, + "fake_acc": 96.68, + "acc": 94.83 + }, + "firefly": { + "ap": 96.59, + "auroc": 95.71, + "real_acc": 92.98, + "fake_acc": 84.14, + "acc": 88.56 + }, + "midjourney_v5": { + "ap": 96.77, + "auroc": 97.09, + "real_acc": 92.98, + "fake_acc": 90.8, + "acc": 91.89 + } + }, + "date": "2026-11-10T20:31:06", + "synthscope_version": "0.1.0" +} diff --git a/repro/bench_results/cure_trained_r3e0_ufd.json b/repro/bench_results/cure_trained_r3e0_ufd.json new file mode 100644 index 0000000000000000000000000000000000000000..e9237af388d095e642a2045980ade1167d248222 --- /dev/null +++ b/repro/bench_results/cure_trained_r3e0_ufd.json @@ -0,0 +1,75 @@ +{ + "tag": "cure_trained_r3e0_ufd", + "model": "cure", + "ckpt": "/local/ssalehid/67200/s23_r3e0/cure_trained.pth", + "model_config": null, + "benchmark": "ufd", + "data_root": "/local/ssalehid/cache/data023/universialfakedetection/test", + "jpeg_fakes": null, + "n_generators": 8, + "means": { + "acc": 93.89, + "map": 98.73, + "mauroc": 98.31 + }, + "per_generator": { + "dalle": { + "ap": 99.78, + "auroc": 99.69, + "real_acc": 100.0, + "fake_acc": 97.9, + "acc": 98.95 + }, + "glide_100_10": { + "ap": 98.71, + "auroc": 98.16, + "real_acc": 100.0, + "fake_acc": 87.5, + "acc": 93.75 + }, + "glide_100_27": { + "ap": 98.26, + "auroc": 97.55, + "real_acc": 100.0, + "fake_acc": 80.6, + "acc": 90.3 + }, + "glide_50_27": { + "ap": 97.8, + "auroc": 96.95, + "real_acc": 100.0, + "fake_acc": 79.9, + "acc": 89.95 + }, + "guided": { + "ap": 95.44, + "auroc": 94.28, + "real_acc": 99.8, + "fake_acc": 59.9, + "acc": 79.85 + }, + "ldm_100": { + "ap": 99.96, + "auroc": 99.95, + "real_acc": 100.0, + "fake_acc": 99.3, + "acc": 99.65 + }, + "ldm_200": { + "ap": 99.98, + "auroc": 99.98, + "real_acc": 100.0, + "fake_acc": 99.2, + "acc": 99.6 + }, + "ldm_200_cfg": { + "ap": 99.92, + "auroc": 99.9, + "real_acc": 100.0, + "fake_acc": 98.2, + "acc": 99.1 + } + }, + "date": "2026-11-10T20:42:48", + "synthscope_version": "0.1.0" +} diff --git a/repro/bench_results/cure_trained_r3e0_wildrf.json b/repro/bench_results/cure_trained_r3e0_wildrf.json new file mode 100644 index 0000000000000000000000000000000000000000..555c3c790e873a72ed7305c0e32f4f6177afb900 --- /dev/null +++ b/repro/bench_results/cure_trained_r3e0_wildrf.json @@ -0,0 +1,40 @@ +{ + "tag": "cure_trained_r3e0_wildrf", + "model": "cure", + "ckpt": "/local/ssalehid/67200/s23_r3e0/cure_trained.pth", + "model_config": null, + "benchmark": "pergen", + "data_root": "/local/ssalehid/cache/data029/WildRF/test", + "jpeg_fakes": null, + "n_generators": 3, + "means": { + "acc": 95.58, + "map": 99.3, + "mauroc": 99.25 + }, + "per_generator": { + "facebook": { + "ap": 98.95, + "auroc": 98.8, + "real_acc": 93.75, + "fake_acc": 93.75, + "acc": 93.75 + }, + "reddit": { + "ap": 99.47, + "auroc": 99.45, + "real_acc": 96.53, + "fake_acc": 97.07, + "acc": 96.8 + }, + "twitter": { + "ap": 99.49, + "auroc": 99.49, + "real_acc": 97.36, + "fake_acc": 95.03, + "acc": 96.19 + } + }, + "date": "2026-11-10T20:32:41", + "synthscope_version": "0.1.0" +} diff --git a/repro/bench_results/cure_trained_realchain.json b/repro/bench_results/cure_trained_realchain.json new file mode 100644 index 0000000000000000000000000000000000000000..6f80cc0fed03a541185948229cbdda901888b29f --- /dev/null +++ b/repro/bench_results/cure_trained_realchain.json @@ -0,0 +1,68 @@ +{ + "tag": "cure_trained_realchain", + "model": "cure", + "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_trained/cure_trained.pth", + "model_config": null, + "benchmark": "pergen", + "data_root": "/local/ssalehid/cache/data029/RealChain/test", + "jpeg_fakes": null, + "n_generators": 7, + "means": { + "acc": 63.33, + "map": 79.6, + "mauroc": 76.5 + }, + "per_generator": { + "Flux1": { + "ap": 85.35, + "auroc": 82.16, + "real_acc": 99.2, + "fake_acc": 32.5, + "acc": 65.85 + }, + "Hunyuan3": { + "ap": 91.87, + "auroc": 89.3, + "real_acc": 99.6, + "fake_acc": 51.0, + "acc": 75.3 + }, + "NanoBanana": { + "ap": 81.65, + "auroc": 79.36, + "real_acc": 99.1, + "fake_acc": 25.3, + "acc": 62.2 + }, + "QwenImage": { + "ap": 85.44, + "auroc": 83.44, + "real_acc": 98.6, + "fake_acc": 34.2, + "acc": 66.4 + }, + "SDv3.5": { + "ap": 79.84, + "auroc": 75.79, + "real_acc": 99.3, + "fake_acc": 24.0, + "acc": 61.65 + }, + "Seedream4": { + "ap": 66.3, + "auroc": 62.25, + "real_acc": 98.0, + "fake_acc": 14.8, + "acc": 56.4 + }, + "i2i": { + "ap": 66.77, + "auroc": 63.17, + "real_acc": 98.4, + "fake_acc": 12.6, + "acc": 55.5 + } + }, + "date": "2026-11-09T04:02:07", + "synthscope_version": "0.1.0" +} diff --git a/repro/bench_results/cure_trained_rrdataset.json b/repro/bench_results/cure_trained_rrdataset.json new file mode 100644 index 0000000000000000000000000000000000000000..544a4792a707224d6c9cdbcdab65c517c3b35ab9 --- /dev/null +++ b/repro/bench_results/cure_trained_rrdataset.json @@ -0,0 +1,40 @@ +{ + "tag": "cure_trained_rrdataset", + "model": "cure", + "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_trained/cure_trained.pth", + "model_config": null, + "benchmark": "pergen", + "data_root": "/local/ssalehid/cache/data029/RRDataset/test", + "jpeg_fakes": null, + "n_generators": 3, + "means": { + "acc": 66.36, + "map": 80.4, + "mauroc": 76.87 + }, + "per_generator": { + "original": { + "ap": 90.13, + "auroc": 87.1, + "real_acc": 98.89, + "fake_acc": 54.31, + "acc": 76.6 + }, + "redigital": { + "ap": 68.37, + "auroc": 65.37, + "real_acc": 98.96, + "fake_acc": 13.71, + "acc": 56.34 + }, + "transfer": { + "ap": 82.71, + "auroc": 78.15, + "real_acc": 99.27, + "fake_acc": 32.99, + "acc": 66.13 + } + }, + "date": "2026-11-09T03:41:15", + "synthscope_version": "0.1.0" +} diff --git a/repro/bench_results/cure_trained_synthwildx.json b/repro/bench_results/cure_trained_synthwildx.json new file mode 100644 index 0000000000000000000000000000000000000000..e09ccaf1b2340c74900642cc6159f23fd027dd9e --- /dev/null +++ b/repro/bench_results/cure_trained_synthwildx.json @@ -0,0 +1,40 @@ +{ + "tag": "cure_trained_synthwildx", + "model": "cure", + "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_trained/cure_trained.pth", + "model_config": null, + "benchmark": "pergen", + "data_root": "/local/ssalehid/cache/data029/SynthWildX/test", + "jpeg_fakes": null, + "n_generators": 3, + "means": { + "acc": 76.11, + "map": 88.83, + "mauroc": 86.84 + }, + "per_generator": { + "dalle3": { + "ap": 88.91, + "auroc": 88.58, + "real_acc": 96.61, + "fake_acc": 56.38, + "acc": 76.49 + }, + "firefly": { + "ap": 91.15, + "auroc": 88.81, + "real_acc": 96.61, + "fake_acc": 58.99, + "acc": 77.8 + }, + "midjourney_v5": { + "ap": 86.44, + "auroc": 83.12, + "real_acc": 96.61, + "fake_acc": 51.49, + "acc": 74.05 + } + }, + "date": "2026-11-09T02:41:43", + "synthscope_version": "0.1.0" +} diff --git a/repro/bench_results/cure_trained_ufd.json b/repro/bench_results/cure_trained_ufd.json new file mode 100644 index 0000000000000000000000000000000000000000..c9c1a05b152282639f217a81912dbfe5ec90e2fe --- /dev/null +++ b/repro/bench_results/cure_trained_ufd.json @@ -0,0 +1,75 @@ +{ + "tag": "cure_trained_ufd", + "model": "cure", + "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_trained/cure_trained.pth", + "model_config": null, + "benchmark": "ufd", + "data_root": "/local/ssalehid/cache/data023/universialfakedetection/test", + "jpeg_fakes": null, + "n_generators": 8, + "means": { + "acc": 82.69, + "map": 95.26, + "mauroc": 93.85 + }, + "per_generator": { + "dalle": { + "ap": 99.09, + "auroc": 98.69, + "real_acc": 100.0, + "fake_acc": 86.2, + "acc": 93.1 + }, + "glide_100_10": { + "ap": 96.27, + "auroc": 94.95, + "real_acc": 100.0, + "fake_acc": 61.6, + "acc": 80.8 + }, + "glide_100_27": { + "ap": 92.08, + "auroc": 89.35, + "real_acc": 100.0, + "fake_acc": 45.2, + "acc": 72.6 + }, + "glide_50_27": { + "ap": 92.94, + "auroc": 90.76, + "real_acc": 100.0, + "fake_acc": 47.0, + "acc": 73.5 + }, + "guided": { + "ap": 83.35, + "auroc": 79.18, + "real_acc": 100.0, + "fake_acc": 21.4, + "acc": 60.7 + }, + "ldm_100": { + "ap": 99.56, + "auroc": 99.39, + "real_acc": 100.0, + "fake_acc": 86.8, + "acc": 93.4 + }, + "ldm_200": { + "ap": 99.56, + "auroc": 99.47, + "real_acc": 100.0, + "fake_acc": 84.0, + "acc": 92.0 + }, + "ldm_200_cfg": { + "ap": 99.27, + "auroc": 98.97, + "real_acc": 100.0, + "fake_acc": 90.8, + "acc": 95.4 + } + }, + "date": "2026-11-09T02:44:02", + "synthscope_version": "0.1.0" +} diff --git a/repro/bench_results/cure_trained_wildrf.json b/repro/bench_results/cure_trained_wildrf.json new file mode 100644 index 0000000000000000000000000000000000000000..848525f14a4ce9dde6a5f594915ba8a8f154b770 --- /dev/null +++ b/repro/bench_results/cure_trained_wildrf.json @@ -0,0 +1,40 @@ +{ + "tag": "cure_trained_wildrf", + "model": "cure", + "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/cure_trained/cure_trained.pth", + "model_config": null, + "benchmark": "pergen", + "data_root": "/local/ssalehid/cache/data029/WildRF/test", + "jpeg_fakes": null, + "n_generators": 3, + "means": { + "acc": 85.8, + "map": 95.0, + "mauroc": 94.59 + }, + "per_generator": { + "facebook": { + "ap": 92.39, + "auroc": 92.72, + "real_acc": 98.12, + "fake_acc": 66.25, + "acc": 82.19 + }, + "reddit": { + "ap": 96.79, + "auroc": 96.36, + "real_acc": 98.27, + "fake_acc": 81.07, + "acc": 89.67 + }, + "twitter": { + "ap": 95.83, + "auroc": 94.68, + "real_acc": 99.71, + "fake_acc": 71.35, + "acc": 85.53 + } + }, + "date": "2026-11-09T02:49:08", + "synthscope_version": "0.1.0" +} diff --git a/repro/bench_results/probe_aigibench.json b/repro/bench_results/probe_aigibench.json new file mode 100644 index 0000000000000000000000000000000000000000..dc2d267a22883c291162c33af99fe387dd75a4fa --- /dev/null +++ b/repro/bench_results/probe_aigibench.json @@ -0,0 +1,33 @@ +{ + "tag": "probe_aigibench", + "model": "probe", + "ckpt": "registry-default", + "model_config": null, + "benchmark": "pergen", + "data_root": "/local/ssalehid/66790/tmp/layouts/aigibench", + "jpeg_fakes": null, + "n_generators": 2, + "means": { + "acc": 89.88, + "map": 96.46, + "mauroc": 95.88 + }, + "per_generator": { + "CommunityAI": { + "ap": 97.08, + "auroc": 96.33, + "real_acc": 97.17, + "fake_acc": 83.6, + "acc": 90.38 + }, + "SocialRF": { + "ap": 95.84, + "auroc": 95.44, + "real_acc": 89.87, + "fake_acc": 88.9, + "acc": 89.38 + } + }, + "date": "2026-11-09T16:13:43", + "synthscope_version": "0.1.0" +} diff --git a/repro/bench_results/probe_genimage_val100k.json b/repro/bench_results/probe_genimage_val100k.json new file mode 100644 index 0000000000000000000000000000000000000000..6e82ec2243dac2f14984f4276771476c33dd5d6c --- /dev/null +++ b/repro/bench_results/probe_genimage_val100k.json @@ -0,0 +1,75 @@ +{ + "tag": "probe_genimage_val100k", + "model": "probe", + "ckpt": "registry-default", + "model_config": null, + "benchmark": "pergen", + "data_root": "/local/ssalehid/cache/data029/GenImage_val_full/test", + "jpeg_fakes": 96, + "n_generators": 8, + "means": { + "acc": 97.47, + "map": 99.77, + "mauroc": 99.8 + }, + "per_generator": { + "adm": { + "ap": 99.32, + "auroc": 99.39, + "real_acc": 98.55, + "fake_acc": 87.88, + "acc": 93.22 + }, + "biggan": { + "ap": 99.65, + "auroc": 99.71, + "real_acc": 98.75, + "fake_acc": 95.38, + "acc": 97.07 + }, + "glide": { + "ap": 99.47, + "auroc": 99.56, + "real_acc": 99.07, + "fake_acc": 88.65, + "acc": 93.86 + }, + "midjourney": { + "ap": 99.86, + "auroc": 99.87, + "real_acc": 98.57, + "fake_acc": 98.9, + "acc": 98.73 + }, + "sdv1.4": { + "ap": 100.0, + "auroc": 100.0, + "real_acc": 98.85, + "fake_acc": 99.97, + "acc": 99.41 + }, + "sdv1.5": { + "ap": 99.99, + "auroc": 99.99, + "real_acc": 98.9, + "fake_acc": 99.87, + "acc": 99.39 + }, + "vqdm": { + "ap": 99.88, + "auroc": 99.89, + "real_acc": 98.62, + "fake_acc": 98.9, + "acc": 98.76 + }, + "wukong": { + "ap": 100.0, + "auroc": 100.0, + "real_acc": 98.68, + "fake_acc": 99.97, + "acc": 99.33 + } + }, + "date": "2026-11-09T13:39:04", + "synthscope_version": "0.1.0" +} diff --git a/repro/bench_results/probe_resnet_aigibench.json b/repro/bench_results/probe_resnet_aigibench.json new file mode 100644 index 0000000000000000000000000000000000000000..852440a53c516858bba7375c750288f1d98f58be --- /dev/null +++ b/repro/bench_results/probe_resnet_aigibench.json @@ -0,0 +1,33 @@ +{ + "tag": "probe_resnet_aigibench", + "model": "probe_resnet", + "ckpt": "registry-default", + "model_config": null, + "benchmark": "pergen", + "data_root": "/local/ssalehid/66790/tmp/layouts/aigibench", + "jpeg_fakes": null, + "n_generators": 2, + "means": { + "acc": 70.44, + "map": 79.8, + "mauroc": 77.55 + }, + "per_generator": { + "CommunityAI": { + "ap": 80.28, + "auroc": 81.36, + "real_acc": 87.1, + "fake_acc": 54.88, + "acc": 70.99 + }, + "SocialRF": { + "ap": 79.31, + "auroc": 73.73, + "real_acc": 84.2, + "fake_acc": 55.57, + "acc": 69.88 + } + }, + "date": "2026-11-09T16:45:46", + "synthscope_version": "0.1.0" +} diff --git a/repro/bench_results/probe_resnet_genimage_val100k.json b/repro/bench_results/probe_resnet_genimage_val100k.json new file mode 100644 index 0000000000000000000000000000000000000000..d676ee59877423946dda5dbaadeaaba739c3dd5d --- /dev/null +++ b/repro/bench_results/probe_resnet_genimage_val100k.json @@ -0,0 +1,75 @@ +{ + "tag": "probe_resnet_genimage_val100k", + "model": "probe_resnet", + "ckpt": "registry-default", + "model_config": null, + "benchmark": "pergen", + "data_root": "/local/ssalehid/cache/data029/GenImage_val_full/test", + "jpeg_fakes": 96, + "n_generators": 8, + "means": { + "acc": 78.38, + "map": 86.69, + "mauroc": 84.81 + }, + "per_generator": { + "adm": { + "ap": 85.17, + "auroc": 86.61, + "real_acc": 98.52, + "fake_acc": 19.37, + "acc": 58.94 + }, + "biggan": { + "ap": 33.88, + "auroc": 18.63, + "real_acc": 98.82, + "fake_acc": 0.0, + "acc": 49.41 + }, + "glide": { + "ap": 85.76, + "auroc": 84.79, + "real_acc": 98.78, + "fake_acc": 27.23, + "acc": 63.01 + }, + "midjourney": { + "ap": 98.63, + "auroc": 98.56, + "real_acc": 98.67, + "fake_acc": 82.8, + "acc": 90.73 + }, + "sdv1.4": { + "ap": 100.0, + "auroc": 100.0, + "real_acc": 98.72, + "fake_acc": 100.0, + "acc": 99.36 + }, + "sdv1.5": { + "ap": 99.99, + "auroc": 99.99, + "real_acc": 98.6, + "fake_acc": 99.89, + "acc": 99.24 + }, + "vqdm": { + "ap": 90.07, + "auroc": 89.93, + "real_acc": 98.72, + "fake_acc": 35.08, + "acc": 66.9 + }, + "wukong": { + "ap": 100.0, + "auroc": 100.0, + "real_acc": 98.87, + "fake_acc": 99.95, + "acc": 99.41 + } + }, + "date": "2026-11-09T14:14:14", + "synthscope_version": "0.1.0" +} diff --git a/repro/bench_results/probe_resnet_synthbuster_coco.json b/repro/bench_results/probe_resnet_synthbuster_coco.json new file mode 100644 index 0000000000000000000000000000000000000000..bd9770fe7ea46e837010721f23c017b00ad29756 --- /dev/null +++ b/repro/bench_results/probe_resnet_synthbuster_coco.json @@ -0,0 +1,82 @@ +{ + "tag": "probe_resnet_synthbuster_coco", + "model": "probe_resnet", + "ckpt": "registry-default", + "model_config": null, + "benchmark": "pergen", + "data_root": "/local/ssalehid/66755/tmp/layouts/Synthbuster_coco", + "jpeg_fakes": null, + "n_generators": 9, + "means": { + "acc": 83.75, + "map": 85.23, + "mauroc": 95.88 + }, + "per_generator": { + "dalle2": { + "ap": 60.83, + "auroc": 91.78, + "real_acc": 99.14, + "fake_acc": 6.8, + "acc": 52.97 + }, + "dalle3": { + "ap": 98.14, + "auroc": 99.72, + "real_acc": 99.14, + "fake_acc": 90.5, + "acc": 94.82 + }, + "firefly": { + "ap": 42.22, + "auroc": 82.88, + "real_acc": 99.14, + "fake_acc": 4.0, + "acc": 51.57 + }, + "glide": { + "ap": 67.67, + "auroc": 88.95, + "real_acc": 99.14, + "fake_acc": 25.0, + "acc": 62.07 + }, + "midjourney-v5": { + "ap": 99.48, + "auroc": 99.89, + "real_acc": 99.14, + "fake_acc": 96.5, + "acc": 97.82 + }, + "stable-diffusion-1-3": { + "ap": 100.0, + "auroc": 100.0, + "real_acc": 99.14, + "fake_acc": 100.0, + "acc": 99.57 + }, + "stable-diffusion-1-4": { + "ap": 100.0, + "auroc": 100.0, + "real_acc": 99.14, + "fake_acc": 100.0, + "acc": 99.57 + }, + "stable-diffusion-2": { + "ap": 99.33, + "auroc": 99.84, + "real_acc": 99.14, + "fake_acc": 96.3, + "acc": 97.72 + }, + "stable-diffusion-xl": { + "ap": 99.41, + "auroc": 99.88, + "real_acc": 99.14, + "fake_acc": 96.2, + "acc": 97.67 + } + }, + "date": "2026-11-09T11:19:41", + "synthscope_version": "0.1.0" +} diff --git a/repro/bench_results/probe_resnet_synthwildx.json b/repro/bench_results/probe_resnet_synthwildx.json new file mode 100644 index 0000000000000000000000000000000000000000..c59ea56f05aec4b42c485b49c87a2b63e990e6c3 --- /dev/null +++ b/repro/bench_results/probe_resnet_synthwildx.json @@ -0,0 +1,40 @@ +{ + "tag": "probe_resnet_synthwildx", + "model": "probe_resnet", + "ckpt": "registry-default", + "model_config": null, + "benchmark": "pergen", + "data_root": "/local/ssalehid/cache/data029/SynthWildX/test", + "jpeg_fakes": null, + "n_generators": 3, + "means": { + "acc": 75.2, + "map": 83.88, + "mauroc": 82.8 + }, + "per_generator": { + "dalle3": { + "ap": 97.31, + "auroc": 96.99, + "real_acc": 89.1, + "fake_acc": 90.31, + "acc": 89.71 + }, + "firefly": { + "ap": 64.22, + "auroc": 62.42, + "real_acc": 89.1, + "fake_acc": 23.47, + "acc": 56.29 + }, + "midjourney_v5": { + "ap": 90.12, + "auroc": 89.0, + "real_acc": 89.1, + "fake_acc": 70.11, + "acc": 79.61 + } + }, + "date": "2026-11-09T10:07:16", + "synthscope_version": "0.1.0" +} diff --git a/repro/bench_results/probe_resnet_wildrf.json b/repro/bench_results/probe_resnet_wildrf.json new file mode 100644 index 0000000000000000000000000000000000000000..208503e4906366eed293fa85787d44a1dee06c8e --- /dev/null +++ b/repro/bench_results/probe_resnet_wildrf.json @@ -0,0 +1,40 @@ +{ + "tag": "probe_resnet_wildrf", + "model": "probe_resnet", + "ckpt": "registry-default", + "model_config": null, + "benchmark": "pergen", + "data_root": "/local/ssalehid/cache/data029/WildRF/test", + "jpeg_fakes": null, + "n_generators": 3, + "means": { + "acc": 81.63, + "map": 89.45, + "mauroc": 85.76 + }, + "per_generator": { + "facebook": { + "ap": 95.24, + "auroc": 94.64, + "real_acc": 82.5, + "fake_acc": 93.12, + "acc": 87.81 + }, + "reddit": { + "ap": 81.04, + "auroc": 73.25, + "real_acc": 89.6, + "fake_acc": 56.13, + "acc": 72.87 + }, + "twitter": { + "ap": 92.08, + "auroc": 89.39, + "real_acc": 89.74, + "fake_acc": 78.65, + "acc": 84.2 + } + }, + "date": "2026-11-09T10:51:44", + "synthscope_version": "0.1.0" +} diff --git a/repro/bench_results/probe_synthbuster_coco.json b/repro/bench_results/probe_synthbuster_coco.json new file mode 100644 index 0000000000000000000000000000000000000000..97cd3aaf51a8ae630539e0a1e9d4af006ee861ad --- /dev/null +++ b/repro/bench_results/probe_synthbuster_coco.json @@ -0,0 +1,82 @@ +{ + "tag": "probe_synthbuster_coco", + "model": "probe", + "ckpt": "registry-default", + "model_config": null, + "benchmark": "pergen", + "data_root": "/local/ssalehid/66755/tmp/layouts/Synthbuster_coco", + "jpeg_fakes": null, + "n_generators": 9, + "means": { + "acc": 98.2, + "map": 99.64, + "mauroc": 99.93 + }, + "per_generator": { + "dalle2": { + "ap": 98.65, + "auroc": 99.74, + "real_acc": 99.54, + "fake_acc": 87.4, + "acc": 93.47 + }, + "dalle3": { + "ap": 99.93, + "auroc": 99.99, + "real_acc": 99.54, + "fake_acc": 99.6, + "acc": 99.57 + }, + "firefly": { + "ap": 99.64, + "auroc": 99.97, + "real_acc": 99.54, + "fake_acc": 100.0, + "acc": 99.77 + }, + "glide": { + "ap": 98.54, + "auroc": 99.68, + "real_acc": 99.54, + "fake_acc": 84.9, + "acc": 92.22 + }, + "midjourney-v5": { + "ap": 99.99, + "auroc": 100.0, + "real_acc": 99.54, + "fake_acc": 100.0, + "acc": 99.77 + }, + "stable-diffusion-1-3": { + "ap": 99.99, + "auroc": 100.0, + "real_acc": 99.54, + "fake_acc": 99.9, + "acc": 99.72 + }, + "stable-diffusion-1-4": { + "ap": 100.0, + "auroc": 100.0, + "real_acc": 99.54, + "fake_acc": 100.0, + "acc": 99.77 + }, + "stable-diffusion-2": { + "ap": 99.99, + "auroc": 100.0, + "real_acc": 99.54, + "fake_acc": 100.0, + "acc": 99.77 + }, + "stable-diffusion-xl": { + "ap": 99.99, + "auroc": 100.0, + "real_acc": 99.54, + "fake_acc": 99.9, + "acc": 99.72 + } + }, + "date": "2026-11-09T10:58:05", + "synthscope_version": "0.1.0" +} diff --git a/repro/bench_results/probe_synthwildx.json b/repro/bench_results/probe_synthwildx.json new file mode 100644 index 0000000000000000000000000000000000000000..c61a6686bd96de042c9754921f66b9100e76aada --- /dev/null +++ b/repro/bench_results/probe_synthwildx.json @@ -0,0 +1,40 @@ +{ + "tag": "probe_synthwildx", + "model": "probe", + "ckpt": "registry-default", + "model_config": null, + "benchmark": "pergen", + "data_root": "/local/ssalehid/cache/data029/SynthWildX/test", + "jpeg_fakes": null, + "n_generators": 3, + "means": { + "acc": 97.3, + "map": 98.8, + "mauroc": 99.18 + }, + "per_generator": { + "dalle3": { + "ap": 99.32, + "auroc": 99.44, + "real_acc": 95.64, + "fake_acc": 99.23, + "acc": 97.44 + }, + "firefly": { + "ap": 97.74, + "auroc": 98.65, + "real_acc": 95.64, + "fake_acc": 98.31, + "acc": 96.98 + }, + "midjourney_v5": { + "ap": 99.34, + "auroc": 99.44, + "real_acc": 95.64, + "fake_acc": 99.31, + "acc": 97.48 + } + }, + "date": "2026-11-09T10:03:08", + "synthscope_version": "0.1.0" +} diff --git a/repro/bench_results/probe_wildrf.json b/repro/bench_results/probe_wildrf.json new file mode 100644 index 0000000000000000000000000000000000000000..53bdda068d47011447bf589e993a1d1755cd3d0c --- /dev/null +++ b/repro/bench_results/probe_wildrf.json @@ -0,0 +1,40 @@ +{ + "tag": "probe_wildrf", + "model": "probe", + "ckpt": "registry-default", + "model_config": null, + "benchmark": "pergen", + "data_root": "/local/ssalehid/cache/data029/WildRF/test", + "jpeg_fakes": null, + "n_generators": 3, + "means": { + "acc": 96.92, + "map": 99.36, + "mauroc": 99.26 + }, + "per_generator": { + "facebook": { + "ap": 99.91, + "auroc": 99.91, + "real_acc": 98.12, + "fake_acc": 99.37, + "acc": 98.75 + }, + "reddit": { + "ap": 98.41, + "auroc": 98.15, + "real_acc": 94.4, + "fake_acc": 92.27, + "acc": 93.33 + }, + "twitter": { + "ap": 99.77, + "auroc": 99.73, + "real_acc": 99.12, + "fake_acc": 98.25, + "acc": 98.68 + } + }, + "date": "2026-11-09T10:44:52", + "synthscope_version": "0.1.0" +} diff --git a/repro/bench_results/waverep_evalcrafter.json b/repro/bench_results/waverep_evalcrafter.json new file mode 100644 index 0000000000000000000000000000000000000000..bc354c103cf3fc6bc296fd5cc72630cb7b0f398b --- /dev/null +++ b/repro/bench_results/waverep_evalcrafter.json @@ -0,0 +1,240 @@ +{ + "tag": "waverep_evalcrafter", + "model": "waverep", + "ckpt": "registry-default", + "benchmark": "video:fakeonly", + "data_root": "/ssdstore/ssalehi/SynthScope/EvalCrafter/test/1_fake", + "n_generators": 14, + "means": { + "acc": 92.84, + "map": 96.93, + "map_real": 97.39, + "mauroc": 97.17 + }, + "per_generator": { + "MoonValley": { + "ap": 99.95, + "ap_real": 99.98, + "auroc": 99.97, + "real_acc": 99.3, + "fake_acc": 99.04, + "acc": 99.17, + "n_real": 1000, + "n_fake": 626, + "failed_real": 0, + "failed_fake": 0, + "failed_other_real": 0, + "failed_other_fake": 0, + "rank_by": "logit" + }, + "floor33": { + "ap": 99.67, + "ap_real": 99.81, + "auroc": 99.74, + "real_acc": 99.3, + "fake_acc": 96.29, + "acc": 97.79, + "n_real": 1000, + "n_fake": 700, + "failed_real": 0, + "failed_fake": 0, + "failed_other_real": 0, + "failed_other_fake": 0, + "rank_by": "logit" + }, + "gen2": { + "ap": 99.98, + "ap_real": 99.99, + "auroc": 99.99, + "real_acc": 99.3, + "fake_acc": 99.71, + "acc": 99.5, + "n_real": 1000, + "n_fake": 681, + "failed_real": 0, + "failed_fake": 0, + "failed_other_real": 0, + "failed_other_fake": 0, + "rank_by": "logit" + }, + "gen2_december": { + "ap": 99.98, + "ap_real": 99.99, + "auroc": 99.99, + "real_acc": 99.3, + "fake_acc": 99.86, + "acc": 99.58, + "n_real": 1000, + "n_fake": 699, + "failed_real": 0, + "failed_fake": 0, + "failed_other_real": 0, + "failed_other_fake": 0, + "rank_by": "logit" + }, + "hotshot": { + "ap": 73.48, + "ap_real": 78.34, + "auroc": 75.95, + "real_acc": 99.3, + "fake_acc": 21.0, + "acc": 60.15, + "n_real": 1000, + "n_fake": 700, + "failed_real": 0, + "failed_fake": 0, + "failed_other_real": 0, + "failed_other_fake": 0, + "rank_by": "logit" + }, + "lavie-base": { + "ap": 99.79, + "ap_real": 99.87, + "auroc": 99.83, + "real_acc": 99.3, + "fake_acc": 97.86, + "acc": 98.58, + "n_real": 1000, + "n_fake": 700, + "failed_real": 0, + "failed_fake": 0, + "failed_other_real": 0, + "failed_other_fake": 0, + "rank_by": "logit" + }, + "lavie-interpolation": { + "ap": 94.54, + "ap_real": 93.69, + "auroc": 94.3, + "real_acc": 99.3, + "fake_acc": 72.0, + "acc": 85.65, + "n_real": 1000, + "n_fake": 700, + "failed_real": 0, + "failed_fake": 0, + "failed_other_real": 0, + "failed_other_fake": 0, + "rank_by": "logit" + }, + "mix-sr": { + "ap": 99.99, + "ap_real": 100.0, + "auroc": 99.99, + "real_acc": 99.3, + "fake_acc": 99.86, + "acc": 99.58, + "n_real": 1000, + "n_fake": 700, + "failed_real": 0, + "failed_fake": 0, + "failed_other_real": 0, + "failed_other_fake": 0, + "rank_by": "logit" + }, + "modelscope": { + "ap": 99.16, + "ap_real": 99.48, + "auroc": 99.31, + "real_acc": 99.3, + "fake_acc": 91.29, + "acc": 95.29, + "n_real": 1000, + "n_fake": 700, + "failed_real": 0, + "failed_fake": 0, + "failed_other_real": 0, + "failed_other_fake": 0, + "rank_by": "logit" + }, + "pika": { + "ap": 99.16, + "ap_real": 99.07, + "auroc": 99.11, + "real_acc": 99.3, + "fake_acc": 93.83, + "acc": 96.57, + "n_real": 1000, + "n_fake": 697, + "failed_real": 0, + "failed_fake": 0, + "failed_other_real": 0, + "failed_other_fake": 0, + "rank_by": "logit" + }, + "pika_v1_december_1": { + "ap": 99.43, + "ap_real": 99.45, + "auroc": 99.42, + "real_acc": 99.3, + "fake_acc": 95.86, + "acc": 97.58, + "n_real": 1000, + "n_fake": 700, + "failed_real": 0, + "failed_fake": 0, + "failed_other_real": 0, + "failed_other_fake": 0, + "rank_by": "logit" + }, + "show_1": { + "ap": 93.78, + "ap_real": 94.96, + "auroc": 94.35, + "real_acc": 99.3, + "fake_acc": 60.14, + "acc": 79.72, + "n_real": 1000, + "n_fake": 700, + "failed_real": 0, + "failed_fake": 0, + "failed_other_real": 0, + "failed_other_fake": 0, + "rank_by": "logit" + }, + "videocrafter-v1.0": { + "ap": 99.78, + "ap_real": 99.85, + "auroc": 99.81, + "real_acc": 99.3, + "fake_acc": 97.71, + "acc": 98.51, + "n_real": 1000, + "n_fake": 700, + "failed_real": 0, + "failed_fake": 0, + "failed_other_real": 0, + "failed_other_fake": 0, + "rank_by": "logit" + }, + "zeroscope": { + "ap": 98.27, + "ap_real": 98.96, + "auroc": 98.68, + "real_acc": 99.3, + "fake_acc": 84.95, + "acc": 92.12, + "n_real": 1000, + "n_fake": 598, + "failed_real": 0, + "failed_fake": 0, + "failed_other_real": 0, + "failed_other_fake": 0, + "rank_by": "logit" + } + }, + "failed_to_decode": { + "fake": 0, + "real_unique": 0 + }, + "failed_other": { + "fake": 0, + "real_unique": 0 + }, + "limit": 1000, + "reals": "/ssdstore/ssalehi/SynthScope/GenVideo/test/Crafter/0_real", + "ckpt_sha256": "1c7566b26c0b0afe3f5642dd4e454039328d59f512a5d815d5edaa10b544a897", + "cache_dir": "/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/waverep_bench_cache/waverep/evalcrafter", + "date": "2026-11-11T00:45:43", + "synthscope_version": "video" +} diff --git a/repro/bench_results/waverep_g4_evalcrafter.json b/repro/bench_results/waverep_g4_evalcrafter.json new file mode 100644 index 0000000000000000000000000000000000000000..176af66905148400c454fff4116133d77aa818a9 --- /dev/null +++ b/repro/bench_results/waverep_g4_evalcrafter.json @@ -0,0 +1,240 @@ +{ + "tag": "waverep_g4_evalcrafter", + "model": "waverep_g4", + "ckpt": "registry-default", + "benchmark": "video:fakeonly", + "data_root": "/ssdstore/ssalehi/SynthScope/EvalCrafter/test/1_fake", + "n_generators": 14, + "means": { + "acc": 96.55, + "map": 99.19, + "map_real": 99.35, + "mauroc": 99.29 + }, + "per_generator": { + "MoonValley": { + "ap": 99.96, + "ap_real": 99.99, + "auroc": 99.98, + "real_acc": 96.8, + "fake_acc": 99.84, + "acc": 98.32, + "n_real": 1000, + "n_fake": 626, + "failed_real": 0, + "failed_fake": 0, + "failed_other_real": 0, + "failed_other_fake": 0, + "rank_by": "logit" + }, + "floor33": { + "ap": 99.91, + "ap_real": 99.95, + "auroc": 99.93, + "real_acc": 96.8, + "fake_acc": 99.29, + "acc": 98.04, + "n_real": 1000, + "n_fake": 700, + "failed_real": 0, + "failed_fake": 0, + "failed_other_real": 0, + "failed_other_fake": 0, + "rank_by": "logit" + }, + "gen2": { + "ap": 99.98, + "ap_real": 99.99, + "auroc": 99.99, + "real_acc": 96.8, + "fake_acc": 99.71, + "acc": 98.25, + "n_real": 1000, + "n_fake": 681, + "failed_real": 0, + "failed_fake": 0, + "failed_other_real": 0, + "failed_other_fake": 0, + "rank_by": "logit" + }, + "gen2_december": { + "ap": 100.0, + "ap_real": 100.0, + "auroc": 100.0, + "real_acc": 96.8, + "fake_acc": 100.0, + "acc": 98.4, + "n_real": 1000, + "n_fake": 699, + "failed_real": 0, + "failed_fake": 0, + "failed_other_real": 0, + "failed_other_fake": 0, + "rank_by": "logit" + }, + "hotshot": { + "ap": 92.88, + "ap_real": 94.24, + "auroc": 93.75, + "real_acc": 96.8, + "fake_acc": 68.86, + "acc": 82.83, + "n_real": 1000, + "n_fake": 700, + "failed_real": 0, + "failed_fake": 0, + "failed_other_real": 0, + "failed_other_fake": 0, + "rank_by": "logit" + }, + "lavie-base": { + "ap": 99.92, + "ap_real": 99.96, + "auroc": 99.94, + "real_acc": 96.8, + "fake_acc": 99.71, + "acc": 98.26, + "n_real": 1000, + "n_fake": 700, + "failed_real": 0, + "failed_fake": 0, + "failed_other_real": 0, + "failed_other_fake": 0, + "rank_by": "logit" + }, + "lavie-interpolation": { + "ap": 98.54, + "ap_real": 98.22, + "auroc": 98.46, + "real_acc": 96.8, + "fake_acc": 93.71, + "acc": 95.26, + "n_real": 1000, + "n_fake": 700, + "failed_real": 0, + "failed_fake": 0, + "failed_other_real": 0, + "failed_other_fake": 0, + "rank_by": "logit" + }, + "mix-sr": { + "ap": 100.0, + "ap_real": 100.0, + "auroc": 100.0, + "real_acc": 96.8, + "fake_acc": 100.0, + "acc": 98.4, + "n_real": 1000, + "n_fake": 700, + "failed_real": 0, + "failed_fake": 0, + "failed_other_real": 0, + "failed_other_fake": 0, + "rank_by": "logit" + }, + "modelscope": { + "ap": 99.46, + "ap_real": 99.73, + "auroc": 99.61, + "real_acc": 96.8, + "fake_acc": 97.14, + "acc": 96.97, + "n_real": 1000, + "n_fake": 700, + "failed_real": 0, + "failed_fake": 0, + "failed_other_real": 0, + "failed_other_fake": 0, + "rank_by": "logit" + }, + "pika": { + "ap": 99.88, + "ap_real": 99.94, + "auroc": 99.92, + "real_acc": 96.8, + "fake_acc": 99.14, + "acc": 97.97, + "n_real": 1000, + "n_fake": 697, + "failed_real": 0, + "failed_fake": 0, + "failed_other_real": 0, + "failed_other_fake": 0, + "rank_by": "logit" + }, + "pika_v1_december_1": { + "ap": 99.9, + "ap_real": 99.93, + "auroc": 99.91, + "real_acc": 96.8, + "fake_acc": 99.57, + "acc": 98.19, + "n_real": 1000, + "n_fake": 700, + "failed_real": 0, + "failed_fake": 0, + "failed_other_real": 0, + "failed_other_fake": 0, + "rank_by": "logit" + }, + "show_1": { + "ap": 99.22, + "ap_real": 99.5, + "auroc": 99.35, + "real_acc": 96.8, + "fake_acc": 95.71, + "acc": 96.26, + "n_real": 1000, + "n_fake": 700, + "failed_real": 0, + "failed_fake": 0, + "failed_other_real": 0, + "failed_other_fake": 0, + "rank_by": "logit" + }, + "videocrafter-v1.0": { + "ap": 99.94, + "ap_real": 99.97, + "auroc": 99.96, + "real_acc": 96.8, + "fake_acc": 99.71, + "acc": 98.26, + "n_real": 1000, + "n_fake": 700, + "failed_real": 0, + "failed_fake": 0, + "failed_other_real": 0, + "failed_other_fake": 0, + "rank_by": "logit" + }, + "zeroscope": { + "ap": 99.11, + "ap_real": 99.46, + "auroc": 99.32, + "real_acc": 96.8, + "fake_acc": 95.82, + "acc": 96.31, + "n_real": 1000, + "n_fake": 598, + "failed_real": 0, + "failed_fake": 0, + "failed_other_real": 0, + "failed_other_fake": 0, + "rank_by": "logit" + } + }, + "failed_to_decode": { + "fake": 0, + "real_unique": 0 + }, + "failed_other": { + "fake": 0, + "real_unique": 0 + }, + "limit": 1000, + "reals": "/ssdstore/ssalehi/SynthScope/GenVideo/test/Crafter/0_real", + "ckpt_sha256": "50d639049d928986ba7d69861a4fe4f3e7afbba1843e3e089cdf6b4748f53d5b", + "cache_dir": "/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/waverep_bench_cache/waverep_g4/evalcrafter", + "date": "2026-11-11T00:46:42", + "synthscope_version": "video" +} diff --git a/repro/bench_results/waverep_g4_genvideo.json b/repro/bench_results/waverep_g4_genvideo.json new file mode 100644 index 0000000000000000000000000000000000000000..f66ed839425a682f71be21af0478f668df1e7068 --- /dev/null +++ b/repro/bench_results/waverep_g4_genvideo.json @@ -0,0 +1,180 @@ +{ + "tag": "waverep_g4_genvideo", + "model": "waverep_g4", + "ckpt": "registry-default", + "benchmark": "video:pergen", + "data_root": "/ssdstore/ssalehi/SynthScope/GenVideo/test", + "n_generators": 10, + "means": { + "acc": 92.65, + "map": 94.47, + "map_real": 97.33, + "mauroc": 96.53 + }, + "per_generator": { + "Crafter": { + "ap": 99.97, + "ap_real": 99.97, + "auroc": 99.97, + "real_acc": 96.8, + "fake_acc": 99.8, + "acc": 98.3, + "n_real": 1000, + "n_fake": 1000, + "failed_real": 0, + "failed_fake": 0, + "failed_other_real": 0, + "failed_other_fake": 0, + "rank_by": "logit" + }, + "Gen2": { + "ap": 99.99, + "ap_real": 99.99, + "auroc": 99.99, + "real_acc": 96.8, + "fake_acc": 99.9, + "acc": 98.35, + "n_real": 1000, + "n_fake": 1000, + "failed_real": 0, + "failed_fake": 0, + "failed_other_real": 0, + "failed_other_fake": 0, + "rank_by": "logit" + }, + "HotShot": { + "ap": 92.88, + "ap_real": 94.24, + "auroc": 93.75, + "real_acc": 96.8, + "fake_acc": 68.86, + "acc": 82.83, + "n_real": 1000, + "n_fake": 700, + "failed_real": 0, + "failed_fake": 0, + "failed_other_real": 0, + "failed_other_fake": 0, + "rank_by": "logit" + }, + "Lavie": { + "ap": 99.2, + "ap_real": 98.21, + "auroc": 98.91, + "real_acc": 96.8, + "fake_acc": 95.5, + "acc": 96.15, + "n_real": 1000, + "n_fake": 1000, + "failed_real": 0, + "failed_fake": 0, + "failed_other_real": 0, + "failed_other_fake": 0, + "rank_by": "logit" + }, + "ModelScope": { + "ap": 99.46, + "ap_real": 99.73, + "auroc": 99.61, + "real_acc": 96.8, + "fake_acc": 97.14, + "acc": 96.97, + "n_real": 1000, + "n_fake": 700, + "failed_real": 0, + "failed_fake": 0, + "failed_other_real": 0, + "failed_other_fake": 0, + "rank_by": "logit" + }, + "MoonValley": { + "ap": 99.96, + "ap_real": 99.99, + "auroc": 99.98, + "real_acc": 96.8, + "fake_acc": 99.84, + "acc": 98.32, + "n_real": 1000, + "n_fake": 626, + "failed_real": 0, + "failed_fake": 0, + "failed_other_real": 0, + "failed_other_fake": 0, + "rank_by": "logit" + }, + "MorphStudio": { + "ap": 99.91, + "ap_real": 99.95, + "auroc": 99.93, + "real_acc": 96.8, + "fake_acc": 99.29, + "acc": 98.04, + "n_real": 1000, + "n_fake": 700, + "failed_real": 0, + "failed_fake": 0, + "failed_other_real": 0, + "failed_other_fake": 0, + "rank_by": "logit" + }, + "Show_1": { + "ap": 99.22, + "ap_real": 99.5, + "auroc": 99.35, + "real_acc": 96.8, + "fake_acc": 95.71, + "acc": 96.26, + "n_real": 1000, + "n_fake": 700, + "failed_real": 0, + "failed_fake": 0, + "failed_other_real": 0, + "failed_other_fake": 0, + "rank_by": "logit" + }, + "Sora": { + "ap": 61.04, + "ap_real": 98.03, + "auroc": 83.28, + "real_acc": 96.8, + "fake_acc": 55.36, + "acc": 76.08, + "n_real": 1000, + "n_fake": 56, + "failed_real": 0, + "failed_fake": 0, + "failed_other_real": 0, + "failed_other_fake": 0, + "rank_by": "logit" + }, + "WildScrape": { + "ap": 93.12, + "ap_real": 83.7, + "auroc": 90.55, + "real_acc": 96.8, + "fake_acc": 73.59, + "acc": 85.2, + "n_real": 1000, + "n_fake": 924, + "failed_real": 0, + "failed_fake": 0, + "failed_other_real": 0, + "failed_other_fake": 0, + "rank_by": "logit" + } + }, + "failed_to_decode": { + "fake": 0, + "real_unique": 0 + }, + "failed_other": { + "fake": 0, + "real_unique": 0 + }, + "limit": 1000, + "reals": null, + "ckpt_sha256": "50d639049d928986ba7d69861a4fe4f3e7afbba1843e3e089cdf6b4748f53d5b", + "cache_dir": "/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/waverep_bench_cache/waverep_g4/genvideo", + "date": "2026-11-11T00:46:08", + "synthscope_version": "video" +} diff --git a/repro/bench_results/waverep_g4_genvideo_full.json b/repro/bench_results/waverep_g4_genvideo_full.json new file mode 100644 index 0000000000000000000000000000000000000000..7aa7452bfdabed01f6e59746338baf9847fd39c7 --- /dev/null +++ b/repro/bench_results/waverep_g4_genvideo_full.json @@ -0,0 +1,180 @@ +{ + "tag": "waverep_g4_genvideo_full", + "model": "waverep_g4", + "ckpt": "registry-default", + "benchmark": "video:pergen", + "data_root": "/ssdstore/ssalehi/SynthScope/GenVideo/test", + "n_generators": 10, + "means": { + "acc": 93.28, + "map": 88.88, + "map_real": 99.69, + "mauroc": 96.69 + }, + "per_generator": { + "Crafter": { + "ap": 99.91, + "ap_real": 100.0, + "auroc": 99.98, + "real_acc": 97.94, + "fake_acc": 99.86, + "acc": 98.9, + "n_real": 10000, + "n_fake": 1398, + "failed_real": 0, + "failed_fake": 0, + "failed_other_real": 0, + "failed_other_fake": 0, + "rank_by": "logit" + }, + "Gen2": { + "ap": 99.96, + "ap_real": 100.0, + "auroc": 99.99, + "real_acc": 97.94, + "fake_acc": 99.86, + "acc": 98.9, + "n_real": 10000, + "n_fake": 1380, + "failed_real": 0, + "failed_fake": 0, + "failed_other_real": 0, + "failed_other_fake": 0, + "rank_by": "logit" + }, + "HotShot": { + "ap": 75.44, + "ap_real": 99.4, + "auroc": 94.15, + "real_acc": 97.94, + "fake_acc": 68.86, + "acc": 83.4, + "n_real": 10000, + "n_fake": 700, + "failed_real": 0, + "failed_fake": 0, + "failed_other_real": 0, + "failed_other_fake": 0, + "rank_by": "logit" + }, + "Lavie": { + "ap": 98.17, + "ap_real": 99.82, + "auroc": 99.26, + "real_acc": 97.94, + "fake_acc": 96.71, + "acc": 97.33, + "n_real": 10000, + "n_fake": 1400, + "failed_real": 0, + "failed_fake": 0, + "failed_other_real": 0, + "failed_other_fake": 0, + "rank_by": "logit" + }, + "ModelScope": { + "ap": 97.32, + "ap_real": 99.98, + "auroc": 99.69, + "real_acc": 97.94, + "fake_acc": 97.14, + "acc": 97.54, + "n_real": 10000, + "n_fake": 700, + "failed_real": 0, + "failed_fake": 0, + "failed_other_real": 0, + "failed_other_fake": 0, + "rank_by": "logit" + }, + "MoonValley": { + "ap": 99.79, + "ap_real": 100.0, + "auroc": 99.98, + "real_acc": 97.94, + "fake_acc": 99.84, + "acc": 98.89, + "n_real": 10000, + "n_fake": 626, + "failed_real": 0, + "failed_fake": 0, + "failed_other_real": 0, + "failed_other_fake": 0, + "rank_by": "logit" + }, + "MorphStudio": { + "ap": 99.54, + "ap_real": 100.0, + "auroc": 99.94, + "real_acc": 97.94, + "fake_acc": 99.29, + "acc": 98.61, + "n_real": 10000, + "n_fake": 700, + "failed_real": 0, + "failed_fake": 0, + "failed_other_real": 0, + "failed_other_fake": 0, + "rank_by": "logit" + }, + "Show_1": { + "ap": 96.62, + "ap_real": 99.95, + "auroc": 99.43, + "real_acc": 97.94, + "fake_acc": 95.71, + "acc": 96.83, + "n_real": 10000, + "n_fake": 700, + "failed_real": 0, + "failed_fake": 0, + "failed_other_real": 0, + "failed_other_fake": 0, + "rank_by": "logit" + }, + "Sora": { + "ap": 41.72, + "ap_real": 99.8, + "auroc": 83.61, + "real_acc": 97.94, + "fake_acc": 55.36, + "acc": 76.65, + "n_real": 10000, + "n_fake": 56, + "failed_real": 0, + "failed_fake": 0, + "failed_other_real": 0, + "failed_other_fake": 0, + "rank_by": "logit" + }, + "WildScrape": { + "ap": 80.36, + "ap_real": 97.99, + "auroc": 90.83, + "real_acc": 97.94, + "fake_acc": 73.59, + "acc": 85.77, + "n_real": 10000, + "n_fake": 924, + "failed_real": 0, + "failed_fake": 0, + "failed_other_real": 0, + "failed_other_fake": 0, + "rank_by": "logit" + } + }, + "failed_to_decode": { + "fake": 0, + "real_unique": 0 + }, + "failed_other": { + "fake": 0, + "real_unique": 0 + }, + "limit": null, + "reals": null, + "ckpt_sha256": "50d639049d928986ba7d69861a4fe4f3e7afbba1843e3e089cdf6b4748f53d5b", + "cache_dir": "/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/waverep_bench_cache/waverep_g4/genvideo", + "date": "2026-11-11T00:45:56", + "synthscope_version": "video" +} diff --git a/repro/bench_results/waverep_g4_videophy.json b/repro/bench_results/waverep_g4_videophy.json new file mode 100644 index 0000000000000000000000000000000000000000..ae2df82cfd43958d10fe5b5b3a32e0fa95536378 --- /dev/null +++ b/repro/bench_results/waverep_g4_videophy.json @@ -0,0 +1,150 @@ +{ + "tag": "waverep_g4_videophy", + "model": "waverep_g4", + "ckpt": "registry-default", + "benchmark": "video:pergen", + "data_root": "/ssdstore/ssalehi/SynthScope/VideoPhy/test", + "n_generators": 8, + "means": { + "acc": 95.73, + "map": 98.2, + "map_real": 99.74, + "mauroc": 99.29 + }, + "per_generator": { + "Dream-Machine": { + "ap": 99.99, + "ap_real": 100.0, + "auroc": 100.0, + "real_acc": 96.8, + "fake_acc": 100.0, + "acc": 98.4, + "n_real": 1000, + "n_fake": 339, + "failed_real": 0, + "failed_fake": 0, + "failed_other_real": 0, + "failed_other_fake": 0, + "rank_by": "logit" + }, + "Gen-2": { + "ap": 99.99, + "ap_real": 100.0, + "auroc": 100.0, + "real_acc": 96.8, + "fake_acc": 100.0, + "acc": 98.4, + "n_real": 1000, + "n_fake": 312, + "failed_real": 0, + "failed_fake": 0, + "failed_other_real": 0, + "failed_other_fake": 0, + "rank_by": "logit" + }, + "LaVie": { + "ap": 99.89, + "ap_real": 99.99, + "auroc": 99.96, + "real_acc": 96.8, + "fake_acc": 100.0, + "acc": 98.4, + "n_real": 1000, + "n_fake": 343, + "failed_real": 0, + "failed_fake": 0, + "failed_other_real": 0, + "failed_other_fake": 0, + "rank_by": "logit" + }, + "OpenSora": { + "ap": 89.79, + "ap_real": 98.66, + "auroc": 96.2, + "real_acc": 96.8, + "fake_acc": 70.06, + "acc": 83.43, + "n_real": 1000, + "n_fake": 344, + "failed_real": 0, + "failed_fake": 0, + "failed_other_real": 0, + "failed_other_fake": 0, + "rank_by": "logit" + }, + "Pika": { + "ap": 99.97, + "ap_real": 100.0, + "auroc": 99.99, + "real_acc": 96.8, + "fake_acc": 100.0, + "acc": 98.4, + "n_real": 1000, + "n_fake": 304, + "failed_real": 0, + "failed_fake": 0, + "failed_other_real": 0, + "failed_other_fake": 0, + "rank_by": "logit" + }, + "SVD": { + "ap": 99.98, + "ap_real": 100.0, + "auroc": 99.99, + "real_acc": 96.8, + "fake_acc": 100.0, + "acc": 98.4, + "n_real": 1000, + "n_fake": 344, + "failed_real": 0, + "failed_fake": 0, + "failed_other_real": 0, + "failed_other_fake": 0, + "rank_by": "logit" + }, + "VideoCrafter2": { + "ap": 99.88, + "ap_real": 99.99, + "auroc": 99.96, + "real_acc": 96.8, + "fake_acc": 99.71, + "acc": 98.25, + "n_real": 1000, + "n_fake": 344, + "failed_real": 0, + "failed_fake": 0, + "failed_other_real": 0, + "failed_other_fake": 0, + "rank_by": "logit" + }, + "ZeroScope": { + "ap": 96.09, + "ap_real": 99.28, + "auroc": 98.22, + "real_acc": 96.8, + "fake_acc": 87.5, + "acc": 92.15, + "n_real": 1000, + "n_fake": 344, + "failed_real": 0, + "failed_fake": 0, + "failed_other_real": 0, + "failed_other_fake": 0, + "rank_by": "logit" + } + }, + "failed_to_decode": { + "fake": 0, + "real_unique": 0 + }, + "failed_other": { + "fake": 0, + "real_unique": 0 + }, + "limit": 1000, + "reals": null, + "ckpt_sha256": "50d639049d928986ba7d69861a4fe4f3e7afbba1843e3e089cdf6b4748f53d5b", + "cache_dir": "/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/waverep_bench_cache/waverep_g4/videophy", + "date": "2026-11-11T00:46:19", + "synthscope_version": "video" +} diff --git a/repro/bench_results/waverep_g4_vidprom.json b/repro/bench_results/waverep_g4_vidprom.json new file mode 100644 index 0000000000000000000000000000000000000000..3c89170babd1af79fe50e3ca2103b1753cff61fd --- /dev/null +++ b/repro/bench_results/waverep_g4_vidprom.json @@ -0,0 +1,90 @@ +{ + "tag": "waverep_g4_vidprom", + "model": "waverep_g4", + "ckpt": "registry-default", + "benchmark": "video:pergen", + "data_root": "/ssdstore/ssalehi/SynthScope/VidProM/test", + "n_generators": 4, + "means": { + "acc": 95.8, + "map": 99.29, + "map_real": 99.19, + "mauroc": 99.25 + }, + "per_generator": { + "ModelScope": { + "ap": 97.67, + "ap_real": 97.45, + "auroc": 97.59, + "real_acc": 96.8, + "fake_acc": 82.0, + "acc": 89.4, + "n_real": 1000, + "n_fake": 1000, + "failed_real": 0, + "failed_fake": 0, + "failed_other_real": 0, + "failed_other_fake": 0, + "rank_by": "logit" + }, + "Pika": { + "ap": 99.98, + "ap_real": 99.98, + "auroc": 99.98, + "real_acc": 96.8, + "fake_acc": 99.9, + "acc": 98.35, + "n_real": 1000, + "n_fake": 998, + "failed_real": 0, + "failed_fake": 2, + "failed_other_real": 0, + "failed_other_fake": 0, + "rank_by": "logit" + }, + "Text2Video-Zero": { + "ap": 99.62, + "ap_real": 99.42, + "auroc": 99.53, + "real_acc": 96.8, + "fake_acc": 97.9, + "acc": 97.35, + "n_real": 1000, + "n_fake": 1000, + "failed_real": 0, + "failed_fake": 0, + "failed_other_real": 0, + "failed_other_fake": 0, + "rank_by": "logit" + }, + "VideoCrafter2": { + "ap": 99.91, + "ap_real": 99.91, + "auroc": 99.91, + "real_acc": 96.8, + "fake_acc": 99.4, + "acc": 98.1, + "n_real": 1000, + "n_fake": 1000, + "failed_real": 0, + "failed_fake": 0, + "failed_other_real": 0, + "failed_other_fake": 0, + "rank_by": "logit" + } + }, + "failed_to_decode": { + "fake": 2, + "real_unique": 0 + }, + "failed_other": { + "fake": 0, + "real_unique": 0 + }, + "limit": 1000, + "reals": null, + "ckpt_sha256": "50d639049d928986ba7d69861a4fe4f3e7afbba1843e3e089cdf6b4748f53d5b", + "cache_dir": "/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/waverep_bench_cache/waverep_g4/vidprom", + "date": "2026-11-11T00:46:30", + "synthscope_version": "video" +} diff --git a/repro/bench_results/waverep_genvideo.json b/repro/bench_results/waverep_genvideo.json new file mode 100644 index 0000000000000000000000000000000000000000..2d2931f9e13beb778f9c62cfac73c5a5744ddc26 --- /dev/null +++ b/repro/bench_results/waverep_genvideo.json @@ -0,0 +1,180 @@ +{ + "tag": "waverep_genvideo", + "model": "waverep", + "ckpt": "registry-default", + "benchmark": "video:pergen", + "data_root": "/ssdstore/ssalehi/SynthScope/GenVideo/test", + "n_generators": 10, + "means": { + "acc": 86.62, + "map": 89.81, + "map_real": 93.96, + "mauroc": 92.09 + }, + "per_generator": { + "Crafter": { + "ap": 99.88, + "ap_real": 99.85, + "auroc": 99.86, + "real_acc": 99.3, + "fake_acc": 98.3, + "acc": 98.8, + "n_real": 1000, + "n_fake": 1000, + "failed_real": 0, + "failed_fake": 0, + "failed_other_real": 0, + "failed_other_fake": 0, + "rank_by": "logit" + }, + "Gen2": { + "ap": 99.99, + "ap_real": 99.99, + "auroc": 99.99, + "real_acc": 99.3, + "fake_acc": 99.8, + "acc": 99.55, + "n_real": 1000, + "n_fake": 1000, + "failed_real": 0, + "failed_fake": 0, + "failed_other_real": 0, + "failed_other_fake": 0, + "rank_by": "logit" + }, + "HotShot": { + "ap": 73.48, + "ap_real": 78.34, + "auroc": 75.95, + "real_acc": 99.3, + "fake_acc": 21.0, + "acc": 60.15, + "n_real": 1000, + "n_fake": 700, + "failed_real": 0, + "failed_fake": 0, + "failed_other_real": 0, + "failed_other_fake": 0, + "rank_by": "logit" + }, + "Lavie": { + "ap": 97.01, + "ap_real": 93.63, + "auroc": 95.93, + "real_acc": 99.3, + "fake_acc": 79.4, + "acc": 89.35, + "n_real": 1000, + "n_fake": 1000, + "failed_real": 0, + "failed_fake": 0, + "failed_other_real": 0, + "failed_other_fake": 0, + "rank_by": "logit" + }, + "ModelScope": { + "ap": 99.16, + "ap_real": 99.48, + "auroc": 99.31, + "real_acc": 99.3, + "fake_acc": 91.29, + "acc": 95.29, + "n_real": 1000, + "n_fake": 700, + "failed_real": 0, + "failed_fake": 0, + "failed_other_real": 0, + "failed_other_fake": 0, + "rank_by": "logit" + }, + "MoonValley": { + "ap": 99.95, + "ap_real": 99.98, + "auroc": 99.97, + "real_acc": 99.3, + "fake_acc": 99.04, + "acc": 99.17, + "n_real": 1000, + "n_fake": 626, + "failed_real": 0, + "failed_fake": 0, + "failed_other_real": 0, + "failed_other_fake": 0, + "rank_by": "logit" + }, + "MorphStudio": { + "ap": 99.67, + "ap_real": 99.81, + "auroc": 99.74, + "real_acc": 99.3, + "fake_acc": 96.29, + "acc": 97.79, + "n_real": 1000, + "n_fake": 700, + "failed_real": 0, + "failed_fake": 0, + "failed_other_real": 0, + "failed_other_fake": 0, + "rank_by": "logit" + }, + "Show_1": { + "ap": 93.78, + "ap_real": 94.96, + "auroc": 94.35, + "real_acc": 99.3, + "fake_acc": 60.14, + "acc": 79.72, + "n_real": 1000, + "n_fake": 700, + "failed_real": 0, + "failed_fake": 0, + "failed_other_real": 0, + "failed_other_fake": 0, + "rank_by": "logit" + }, + "Sora": { + "ap": 44.58, + "ap_real": 95.27, + "auroc": 68.75, + "real_acc": 99.3, + "fake_acc": 35.71, + "acc": 67.51, + "n_real": 1000, + "n_fake": 56, + "failed_real": 0, + "failed_fake": 0, + "failed_other_real": 0, + "failed_other_fake": 0, + "rank_by": "logit" + }, + "WildScrape": { + "ap": 90.59, + "ap_real": 78.28, + "auroc": 87.03, + "real_acc": 99.3, + "fake_acc": 58.55, + "acc": 78.92, + "n_real": 1000, + "n_fake": 924, + "failed_real": 0, + "failed_fake": 0, + "failed_other_real": 0, + "failed_other_fake": 0, + "rank_by": "logit" + } + }, + "failed_to_decode": { + "fake": 0, + "real_unique": 0 + }, + "failed_other": { + "fake": 0, + "real_unique": 0 + }, + "limit": 1000, + "reals": null, + "ckpt_sha256": "1c7566b26c0b0afe3f5642dd4e454039328d59f512a5d815d5edaa10b544a897", + "cache_dir": "/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/waverep_bench_cache/waverep/genvideo", + "date": "2026-11-11T00:45:07", + "synthscope_version": "video" +} diff --git a/repro/bench_results/waverep_genvideo_full.json b/repro/bench_results/waverep_genvideo_full.json new file mode 100644 index 0000000000000000000000000000000000000000..c61acc7053d963c2f7086e74a176bc6acae0d9f6 --- /dev/null +++ b/repro/bench_results/waverep_genvideo_full.json @@ -0,0 +1,180 @@ +{ + "tag": "waverep_genvideo_full", + "model": "waverep", + "ckpt": "registry-default", + "benchmark": "video:pergen", + "data_root": "/ssdstore/ssalehi/SynthScope/GenVideo/test", + "n_generators": 10, + "means": { + "acc": 86.87, + "map": 79.85, + "map_real": 99.24, + "mauroc": 92.13 + }, + "per_generator": { + "Crafter": { + "ap": 99.65, + "ap_real": 99.98, + "auroc": 99.9, + "real_acc": 99.2, + "fake_acc": 98.78, + "acc": 98.99, + "n_real": 10000, + "n_fake": 1398, + "failed_real": 0, + "failed_fake": 0, + "failed_other_real": 0, + "failed_other_fake": 0, + "rank_by": "logit" + }, + "Gen2": { + "ap": 99.94, + "ap_real": 100.0, + "auroc": 99.99, + "real_acc": 99.2, + "fake_acc": 99.78, + "acc": 99.49, + "n_real": 10000, + "n_fake": 1380, + "failed_real": 0, + "failed_fake": 0, + "failed_other_real": 0, + "failed_other_fake": 0, + "rank_by": "logit" + }, + "HotShot": { + "ap": 34.65, + "ap_real": 97.21, + "auroc": 75.6, + "real_acc": 99.2, + "fake_acc": 21.0, + "acc": 60.1, + "n_real": 10000, + "n_fake": 700, + "failed_real": 0, + "failed_fake": 0, + "failed_other_real": 0, + "failed_other_fake": 0, + "rank_by": "logit" + }, + "Lavie": { + "ap": 93.31, + "ap_real": 99.3, + "auroc": 97.03, + "real_acc": 99.2, + "fake_acc": 84.93, + "acc": 92.06, + "n_real": 10000, + "n_fake": 1400, + "failed_real": 0, + "failed_fake": 0, + "failed_other_real": 0, + "failed_other_fake": 0, + "rank_by": "logit" + }, + "ModelScope": { + "ap": 95.91, + "ap_real": 99.95, + "auroc": 99.31, + "real_acc": 99.2, + "fake_acc": 91.29, + "acc": 95.24, + "n_real": 10000, + "n_fake": 700, + "failed_real": 0, + "failed_fake": 0, + "failed_other_real": 0, + "failed_other_fake": 0, + "rank_by": "logit" + }, + "MoonValley": { + "ap": 99.68, + "ap_real": 100.0, + "auroc": 99.97, + "real_acc": 99.2, + "fake_acc": 99.04, + "acc": 99.12, + "n_real": 10000, + "n_fake": 626, + "failed_real": 0, + "failed_fake": 0, + "failed_other_real": 0, + "failed_other_fake": 0, + "rank_by": "logit" + }, + "MorphStudio": { + "ap": 98.25, + "ap_real": 99.98, + "auroc": 99.74, + "real_acc": 99.2, + "fake_acc": 96.29, + "acc": 97.74, + "n_real": 10000, + "n_fake": 700, + "failed_real": 0, + "failed_fake": 0, + "failed_other_real": 0, + "failed_other_fake": 0, + "rank_by": "logit" + }, + "Show_1": { + "ap": 76.68, + "ap_real": 99.44, + "auroc": 94.27, + "real_acc": 99.2, + "fake_acc": 60.14, + "acc": 79.67, + "n_real": 10000, + "n_fake": 700, + "failed_real": 0, + "failed_fake": 0, + "failed_other_real": 0, + "failed_other_fake": 0, + "rank_by": "logit" + }, + "Sora": { + "ap": 26.72, + "ap_real": 99.49, + "auroc": 68.54, + "real_acc": 99.2, + "fake_acc": 35.71, + "acc": 67.46, + "n_real": 10000, + "n_fake": 56, + "failed_real": 0, + "failed_fake": 0, + "failed_other_real": 0, + "failed_other_fake": 0, + "rank_by": "logit" + }, + "WildScrape": { + "ap": 73.74, + "ap_real": 97.03, + "auroc": 86.92, + "real_acc": 99.2, + "fake_acc": 58.55, + "acc": 78.87, + "n_real": 10000, + "n_fake": 924, + "failed_real": 0, + "failed_fake": 0, + "failed_other_real": 0, + "failed_other_fake": 0, + "rank_by": "logit" + } + }, + "failed_to_decode": { + "fake": 0, + "real_unique": 0 + }, + "failed_other": { + "fake": 0, + "real_unique": 0 + }, + "limit": null, + "reals": null, + "ckpt_sha256": "1c7566b26c0b0afe3f5642dd4e454039328d59f512a5d815d5edaa10b544a897", + "cache_dir": "/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/waverep_bench_cache/waverep/genvideo", + "date": "2026-11-11T00:44:54", + "synthscope_version": "video" +} diff --git a/repro/bench_results/waverep_videophy.json b/repro/bench_results/waverep_videophy.json new file mode 100644 index 0000000000000000000000000000000000000000..042910472d884f2cd04bef65878ef0ecdf656808 --- /dev/null +++ b/repro/bench_results/waverep_videophy.json @@ -0,0 +1,150 @@ +{ + "tag": "waverep_videophy", + "model": "waverep", + "ckpt": "registry-default", + "benchmark": "video:pergen", + "data_root": "/ssdstore/ssalehi/SynthScope/VideoPhy/test", + "n_generators": 8, + "means": { + "acc": 90.0, + "map": 93.21, + "map_real": 98.44, + "mauroc": 96.54 + }, + "per_generator": { + "Dream-Machine": { + "ap": 99.95, + "ap_real": 99.99, + "auroc": 99.98, + "real_acc": 99.3, + "fake_acc": 99.71, + "acc": 99.5, + "n_real": 1000, + "n_fake": 339, + "failed_real": 0, + "failed_fake": 0, + "failed_other_real": 0, + "failed_other_fake": 0, + "rank_by": "logit" + }, + "Gen-2": { + "ap": 99.98, + "ap_real": 100.0, + "auroc": 99.99, + "real_acc": 99.3, + "fake_acc": 100.0, + "acc": 99.65, + "n_real": 1000, + "n_fake": 312, + "failed_real": 0, + "failed_fake": 0, + "failed_other_real": 0, + "failed_other_fake": 0, + "rank_by": "logit" + }, + "LaVie": { + "ap": 99.7, + "ap_real": 99.96, + "auroc": 99.88, + "real_acc": 99.3, + "fake_acc": 97.67, + "acc": 98.48, + "n_real": 1000, + "n_fake": 343, + "failed_real": 0, + "failed_fake": 0, + "failed_other_real": 0, + "failed_other_fake": 0, + "rank_by": "logit" + }, + "OpenSora": { + "ap": 75.67, + "ap_real": 95.35, + "auroc": 88.55, + "real_acc": 99.3, + "fake_acc": 25.0, + "acc": 62.15, + "n_real": 1000, + "n_fake": 344, + "failed_real": 0, + "failed_fake": 0, + "failed_other_real": 0, + "failed_other_fake": 0, + "rank_by": "logit" + }, + "Pika": { + "ap": 99.83, + "ap_real": 99.98, + "auroc": 99.94, + "real_acc": 99.3, + "fake_acc": 99.34, + "acc": 99.32, + "n_real": 1000, + "n_fake": 304, + "failed_real": 0, + "failed_fake": 0, + "failed_other_real": 0, + "failed_other_fake": 0, + "rank_by": "logit" + }, + "SVD": { + "ap": 99.48, + "ap_real": 99.83, + "auroc": 99.67, + "real_acc": 99.3, + "fake_acc": 97.38, + "acc": 98.34, + "n_real": 1000, + "n_fake": 344, + "failed_real": 0, + "failed_fake": 0, + "failed_other_real": 0, + "failed_other_fake": 0, + "rank_by": "logit" + }, + "VideoCrafter2": { + "ap": 99.76, + "ap_real": 99.97, + "auroc": 99.91, + "real_acc": 99.3, + "fake_acc": 98.26, + "acc": 98.78, + "n_real": 1000, + "n_fake": 344, + "failed_real": 0, + "failed_fake": 0, + "failed_other_real": 0, + "failed_other_fake": 0, + "rank_by": "logit" + }, + "ZeroScope": { + "ap": 71.28, + "ap_real": 92.44, + "auroc": 84.42, + "real_acc": 99.3, + "fake_acc": 28.2, + "acc": 63.75, + "n_real": 1000, + "n_fake": 344, + "failed_real": 0, + "failed_fake": 0, + "failed_other_real": 0, + "failed_other_fake": 0, + "rank_by": "logit" + } + }, + "failed_to_decode": { + "fake": 0, + "real_unique": 0 + }, + "failed_other": { + "fake": 0, + "real_unique": 0 + }, + "limit": 1000, + "reals": null, + "ckpt_sha256": "1c7566b26c0b0afe3f5642dd4e454039328d59f512a5d815d5edaa10b544a897", + "cache_dir": "/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/waverep_bench_cache/waverep/videophy", + "date": "2026-11-11T00:45:20", + "synthscope_version": "video" +} diff --git a/repro/bench_results/waverep_vidprom.json b/repro/bench_results/waverep_vidprom.json new file mode 100644 index 0000000000000000000000000000000000000000..ea41a435fd8857517af0606e4418754b8d59bc25 --- /dev/null +++ b/repro/bench_results/waverep_vidprom.json @@ -0,0 +1,90 @@ +{ + "tag": "waverep_vidprom", + "model": "waverep", + "ckpt": "registry-default", + "benchmark": "video:pergen", + "data_root": "/ssdstore/ssalehi/SynthScope/VidProM/test", + "n_generators": 4, + "means": { + "acc": 89.85, + "map": 98.11, + "map_real": 97.94, + "mauroc": 98.06 + }, + "per_generator": { + "ModelScope": { + "ap": 94.35, + "ap_real": 94.69, + "auroc": 94.52, + "real_acc": 99.3, + "fake_acc": 43.8, + "acc": 71.55, + "n_real": 1000, + "n_fake": 1000, + "failed_real": 0, + "failed_fake": 0, + "failed_other_real": 0, + "failed_other_fake": 0, + "rank_by": "logit" + }, + "Pika": { + "ap": 99.97, + "ap_real": 99.97, + "auroc": 99.97, + "real_acc": 99.3, + "fake_acc": 99.4, + "acc": 99.35, + "n_real": 1000, + "n_fake": 998, + "failed_real": 0, + "failed_fake": 2, + "failed_other_real": 0, + "failed_other_fake": 0, + "rank_by": "logit" + }, + "Text2Video-Zero": { + "ap": 98.45, + "ap_real": 97.43, + "auroc": 98.1, + "real_acc": 99.3, + "fake_acc": 83.8, + "acc": 91.55, + "n_real": 1000, + "n_fake": 1000, + "failed_real": 0, + "failed_fake": 0, + "failed_other_real": 0, + "failed_other_fake": 0, + "rank_by": "logit" + }, + "VideoCrafter2": { + "ap": 99.69, + "ap_real": 99.66, + "auroc": 99.66, + "real_acc": 99.3, + "fake_acc": 94.6, + "acc": 96.95, + "n_real": 1000, + "n_fake": 1000, + "failed_real": 0, + "failed_fake": 0, + "failed_other_real": 0, + "failed_other_fake": 0, + "rank_by": "logit" + } + }, + "failed_to_decode": { + "fake": 2, + "real_unique": 0 + }, + "failed_other": { + "fake": 0, + "real_unique": 0 + }, + "limit": 1000, + "reals": null, + "ckpt_sha256": "1c7566b26c0b0afe3f5642dd4e454039328d59f512a5d815d5edaa10b544a897", + "cache_dir": "/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/waverep_bench_cache/waverep/vidprom", + "date": "2026-11-11T00:45:32", + "synthscope_version": "video" +} diff --git a/repro/benchmark_specs/aide.json b/repro/benchmark_specs/aide.json index 693c053fdd816d742ddf418d48f8562b0ec35336..b268d37b0fb8e2109fa3dca30665496ebf055afe 100644 --- a/repro/benchmark_specs/aide.json +++ b/repro/benchmark_specs/aide.json @@ -96,13 +96,13 @@ }, "paper_section": "Table 4 (p.7-8). Trained on ImageNet reals + SDv1.4 fakes, eval over 8 generators.", "official_eval_protocol": "Same TestDataset path: native-res DCT patch selection, patches+token resized to 256 + ImageNet-norm, ConvNeXt-XXL semantic branch. Checkpoint AIDE_checkpoints/sd14_train.pth. (A GenImage_train.pth checkpoint also exists and scores ~99.96 mAP but that is trained on the full GenImage train, not the paper's SDv1.4-only Setting-I.)", - "our_status": "reproduced", + "our_status": "official", "our_number": { "map": 97.12, "acc": 85.91, - "note": "official sd14_train.pth, faithful vendored eval; acc 85.91 ~ paper 86.88 (tag aide_official_genimage8). FROM-SCRATCH reproduction (native-res 5-view, aide_native_v2/model_2): GenImage-8 96.42 mAP / 97.07 mAUROC / 77.9 acc (tag aide_retrain_native_g8) = reproduces official 97.12. The old resize-256 retrains (91.75 / 92.47) were capped by the resize-before-DCT bug." + "note": "official sd14_train.pth, faithful vendored eval; acc 85.91 ~ paper 86.88 (tag aide_official_genimage8, full GenImage_full/test: 1500 real + 1500 fake per generator, 6000 + 6000 for sdv1.4). SYNTHSCOPE-TRAINED (the official recipe through experiments/image/aide.sh, train job 281041 on 4x A6000, model_best = epoch 4, val acc 0.9984): full GenImage-8 93.90 mAP / 91.66 mAUROC / 80.73 acc (tag aide_trained_genimage8, DAS6 job 66956); on the first 300 images per class and generator (the protocol of aide_served_genimage8 and aide_retrain_native_g8) 92.57 mAP / 89.63 mAUROC / 80.69 acc (tag aide_trained_genimage8_l300). Per generator acc (full): adm 58.63, biggan 50.87, glide 92.00, midjourney 74.60, sdv1.4 99.97, sdv1.5 100.0, vqdm 69.83, wukong 99.93 (official weights: 76.6 / 60.63 / 90.83 / 83.7 / 99.76 / 99.8 / 76.8 / 99.13). Previous retrain (aide_native_v2/model_2, tag aide_retrain_native_g8, 300 per class): 96.42 mAP / 97.07 mAUROC / 77.87 acc. The old resize-256 retrains (91.75 / 92.47) were capped by the resize-before-DCT bug." }, - "gap_cause": "RESOLVED. The native-res DCT (the patch selector must run at native resolution; resize-256-before-DCT costs ~12 mAP on the same weights, ablation) is now wired into BOTH serving and training. A from-scratch retrain reproduces (96.42 ~ official 97.12).", + "gap_cause": "Trained number is BELOW the paper and the official weights. The 2026-11 retrain follows the official code (survey of shilinyan99/AIDE): blur + JPEG perturbations at native resolution, no flip, label smoothing 0.1, AdamW 5e-4 / wd 0 / 5 epochs / per-iteration cosine to 1e-6, effective batch 256 (4 GPUs x 8 x accumulation 8) with SyncBatchNorm over 32 images, fp32, no clipping, model_best by validation accuracy; deviation: long side capped at 1024 before the DCT. Result 93.90 mAP / 80.73 acc against the paper 86.88 acc (-6.15, outside the 2-point tolerance) and the official weights 97.12 mAP / 85.91 acc. In-domain subsets (sdv1.4, sdv1.5, wukong, glide) match the official weights; the gap is on ADM (acc 58.6 vs 76.6, AP 75.7 vs 94.3), Midjourney (74.6 vs 83.7) and VQDM (69.8 vs 76.8): the cross-generator transfer of the SD v1.4-trained checkpoint is weaker. Real accuracy is 99.93-100 on every subset, so the loss is fake recall (threshold 0.5). Cause not identified.", "dataset_source": "on-disk /hddstore/ssalehi/SynthScope/GenImage_full/test (8 gens present)" }, { diff --git a/repro/benchmark_specs/cure.json b/repro/benchmark_specs/cure.json index 43dd14447218a4ebf02463ff4f77304cd3740943..78b146bfc5331798786b3c5721db8e73630ff7d0 100644 --- a/repro/benchmark_specs/cure.json +++ b/repro/benchmark_specs/cure.json @@ -3,7 +3,7 @@ "paper": "CuRe: Learning Continuous Source Responses for Generalizable AI-Generated Image Detection (arXiv 2609.14316)", "arxiv_id": "2609.14316", "official_repo": "https://github.com/manic-cui/CuRe", - "training_set_in_paper": "Trained only on GenImage SD-v1.4. The paper's two-stage mixing-ratio-regression training recipe is not in the official release, so only the official adapter (weights) is evaluated here; there is no SynthScope-trained checkpoint.", + "training_set_in_paper": "Trained only on GenImage SD-v1.4. The official release has no training code; SynthScope implements the paper's three-stage recipe (experiments/image/cure.sh, models/image/cure/README.md). Run as written (last stage-1 epoch, job 66658, tags cure_trained_*) it falls about 13 acc points short (stage 1 over-adapts to SD-v1.4). With a pre-registered, non-benchmark early-stopping rule (repro/cure_stage1/epoch_select.py) and DDA-style training augmentation (an assumption the paper does not state) the best checkpoint, r3e0 (tags cure_trained_r3e0_*), partially reproduces the paper: 4 of 8 comparable benchmarks, mean acc 85.15 vs 90.10 (paper settings only, r1e0: 3 of 8, 84.27). Remaining gaps: BFree-Online (ranking), RRDataset, RealChain and EvalGEN (mostly calibration). The served cure model is the official adapter, which reproduces the paper.", "benchmarks": [ { "name": "AIGIBench (20 full-image-synthesis subsets, full test data)", @@ -16,9 +16,9 @@ "auroc": 97.5, "note": "Paper Table 2: unweighted macro-average over the 20 full-image-synthesis subsets." }, - "our_status": "official", + "our_status": "reproduced", "our_number": { - "note": "Official adapter through SynthScope reproduces every one of the 20 subsets within 0.10 pt (92.85 acc / 97.48 AUROC)." + "note": "Reproduced by the SynthScope-trained r3e0 ONLY with the unstated augmentation assumption (pre-registered non-benchmark selection; single seed; the paper-settings-only r1e0 gives 88.85 acc, not reproduced); the served cure model is the official adapter. Official adapter through SynthScope reproduces every one of the 20 subsets within 0.10 pt (92.85 acc / 97.48 AUROC). SynthScope-trained: r3e0, the best checkpoint by the pre-registered non-benchmark selection rule (paper recipe + DDA-style augmentation, stage-1 epoch 0; tag cure_trained_r3e0_aigibench20_full): acc 91.12 / AUROC 97.1 (reproduced); the recipe's last epoch (tag cure_trained_aigibench20_full): acc 85.05 / AUROC 91.84." } }, { @@ -32,7 +32,7 @@ }, "our_status": "reference", "our_number": { - "note": "UFD-8 mean balanced accuracy 93.94; 16-generator union 89.27 (aggregation differs from the paper)." + "note": "UFD-8 mean balanced accuracy 93.94; 16-generator union 89.27 (aggregation differs from the paper). SynthScope-trained: r3e0, the best checkpoint by the pre-registered non-benchmark selection rule (paper recipe + DDA-style augmentation, stage-1 epoch 0; tag cure_trained_r3e0_ufd): acc 93.89 / AUROC 98.31 (reference); the recipe's last epoch (tag cure_trained_ufd): acc 82.69 / AUROC 93.85." } }, { @@ -46,7 +46,7 @@ }, "our_status": "reference", "our_number": { - "note": "Mean balanced accuracy 81.95 (low scores are fake-recall; AP/AUROC are 95-99 on those generators)." + "note": "Mean balanced accuracy 81.95 (low scores are fake-recall; AP/AUROC are 95-99 on those generators). SynthScope-trained: r3e0, the best checkpoint by the pre-registered non-benchmark selection rule (paper recipe + DDA-style augmentation, stage-1 epoch 0; tag cure_trained_r3e0_forensynths): acc 89.36 / AUROC 96.58 (reference); the recipe's last epoch (tag cure_trained_forensynths): acc 75.83 / AUROC 93.56." } }, { @@ -60,7 +60,7 @@ }, "our_status": "reference", "our_number": { - "note": "SD-v1.4 99.73, SD-v1.5 99.80, Wukong 99.87; weaker on ADM/BigGAN/VQDM at the fixed 0.5 threshold." + "note": "SD-v1.4 99.73, SD-v1.5 99.80, Wukong 99.87; weaker on ADM/BigGAN/VQDM at the fixed 0.5 threshold. SynthScope-trained: r3e0, the best checkpoint by the pre-registered non-benchmark selection rule (paper recipe + DDA-style augmentation, stage-1 epoch 0; tag cure_trained_r3e0_genimage8): acc 86.22 / AUROC 97.59 (reference); the recipe's last epoch (tag cure_trained_genimage8): acc 77.7 / AUROC 87.88." } }, { @@ -74,9 +74,9 @@ "auroc": 98.0, "note": "Paper Table 6: unweighted mean over the 17 generators; 76.3k real / 76.3k fake." }, - "our_status": "official", + "our_status": "reproduced", "our_number": { - "note": "Official adapter through SynthScope: 89.30 balanced acc / 98.02 AUROC (mAP 98.08) on all 17 generators, full test data, 76,299 real / 76,299 fake (tag cure_aigcdetect, job 251523)." + "note": "Reproduced by the SynthScope-trained r3e0 (pre-registered non-benchmark selection; single seed) and, without the augmentation assumption, by the paper-settings-only r1e0 (92.25 acc); the served cure model is the official adapter. Official adapter through SynthScope: 89.30 balanced acc / 98.02 AUROC (mAP 98.08) on all 17 generators, full test data, 76,299 real / 76,299 fake (tag cure_aigcdetect, job 251523). SynthScope-trained: r3e0, the best checkpoint by the pre-registered non-benchmark selection rule (paper recipe + DDA-style augmentation, stage-1 epoch 0; tag cure_trained_r3e0_aigcdetect): acc 92.01 / AUROC 98.38 (reproduced); the recipe's last epoch (tag cure_trained_aigcdetect): acc 81.55 / AUROC 92.22." } }, { @@ -91,7 +91,7 @@ }, "our_status": "official", "our_number": { - "note": "Official adapter through SynthScope: 98.14 balanced acc (mAP 99.86, AUROC 99.66) on all 55,298 fakes vs MSCOCO val2017 (5000 reals; our choice of pool) (tag cure_evalgen, job 251412)." + "note": "Trained r3e0 not reproduced (-4.8 acc); the served cure model is the official adapter. Official adapter through SynthScope: 98.14 balanced acc (mAP 99.86, AUROC 99.66) on all 55,298 fakes vs MSCOCO val2017 (5000 reals; our choice of pool) (tag cure_evalgen, job 251412). SynthScope-trained: r3e0, the best checkpoint by the pre-registered non-benchmark selection rule (paper recipe + DDA-style augmentation, stage-1 epoch 0; tag cure_trained_r3e0_evalgen): acc 93.32 / AUROC 98.85 (not reproduced, -4.8 acc); the recipe's last epoch (tag cure_trained_evalgen): acc 90.65 / AUROC 95.96." } }, { @@ -104,9 +104,9 @@ "acc": 92.7, "note": "Paper Table 1; 0.5k real / 1.5k fake; unweighted mean over DALL-E 3, Firefly, Midjourney v5." }, - "our_status": "official", + "our_status": "reproduced", "our_number": { - "note": "Official adapter through SynthScope: 92.69 balanced acc (mAP 95.61, AUROC 96.50) on the 1713 of 2000 images still online on X (413 real; 392/473/435 fake) (tag cure_synthwildx, job 251435)." + "note": "Reproduced by the SynthScope-trained r3e0 (pre-registered non-benchmark selection; single seed) and, without the augmentation assumption, by the paper-settings-only r1e0 (90.99 acc); the served cure model is the official adapter. Official adapter through SynthScope: 92.69 balanced acc (mAP 95.61, AUROC 96.50) on the 1713 of 2000 images still online on X (413 real; 392/473/435 fake) (tag cure_synthwildx, job 251435). SynthScope-trained: r3e0, the best checkpoint by the pre-registered non-benchmark selection rule (paper recipe + DDA-style augmentation, stage-1 epoch 0; tag cure_trained_r3e0_synthwildx): acc 91.76 / AUROC 97.09 (reproduced); the recipe's last epoch (tag cure_trained_synthwildx): acc 76.11 / AUROC 86.84." } }, { @@ -119,9 +119,9 @@ "acc": 95.8, "note": "Paper Table 1; 1.3k real / 1.3k fake; unweighted mean over the Reddit, Facebook and X test subsets." }, - "our_status": "official", + "our_status": "reproduced", "our_number": { - "note": "Official adapter through SynthScope: 95.89 balanced acc (mAP 99.13, AUROC 99.14) on the full test split, 1251 real / 1252 fake (tag cure_wildrf, job 251440)." + "note": "Reproduced by the SynthScope-trained r3e0 (pre-registered non-benchmark selection; single seed) and, without the augmentation assumption, by the paper-settings-only r1e0 (95.23 acc); the served cure model is the official adapter. Official adapter through SynthScope: 95.89 balanced acc (mAP 99.13, AUROC 99.14) on the full test split, 1251 real / 1252 fake (tag cure_wildrf, job 251440). SynthScope-trained: r3e0, the best checkpoint by the pre-registered non-benchmark selection rule (paper recipe + DDA-style augmentation, stage-1 epoch 0; tag cure_trained_r3e0_wildrf): acc 95.58 / AUROC 99.25 (reproduced); the recipe's last epoch (tag cure_trained_wildrf): acc 85.8 / AUROC 94.59." } }, { @@ -136,7 +136,7 @@ }, "our_status": "reference", "our_number": { - "note": "Official adapter through SynthScope: 91.64 balanced acc (mAP 99.06, AUROC 98.08) on the 807 of 1111 listed images still online (269 real / 538 fake), about 58% of the paper's set, so not a like-for-like comparison (tag cure_bfree_online, job 251449)." + "note": "Trained r3e0 not reproduced (-19.7 acc); the served cure model is the official adapter. Official adapter through SynthScope: 91.64 balanced acc (mAP 99.06, AUROC 98.08) on the 807 of 1111 listed images still online (269 real / 538 fake), about 58% of the paper's set, so not a like-for-like comparison (tag cure_bfree_online, job 251449). SynthScope-trained: r3e0, the best checkpoint by the pre-registered non-benchmark selection rule (paper recipe + DDA-style augmentation, stage-1 epoch 0; tag cure_trained_r3e0_bfree_online): acc 71.19 / AUROC 79.51 (not reproduced, -19.7 acc); the recipe's last epoch (tag cure_trained_bfree_online): acc 66.64 / AUROC 85.77." } }, { @@ -151,7 +151,7 @@ }, "our_status": "official", "our_number": { - "note": "Official adapter through SynthScope: 82.04 balanced acc (mAP 90.40, AUROC 88.88) on the public test archive, 25,499 real / 25,500 fake (original 91.08, transfer 85.52, redigital 69.51) (tag cure_rrdataset, job 251476)." + "note": "Trained r3e0 not reproduced (-8.0 acc); the served cure model is the official adapter. Official adapter through SynthScope: 82.04 balanced acc (mAP 90.40, AUROC 88.88) on the public test archive, 25,499 real / 25,500 fake (original 91.08, transfer 85.52, redigital 69.51) (tag cure_rrdataset, job 251476). SynthScope-trained: r3e0, the best checkpoint by the pre-registered non-benchmark selection rule (paper recipe + DDA-style augmentation, stage-1 epoch 0; tag cure_trained_r3e0_rrdataset): acc 73.46 / AUROC 85.32 (not reproduced, -8.0 acc); the recipe's last epoch (tag cure_trained_rrdataset): acc 66.36 / AUROC 76.87." } }, { @@ -166,7 +166,7 @@ }, "our_status": "official", "our_number": { - "note": "Official adapter through SynthScope: 79.69 balanced acc (mAP 87.39, AUROC 85.47) on the full released set (tag cure_realchain, job 251412). The release is one JPEG-q60 image set; the 7000 unpaired reals are split into 7 disjoint slices, so the mean per-generator balanced accuracy equals the pooled one." + "note": "Trained r3e0 not reproduced (-7.0 acc); the served cure model is the official adapter. Official adapter through SynthScope: 79.69 balanced acc (mAP 87.39, AUROC 85.47) on the full released set (tag cure_realchain, job 251412). The release is one JPEG-q60 image set; the 7000 unpaired reals are split into 7 disjoint slices, so the mean per-generator balanced accuracy equals the pooled one. SynthScope-trained: r3e0, the best checkpoint by the pre-registered non-benchmark selection rule (paper recipe + DDA-style augmentation, stage-1 epoch 0; tag cure_trained_r3e0_realchain): acc 72.75 / AUROC 84.7 (not reproduced, -7.0 acc); the recipe's last epoch (tag cure_trained_realchain): acc 63.33 / AUROC 76.5." } }, { @@ -185,4 +185,4 @@ } } ] -} \ No newline at end of file +} diff --git a/repro/benchmark_specs/probe.json b/repro/benchmark_specs/probe.json new file mode 100644 index 0000000000000000000000000000000000000000..34e8a1b81ff64d57348834cad59abc38a45381a2 --- /dev/null +++ b/repro/benchmark_specs/probe.json @@ -0,0 +1,114 @@ +{ + "model": "probe", + "paper": "Where Detectors Fail: Probing Generative Space for Generalizable AI-Generated Image Detection (PROBE, ICML 2026, arXiv 2605.24906)", + "arxiv_id": "2605.24906", + "official_repo": "https://github.com/Amamiya-C/PROBE-AIGI-Detection", + "training_set_in_paper": "PROBE-DINOv2 (DINOv2 ViT-L/14 with registers, trained on the Reconstruction Training Set + PROBE samples). Only the released checkpoint (DINOv2_best_model_step_34999.pth, ModelScope shuinishaojiu/PROBE-AIGI-Detection) is evaluated here; the generator-probing and fine-tuning code is not released, so there is no SynthScope-trained checkpoint. Metric: balanced accuracy at 0.5 (positive = fake), mean over the paper's subsets (Table 1 Avg = mean of Tables 2-4); SynthScope's means.acc is the same quantity. Inference: official protocol (pad to the crop size, ImageNet normalisation, mean logit of non-overlapping 336 patches), exact parity with the official evaluate_dino.py. The paper's 7-benchmark Avg (93.9) is not comparable with our 5-benchmark mean because Chameleon and AIGI-Quality-Paradox were not run.", + "benchmarks": [ + { + "name": "GenImage (8 subsets, val100k, fakes JPEG q96)", + "datasets": [ + "GenImage" + ], + "metric": "balanced accuracy at 0.5 (mean of real and fake accuracy), mean over subsets", + "paper_number": { + "acc": 96.8, + "note": "Table 1 (Avg of Tables 2-4); the paper JPEG-compresses all generated images at quality 96." + }, + "our_status": "official", + "our_number": { + "note": "97.47 bAcc / 99.77 mAP, +0.67 vs the paper. Caveats: fakes JPEG q96 as the paper; sdv1.5 8000 per class (paper 6000); DINOv2 ADM/GLIDE/BigGAN about +2 above the paper while SynthScope equals the official code on every file compared (not run on GenImage), cause undetermined. Per subset (diff to the paper): midjourney 98.73 (-0.07); sdv1.4 99.41 (+0.01); sdv1.5 99.39 (-0.01); adm 93.22 (+2.22); glide 93.86 (+1.76); wukong 99.33 (-0.17); vqdm 98.76 (-0.14); biggan 97.07 (+2.07). Full val split, fakes JPEG q96 (reals untouched), 6000 + 6000 per generator except sdv1.5 8000 + 8000 (paper Table 12: 48k / 48k). Tag probe_genimage_val100k, job 66753." + } + }, + { + "name": "Synthbuster (9 subsets, vs 5000 MSCOCO reals - not the paper's RAISE-1k)", + "datasets": [ + "Synthbuster" + ], + "metric": "balanced accuracy at 0.5 (mean of real and fake accuracy), mean over subsets (reals: 5000 MSCOCO val2017, different from the paper)", + "paper_number": { + "acc": 97.5, + "note": "Table 1 (Avg of Tables 2-4); the paper pairs the 9k fakes with the 1k RAISE-1k reals (Table 12)." + }, + "our_status": "reference", + "our_number": { + "note": "98.2 bAcc / 99.64 mAP with DIFFERENT REALS: 5000 MSCOCO val2017 images (EvalGEN/Flux/0_real) instead of the paper's RAISE-1k (registration-gated, not in SynthScope), so this is not a like-for-like comparison and does not reproduce the paper's number. Per subset (diff to the paper): dalle2 93.47 (-1.13); dalle3 99.57 (+0.17); firefly 99.77 (+0.27); glide 92.22 (+5.52); midjourney-v5 99.77 (+0.27); stable-diffusion-1-3 99.72 (+0.22); stable-diffusion-1-4 99.77 (+0.27); stable-diffusion-2 99.77 (+0.27); stable-diffusion-xl 99.72 (+0.22). Real accuracy 99.54 on every subset. Tag probe_synthbuster_coco, job 66755." + } + }, + { + "name": "SynthWildX (dalle3 / firefly / midjourney_v5)", + "datasets": [ + "SynthWildX" + ], + "metric": "balanced accuracy at 0.5 (mean of real and fake accuracy), mean over subsets", + "paper_number": { + "acc": 96.4, + "note": "Table 1 (Avg of Tables 2-4)." + }, + "our_status": "official", + "our_number": { + "note": "97.3 bAcc / 98.8 mAP, +0.90. Per subset (diff): dalle3 97.44 (+0.94); firefly 96.98 (+0.58); midjourney_v5 97.48 (+0.98). Our copy: 413 reals and 392 / 473 / 435 fakes (paper Table 12: 0.5k and 1.5k). The unmodified official code gives the same bAcc on every subset (max |dP| 4.8e-6, 0 flips). Tag probe_synthwildx, job 66753." + } + }, + { + "name": "WildRF (facebook / reddit / twitter)", + "datasets": [ + "WildRF" + ], + "metric": "balanced accuracy at 0.5 (mean of real and fake accuracy), mean over subsets", + "paper_number": { + "acc": 96.9, + "note": "Table 1 (Avg of Tables 2-4)." + }, + "our_status": "official", + "our_number": { + "note": "96.92 bAcc / 99.36 mAP, +0.02. Per subset (diff): facebook 98.75 (+0.35); reddit 93.33 (-0.07); twitter 98.68 (-0.32). 2503 files (the paper lists 1.25k + 1.25k). The official code drops the 262 .jfif files of twitter (.jpg/.jpeg/.png only); on the common files it equals SynthScope (0 flips, max |dP| 3.0e-6). Tag probe_wildrf, job 66753." + } + }, + { + "name": "AIGI-Bench (CommunityAI + SocialRF)", + "datasets": [ + "AIGIBench" + ], + "metric": "balanced accuracy at 0.5 (mean of real and fake accuracy), mean over subsets", + "paper_number": { + "acc": 89.9, + "note": "Table 1 (Avg of Tables 2-4; the paper's two subsets, 9k + 9k)." + }, + "our_status": "official", + "our_number": { + "note": "89.88 bAcc / 96.46 mAP, -0.02. Per subset (diff): CommunityAI 90.38 (+0.58); SocialRF 89.38 (-0.52). Only the paper's two subsets were scored: CommunityAI 6000 + 6000, SocialRF 3000 + 3000. Tag probe_aigibench, job 66790." + } + }, + { + "name": "Chameleon", + "datasets": [ + "Chameleon" + ], + "metric": "balanced accuracy at 0.5 (mean of real and fake accuracy), mean over subsets", + "paper_number": { + "acc": 86.6, + "note": "Table 1." + }, + "our_status": "missing", + "our_number": { + "note": "Not run: Chameleon is available by request only and has no loader in SynthScope." + } + }, + { + "name": "AIGI-Quality-Paradox", + "datasets": [ + "AIGI-Quality-Paradox" + ], + "metric": "balanced accuracy at 0.5 (mean of real and fake accuracy), mean over subsets", + "paper_number": { + "acc": 92.9, + "note": "Table 1." + }, + "our_status": "missing", + "our_number": { + "note": "Not run: no loader in SynthScope." + } + } + ] +} diff --git a/repro/benchmark_specs/probe_resnet.json b/repro/benchmark_specs/probe_resnet.json new file mode 100644 index 0000000000000000000000000000000000000000..df003a29dad30fd6fcd461194c0f5a4a89e8236f --- /dev/null +++ b/repro/benchmark_specs/probe_resnet.json @@ -0,0 +1,114 @@ +{ + "model": "probe_resnet", + "paper": "Where Detectors Fail: Probing Generative Space for Generalizable AI-Generated Image Detection (PROBE, ICML 2026, arXiv 2605.24906)", + "arxiv_id": "2605.24906", + "official_repo": "https://github.com/Amamiya-C/PROBE-AIGI-Detection", + "training_set_in_paper": "PROBE-ResNet50 (ResNet-50 trained on GenImage SD v1.4 + PROBE samples). Only the released checkpoint (ResNet50_best_model_step_19343.pth, ModelScope shuinishaojiu/PROBE-AIGI-Detection) is evaluated here; the generator-probing and fine-tuning code is not released, so there is no SynthScope-trained checkpoint. Metric: balanced accuracy at 0.5 (positive = fake), mean over the paper's subsets (Table 1 Avg = mean of Tables 2-4); SynthScope's means.acc is the same quantity. Inference: official protocol (pad to the crop size, ImageNet normalisation, mean logit of non-overlapping 224 patches), exact parity with the official evaluate_resnet.py. The paper's 7-benchmark Avg (78.1) is not comparable with our 5-benchmark mean because Chameleon and AIGI-Quality-Paradox were not run.", + "benchmarks": [ + { + "name": "GenImage (8 subsets, val100k, fakes JPEG q96)", + "datasets": [ + "GenImage" + ], + "metric": "balanced accuracy at 0.5 (mean of real and fake accuracy), mean over subsets", + "paper_number": { + "acc": 78.4, + "note": "Table 1 (Avg of Tables 2-4); the paper JPEG-compresses all generated images at quality 96." + }, + "our_status": "official", + "our_number": { + "note": "78.38 bAcc / 86.69 mAP, -0.02 vs the paper. Caveats: fakes JPEG q96 as the paper; sdv1.5 8000 per class (paper 6000). Equal to the paper in 7 of 8 subsets (within 0.1); ADM 58.94 vs 60.0. Per subset (diff to the paper): midjourney 90.73 (+0.03); sdv1.4 99.36 (-0.04); sdv1.5 99.24 (+0.04); adm 58.94 (-1.06); glide 63.01 (+0.01); wukong 99.41 (+0.01); vqdm 66.90 (+0.00); biggan 49.41 (+0.01). Full val split, fakes JPEG q96 (reals untouched), 6000 + 6000 per generator except sdv1.5 8000 + 8000 (paper Table 12: 48k / 48k). Tag probe_resnet_genimage_val100k, job 66753." + } + }, + { + "name": "Synthbuster (9 subsets, vs 5000 MSCOCO reals - not the paper's RAISE-1k)", + "datasets": [ + "Synthbuster" + ], + "metric": "balanced accuracy at 0.5 (mean of real and fake accuracy), mean over subsets (reals: 5000 MSCOCO val2017, different from the paper)", + "paper_number": { + "acc": 79.1, + "note": "Table 1 (Avg of Tables 2-4); the paper pairs the 9k fakes with the 1k RAISE-1k reals (Table 12)." + }, + "our_status": "reference", + "our_number": { + "note": "83.75 bAcc / 85.23 mAP with DIFFERENT REALS: 5000 MSCOCO val2017 images (EvalGEN/Flux/0_real) instead of the paper's RAISE-1k (registration-gated, not in SynthScope), so this is not a like-for-like comparison and does not reproduce the paper's number. Per subset (diff to the paper): dalle2 52.97 (+4.67); dalle3 94.82 (+4.62); firefly 51.57 (+4.67); glide 62.07 (+4.67); midjourney-v5 97.82 (+4.62); stable-diffusion-1-3 99.57 (+4.67); stable-diffusion-1-4 99.57 (+4.67); stable-diffusion-2 97.72 (+4.62); stable-diffusion-xl 97.67 (+4.67). Real accuracy 99.14 on every subset. Tag probe_resnet_synthbuster_coco, job 66755." + } + }, + { + "name": "SynthWildX (dalle3 / firefly / midjourney_v5)", + "datasets": [ + "SynthWildX" + ], + "metric": "balanced accuracy at 0.5 (mean of real and fake accuracy), mean over subsets", + "paper_number": { + "acc": 75.6, + "note": "Table 1 (Avg of Tables 2-4)." + }, + "our_status": "official", + "our_number": { + "note": "75.2 bAcc / 83.88 mAP, -0.40. Per subset (diff): dalle3 89.71 (-0.59); firefly 56.29 (-0.41); midjourney_v5 79.61 (-0.09). Our copy: 413 reals and 392 / 473 / 435 fakes (paper Table 12: 0.5k and 1.5k). The unmodified official code gives the same bAcc on every subset (max |dP| 4.7e-4, 0 flips). Tag probe_resnet_synthwildx, job 66753." + } + }, + { + "name": "WildRF (facebook / reddit / twitter)", + "datasets": [ + "WildRF" + ], + "metric": "balanced accuracy at 0.5 (mean of real and fake accuracy), mean over subsets", + "paper_number": { + "acc": 81.3, + "note": "Table 1 (Avg of Tables 2-4)." + }, + "our_status": "official", + "our_number": { + "note": "81.63 bAcc / 89.45 mAP, +0.33. Per subset (diff): facebook 87.81 (+0.01); reddit 72.87 (-0.03); twitter 84.20 (+0.90). 2503 files (the paper lists 1.25k + 1.25k). The official code drops the 262 .jfif files of twitter (.jpg/.jpeg/.png only); on the common files it equals SynthScope (0 flips, max |dP| 1.3e-3). Tag probe_resnet_wildrf, job 66753." + } + }, + { + "name": "AIGI-Bench (CommunityAI + SocialRF)", + "datasets": [ + "AIGIBench" + ], + "metric": "balanced accuracy at 0.5 (mean of real and fake accuracy), mean over subsets", + "paper_number": { + "acc": 70.4, + "note": "Table 1 (Avg of Tables 2-4; the paper's two subsets, 9k + 9k)." + }, + "our_status": "official", + "our_number": { + "note": "70.44 bAcc / 79.8 mAP, +0.04. Per subset (diff): CommunityAI 70.99 (-0.01); SocialRF 69.88 (-0.02). Only the paper's two subsets were scored: CommunityAI 6000 + 6000, SocialRF 3000 + 3000. Tag probe_resnet_aigibench, job 66790." + } + }, + { + "name": "Chameleon", + "datasets": [ + "Chameleon" + ], + "metric": "balanced accuracy at 0.5 (mean of real and fake accuracy), mean over subsets", + "paper_number": { + "acc": 74.0, + "note": "Table 1." + }, + "our_status": "missing", + "our_number": { + "note": "Not run: Chameleon is available by request only and has no loader in SynthScope." + } + }, + { + "name": "AIGI-Quality-Paradox", + "datasets": [ + "AIGI-Quality-Paradox" + ], + "metric": "balanced accuracy at 0.5 (mean of real and fake accuracy), mean over subsets", + "paper_number": { + "acc": 87.7, + "note": "Table 1." + }, + "our_status": "missing", + "our_number": { + "note": "Not run: no loader in SynthScope." + } + } + ] +} diff --git a/repro/benchmark_specs/waverep.json b/repro/benchmark_specs/waverep.json new file mode 100644 index 0000000000000000000000000000000000000000..0471f0e5d6d50d132a5d2a63b615dd8673d02cb3 --- /dev/null +++ b/repro/benchmark_specs/waverep.json @@ -0,0 +1,551 @@ +{ + "model": "waverep", + "paper": "Seeing What Matters: Generalizable AI-generated Video Detection with Forensic-Oriented Augmentation (WaveRep, Corvi, Cozzolino, Prashnani, De Mello, Nagano, Verdoliva, NeurIPS 2025, arXiv 2506.16802)", + "arxiv_id": "2506.16802", + "official_repo": "https://github.com/grip-unina/WaveRep-SyntheticVideoDetection", + "training_set_in_paper": "The paper's main detector is trained on ONE generator (Pyramid Flow) and Table 5 adds CogVideoX 1.5, Allegro and Open-Sora Plan. The official demo README only says that weights_dinov2_G1.ckpt (key waverep) is trained on \"a single generator\" and weights_dinov2_G4.ckpt (key waverep_g4, the demo's default) on \"four generators\"; reading G1 as the paper's Pyramid Flow detector and G4 as the Pyramid Flow + CogVideoX 1.5 + Allegro + Open-Sora Plan set of Table 5 is our inference, not stated in the release. Both are the official checkpoints (no training code released for the model; only the augmentation), so there is no SynthScope-trained number. Metrics: balanced accuracy at 0.5 and AUC (Tables 1-2 and 7); video score = mean logit of the first 64 frames, center-cropped to 504 (App. D). The paper's own test set (7 generators vs 300 Panda-70M YouTube reals) is NOT held: the reals need a YouTube downloader and were not scraped. The only paper-comparable numbers here are the paper's 8 GenVideo columns, scored on GenVideo-Val with its own 10,000 reals (the paper does not say which reals it paired). Everything else is a zero-shot reference row, not a paper reproduction. Protocol is the same for every row: official OpenCV reader, first 64 frames, 504 centre crop, mean logit, threshold logit 0; exact parity with the official demo (15 videos / 6 codecs: inputs bit-exact, video logit max diff 6e-7; 180 GenVideo-Val files, both checkpoints: max |logit diff| 1.05e-5, 0 sign flips).", + "benchmarks": [ + { + "name": "GenVideo-Val, the paper's 8 GenVideo generators (PARTIAL comparison)", + "datasets": [ + "GenVideo-Val" + ], + "subsets_or_generators": [ + "Crafter", + "Gen2", + "HotShot", + "LaVie", + "ModelScope", + "MorphStudio", + "Show-1", + "MoonValley" + ], + "metric": "balanced accuracy at 0.5 and AUC, mean over the paper's 8 GenVideo columns (full GenVideo-Val: 10,000 reals + all fakes of each generator, 64 frames)", + "paper_number": { + "acc": 94.83, + "auroc": 98.03, + "note": "Derived: mean of the 8 printed per-generator values (Table 1 bAcc, Table 7 AUC), 'Ours' = the paper's single-generator (Pyramid Flow) detector, which we infer is waverep (G1); the release says only 'a single generator'." + }, + "paper_per_generator": { + "Crafter": { + "paper_bacc": 98.3, + "paper_auc": 99.8 + }, + "Gen2": { + "paper_bacc": 98.8, + "paper_auc": 100.0 + }, + "HotShot": { + "paper_bacc": 81.4, + "paper_auc": 91.0 + }, + "LaVie": { + "paper_bacc": 95.5, + "paper_auc": 97.7 + }, + "ModelScope": { + "paper_bacc": 97.1, + "paper_auc": 99.4 + }, + "MorphStudio": { + "paper_bacc": 97.0, + "paper_auc": 99.3 + }, + "Show-1": { + "paper_bacc": 92.1, + "paper_auc": 97.1 + }, + "MoonValley": { + "paper_bacc": 98.4, + "paper_auc": 99.9 + } + }, + "our_status": "below", + "our_number": { + "acc": 90.3, + "auroc": 95.73, + "per_generator": { + "Crafter": { + "bacc": 98.99, + "auc": 99.9, + "n_fake": 1398 + }, + "Gen2": { + "bacc": 99.49, + "auc": 99.99, + "n_fake": 1380 + }, + "HotShot": { + "bacc": 60.1, + "auc": 75.6, + "n_fake": 700 + }, + "LaVie": { + "bacc": 92.06, + "auc": 97.03, + "n_fake": 1400 + }, + "ModelScope": { + "bacc": 95.24, + "auc": 99.31, + "n_fake": 700 + }, + "MorphStudio": { + "bacc": 97.74, + "auc": 99.74, + "n_fake": 700 + }, + "Show-1": { + "bacc": 79.67, + "auc": 94.27, + "n_fake": 700 + }, + "MoonValley": { + "bacc": 99.12, + "auc": 99.97, + "n_fake": 626 + } + }, + "note": "PARTIAL: the paper's 8 GenVideo columns, scored with GenVideo-Val's own 10,000 reals (the paper does not say which reals it paired). 5 of 8 within ~2 pts; HotShot (60.1 vs 81.4), Show-1 (79.7 vs 92.1) and LaVie (92.1 vs 95.5) NOT reproduced; HotShot fake recall 21%, AUC 75.6 (cause untested)." + }, + "gap_cause": "Cause untested. Real accuracy is 99.2 on every generator, so the HotShot gap is a low fake recall (21.0%), and AUC drops with it (75.6 vs 91.0), so it is not a threshold offset. A different real pool or fake subset in the paper (unstated) is a possible cause; we cannot test it. Show-1: fake recall 60.1%, AUC 94.3 vs 97.1; LaVie: 84.9%, AUC 97.0 vs 97.7. Of the other five cells, four (Crafter, Gen2, MorphStudio, MoonValley) are within 0.75 bAcc of the paper (all slightly above it) and ModelScope is 1.86 below.", + "dataset_source": "GenVideo-Val (ModelScope cccnju/Gen-Video), reals = MSR-VTT; tag waverep_genvideo_full." + }, + { + "name": "GenVideo-Val full, 10 generators (zero-shot reference)", + "datasets": [ + "GenVideo-Val" + ], + "subsets_or_generators": [ + "Crafter", + "Gen2", + "HotShot", + "Lavie", + "ModelScope", + "MoonValley", + "MorphStudio", + "Show_1", + "Sora", + "WildScrape" + ], + "metric": "mean over 10 generators: balanced accuracy at 0.5, AP (fake positive), AUROC; 10,000 reals + all fakes", + "paper_number": null, + "our_status": "reference", + "our_number": { + "acc": 86.87, + "map": 79.85, + "auroc": 92.13, + "map_real_positive": 99.24, + "per_generator": { + "Crafter": { + "bacc": 98.99, + "auroc": 99.9, + "n_real": 10000, + "n_fake": 1398 + }, + "Gen2": { + "bacc": 99.49, + "auroc": 99.99, + "n_real": 10000, + "n_fake": 1380 + }, + "HotShot": { + "bacc": 60.1, + "auroc": 75.6, + "n_real": 10000, + "n_fake": 700 + }, + "Lavie": { + "bacc": 92.06, + "auroc": 97.03, + "n_real": 10000, + "n_fake": 1400 + }, + "ModelScope": { + "bacc": 95.24, + "auroc": 99.31, + "n_real": 10000, + "n_fake": 700 + }, + "MoonValley": { + "bacc": 99.12, + "auroc": 99.97, + "n_real": 10000, + "n_fake": 626 + }, + "MorphStudio": { + "bacc": 97.74, + "auroc": 99.74, + "n_real": 10000, + "n_fake": 700 + }, + "Show_1": { + "bacc": 79.67, + "auroc": 94.27, + "n_real": 10000, + "n_fake": 700 + }, + "Sora": { + "bacc": 67.46, + "auroc": 68.54, + "n_real": 10000, + "n_fake": 56 + }, + "WildScrape": { + "bacc": 78.87, + "auroc": 86.92, + "n_real": 10000, + "n_fake": 924 + } + }, + "note": "Zero-shot reference, NOT a paper reproduction (the 8 paper columns are in the row above; Sora and WildScrape have no paper cell). mAP (fake positive) is low because of the 10,000 : 56-1400 class imbalance; AUROC is not affected the same way." + }, + "dataset_source": "tag waverep_genvideo_full." + }, + { + "name": "GenVideo-Val --limit 1000 (zero-shot reference)", + "datasets": [ + "GenVideo-Val" + ], + "subsets_or_generators": [ + "Crafter", + "Gen2", + "HotShot", + "Lavie", + "ModelScope", + "MoonValley", + "MorphStudio", + "Show_1", + "Sora", + "WildScrape" + ], + "metric": "mean over 10 generators; first 1000 reals and first 1000 fakes per generator (the D3 protocol)", + "paper_number": null, + "our_status": "reference", + "our_number": { + "acc": 86.62, + "map": 89.81, + "auroc": 92.09, + "map_real_positive": 93.96, + "per_generator": { + "Crafter": { + "bacc": 98.8, + "auroc": 99.86, + "n_real": 1000, + "n_fake": 1000 + }, + "Gen2": { + "bacc": 99.55, + "auroc": 99.99, + "n_real": 1000, + "n_fake": 1000 + }, + "HotShot": { + "bacc": 60.15, + "auroc": 75.95, + "n_real": 1000, + "n_fake": 700 + }, + "Lavie": { + "bacc": 89.35, + "auroc": 95.93, + "n_real": 1000, + "n_fake": 1000 + }, + "ModelScope": { + "bacc": 95.29, + "auroc": 99.31, + "n_real": 1000, + "n_fake": 700 + }, + "MoonValley": { + "bacc": 99.17, + "auroc": 99.97, + "n_real": 1000, + "n_fake": 626 + }, + "MorphStudio": { + "bacc": 97.79, + "auroc": 99.74, + "n_real": 1000, + "n_fake": 700 + }, + "Show_1": { + "bacc": 79.72, + "auroc": 94.35, + "n_real": 1000, + "n_fake": 700 + }, + "Sora": { + "bacc": 67.51, + "auroc": 68.75, + "n_real": 1000, + "n_fake": 56 + }, + "WildScrape": { + "bacc": 78.92, + "auroc": 87.03, + "n_real": 1000, + "n_fake": 924 + } + }, + "note": "Zero-shot reference, NOT a paper reproduction: the first 1000 clips per class (--limit 1000), so up to 1000 fakes and exactly 1000 reals per generator." + }, + "dataset_source": "tag waverep_genvideo." + }, + { + "name": "VideoPhy --limit 1000 (zero-shot reference)", + "datasets": [ + "VideoPhy" + ], + "subsets_or_generators": [ + "Dream-Machine", + "Gen-2", + "LaVie", + "OpenSora", + "Pika", + "SVD", + "VideoCrafter2", + "ZeroScope" + ], + "metric": "mean over the 8 generators online; first 1000 reals, up to 1000 fakes per generator", + "paper_number": null, + "our_status": "reference", + "our_number": { + "acc": 90.0, + "map": 93.21, + "auroc": 96.54, + "map_real_positive": 98.44, + "per_generator": { + "Dream-Machine": { + "bacc": 99.5, + "auroc": 99.98, + "n_real": 1000, + "n_fake": 339 + }, + "Gen-2": { + "bacc": 99.65, + "auroc": 99.99, + "n_real": 1000, + "n_fake": 312 + }, + "LaVie": { + "bacc": 98.48, + "auroc": 99.88, + "n_real": 1000, + "n_fake": 343 + }, + "OpenSora": { + "bacc": 62.15, + "auroc": 88.55, + "n_real": 1000, + "n_fake": 344 + }, + "Pika": { + "bacc": 99.32, + "auroc": 99.94, + "n_real": 1000, + "n_fake": 304 + }, + "SVD": { + "bacc": 98.34, + "auroc": 99.67, + "n_real": 1000, + "n_fake": 344 + }, + "VideoCrafter2": { + "bacc": 98.78, + "auroc": 99.91, + "n_real": 1000, + "n_fake": 344 + }, + "ZeroScope": { + "bacc": 63.75, + "auroc": 84.42, + "n_real": 1000, + "n_fake": 344 + } + }, + "note": "Zero-shot reference, NOT a paper reproduction; first 1000 clips per class (--limit 1000); 8 of the 10 VideoPhy generators (dead links skipped). Weakest: OpenSora and ZeroScope." + }, + "dataset_source": "tag waverep_videophy." + }, + { + "name": "VidProM --limit 1000 (zero-shot reference)", + "datasets": [ + "VidProM" + ], + "subsets_or_generators": [ + "ModelScope", + "Pika", + "Text2Video-Zero", + "VideoCrafter2" + ], + "metric": "mean over 4 generators (ModelScope, Pika, Text2Video-Zero, VideoCrafter2); first 1000 clips per class", + "paper_number": null, + "our_status": "reference", + "our_number": { + "acc": 89.85, + "map": 98.11, + "auroc": 98.06, + "map_real_positive": 97.94, + "per_generator": { + "ModelScope": { + "bacc": 71.55, + "auroc": 94.52, + "n_real": 1000, + "n_fake": 1000 + }, + "Pika": { + "bacc": 99.35, + "auroc": 99.97, + "n_real": 1000, + "n_fake": 998 + }, + "Text2Video-Zero": { + "bacc": 91.55, + "auroc": 98.1, + "n_real": 1000, + "n_fake": 1000 + }, + "VideoCrafter2": { + "bacc": 96.95, + "auroc": 99.66, + "n_real": 1000, + "n_fake": 1000 + } + }, + "note": "Zero-shot reference, NOT a paper reproduction; first 1000 clips per class (--limit 1000); 2 Pika fakes (00642, 00891) are empty 0-byte files in our copy, so OpenCV decodes no frame; excluded (998 scored). VidProM is non-commercial." + }, + "dataset_source": "tag waverep_vidprom." + }, + { + "name": "EvalCrafter (zero-shot reference)", + "datasets": [ + "EvalCrafter" + ], + "subsets_or_generators": [ + "MoonValley", + "floor33", + "gen2", + "gen2_december", + "hotshot", + "lavie-base", + "lavie-interpolation", + "mix-sr", + "modelscope", + "pika", + "pika_v1_december_1", + "show_1", + "videocrafter-v1.0", + "zeroscope" + ], + "metric": "mean over 14 generators; the fakes of each generator vs the first 1000 GenVideo-Val MSR-VTT reals", + "paper_number": null, + "our_status": "reference", + "our_number": { + "acc": 92.84, + "map": 96.93, + "auroc": 97.17, + "map_real_positive": 97.39, + "per_generator": { + "MoonValley": { + "bacc": 99.17, + "auroc": 99.97, + "n_real": 1000, + "n_fake": 626 + }, + "floor33": { + "bacc": 97.79, + "auroc": 99.74, + "n_real": 1000, + "n_fake": 700 + }, + "gen2": { + "bacc": 99.5, + "auroc": 99.99, + "n_real": 1000, + "n_fake": 681 + }, + "gen2_december": { + "bacc": 99.58, + "auroc": 99.99, + "n_real": 1000, + "n_fake": 699 + }, + "hotshot": { + "bacc": 60.15, + "auroc": 75.95, + "n_real": 1000, + "n_fake": 700 + }, + "lavie-base": { + "bacc": 98.58, + "auroc": 99.83, + "n_real": 1000, + "n_fake": 700 + }, + "lavie-interpolation": { + "bacc": 85.65, + "auroc": 94.3, + "n_real": 1000, + "n_fake": 700 + }, + "mix-sr": { + "bacc": 99.58, + "auroc": 99.99, + "n_real": 1000, + "n_fake": 700 + }, + "modelscope": { + "bacc": 95.29, + "auroc": 99.31, + "n_real": 1000, + "n_fake": 700 + }, + "pika": { + "bacc": 96.57, + "auroc": 99.11, + "n_real": 1000, + "n_fake": 697 + }, + "pika_v1_december_1": { + "bacc": 97.58, + "auroc": 99.42, + "n_real": 1000, + "n_fake": 700 + }, + "show_1": { + "bacc": 79.72, + "auroc": 94.35, + "n_real": 1000, + "n_fake": 700 + }, + "videocrafter-v1.0": { + "bacc": 98.51, + "auroc": 99.81, + "n_real": 1000, + "n_fake": 700 + }, + "zeroscope": { + "bacc": 92.12, + "auroc": 98.68, + "n_real": 1000, + "n_fake": 598 + } + }, + "note": "Zero-shot reference, NOT a paper reproduction. EvalCrafter has no reals of its own: the reals are the first 1000 GenVideo-Val MSR-VTT videos (--limit 1000), the same for every generator." + }, + "dataset_source": "tag waverep_evalcrafter." + }, + { + "name": "The paper's own test set: Allegro, CogVideoX1.5, Open-Sora-Plan, Mochi-1, NOVA, Sora, FLUX vs 300 Panda-70M reals (NOT HELD)", + "datasets": [], + "metric": "balanced accuracy and AUC", + "paper_number": null, + "our_status": "missing", + "our_number": null, + "gap_cause": "NOT HELD: the 2,100 fakes are downloadable from grip.unina.it, but the 300 real clips are Panda-70M YouTube videos that need dataset/script_download_real.py with a YouTube downloader and cookies; not scraped. Without the reals there is no AUC or balanced accuracy, so a fakes-only run would not be the paper's benchmark." + } + ] +} \ No newline at end of file diff --git a/repro/benchmark_specs/waverep_g4.json b/repro/benchmark_specs/waverep_g4.json new file mode 100644 index 0000000000000000000000000000000000000000..0297685798610f9db2d0e75eff6ce11c9930c95a --- /dev/null +++ b/repro/benchmark_specs/waverep_g4.json @@ -0,0 +1,504 @@ +{ + "model": "waverep_g4", + "paper": "Seeing What Matters: Generalizable AI-generated Video Detection with Forensic-Oriented Augmentation (WaveRep, Corvi, Cozzolino, Prashnani, De Mello, Nagano, Verdoliva, NeurIPS 2025, arXiv 2506.16802)", + "arxiv_id": "2506.16802", + "official_repo": "https://github.com/grip-unina/WaveRep-SyntheticVideoDetection", + "training_set_in_paper": "The paper's main detector is trained on ONE generator (Pyramid Flow) and Table 5 adds CogVideoX 1.5, Allegro and Open-Sora Plan. The official demo README only says that weights_dinov2_G1.ckpt (key waverep) is trained on \"a single generator\" and weights_dinov2_G4.ckpt (key waverep_g4, the demo's default) on \"four generators\"; reading G1 as the paper's Pyramid Flow detector and G4 as the Pyramid Flow + CogVideoX 1.5 + Allegro + Open-Sora Plan set of Table 5 is our inference, not stated in the release. Both are the official checkpoints (no training code released for the model; only the augmentation), so there is no SynthScope-trained number. Metrics: balanced accuracy at 0.5 and AUC (Tables 1-2 and 7); video score = mean logit of the first 64 frames, center-cropped to 504 (App. D). The paper's own test set (7 generators vs 300 Panda-70M YouTube reals) is NOT held: the reals need a YouTube downloader and were not scraped. The only paper-comparable numbers here are the paper's 8 GenVideo columns, scored on GenVideo-Val with its own 10,000 reals (the paper does not say which reals it paired). Everything else is a zero-shot reference row, not a paper reproduction. Protocol is the same for every row: official OpenCV reader, first 64 frames, 504 centre crop, mean logit, threshold logit 0; exact parity with the official demo (15 videos / 6 codecs: inputs bit-exact, video logit max diff 6e-7; 180 GenVideo-Val files, both checkpoints: max |logit diff| 1.05e-5, 0 sign flips).", + "benchmarks": [ + { + "name": "GenVideo-Val, the paper's 8 GenVideo generators (reference only: G4 is not the paper's single-generator model)", + "datasets": [ + "GenVideo-Val" + ], + "subsets_or_generators": [ + "Crafter", + "Gen2", + "HotShot", + "LaVie", + "ModelScope", + "MorphStudio", + "Show-1", + "MoonValley" + ], + "metric": "balanced accuracy at 0.5 and AUC, mean over the paper's 8 GenVideo columns (full GenVideo-Val, 64 frames)", + "paper_number": null, + "paper_per_generator": "No paper cell: Table 5 trains G4 on four generators and reports other test sets. The paper's G1 per-generator values are in the waverep spec.", + "our_status": "reference", + "our_number": { + "acc": 96.3, + "auroc": 99.05, + "per_generator": { + "Crafter": { + "bacc": 98.9, + "auc": 99.98, + "n_fake": 1398 + }, + "Gen2": { + "bacc": 98.9, + "auc": 99.99, + "n_fake": 1380 + }, + "HotShot": { + "bacc": 83.4, + "auc": 94.15, + "n_fake": 700 + }, + "LaVie": { + "bacc": 97.33, + "auc": 99.26, + "n_fake": 1400 + }, + "ModelScope": { + "bacc": 97.54, + "auc": 99.69, + "n_fake": 700 + }, + "MorphStudio": { + "bacc": 98.61, + "auc": 99.94, + "n_fake": 700 + }, + "Show-1": { + "bacc": 96.83, + "auc": 99.43, + "n_fake": 700 + }, + "MoonValley": { + "bacc": 98.89, + "auc": 99.98, + "n_fake": 626 + } + }, + "note": "REFERENCE ONLY: G4 is trained on four generators, not the paper's single-generator setting (the paper's G1 values are in the waverep rows). PARTIAL as for G1: GenVideo-Val's own 10,000 reals (the paper's pairing is unstated). Above the paper's G1 on every column but Gen2 AUC, by up to 4.7 bAcc (Show-1)." + }, + "dataset_source": "GenVideo-Val, reals = MSR-VTT; tag waverep_g4_genvideo_full." + }, + { + "name": "GenVideo-Val full, 10 generators (zero-shot reference)", + "datasets": [ + "GenVideo-Val" + ], + "subsets_or_generators": [ + "Crafter", + "Gen2", + "HotShot", + "Lavie", + "ModelScope", + "MoonValley", + "MorphStudio", + "Show_1", + "Sora", + "WildScrape" + ], + "metric": "mean over 10 generators: balanced accuracy at 0.5, AP (fake positive), AUROC; 10,000 reals + all fakes", + "paper_number": null, + "our_status": "reference", + "our_number": { + "acc": 93.28, + "map": 88.88, + "auroc": 96.69, + "map_real_positive": 99.69, + "per_generator": { + "Crafter": { + "bacc": 98.9, + "auroc": 99.98, + "n_real": 10000, + "n_fake": 1398 + }, + "Gen2": { + "bacc": 98.9, + "auroc": 99.99, + "n_real": 10000, + "n_fake": 1380 + }, + "HotShot": { + "bacc": 83.4, + "auroc": 94.15, + "n_real": 10000, + "n_fake": 700 + }, + "Lavie": { + "bacc": 97.33, + "auroc": 99.26, + "n_real": 10000, + "n_fake": 1400 + }, + "ModelScope": { + "bacc": 97.54, + "auroc": 99.69, + "n_real": 10000, + "n_fake": 700 + }, + "MoonValley": { + "bacc": 98.89, + "auroc": 99.98, + "n_real": 10000, + "n_fake": 626 + }, + "MorphStudio": { + "bacc": 98.61, + "auroc": 99.94, + "n_real": 10000, + "n_fake": 700 + }, + "Show_1": { + "bacc": 96.83, + "auroc": 99.43, + "n_real": 10000, + "n_fake": 700 + }, + "Sora": { + "bacc": 76.65, + "auroc": 83.61, + "n_real": 10000, + "n_fake": 56 + }, + "WildScrape": { + "bacc": 85.77, + "auroc": 90.83, + "n_real": 10000, + "n_fake": 924 + } + }, + "note": "Zero-shot reference, NOT a paper reproduction (the 8 paper columns are in the row above; Sora and WildScrape have no paper cell). mAP (fake positive) is low because of the 10,000 : 56-1400 class imbalance; AUROC is not affected the same way." + }, + "dataset_source": "tag waverep_g4_genvideo_full." + }, + { + "name": "GenVideo-Val --limit 1000 (zero-shot reference)", + "datasets": [ + "GenVideo-Val" + ], + "subsets_or_generators": [ + "Crafter", + "Gen2", + "HotShot", + "Lavie", + "ModelScope", + "MoonValley", + "MorphStudio", + "Show_1", + "Sora", + "WildScrape" + ], + "metric": "mean over 10 generators; first 1000 reals and first 1000 fakes per generator (the D3 protocol)", + "paper_number": null, + "our_status": "reference", + "our_number": { + "acc": 92.65, + "map": 94.47, + "auroc": 96.53, + "map_real_positive": 97.33, + "per_generator": { + "Crafter": { + "bacc": 98.3, + "auroc": 99.97, + "n_real": 1000, + "n_fake": 1000 + }, + "Gen2": { + "bacc": 98.35, + "auroc": 99.99, + "n_real": 1000, + "n_fake": 1000 + }, + "HotShot": { + "bacc": 82.83, + "auroc": 93.75, + "n_real": 1000, + "n_fake": 700 + }, + "Lavie": { + "bacc": 96.15, + "auroc": 98.91, + "n_real": 1000, + "n_fake": 1000 + }, + "ModelScope": { + "bacc": 96.97, + "auroc": 99.61, + "n_real": 1000, + "n_fake": 700 + }, + "MoonValley": { + "bacc": 98.32, + "auroc": 99.98, + "n_real": 1000, + "n_fake": 626 + }, + "MorphStudio": { + "bacc": 98.04, + "auroc": 99.93, + "n_real": 1000, + "n_fake": 700 + }, + "Show_1": { + "bacc": 96.26, + "auroc": 99.35, + "n_real": 1000, + "n_fake": 700 + }, + "Sora": { + "bacc": 76.08, + "auroc": 83.28, + "n_real": 1000, + "n_fake": 56 + }, + "WildScrape": { + "bacc": 85.2, + "auroc": 90.55, + "n_real": 1000, + "n_fake": 924 + } + }, + "note": "Zero-shot reference, NOT a paper reproduction: the first 1000 clips per class (--limit 1000), so up to 1000 fakes and exactly 1000 reals per generator." + }, + "dataset_source": "tag waverep_g4_genvideo." + }, + { + "name": "VideoPhy --limit 1000 (zero-shot reference)", + "datasets": [ + "VideoPhy" + ], + "subsets_or_generators": [ + "Dream-Machine", + "Gen-2", + "LaVie", + "OpenSora", + "Pika", + "SVD", + "VideoCrafter2", + "ZeroScope" + ], + "metric": "mean over the 8 generators online; first 1000 reals, up to 1000 fakes per generator", + "paper_number": null, + "our_status": "reference", + "our_number": { + "acc": 95.73, + "map": 98.2, + "auroc": 99.29, + "map_real_positive": 99.74, + "per_generator": { + "Dream-Machine": { + "bacc": 98.4, + "auroc": 100.0, + "n_real": 1000, + "n_fake": 339 + }, + "Gen-2": { + "bacc": 98.4, + "auroc": 100.0, + "n_real": 1000, + "n_fake": 312 + }, + "LaVie": { + "bacc": 98.4, + "auroc": 99.96, + "n_real": 1000, + "n_fake": 343 + }, + "OpenSora": { + "bacc": 83.43, + "auroc": 96.2, + "n_real": 1000, + "n_fake": 344 + }, + "Pika": { + "bacc": 98.4, + "auroc": 99.99, + "n_real": 1000, + "n_fake": 304 + }, + "SVD": { + "bacc": 98.4, + "auroc": 99.99, + "n_real": 1000, + "n_fake": 344 + }, + "VideoCrafter2": { + "bacc": 98.25, + "auroc": 99.96, + "n_real": 1000, + "n_fake": 344 + }, + "ZeroScope": { + "bacc": 92.15, + "auroc": 98.22, + "n_real": 1000, + "n_fake": 344 + } + }, + "note": "Zero-shot reference, NOT a paper reproduction; first 1000 clips per class (--limit 1000); 8 of the 10 VideoPhy generators (dead links skipped). Weakest: OpenSora and ZeroScope." + }, + "dataset_source": "tag waverep_g4_videophy." + }, + { + "name": "VidProM --limit 1000 (zero-shot reference)", + "datasets": [ + "VidProM" + ], + "subsets_or_generators": [ + "ModelScope", + "Pika", + "Text2Video-Zero", + "VideoCrafter2" + ], + "metric": "mean over 4 generators (ModelScope, Pika, Text2Video-Zero, VideoCrafter2); first 1000 clips per class", + "paper_number": null, + "our_status": "reference", + "our_number": { + "acc": 95.8, + "map": 99.29, + "auroc": 99.25, + "map_real_positive": 99.19, + "per_generator": { + "ModelScope": { + "bacc": 89.4, + "auroc": 97.59, + "n_real": 1000, + "n_fake": 1000 + }, + "Pika": { + "bacc": 98.35, + "auroc": 99.98, + "n_real": 1000, + "n_fake": 998 + }, + "Text2Video-Zero": { + "bacc": 97.35, + "auroc": 99.53, + "n_real": 1000, + "n_fake": 1000 + }, + "VideoCrafter2": { + "bacc": 98.1, + "auroc": 99.91, + "n_real": 1000, + "n_fake": 1000 + } + }, + "note": "Zero-shot reference, NOT a paper reproduction; first 1000 clips per class (--limit 1000); 2 Pika fakes (00642, 00891) are empty 0-byte files in our copy, so OpenCV decodes no frame; excluded (998 scored). VidProM is non-commercial." + }, + "dataset_source": "tag waverep_g4_vidprom." + }, + { + "name": "EvalCrafter (zero-shot reference)", + "datasets": [ + "EvalCrafter" + ], + "subsets_or_generators": [ + "MoonValley", + "floor33", + "gen2", + "gen2_december", + "hotshot", + "lavie-base", + "lavie-interpolation", + "mix-sr", + "modelscope", + "pika", + "pika_v1_december_1", + "show_1", + "videocrafter-v1.0", + "zeroscope" + ], + "metric": "mean over 14 generators; the fakes of each generator vs the first 1000 GenVideo-Val MSR-VTT reals", + "paper_number": null, + "our_status": "reference", + "our_number": { + "acc": 96.55, + "map": 99.19, + "auroc": 99.29, + "map_real_positive": 99.35, + "per_generator": { + "MoonValley": { + "bacc": 98.32, + "auroc": 99.98, + "n_real": 1000, + "n_fake": 626 + }, + "floor33": { + "bacc": 98.04, + "auroc": 99.93, + "n_real": 1000, + "n_fake": 700 + }, + "gen2": { + "bacc": 98.25, + "auroc": 99.99, + "n_real": 1000, + "n_fake": 681 + }, + "gen2_december": { + "bacc": 98.4, + "auroc": 100.0, + "n_real": 1000, + "n_fake": 699 + }, + "hotshot": { + "bacc": 82.83, + "auroc": 93.75, + "n_real": 1000, + "n_fake": 700 + }, + "lavie-base": { + "bacc": 98.26, + "auroc": 99.94, + "n_real": 1000, + "n_fake": 700 + }, + "lavie-interpolation": { + "bacc": 95.26, + "auroc": 98.46, + "n_real": 1000, + "n_fake": 700 + }, + "mix-sr": { + "bacc": 98.4, + "auroc": 100.0, + "n_real": 1000, + "n_fake": 700 + }, + "modelscope": { + "bacc": 96.97, + "auroc": 99.61, + "n_real": 1000, + "n_fake": 700 + }, + "pika": { + "bacc": 97.97, + "auroc": 99.92, + "n_real": 1000, + "n_fake": 697 + }, + "pika_v1_december_1": { + "bacc": 98.19, + "auroc": 99.91, + "n_real": 1000, + "n_fake": 700 + }, + "show_1": { + "bacc": 96.26, + "auroc": 99.35, + "n_real": 1000, + "n_fake": 700 + }, + "videocrafter-v1.0": { + "bacc": 98.26, + "auroc": 99.96, + "n_real": 1000, + "n_fake": 700 + }, + "zeroscope": { + "bacc": 96.31, + "auroc": 99.32, + "n_real": 1000, + "n_fake": 598 + } + }, + "note": "Zero-shot reference, NOT a paper reproduction. EvalCrafter has no reals of its own: the reals are the first 1000 GenVideo-Val MSR-VTT videos (--limit 1000), the same for every generator." + }, + "dataset_source": "tag waverep_g4_evalcrafter." + } + ] +} \ No newline at end of file diff --git a/repro/cure_stage1/check_head_features.py b/repro/cure_stage1/check_head_features.py new file mode 100644 index 0000000000000000000000000000000000000000..f3bcabe3e6f209d32dcff58bfdd9adb73ca5fbb5 --- /dev/null +++ b/repro/cure_stage1/check_head_features.py @@ -0,0 +1,80 @@ +"""Debug check (Task 2): why did the stage-3 export check fail for multi_stage23.py's cached head features (r1e0)? +Compares, on the stage-3 export-check images (first 32 reals + first 32 generated of GenImage SD1.4 train), the 1024-d +features from: the cache (head_features.pt), a single encoder on the 64-image batch, a single encoder on LabelledImages +batches of 128, the multi path (all encoders loaded, same order), and the model reloaded from cure_trained.pth. + + python repro/cure_stage1/check_head_features.py --data --out --lora r1e0=

--lora r2e1=

... +""" +import argparse + +import torch +from torch.utils.data import DataLoader, Subset + +from dataset import CuReEndpoints +from models.image.cure.train_stages import LabelledImages, build_model, endpoint_transform + + +def main(): + ap = argparse.ArgumentParser() + ap.add_argument("--data", required=True) + ap.add_argument("--out", default=None, help="the s23_ dir of the FIRST --lora (omit: no cache / export comparison)") + ap.add_argument("--lora", action="append", required=True, help="name=path, in the multi run's order; first = under test") + args = ap.parse_args() + loras = [l.split("=", 1) for l in args.lora] + dev = "cuda" + ep = CuReEndpoints(args.data, "train", endpoint_transform(), None) + n_r = len(ep.reals) + idx = list(range(32)) + [n_r + i for i in range(32)] + if args.out: + zc = torch.load(f"{args.out}/head_features.pt", map_location="cpu", weights_only=True)["z"][idx] + else: + zc = None + probe = torch.stack([ep.load(ep.reals[i]) for i in range(32)] + [ep.load(ep.fakes[i]) for i in range(32)]).to(dev) + + def d(a, b): + if a is None or b is None: + return "n/a" + return f"max|diff| {float((a.float().cpu() - b.float().cpu()).abs().max()):.3e}" + single = build_model(loras[0][1], dev) + with torch.no_grad(): + zs = single.features(probe).float().cpu() + print("single encoder, 64-image batch vs cache:", d(zs, zc), flush=True) + # LabelledImages batches of 128 (the cache's batching): items 0..127 are reals; fakes start at n_r + li = LabelledImages(ep) + with torch.no_grad(): + xb = torch.stack([li[i][0] for i in range(128)]).to(dev) + xf = torch.stack([li[n_r + i][0] for i in range(128)]).to(dev) + zb = torch.cat([single.features(xb)[:32], single.features(xf)[:32]]).float().cpu() + print("single encoder, 128 batches vs cache:", d(zb, zc), "| vs 64 batch:", d(zb, zs), flush=True) + print("probe tensors == LabelledImages tensors:", d(torch.cat([xb[:32], xf[:32]]), probe), flush=True) + models = {k: build_model(p, dev) for k, p in loras} + with torch.no_grad(): + zm = {} + for k, m in models.items(): + zm[k] = torch.cat([m.features(xb)[:32], m.features(xf)[:32]]).float().cpu() + first = loras[0][0] + print(f"multi path ({first}) vs cache:", d(zm[first], zc), "| vs single:", d(zm[first], zb), flush=True) + for k in zm: + print(f" cache vs multi-path encoder {k}:", d(zm[k], zc), flush=True) + check = build_model(None, dev) + if args.out: + st = torch.load(f"{args.out}/cure_trained.pth", map_location="cpu", weights_only=True) + else: + st = {k: v.cpu() for k, v in single.adapter_state_dict().items()} + print("reload:", check.load_state_dict(st, strict=False).unexpected_keys, flush=True) + with torch.no_grad(): + zr = check.features(probe).float().cpu() + print("reloaded model vs cache:", d(zr, zc), "| vs single:", d(zr, zs), flush=True) + lt = {k: v for k, v in st.items() if "lora_" in k} + ls = {k: v for k, v in single.state_dict().items() if "lora_" in k} + print("LoRA tensors in cure_trained.pth vs --lora file:", max(float((lt[k].float() - ls[k].float().cpu()).abs().max()) for k in lt), flush=True) + if args.out: + W, mu, hw, hb = st["W"].float(), st["mu"].float(), st["head.weight"].float(), st["head.bias"].float() + logit = lambda z: ((z - mu) @ W) @ hw.T + hb + print("logits: cache vs reloaded", d(logit(zc), logit(zr)), "| |logit| max", float(logit(zc).abs().max()), + "| head |w| max", float(hw.abs().max()), flush=True) + print("feature scale: |z| max", float(zs.abs().max()), "mean |z|", float(zs.abs().mean()), flush=True) + + +if __name__ == "__main__": + main() diff --git a/repro/cure_stage1/epoch_select.py b/repro/cure_stage1/epoch_select.py new file mode 100644 index 0000000000000000000000000000000000000000..181ec017ab557784fa01bdd5840961673ffa5ef4 --- /dev/null +++ b/repro/cure_stage1/epoch_select.py @@ -0,0 +1,176 @@ +"""CuRe stage-1 investigation, Task 2: per-epoch selection numbers for the R1 / R2 stage-1 retrains (and reference rows +for the released encoder, the frozen base and our original run), on NON-benchmark data only. + +PRE-REGISTERED SELECTION RULE (fixed before any R1 / R2 epoch was scored; plans/2026-11-09-cure-stage1-investigation.md, +Task 2 ruling): for R1 (and, by the same rule, R3: --select-prefix r3e), the selected epoch is the one with the highest + select_score = mean( Synthbuster bacc of the stage-1 ratio head used directly (threshold 0.5), + Synthbuster bacc of the SD1.4-fitted linear probe (logistic regression, C = 1, threshold 0.5) ) +where "Synthbuster" = the 1287 Synthbuster fakes (143 per generator, every 7th file; not a CuRe paper benchmark) scored +together with the 2000 SD1.4-test reals; ties within 0.5 points go to the EARLIER epoch. R2 uses its final epoch (ruling). +Reported for every epoch but not used in the rule: the LoRA update norm (total ||2 B A||_F, and its ratio to the released +adapter's), the SD1.4 mixing fit (excess BCE over the floor of a fresh linear ratio head and of the run's own ratio head +on the 2000 SD1.4-test "after" mixtures), the SD1.4-test bacc, and WildRF (DIAGNOSTIC ONLY, never used for selection). + + python repro/cure_stage1/epoch_select.py --enc released= --enc r1e0= ... \ + --train-dir ... --test-dir ... --wild-dir ... --extra-fake-dir ... --out

+ +Features are cached per encoder in ``/feat_.pt`` (a rerun encodes only new encoders); the numbers go to +``/epoch_select.json``. The image sets and mixing pairs are exactly those of ``feature_diag.py`` (same seed). +""" +import argparse +import json +import time +from pathlib import Path + +import numpy as np +import torch +from sklearn.linear_model import LogisticRegression +from sklearn.preprocessing import StandardScaler +from torch.utils.data import DataLoader + +from models.image.cure.train_stages import build_model +from repro.cure_stage1.feature_diag import Jobs, list_images +from repro.cure_stage1.feature_analysis import apply_head, binary_metrics, fit_ratio_head, ratio_metrics + +SCALE = 2.0 +RELEASED_TOTAL_DW = None # computed from --enc released + + +def build_sets(args): + tr_r, tr_f = list_images(Path(args.train_dir) / "real"), list_images(Path(args.train_dir) / "fake") + te_r, te_f = list_images(Path(args.test_dir) / "real"), list_images(Path(args.test_dir) / "fake") + wild = [(p, 0 if "0_real" in p.parts else 1) for p in list_images(args.wild_dir)] + extra = list_images(args.extra_fake_dir) + g = torch.Generator().manual_seed(1234) # feature_diag.py's seed and draw order (mix_train, then mix_val) + meta, jobs = {}, [] + + def add(name, js, **cols): + meta[name] = {"start": len(jobs), "n": len(js), **cols} + jobs.extend(js) + add("train_clean", [("clean", p) for p in tr_r + tr_f], label=[0] * len(tr_r) + [1] * len(tr_f)) + add("test_clean", [("clean", p) for p in te_r + te_f], label=[0] * len(te_r) + [1] * len(te_f)) + for split, (R, F_, n) in {"mix_train": (tr_r, tr_f, 4000), "mix_val": (te_r, te_f, 2000)}.items(): + ri = torch.randint(len(R), (n,), generator=g).tolist() + fi = torch.randint(len(F_), (n,), generator=g).tolist() + al = torch.rand(n, generator=g, dtype=torch.float64).tolist() + add(f"{split}_after", [("mix", R[a], F_[b], c, "after") for a, b, c in zip(ri, fi, al)], alpha=al) + add("wild", [("clean", w[0]) for w in wild], label=[w[1] for w in wild]) + add("synthbuster_fake", [("clean", p) for p in extra], label=[1] * len(extra), + generator=[p.relative_to(args.extra_fake_dir).parts[0] for p in extra]) + return meta, jobs, len(te_r) + + +def lora_total_dw(path): + st = torch.load(path, map_location="cpu", weights_only=True, mmap=True) + st = st.get("model", st) + tot = 0.0 + for layer in range(24): + for proj in "qv": + p = f"backbone.transformer.resblocks.{layer}.attn.lora_" + tot += float((SCALE * st[p + f"B_{proj}"].double() @ st[p + f"A_{proj}"].double()).norm() ** 2) + ratio = (st["ratio_head.weight"].float().view(-1), st["ratio_head.bias"].float().view(())) if "ratio_head.weight" in st else None + return tot ** 0.5, ratio + + +def main(): + ap = argparse.ArgumentParser() + ap.add_argument("--enc", action="append", required=True, help="name=path (LoRA source; 'base' = no LoRA)") + ap.add_argument("--train-dir", required=True) + ap.add_argument("--test-dir", required=True) + ap.add_argument("--wild-dir", required=True) + ap.add_argument("--extra-fake-dir", required=True) + ap.add_argument("--out", required=True) + ap.add_argument("--json", default="epoch_select.json", help="result file name inside --out") + ap.add_argument("--select-prefix", default="r1e", help="apply the selection rule to the encoders named ") + ap.add_argument("--bs", type=int, default=32) + ap.add_argument("--workers", type=int, default=12) + args = ap.parse_args() + out = Path(args.out) + out.mkdir(parents=True, exist_ok=True) + encs = dict(e.split("=", 1) for e in args.enc) + meta, jobs, n_te_r = build_sets(args) + print(f"[sel] {len(jobs)} images: " + ", ".join(f"{k} {v['n']}" for k, v in meta.items()), flush=True) + + todo = [k for k in encs if not (out / f"feat_{k}.pt").is_file()] + if todo: + models = {k: build_model(None if encs[k] == "base" else encs[k], "cuda") for k in todo} + feats = {k: torch.zeros(len(jobs), 1024, dtype=torch.float16) for k in todo} + loader = DataLoader(Jobs(jobs), batch_size=args.bs, shuffle=False, num_workers=args.workers, pin_memory=True) + t0 = time.time() + with torch.no_grad(): + for step, (x, idx) in enumerate(loader): + x = x.cuda(non_blocking=True) + for k, m in models.items(): + feats[k][idx] = m.features(x).half().cpu() + if step % 100 == 0: + print(f"[sel] {(step + 1) * args.bs}/{len(jobs)} {(step + 1) * args.bs / (time.time() - t0):.1f} img/s", flush=True) + for k in todo: + assert torch.isfinite(feats[k].float()).all(), k + torch.save({"features": feats[k], "n": len(jobs)}, out / f"feat_{k}.pt") + del models + + def blk(F, name): + m = meta[name] + return F[m["start"]:m["start"] + m["n"]].float() + y_tr = np.asarray(meta["train_clean"]["label"]) + y_te = np.asarray(meta["test_clean"]["label"]) + y_wild = np.asarray(meta["wild"]["label"]) + n_sb = meta["synthbuster_fake"]["n"] + y_sb = np.r_[np.zeros(n_te_r), np.ones(n_sb)] + a_tr, a_va = torch.tensor(meta["mix_train_after"]["alpha"]), torch.tensor(meta["mix_val_after"]["alpha"]) + rel_dw = lora_total_dw(encs["released"])[0] if "released" in encs and encs["released"] != "base" else None + res = {"rule": "select_score = mean(Synthbuster bacc of the stage-1 ratio head direct, Synthbuster bacc of the SD1.4 " + "linear probe); argmax over R1 epochs, ties within 0.5 -> earlier epoch; R2: final epoch", + "released_total_dW": rel_dw, "rows": {}} + for k, path in encs.items(): + Fk = torch.load(out / f"feat_{k}.pt", weights_only=False)["features"] + row = {} + if path != "base": + dw, ratio = lora_total_dw(path) + row["total_dW"] = round(dw, 4) + if rel_dw: + row["dW_over_released"] = round(dw / rel_dw, 3) + else: + ratio = None + head = fit_ratio_head(blk(Fk, "mix_train_after"), a_tr) + row["mix_fit_fresh_head"] = ratio_metrics(apply_head(head, blk(Fk, "mix_val_after")), a_va, True) + sb_X = torch.cat([blk(Fk, "test_clean")[:n_te_r], blk(Fk, "synthbuster_fake")]) + sc = StandardScaler().fit(blk(Fk, "train_clean").numpy()) + clf = LogisticRegression(C=1.0, max_iter=3000).fit(sc.transform(blk(Fk, "train_clean").numpy()), y_tr) + probe = lambda X: clf.predict_proba(sc.transform(X.numpy()))[:, 1] + row["probe_sd14_test"] = binary_metrics(probe(blk(Fk, "test_clean")), y_te) + row["probe_synthbuster"] = binary_metrics(probe(sb_X), y_sb) + row["probe_wildrf_DIAGNOSTIC"] = binary_metrics(probe(blk(Fk, "wild")), y_wild) + if ratio is not None: # the run's own stage-1 ratio head, used directly (paper Table 4 "Direct") + w, b = ratio + direct = lambda X: torch.sigmoid(X @ w + b).numpy() + row["mix_fit_own_head"] = ratio_metrics(blk(Fk, "mix_val_after") @ w + b, a_va, False) + tag = "own" + else: # released / base have no ratio head: the fresh head (reference rows only) + direct = lambda X: apply_head(head, X).numpy() + tag = "fresh" + row["direct_head"] = tag + row["direct_sd14_test"] = binary_metrics(direct(blk(Fk, "test_clean")), y_te) + row["direct_synthbuster"] = binary_metrics(direct(sb_X), y_sb) + row["direct_wildrf_DIAGNOSTIC"] = binary_metrics(direct(blk(Fk, "wild")), y_wild) + row["select_score"] = round((row["direct_synthbuster"]["bacc"] + row["probe_synthbuster"]["bacc"]) / 2, 3) + res["rows"][k] = row + print(f"[sel] {k:10s} dW {row.get('total_dW', '-')} ({row.get('dW_over_released', '-')}x rel) | mix excess fresh " + f"{row['mix_fit_fresh_head']['excess_bce']} own {row.get('mix_fit_own_head', {}).get('excess_bce', '-')} | " + f"SB direct {row['direct_synthbuster']['bacc']} probe {row['probe_synthbuster']['bacc']} -> score " + f"{row['select_score']} | SD14 direct {row['direct_sd14_test']['bacc']} | WildRF(diag) direct " + f"{row['direct_wildrf_DIAGNOSTIC']['bacc']} probe {row['probe_wildrf_DIAGNOSTIC']['bacc']}", flush=True) + # the pre-registered rule, applied to the epochs of the run named by --select-prefix (r1e: R1; r3e: R3, same rule) + cand = sorted(k for k in res["rows"] if k.startswith(args.select_prefix)) + if cand: + best = max(res["rows"][k]["select_score"] for k in cand) + sel = next(k for k in cand if res["rows"][k]["select_score"] >= best - 0.5) + res["selected"] = sel + res[f"{args.select_prefix[:-1]}_selected"] = sel + print(f"[sel] {args.select_prefix[:-1].upper()} selected (pre-registered rule): {sel}", flush=True) + with open(out / args.json, "w") as f: + json.dump(res, f, indent=1) + + +if __name__ == "__main__": + main() diff --git a/repro/cure_stage1/feature_analysis.py b/repro/cure_stage1/feature_analysis.py new file mode 100644 index 0000000000000000000000000000000000000000..d4f09b1351c9f0d84eaf28650d6778429ad3c077 --- /dev/null +++ b/repro/cure_stage1/feature_analysis.py @@ -0,0 +1,283 @@ +"""CuRe stage-1 investigation (Task 1): analysis of the features saved by ``feature_diag.py`` (CPU). + +1. Ratio regression with a FRESH linear ratio head per encoder and per mixing variant (after / before / noq70): fit on + mix_train (BCE with the soft target a, L2 1e-4 on standardised features, fixed a priori), report on mix_val the BCE, + its excess over the floor (the mean binary entropy of the val ratios, reached by a perfect predictor), MAE and + Pearson / Spearman correlation. Also our trained stage-1 ratio head as is. +2. Linear-probe separability (real vs generated endpoints): logistic regression (C = 1, standardised; fixed) fitted on + train_clean, evaluated on test_clean, the perturbed test copies and the wild set (diagnostic only); plus a 5-fold + CV probe fitted on the wild set itself (intrinsic separability, diagnostic only). +3. Detector scores at the 0.5 threshold: the released detector (released LoRA + its mu / W / head), our detector (our + LoRA + our stage-2/3 mu / W / head), our stage-1 ratio head used directly (paper Table 4 "Direct"), and a fresh ratio + head (fitted in 1. on the "after" variant) used directly, for every encoder. +4. Feature geometry: drift from the frozen base (cosine, relative L2), the real-vs-generated mean-difference direction + (cosine between encoders, Cohen's d along it on test / wild), linear CKA between encoders, and the relative feature + change under each perturbation. + +Nothing here selects or tunes anything; every hyper-parameter is fixed above. +""" +import argparse +import json +import math + +import numpy as np +import torch +import torch.nn.functional as F +from scipy.stats import pearsonr, spearmanr +from sklearn.linear_model import LogisticRegression +from sklearn.metrics import roc_auc_score +from sklearn.model_selection import StratifiedKFold +from sklearn.preprocessing import StandardScaler + +ENCODERS = ("base", "released", "ours") +VARIANTS = ("after", "before", "noq70") +PERTS = ("jpeg50", "blur1", "blur2", "resize05") + + +def block(data, name, enc): + m = data["meta"][name] + return data["features"][enc][m["start"]:m["start"] + m["n"]].float() + + +def binary_metrics(score, label, thr=0.5): + score, label = np.asarray(score, dtype=np.float64), np.asarray(label) + pred = score >= thr + real_acc = float((~pred[label == 0]).mean()) if (label == 0).any() else float("nan") + fake_rec = float(pred[label == 1].mean()) if (label == 1).any() else float("nan") + out = {"real_acc": real_acc, "fake_recall": fake_rec, "bacc": (real_acc + fake_rec) / 2} + out["auroc"] = float(roc_auc_score(label, score)) if len(set(label.tolist())) == 2 else float("nan") + out["mean_score_real"] = float(score[label == 0].mean()) if (label == 0).any() else float("nan") + out["mean_score_fake"] = float(score[label == 1].mean()) if (label == 1).any() else float("nan") + return {k: round(v * 100, 2) if k in ("real_acc", "fake_recall", "bacc", "auroc") else round(v, 4) for k, v in out.items()} + + +def fit_ratio_head(X, a, l2=1e-4, iters=500): + """Linear head on standardised X, BCE with soft target a; returns (mean, std, w, b).""" + mu, sd = X.mean(0), X.std(0) + 1e-6 + Z = (X - mu) / sd + w = torch.zeros(X.shape[1], dtype=torch.float64, requires_grad=True) + b = torch.zeros((), dtype=torch.float64, requires_grad=True) + Z, a = Z.double(), a.double() + opt = torch.optim.LBFGS([w, b], lr=1, max_iter=iters, history_size=20, line_search_fn="strong_wolfe") + + def closure(): + opt.zero_grad() + loss = F.binary_cross_entropy_with_logits(Z @ w + b, a) + 0.5 * l2 * w.pow(2).sum() + loss.backward() + return loss + opt.step(closure) + return mu.double(), sd.double(), w.detach(), b.detach() + + +def apply_head(head, X): + mu, sd, w, b = head + return torch.sigmoid(((X.double() - mu) / sd) @ w + b) + + +def ratio_metrics(pred_logit_or_prob, a, is_prob): + a = a.double() + if is_prob: + p = pred_logit_or_prob.double().clamp(1e-7, 1 - 1e-7) + bce = float(F.binary_cross_entropy(p, a)) + else: + p = torch.sigmoid(pred_logit_or_prob.double()) + bce = float(F.binary_cross_entropy_with_logits(pred_logit_or_prob.double(), a)) + ac = a.clamp(1e-12, 1 - 1e-12) + floor = float((-(ac * ac.log() + (1 - ac) * (1 - ac).log())).mean()) + return {"bce": round(bce, 5), "excess_bce": round(bce - floor, 5), "floor": round(floor, 5), + "mae": round(float((p - a).abs().mean()), 4), "pearson": round(float(pearsonr(p.numpy(), a.numpy())[0]), 4), + "spearman": round(float(spearmanr(p.numpy(), a.numpy())[0]), 4)} + + +def linear_cka(X, Y): + X, Y = X.double() - X.double().mean(0), Y.double() - Y.double().mean(0) + return float((Y.T @ X).norm() ** 2 / ((X.T @ X).norm() * (Y.T @ Y).norm())) + + +def cohen_d(proj, label): + r, f = proj[label == 0], proj[label == 1] + pooled = math.sqrt((r.var() + f.var()) / 2) + return float((f.mean() - r.mean()) / pooled) + + +def main(): + ap = argparse.ArgumentParser() + ap.add_argument("--features", required=True) + ap.add_argument("--released", required=True, help="released cure_adapter.pt (mu / W / head)") + ap.add_argument("--ours-stage1", required=True, help="our stage-1 model_last.pth (ratio_head)") + ap.add_argument("--ours-adapter", required=True, help="our cure_trained.pth (mu / W / head)") + ap.add_argument("--extra", default=None, help="features_extra.pt (extra_fake set, scored against the test_clean reals)") + ap.add_argument("--aug", nargs="*", default=[], help="features_aug.pt (test_jpeg95 + mix_val_aug_* sets), features_native.pt") + ap.add_argument("--out", required=True) + args = ap.parse_args() + data = torch.load(args.features, map_location="cpu", weights_only=False) + meta = data["meta"] + if args.extra: + ex = torch.load(args.extra, map_location="cpu", weights_only=False) + tc = meta["test_clean"] + n_r = sum(1 for v in tc["label"] if v == 0) + # extra_vs_real: the test_clean reals followed by the extra fakes (one contiguous block appended to the features) + reals = {k: data["features"][k][tc["start"]:tc["start"] + n_r] for k in ENCODERS} + base_n = data["features"]["base"].shape[0] + for k in ENCODERS: + data["features"][k] = torch.cat([data["features"][k], reals[k], ex["features"][k]]) + em = ex["meta"]["extra_fake"] + meta["extra_vs_real"] = {"start": base_n, "n": n_r + em["n"], "label": [0] * n_r + em["label"], + "generator": ["real"] * n_r + em["generator"]} + for aug_path in args.aug: + ag = torch.load(aug_path, map_location="cpu", weights_only=False) + off = data["features"]["base"].shape[0] + for k in ENCODERS: + data["features"][k] = torch.cat([data["features"][k], ag["features"][k]]) + for name, m in ag["meta"].items(): + meta[name] = {**m, "start": m["start"] + off} + res = {"counts": {k: v["n"] for k, v in meta.items()}} + + # ---- 1. ratio regression + s1 = torch.load(args.ours_stage1, map_location="cpu", weights_only=True, mmap=True) + s1 = s1.get("model", s1) + rw, rb = s1["ratio_head.weight"].float().view(-1), s1["ratio_head.bias"].float().view(()) + ratio, heads = {}, {} + variants = [v for v in VARIANTS + ("native",) if f"mix_train_{v}" in meta] + for enc in ENCODERS: + for v in variants: + Xtr, atr = block(data, f"mix_train_{v}", enc), torch.tensor(meta[f"mix_train_{v}"]["alpha"]) + Xva, ava = block(data, f"mix_val_{v}", enc), torch.tensor(meta[f"mix_val_{v}"]["alpha"]) + head = fit_ratio_head(Xtr, atr) + heads[(enc, v)] = head + ratio[f"{enc}/{v}/fresh_head_val"] = ratio_metrics(apply_head(head, Xva), ava, True) + ratio[f"{enc}/{v}/fresh_head_train"] = ratio_metrics(apply_head(head, Xtr), atr, True) + if enc == "ours": + ratio[f"ours/{v}/trained_ratio_head_val"] = ratio_metrics(Xva @ rw + rb, ava, False) + # cross-variant transfer of the head fitted on "after" + for v in variants[1:]: + Xva, ava = block(data, f"mix_val_{v}", enc), torch.tensor(meta[f"mix_val_{v}"]["alpha"]) + ratio[f"{enc}/head_after_on_{v}_val"] = ratio_metrics(apply_head(heads[(enc, "after")], Xva), ava, True) + for enc in ENCODERS: + for k in ("gray", "blur1", "jpeg60"): + if f"mix_val_aug_{k}" in meta: + Xa, aa = block(data, f"mix_val_aug_{k}", enc), torch.tensor(meta[f"mix_val_aug_{k}"]["alpha"]) + ratio[f"{enc}/head_after_on_aug_{k}_val"] = ratio_metrics(apply_head(heads[(enc, "after")], Xa), aa, True) + if enc == "ours": + ratio[f"ours/trained_ratio_head_on_aug_{k}_val"] = ratio_metrics(Xa @ rw + rb, aa, False) + res["ratio_regression"] = ratio + + # ---- 2. linear probes + EVAL = ["test_clean", "wild"] + [f"test_{k}" for k in PERTS] + (["extra_vs_real"] if "extra_vs_real" in meta else []) + lab = {n: np.asarray(meta[n]["label"]) for n in ["train_clean"] + EVAL} + probes = {} + for enc in ENCODERS: + sc = StandardScaler().fit(block(data, "train_clean", enc).numpy()) + clf = LogisticRegression(C=1.0, max_iter=3000).fit(sc.transform(block(data, "train_clean", enc).numpy()), lab["train_clean"]) + for n in EVAL: + probes[f"{enc}/genimage_probe_on_{n}"] = binary_metrics(clf.predict_proba(sc.transform(block(data, n, enc).numpy()))[:, 1], lab[n]) + Xw, yw = block(data, "wild", enc).numpy(), lab["wild"] + scores = np.zeros(len(yw)) + for tr, te in StratifiedKFold(5, shuffle=True, random_state=0).split(Xw, yw): + s = StandardScaler().fit(Xw[tr]) + scores[te] = LogisticRegression(C=1.0, max_iter=3000).fit(s.transform(Xw[tr]), yw[tr]).predict_proba(s.transform(Xw[te]))[:, 1] + probes[f"{enc}/wild_5fold_cv_probe"] = binary_metrics(scores, yw) + res["linear_probes"] = probes + + # ---- 3. detectors + def subspace_scorer(adapter_path): + st = torch.load(adapter_path, map_location="cpu", weights_only=True) + W = st["W"].float() + W = W if W.shape[0] == 1024 else W.T + mu, hw, hb = st["mu"].float(), st["head.weight"].float(), st["head.bias"].float() + return lambda X: torch.softmax(((X - mu) @ W) @ hw.T + hb, dim=1)[:, 1] + det_rel, det_ours = subspace_scorer(args.released), subspace_scorer(args.ours_adapter) + dets = {} + for n in EVAL: + dets[f"released_detector/{n}"] = binary_metrics(det_rel(block(data, n, "released")).numpy(), lab[n]) + dets[f"ours_detector/{n}"] = binary_metrics(det_ours(block(data, n, "ours")).numpy(), lab[n]) + dets[f"ours_stage1_ratio_head_direct/{n}"] = binary_metrics(torch.sigmoid(block(data, n, "ours") @ rw + rb).numpy(), lab[n]) + for enc in ENCODERS: + dets[f"{enc}_fresh_ratio_head_after_direct/{n}"] = binary_metrics(apply_head(heads[(enc, "after")], block(data, n, enc)).numpy(), lab[n]) + plat = np.asarray(meta["wild"]["platform"]) + for p in sorted(set(plat.tolist())): + sel = plat == p + dets[f"released_detector/wild_{p}"] = binary_metrics(det_rel(block(data, "wild", "released")).numpy()[sel], lab["wild"][sel]) + dets[f"ours_detector/wild_{p}"] = binary_metrics(det_ours(block(data, "wild", "ours")).numpy()[sel], lab["wild"][sel]) + if "extra_vs_real" in meta: + gen = np.asarray(meta["extra_vs_real"]["generator"]) + y = lab["extra_vs_real"] + sr = det_rel(block(data, "extra_vs_real", "released")).numpy() + so = det_ours(block(data, "extra_vs_real", "ours")).numpy() + for gname in sorted(set(gen.tolist()) - {"real"}): + sel = (gen == gname) | (gen == "real") + dets[f"released_detector/extra_{gname}"] = binary_metrics(sr[sel], y[sel]) + dets[f"ours_detector/extra_{gname}"] = binary_metrics(so[sel], y[sel]) + res["detectors"] = dets + + # ---- 4. geometry + geo = {} + Tb = block(data, "test_clean", "base") + for enc in ("released", "ours"): + T = block(data, "test_clean", enc) + cos = F.cosine_similarity(T, Tb, dim=1) + rel = (T - Tb).norm(dim=1) / Tb.norm(dim=1) + y = lab["test_clean"] + geo[f"{enc}/drift_from_base"] = {"cos_real": round(float(cos[y == 0].mean()), 4), "cos_fake": round(float(cos[y == 1].mean()), 4), + "relL2_real": round(float(rel[y == 0].mean()), 4), "relL2_fake": round(float(rel[y == 1].mean()), 4)} + dirs = {} + for enc in ENCODERS: + X, y = block(data, "train_clean", enc), lab["train_clean"] + d = X[y == 1].mean(0) - X[y == 0].mean(0) + dirs[enc] = d / d.norm() + geo[f"{enc}/mean_diff_norm_train"] = round(float(d.norm()), 4) + for n in ["train_clean"] + EVAL: + geo[f"{enc}/cohen_d_along_train_meandiff/{n}"] = round(cohen_d((block(data, n, enc) @ dirs[enc]).numpy(), lab[n]), 3) + geo["cos_meandiff_released_ours"] = round(float(dirs["released"] @ dirs["ours"]), 4) + geo["cos_meandiff_released_base"] = round(float(dirs["released"] @ dirs["base"]), 4) + geo["cos_meandiff_ours_base"] = round(float(dirs["ours"] @ dirs["base"]), 4) + for a, b in (("released", "ours"), ("released", "base"), ("ours", "base")): + geo[f"cka_test_clean/{a}_vs_{b}"] = round(linear_cka(block(data, "test_clean", a), block(data, "test_clean", b)), 4) + geo[f"cka_wild/{a}_vs_{b}"] = round(linear_cka(block(data, "wild", a), block(data, "wild", b)), 4) + n_r = sum(1 for v in meta["test_clean"]["label"] if v == 0) + for k in PERTS: + npert = meta[f"test_{k}"]["n"] // 2 + idx = list(range(npert)) + [n_r + i for i in range(npert)] + for enc in ENCODERS: + C, P = block(data, "test_clean", enc)[idx], block(data, f"test_{k}", enc) + geo[f"{enc}/rel_feature_change/{k}"] = round(float(((P - C).norm(dim=1) / C.norm(dim=1)).mean()), 4) + # stage-2 mean mu under mixing after / before q70 vs the released mu (paired: same pairs and grid) + st = torch.load(args.released, map_location="cpu", weights_only=True) + mu_rel = st["mu"].double() + for enc in ENCODERS: + for v in ("after", "before"): + X = block(data, f"rf_grid_{v}", enc).double() + pair = torch.tensor(meta[f"rf_grid_{v}"]["pair"]) + mu = X.mean(0) + h1, h2 = X[pair % 2 == 0].mean(0), X[pair % 2 == 1].mean(0) + geo[f"{enc}/stage2_mu_{v}"] = {"rel_dist_to_released_mu_pct": round(float((mu - mu_rel).norm() / mu_rel.norm() * 100), 4), + "cos_to_released_mu": round(float(F.cosine_similarity(mu, mu_rel, dim=0)), 7), + "split_half_rel_dist_pct": round(float((h1 - h2).norm() / mu_rel.norm() * 100), 4)} + Xa, Xb = block(data, "rf_grid_after", enc).double(), block(data, "rf_grid_before", enc).double() + geo[f"{enc}/stage2_mu_after_vs_before_rel_dist_pct"] = round(float((Xa.mean(0) - Xb.mean(0)).norm() / mu_rel.norm() * 100), 4) + # paper Fig. 2 "format" groups: the same test images at JPEG q95 vs q50; how linearly separable is the JPEG quality + if "test_jpeg95" in meta: + from sklearn.model_selection import GroupKFold + n = meta["test_jpeg95"]["n"] + for enc in ENCODERS: + X = torch.cat([block(data, "test_jpeg95", enc), block(data, "test_jpeg50", enc)]).numpy() + y = np.r_[np.zeros(n), np.ones(n)] + grp = np.r_[np.arange(n), np.arange(n)] + sc_ = np.zeros(2 * n) + for tr, te in GroupKFold(5).split(X, y, grp): + s_ = StandardScaler().fit(X[tr]) + sc_[te] = LogisticRegression(C=1.0, max_iter=3000).fit(s_.transform(X[tr]), y[tr]).predict_proba(s_.transform(X[te]))[:, 1] + geo[f"{enc}/format_probe_q95_vs_q50_5fold"] = binary_metrics(sc_, y) + d = X[y == 1].mean(0) - X[y == 0].mean(0) + rf = block(data, "train_clean", enc) + lab_tr = np.asarray(meta["train_clean"]["label"]) + dsrc = (rf[lab_tr == 1].mean(0) - rf[lab_tr == 0].mean(0)).numpy() + geo[f"{enc}/format_shift_norm_over_source_shift_norm"] = round(float(np.linalg.norm(d) / np.linalg.norm(dsrc)), 4) + res["geometry"] = geo + with open(args.out, "w") as f: + json.dump(res, f, indent=1) + print(json.dumps(res, indent=1)) + + +if __name__ == "__main__": + main() diff --git a/repro/cure_stage1/feature_diag.py b/repro/cure_stage1/feature_diag.py new file mode 100644 index 0000000000000000000000000000000000000000..d4bba6c3c6458b283031a4c868c9359a7a050754 --- /dev/null +++ b/repro/cure_stage1/feature_diag.py @@ -0,0 +1,280 @@ +"""CuRe stage-1 investigation (Task 1, diagnostics 1 and 2): encode one fixed set of images with three frozen encoders +(PE Core base without LoRA, the released stage-1 LoRA, our trained stage-1 LoRA) and save the 1024-d features. The +analysis (fresh ratio heads, linear probes, detector scores, drift) is ``feature_analysis.py`` on the saved file. + +Image sets (all labelled; none is used to tune or select anything): + train_clean GenImage SD v1.4 train subset, clean endpoints (the official test-time pipeline) -> probe fitting + test_clean GenImage SD v1.4 test subset, clean endpoints -> held-out val + test_pert the first ``--n-pert`` reals and fakes of test_clean under one perturbation each (JPEG q50, Gaussian + blur sigma 1 / 2, bicubic x0.5), applied to the format-aligned image BEFORE the pipeline, as the paper's + robustness protocol ("before method-specific preprocessing") + mix_train / mix_val pixel mixtures x_a = (1 - a) x_r + a x_g, a ~ U(0, 1), of random real / generated pairs (train + subset / test subset), each pair in three preprocessing variants: + after mix the two preprocessed endpoints after the final JPEG q70 (our stage-1 recipe) + before mix the resized uint8 endpoints, round, then JPEG q70 on the mixture, then normalise + noq70 mix the resized endpoints, no JPEG q70 at all + native (``--only-native`` run -> features_native.pt) DDA's ``pixel_blend_mix``: the format-aligned generated + image resized to the real image's size (LANCZOS), blended at native resolution in float, clipped + and truncated to uint8, then the whole pipeline (390 / crop / 336 / q70) on the mixture + rf_grid_after / rf_grid_before ``--n-rf-grid`` real->generated trajectories on the stage-2 grid {0, .2, ..., 1} + (mixing after / before q70): the stage-2 mean mu of each variant is compared with the released mu + wild a small in-the-wild set (WildRF test), a DIAGNOSTIC ONLY, never used for selection + extra_fake (``--only-extra``, a separate run -> features_extra.pt) generated images of ``--extra-fake-dir`` + (/1_fake; Synthbuster, not a CuRe paper benchmark), scored against the test_clean reals + aug sets (``--only-aug``, a separate run -> features_aug.pt) test_jpeg95: the n_pert test images JPEG q95 (with + test_jpeg50 the paper's Fig. 2 "format" groups q95 / q50); mix_val_aug_: the mix_val pairs and ratios + ("after" variant) with both endpoints perturbed first (k = gray, blur1, jpeg60), to compare how the + ratio read-out of each encoder degrades under training-style augmentations + +The pipeline is the official ``cure/preprocess.py`` (PNG source -> JPEG q96; SmallestMaxSize 390 cubic; CenterCrop 390; +Resize 336 cubic; JPEG q70; mean = std = 0.5), split into its steps here so the mixture can be placed before or after +the q70 step; at start-up the split pipeline is checked bit-exact against ``CuReTransform``. +""" +import argparse +import io +import json +import time +from pathlib import Path + +import cv2 +import numpy as np +import torch +from PIL import Image +from torch.utils.data import DataLoader, Dataset + +from models.image.cure.preprocess import CuReTransform, SRC_FORMAT_KEY +from models.image.cure.train_stages import build_model + +EXTS = {".jpg", ".jpeg", ".png", ".webp", ".bmp", ".tif", ".tiff", ".jfif"} +VARIANTS = ("after", "before", "noq70") +PERTS = ("jpeg50", "blur1", "blur2", "resize05") +GRID = (0.0, 0.2, 0.4, 0.6, 0.8, 1.0) + + +def list_images(d): + return sorted(p for p in Path(d).rglob("*") if p.is_file() and p.suffix.lower() in EXTS) + + +def load_aligned(path): + """Decode -> RGB; a PNG source is re-encoded as JPEG q96 (the paper's format alignment / official step 1).""" + with Image.open(path) as src: + fmt = src.format + img = src.convert("RGB") + img.load() + if fmt == "PNG": + buf = io.BytesIO() + img.save(buf, format="JPEG", quality=96) + buf.seek(0) + with Image.open(buf) as dec: + img = dec.convert("RGB") + img.load() + return img + + +def geom(img): + """SmallestMaxSize(390, cubic) -> CenterCrop(390) -> Resize(336, cubic): uint8 [336, 336, 3].""" + arr = np.asarray(img) + h, w = arr.shape[:2] + s = 390 / min(h, w) + nh, nw = max(1, round(h * s)), max(1, round(w * s)) + if (nh, nw) != (h, w): + arr = cv2.resize(arr, (nw, nh), interpolation=cv2.INTER_CUBIC) + top, left = (arr.shape[0] - 390) // 2, (arr.shape[1] - 390) // 2 + arr = np.ascontiguousarray(arr[top:top + 390, left:left + 390]) + return cv2.resize(arr, (336, 336), interpolation=cv2.INTER_CUBIC) + + +def q70(arr): + _, enc = cv2.imencode(".jpg", arr, (int(cv2.IMWRITE_JPEG_QUALITY), 70)) + return cv2.imdecode(enc, cv2.IMREAD_UNCHANGED) + + +def norm(arr): + return torch.from_numpy((arr.astype(np.float32) - 127.5) / 127.5).permute(2, 0, 1).contiguous() + + +def perturb(img, kind): + if kind == "jpeg50": + buf = io.BytesIO() + img.save(buf, format="JPEG", quality=50) + buf.seek(0) + with Image.open(buf) as dec: + out = dec.convert("RGB") + out.load() + return out + if kind in ("blur1", "blur2"): + sigma = 1.0 if kind == "blur1" else 2.0 + return Image.fromarray(cv2.GaussianBlur(np.asarray(img), (0, 0), sigmaX=sigma, sigmaY=sigma)) + if kind == "jpeg95" or kind == "jpeg60": + buf = io.BytesIO() + img.save(buf, format="JPEG", quality=int(kind[4:])) + buf.seek(0) + with Image.open(buf) as dec: + out = dec.convert("RGB") + out.load() + return out + if kind == "gray": + return img.convert("L").convert("RGB") + if kind == "resize05": + w, h = img.size + return img.resize((max(1, round(w * 0.5)), max(1, round(h * 0.5))), Image.BICUBIC) + raise ValueError(kind) + + +class Jobs(Dataset): + """``jobs[i]`` is ("clean", path) | ("pert", path, kind) | ("mix", real_path, gen_path, alpha, variant).""" + + def __init__(self, jobs): + self.jobs = jobs + + def __len__(self): + return len(self.jobs) + + def __getitem__(self, i): + j = self.jobs[i] + if j[0] == "clean": + x = norm(q70(geom(load_aligned(j[1])))) + elif j[0] == "pert": + x = norm(q70(geom(perturb(load_aligned(j[1]), j[2])))) + elif j[0] == "mixp": + _, pr, pg, a, kind = j + x = (1 - a) * norm(q70(geom(perturb(load_aligned(pr), kind)))) + a * norm(q70(geom(perturb(load_aligned(pg), kind)))) + else: + _, pr, pg, a, var = j + if var == "native": + ir, ig = load_aligned(pr), load_aligned(pg) + ig = ig.resize(ir.size, Image.LANCZOS) if ig.size != ir.size else ig + m = np.clip(a * np.asarray(ig, dtype=np.float32) + (1 - a) * np.asarray(ir, dtype=np.float32), 0, 255).astype(np.uint8) + return norm(q70(geom(Image.fromarray(m)))), i + gr, gg = geom(load_aligned(pr)), geom(load_aligned(pg)) + if var == "after": + x = (1 - a) * norm(q70(gr)) + a * norm(q70(gg)) + elif var == "before": + m = np.clip(np.rint((1 - a) * gr.astype(np.float32) + a * gg.astype(np.float32)), 0, 255).astype(np.uint8) + x = norm(q70(m)) + else: + x = (1 - a) * norm(gr) + a * norm(gg) + return x, i + + +def check_pipeline(paths): + """The split pipeline must equal the repo's CuReTransform (== official preprocess) bit for bit.""" + t = CuReTransform() + for p in paths: + with Image.open(p) as src: + fmt = src.format + img = src.convert("RGB") + img.info[SRC_FORMAT_KEY] = fmt + ref = t(img) + mine = norm(q70(geom(load_aligned(p)))) + d = float((ref - mine).abs().max()) + if d != 0.0: + raise RuntimeError(f"pipeline mismatch on {p}: max|diff| {d}") + return len(paths) + + +def main(): + ap = argparse.ArgumentParser() + ap.add_argument("--released", required=True, help="released cure_adapter.pt (LoRA source)") + ap.add_argument("--ours", required=True, help="our stage-1 model_last.pth") + ap.add_argument("--train-dir", required=True, help="GenImage SD1.4 train subset with real/ fake/") + ap.add_argument("--test-dir", required=True, help="GenImage SD1.4 test subset with real/ fake/") + ap.add_argument("--wild-dir", required=True, help="WildRF test (/{0_real,1_fake}); diagnostic only") + ap.add_argument("--out", required=True) + ap.add_argument("--n-mix-train", type=int, default=4000) + ap.add_argument("--n-mix-val", type=int, default=2000) + ap.add_argument("--n-pert", type=int, default=1000) + ap.add_argument("--n-rf-grid", type=int, default=2000) + ap.add_argument("--extra-fake-dir", default=None, help="/1_fake tree (Synthbuster subset)") + ap.add_argument("--only-extra", action="store_true", help="encode only the extra fakes (features_extra.pt)") + ap.add_argument("--only-aug", action="store_true", help="encode only the format / augmented-mixture sets (features_aug.pt)") + ap.add_argument("--only-native", action="store_true", help="encode only the native-resolution mixing variant") + ap.add_argument("--bs", type=int, default=32) + ap.add_argument("--workers", type=int, default=10) + ap.add_argument("--seed", type=int, default=1234) + args = ap.parse_args() + out = Path(args.out) + out.mkdir(parents=True, exist_ok=True) + + tr_r, tr_f = list_images(Path(args.train_dir) / "real"), list_images(Path(args.train_dir) / "fake") + te_r, te_f = list_images(Path(args.test_dir) / "real"), list_images(Path(args.test_dir) / "fake") + wild = [(p, 0 if "0_real" in p.parts else 1, p.relative_to(args.wild_dir).parts[0]) for p in list_images(args.wild_dir)] + print(f"[diag] train {len(tr_r)}+{len(tr_f)} test {len(te_r)}+{len(te_f)} wild {len(wild)}", flush=True) + print(f"[diag] pipeline check: {check_pipeline(te_r[:6] + te_f[:6] + [w[0] for w in wild[:6]])} images bit-exact", flush=True) + + g = torch.Generator().manual_seed(args.seed) + meta, jobs = {}, [] + + def add(name, js, **cols): + meta[name] = {"start": len(jobs), "n": len(js), **{k: v for k, v in cols.items()}} + jobs.extend(js) + + add("train_clean", [("clean", p) for p in tr_r + tr_f], label=[0] * len(tr_r) + [1] * len(tr_f)) + add("test_clean", [("clean", p) for p in te_r + te_f], label=[0] * len(te_r) + [1] * len(te_f)) + pr, pf = te_r[:args.n_pert], te_f[:args.n_pert] + for k in PERTS: + add(f"test_{k}", [("pert", p, k) for p in pr + pf], label=[0] * len(pr) + [1] * len(pf)) + for split, (R, F_, n) in {"mix_train": (tr_r, tr_f, args.n_mix_train), "mix_val": (te_r, te_f, args.n_mix_val)}.items(): + ri = torch.randint(len(R), (n,), generator=g).tolist() + fi = torch.randint(len(F_), (n,), generator=g).tolist() + al = torch.rand(n, generator=g, dtype=torch.float64).tolist() + for v in VARIANTS: + add(f"{split}_{v}", [("mix", R[a], F_[b], c, v) for a, b, c in zip(ri, fi, al)], alpha=al) + ri = torch.randint(len(tr_r), (args.n_rf_grid,), generator=g).tolist() + fi = torch.randint(len(tr_f), (args.n_rf_grid,), generator=g).tolist() + for v in ("after", "before"): + js, pair, alpha = [], [], [] + for k, (a, b) in enumerate(zip(ri, fi)): + for al in GRID: + js.append(("mix", tr_r[a], tr_f[b], al, v)) + pair.append(k) + alpha.append(al) + add(f"rf_grid_{v}", js, pair=pair, alpha=alpha) + add("wild", [("clean", w[0]) for w in wild], label=[w[1] for w in wild], platform=[w[2] for w in wild]) + if args.only_aug: + mv = jobs[meta["mix_val_after"]["start"]:meta["mix_val_after"]["start"] + meta["mix_val_after"]["n"]] + mv_alpha = meta["mix_val_after"]["alpha"] + meta, jobs = {}, [] + add("test_jpeg95", [("pert", p, "jpeg95") for p in pr + pf], label=[0] * len(pr) + [1] * len(pf)) + for k in ("gray", "blur1", "jpeg60"): + add(f"mix_val_aug_{k}", [("mixp", j[1], j[2], j[3], k) for j in mv], alpha=mv_alpha) + if args.only_native: + old_meta, old_jobs = meta, jobs + meta, jobs = {}, [] + for split in ("mix_train", "mix_val"): + m = old_meta[f"{split}_after"] + add(f"{split}_native", [("mix", j[1], j[2], j[3], "native") for j in old_jobs[m["start"]:m["start"] + m["n"]]], + alpha=m["alpha"]) + if args.only_extra: + meta, jobs = {}, [] + fakes = list_images(args.extra_fake_dir) + add("extra_fake", [("clean", p) for p in fakes], label=[1] * len(fakes), + generator=[p.relative_to(args.extra_fake_dir).parts[0] for p in fakes]) + print(f"[diag] {len(jobs)} items: " + ", ".join(f"{k} {v['n']}" for k, v in meta.items()), flush=True) + + dev = "cuda" + encoders = {"base": build_model(None, dev), "released": build_model(args.released, dev), "ours": build_model(args.ours, dev)} + feats = {k: torch.zeros(len(jobs), 1024, dtype=torch.float16) for k in encoders} + loader = DataLoader(Jobs(jobs), batch_size=args.bs, shuffle=False, num_workers=args.workers, pin_memory=True) + t0 = time.time() + with torch.no_grad(): + for step, (x, idx) in enumerate(loader): + x = x.to(dev, non_blocking=True) + for k, m in encoders.items(): + feats[k][idx] = m.features(x).half().cpu() + if step % 50 == 0: + done = (step + 1) * args.bs + print(f"[diag] {done}/{len(jobs)} {done / (time.time() - t0):.1f} items/s", flush=True) + for k in feats: + if not torch.isfinite(feats[k].float()).all(): + raise RuntimeError(f"non-finite features from {k}") + torch.save({"features": feats, "meta": meta, "args": {k: v for k, v in vars(args).items() + if k not in ("released", "ours", "train_dir", "test_dir", "wild_dir", "out", + "extra_fake_dir")}}, + out / ("features_extra.pt" if args.only_extra else "features_aug.pt" if args.only_aug else + "features_native.pt" if args.only_native else "features.pt")) + print(f"[diag] saved {out} in {time.time() - t0:.0f}s", flush=True) + + +if __name__ == "__main__": + main() diff --git a/repro/cure_stage1/lora_norms.py b/repro/cure_stage1/lora_norms.py new file mode 100644 index 0000000000000000000000000000000000000000..4332d192f8878ef57f7d3c565900d40a48a02970 --- /dev/null +++ b/repro/cure_stage1/lora_norms.py @@ -0,0 +1,110 @@ +"""CuRe stage-1 investigation (Task 1, diagnostic 2c): per-layer LoRA statistics of the released adapter vs our trained +stage-1 LoRA, CPU only. + +For every one of the 24 attention layers and both adapted projections (q, v) it reports the Frobenius norms of A and B, +the effective update dW = (alpha / r) * B @ A (alpha / r = 2, as the official forward), its spectral norm and stable +rank, ||dW|| relative to the frozen base projection, the largest |B_ij| and |A_ij|, and the subspace overlap of the +released and our dW (top-8 left singular vectors). + +Why the max |B_ij| matters: B starts at 0 and AdamW moves an element by about lr_t per step (|m / sqrt(v)| <= ~1 for +steady gradients; the decoupled weight decay is negligible at lr 1e-5), so max |B_ij| <= sum_t lr_t ~= the "update +budget" of the run. For the paper's schedule (2 warmup epochs linear from 0, cosine over 3 epochs from 1e-5 to 1e-6) +the budget is about 2.65 * lr * S with S optimizer steps per epoch = 162,000 / global batch. A released max |B_ij| far +above our run's budget means the release took more (or larger) optimizer steps than our 843 steps/epoch. + + python repro/cure_stage1/lora_norms.py --released cure_adapter.pt --ours model_last.pth --base PE-Core-L14-336.pt \ + --out repro/cure_stage1/results/lora_norms.json +""" +import argparse +import json +import math + +import torch + +LAYERS = 24 +RANK = 64 +SCALE = 2.0 # alpha / r = 128 / 64 (official backbone.py: 2.0 * B(A(x))) +KAIMING_BOUND = 1 / 32 # kaiming_uniform_(a=sqrt(5)) on [64, 1024]: U(-1/sqrt(1024), 1/sqrt(1024)) + + +def lora(state, layer, proj): + p = f"backbone.transformer.resblocks.{layer}.attn.lora_" + return state[p + f"A_{proj}"].double(), state[p + f"B_{proj}"].double() + + +def budget(steps_per_epoch, lr=1e-5, min_lr=1e-6, warm=2, total=5): + """sum_t lr_t for linear warmup from 0 over ``warm`` epochs + cosine from lr to min_lr over the rest.""" + s_w, s_c = warm * steps_per_epoch, (total - warm) * steps_per_epoch + warm_sum = sum(lr * i / s_w for i in range(s_w)) + cos_sum = sum(min_lr + 0.5 * (lr - min_lr) * (1 + math.cos(math.pi * i / s_c)) for i in range(s_c)) + return warm_sum + cos_sum + + +def stats(A, B, W0): + dW = SCALE * B @ A + sv = torch.linalg.svdvals(dW) + sa = torch.linalg.svdvals(A) + return { + "A_fro": float(A.norm()), "B_fro": float(B.norm()), "dW_fro": float(dW.norm()), "dW_spec": float(sv[0]), + "dW_stable_rank": float((sv ** 2).sum() / sv[0] ** 2), "dW_rel_base": float(dW.norm() / W0.norm()), + "B_maxabs": float(B.abs().max()), "B_rms": float(B.pow(2).mean().sqrt()), "A_maxabs": float(A.abs().max()), + "A_sv_max_over_min": float(sa[0] / sa[-1]), + } + + +def top_left(dW, k=8): + return torch.linalg.svd(dW, full_matrices=False)[0][:, :k] + + +def main(): + ap = argparse.ArgumentParser() + ap.add_argument("--released", required=True) + ap.add_argument("--ours", required=True) + ap.add_argument("--base", required=True) + ap.add_argument("--out", required=True) + args = ap.parse_args() + rel = torch.load(args.released, map_location="cpu", weights_only=True) + ours = torch.load(args.ours, map_location="cpu", weights_only=True, mmap=True) + ours = ours.get("model", ours) + base = torch.load(args.base, map_location="cpu", weights_only=True, mmap=True) + # random reference: a kaiming-uniform A (the standard LoRA init, = SynthScope's _init_trainable) and its stats + g = torch.Generator().manual_seed(0) + A_init = (torch.rand(RANK, 1024, generator=g, dtype=torch.float64) * 2 - 1) * KAIMING_BOUND + init_ref = {"A_fro": float(A_init.norm()), "A_maxabs": float(A_init.abs().max()), + "A_sv_max_over_min": float((lambda s: s[0] / s[-1])(torch.linalg.svdvals(A_init)))} + rows = [] + for layer in range(LAYERS): + W_in = base[f"visual.transformer.resblocks.{layer}.attn.in_proj_weight"].double() + for proj, sl in (("q", slice(0, 1024)), ("v", slice(2048, 3072))): + W0 = W_in[sl] + Ar, Br = lora(rel, layer, proj) + Ao, Bo = lora(ours, layer, proj) + r, o = stats(Ar, Br, W0), stats(Ao, Bo, W0) + Ur, Uo = top_left(SCALE * Br @ Ar), top_left(SCALE * Bo @ Ao) + overlap = float((Ur.T @ Uo).pow(2).sum() / Ur.shape[1]) + rows.append({"layer": layer, "proj": proj, "released": r, "ours": o, "top8_left_overlap": overlap}) + def agg(who, key, fn=lambda v: sum(v) / len(v)): + return fn([row[who][key] for row in rows]) + summary = {} + for key in ("A_fro", "B_fro", "dW_fro", "dW_spec", "dW_stable_rank", "dW_rel_base", "B_maxabs", "B_rms", "A_maxabs", + "A_sv_max_over_min"): + summary[key] = {"released_mean": agg("released", key), "ours_mean": agg("ours", key), + "released_max": agg("released", key, max), "ours_max": agg("ours", key, max)} + summary["dW_fro_ratio_released_over_ours_mean"] = sum(r["released"]["dW_fro"] / r["ours"]["dW_fro"] for r in rows) / len(rows) + summary["top8_left_overlap_mean"] = sum(r["top8_left_overlap"] for r in rows) / len(rows) + summary["random_top8_overlap"] = 8 / 1024 + budgets = {f"{n}gpu_x64": {"steps_per_epoch": 162000 // (64 * n), "sum_lr": budget(162000 // (64 * n))} + for n in (1, 2, 3, 4, 8)} + out = {"kaiming_init_reference": init_ref, "update_budget_sum_lr": budgets, "summary": summary, "per_layer": rows} + with open(args.out, "w") as f: + json.dump(out, f, indent=1) + print(json.dumps({"kaiming_init_reference": init_ref, "update_budget_sum_lr": budgets, "summary": summary}, indent=1)) + print("layer proj | rel dW_fro ours dW_fro | rel Bmax ours Bmax | rel Afro ours Afro | overlap") + for r in rows: + print(f"{r['layer']:2d} {r['proj']} | {r['released']['dW_fro']:.3f} {r['ours']['dW_fro']:.3f} | " + f"{r['released']['B_maxabs']:.4f} {r['ours']['B_maxabs']:.4f} | {r['released']['A_fro']:.3f} " + f"{r['ours']['A_fro']:.3f} | {r['top8_left_overlap']:.3f}") + + +if __name__ == "__main__": + main() diff --git a/repro/cure_stage1/multi_stage23.py b/repro/cure_stage1/multi_stage23.py new file mode 100644 index 0000000000000000000000000000000000000000..e26c128c49c1bdde65d29737b7fa7c73e5c64173 --- /dev/null +++ b/repro/cure_stage1/multi_stage23.py @@ -0,0 +1,124 @@ +"""CuRe stage-1 investigation, Task 2: stages 2 and 3 for SEVERAL stage-1 encoders with one pass over the images. + +The expensive part of ``models/image/cure/train_stages.py`` is decoding / preprocessing the images (20,000 x 3 endpoint +pairs for stage 2, all 324k training images for stage 3), which is identical for every encoder. This driver reads each +image once, runs every encoder on it, and writes for each encoder exactly the caches that ``train_stages.py`` itself would +write (``/trajectories.pt`` with the same pairs, seed and fields; ``/head_features.pt``). It then calls the +UNCHANGED ``train_stages.py stage2`` / ``stage3`` for each encoder, which reuse those caches, so the solve (Eq. 6-11), the +head training and the export / reload check are the recipe's own code with its defaults. + + python repro/cure_stage1/multi_stage23.py --data --reference-adapter \ + --run r2e4=: --run r2e1=: ... +""" +import argparse +import json +import time +from pathlib import Path + +import torch +from torch.utils.data import DataLoader + +from dataset import CuReEndpoints, cure_mix +from models.image.cure import subspace as S +from models.image.cure.cure import FEATURE_DIM +from models.image.cure.train_stages import (TYPES, LabelledImages, TrajectoryPairs, build_model, draw_pairs, + endpoint_transform, main as train_stages_main) + + +def main(): + ap = argparse.ArgumentParser() + ap.add_argument("--data", required=True) + ap.add_argument("--run", action="append", required=True, help="name=lora_path:out_dir") + ap.add_argument("--reference-adapter", default=None) + ap.add_argument("--pairs", type=int, default=20000) # train_stages.py stage2 default + ap.add_argument("--seed", type=int, default=0) # train_stages.py default + ap.add_argument("--batch-pairs", type=int, default=16) # train_stages.py stage2 default + ap.add_argument("--encode-batch", type=int, default=128) # train_stages.py stage3 default + ap.add_argument("--workers", type=int, default=16) + ap.add_argument("--max-images", type=int, default=None, help="smoke tests only") + ap.add_argument("--device", default="cuda") + args = ap.parse_args() + runs = {} + for r in args.run: + name, rest = r.split("=", 1) + lora, out = rest.rsplit(":", 1) + runs[name] = (lora, Path(out)) + Path(out).mkdir(parents=True, exist_ok=True) + dev = args.device + models = {k: build_model(v[0], dev) for k, v in runs.items()} + ep = CuReEndpoints(args.data, "train", endpoint_transform("none"), args.max_images) + + # ---- stage 2 trajectories (train_stages.stage2's pair draw, same order and seed) + if not all((o / "trajectories.pt").exists() for _, o in runs.values()): + gen = torch.Generator().manual_seed(args.seed) + n_r, n_f = len(ep.reals), len(ep.fakes) + pairs = {"RF": draw_pairs(args.pairs, n_r, n_f, False, gen), "RR": draw_pairs(args.pairs, n_r, n_r, True, gen), + "FF": draw_pairs(args.pairs, n_f, n_f, True, gen)} + print(f"[multi] stage-2 trajectories: {n_r} / {n_f} images, {args.pairs} pairs per type, {len(runs)} encoders", flush=True) + loader = DataLoader(TrajectoryPairs(ep, pairs), batch_size=args.batch_pairs, shuffle=False, + num_workers=args.workers, pin_memory=True) + grid = torch.tensor(S.GRID, device=dev).view(1, -1, 1, 1, 1) + outs = {k: {f"{a}_{t}": torch.zeros(args.pairs, FEATURE_DIM) for t in TYPES for a in ("b", "zbar")} for k in runs} + done, t0 = 0, time.time() + with torch.no_grad(): + for step, (x0, x1, types, idx) in enumerate(loader): + x0, x1 = x0.to(dev, non_blocking=True), x1.to(dev, non_blocking=True) + mixed = cure_mix(x0.unsqueeze(1), x1.unsqueeze(1), grid).flatten(0, 1) + for k, m in models.items(): + z = m.features(mixed).view(x0.shape[0], len(S.GRID), FEATURE_DIM) + b, zbar = S.trajectory_summary(z) + for j in range(x0.shape[0]): + t = TYPES[int(types[j])] + outs[k][f"b_{t}"][int(idx[j])] = b[j].float().cpu() + outs[k][f"zbar_{t}"][int(idx[j])] = zbar[j].float().cpu() + done += x0.shape[0] + if (step + 1) % 200 == 0: + print(f" trajectories {done}/{3 * args.pairs} ({done / (time.time() - t0):.1f} pairs/s)", flush=True) + for k, (lora, out) in runs.items(): + traj = outs[k] + traj["pairs"] = pairs + traj["meta"] = json.dumps({"lora": lora, "data": args.data, "pairs": args.pairs, "seed": args.seed, + "max_images": args.max_images, "control": "none", "driver": "repro/cure_stage1/multi_stage23.py"}) + torch.save(traj, out / "trajectories.pt") + del outs + + # ---- stage 3 head features (train_stages.stage3's LabelledImages, all training images) + if not all((o / "head_features.pt").exists() for _, o in runs.values()): + print(f"[multi] stage-3 features: {len(ep.reals)} + {len(ep.fakes)} images, {len(runs)} encoders", flush=True) + loader = DataLoader(LabelledImages(ep), batch_size=args.encode_batch, shuffle=False, num_workers=args.workers, + pin_memory=True) + feats, labels, t0 = {k: [] for k in runs}, [], time.time() + with torch.no_grad(): + for i, (x, y) in enumerate(loader): + x = x.to(dev, non_blocking=True) + for k, m in models.items(): + feats[k].append(m.features(x).float().cpu()) + labels.append(y) + if (i + 1) % 100 == 0: + n = sum(len(f) for f in labels) + print(f" head features {n}/{len(loader.dataset)} ({n / (time.time() - t0):.0f} images/s)", flush=True) + y = torch.cat(labels) + for k, (_, out) in runs.items(): + torch.save({"z": torch.cat(feats[k]), "y": y, "encode_batch": args.encode_batch}, out / "head_features.pt") + del feats + del models + if dev.startswith("cuda"): + torch.cuda.empty_cache() + + # ---- the recipe's own solve / head / export, reusing the caches + for k, (lora, out) in runs.items(): + common = ["--lora", lora, "--data", args.data, "--out", str(out), "--seed", str(args.seed), "--device", dev] + if args.max_images: + common += ["--max-images", str(args.max_images)] + a2 = ["stage2", *common, "--pairs", str(args.pairs)] + if args.reference_adapter: + a2 += ["--reference-adapter", args.reference_adapter] + print(f"[multi] {k}: train_stages {' '.join(a2)}", flush=True) + train_stages_main(a2) + a3 = ["stage3", *common, "--encode-batch", str(args.encode_batch)] + print(f"[multi] {k}: train_stages {' '.join(a3)}", flush=True) + train_stages_main(a3) + + +if __name__ == "__main__": + main() diff --git a/repro/cure_stage1/results/epoch_select_r1.json b/repro/cure_stage1/results/epoch_select_r1.json new file mode 100644 index 0000000000000000000000000000000000000000..f6686871c0d543f765b94845607863b5036d6f02 --- /dev/null +++ b/repro/cure_stage1/results/epoch_select_r1.json @@ -0,0 +1,549 @@ +{ + "rule": "select_score = mean(Synthbuster bacc of the stage-1 ratio head direct, Synthbuster bacc of the SD1.4 linear probe); argmax over R1 epochs, ties within 0.5 -> earlier epoch; R2: final epoch", + "released_total_dW": 1.8575520282872215, + "rows": { + "released": { + "total_dW": 1.8576, + "dW_over_released": 1.0, + "mix_fit_fresh_head": { + "bce": 0.51163, + "excess_bce": 0.022, + "floor": 0.48963, + "mae": 0.0643, + "pearson": 0.9539, + "spearman": 0.9537 + }, + "probe_sd14_test": { + "real_acc": 99.7, + "fake_recall": 99.95, + "bacc": 99.83, + "auroc": 100.0, + "mean_score_real": 0.003, + "mean_score_fake": 0.9992 + }, + "probe_synthbuster": { + "real_acc": 99.7, + "fake_recall": 90.37, + "bacc": 95.03, + "auroc": 99.15, + "mean_score_real": 0.003, + "mean_score_fake": 0.8978 + }, + "probe_wildrf_DIAGNOSTIC": { + "real_acc": 95.2, + "fake_recall": 98.08, + "bacc": 96.64, + "auroc": 99.28, + "mean_score_real": 0.0553, + "mean_score_fake": 0.9755 + }, + "direct_head": "fresh", + "direct_sd14_test": { + "real_acc": 99.6, + "fake_recall": 99.95, + "bacc": 99.78, + "auroc": 100.0, + "mean_score_real": 0.0584, + "mean_score_fake": 0.9545 + }, + "direct_synthbuster": { + "real_acc": 99.6, + "fake_recall": 91.14, + "bacc": 95.37, + "auroc": 98.59, + "mean_score_real": 0.0584, + "mean_score_fake": 0.8345 + }, + "direct_wildrf_DIAGNOSTIC": { + "real_acc": 92.57, + "fake_recall": 98.32, + "bacc": 95.44, + "auroc": 98.78, + "mean_score_real": 0.1462, + "mean_score_fake": 0.9049 + }, + "select_score": 95.2 + }, + "base": { + "mix_fit_fresh_head": { + "bce": 0.58778, + "excess_bce": 0.09815, + "floor": 0.48963, + "mae": 0.1486, + "pearson": 0.7623, + "spearman": 0.7614 + }, + "probe_sd14_test": { + "real_acc": 98.65, + "fake_recall": 98.9, + "bacc": 98.78, + "auroc": 99.93, + "mean_score_real": 0.0165, + "mean_score_fake": 0.9856 + }, + "probe_synthbuster": { + "real_acc": 98.65, + "fake_recall": 86.4, + "bacc": 92.53, + "auroc": 98.03, + "mean_score_real": 0.0165, + "mean_score_fake": 0.8578 + }, + "probe_wildrf_DIAGNOSTIC": { + "real_acc": 84.81, + "fake_recall": 97.36, + "bacc": 91.09, + "auroc": 98.65, + "mean_score_real": 0.1626, + "mean_score_fake": 0.9731 + }, + "direct_head": "fresh", + "direct_sd14_test": { + "real_acc": 95.15, + "fake_recall": 97.45, + "bacc": 96.3, + "auroc": 99.48, + "mean_score_real": 0.1877, + "mean_score_fake": 0.8734 + }, + "direct_synthbuster": { + "real_acc": 95.15, + "fake_recall": 77.86, + "bacc": 86.5, + "auroc": 93.97, + "mean_score_real": 0.1877, + "mean_score_fake": 0.6901 + }, + "direct_wildrf_DIAGNOSTIC": { + "real_acc": 88.17, + "fake_recall": 93.13, + "bacc": 90.65, + "auroc": 96.89, + "mean_score_real": 0.254, + "mean_score_fake": 0.8143 + }, + "select_score": 89.515 + }, + "orig": { + "total_dW": 3.1762, + "dW_over_released": 1.71, + "mix_fit_fresh_head": { + "bce": 0.4968, + "excess_bce": 0.00717, + "floor": 0.48963, + "mae": 0.0351, + "pearson": 0.9858, + "spearman": 0.9859 + }, + "probe_sd14_test": { + "real_acc": 99.9, + "fake_recall": 100.0, + "bacc": 99.95, + "auroc": 100.0, + "mean_score_real": 0.0011, + "mean_score_fake": 0.9995 + }, + "probe_synthbuster": { + "real_acc": 99.9, + "fake_recall": 62.0, + "bacc": 80.95, + "auroc": 96.27, + "mean_score_real": 0.0011, + "mean_score_fake": 0.6228 + }, + "probe_wildrf_DIAGNOSTIC": { + "real_acc": 99.12, + "fake_recall": 73.4, + "bacc": 86.26, + "auroc": 98.2, + "mean_score_real": 0.0099, + "mean_score_fake": 0.7346 + }, + "mix_fit_own_head": { + "bce": 0.49458, + "excess_bce": 0.00495, + "floor": 0.48963, + "mae": 0.0269, + "pearson": 0.9902, + "spearman": 0.9903 + }, + "direct_head": "own", + "direct_sd14_test": { + "real_acc": 99.9, + "fake_recall": 100.0, + "bacc": 99.95, + "auroc": 100.0, + "mean_score_real": 0.026, + "mean_score_fake": 0.9807 + }, + "direct_synthbuster": { + "real_acc": 99.9, + "fake_recall": 69.7, + "bacc": 84.8, + "auroc": 97.61, + "mean_score_real": 0.026, + "mean_score_fake": 0.6842 + }, + "direct_wildrf_DIAGNOSTIC": { + "real_acc": 98.48, + "fake_recall": 79.15, + "bacc": 88.82, + "auroc": 97.83, + "mean_score_real": 0.0529, + "mean_score_fake": 0.7629 + }, + "select_score": 82.875 + }, + "r1e0": { + "total_dW": 1.233, + "dW_over_released": 0.664, + "mix_fit_fresh_head": { + "bce": 0.53548, + "excess_bce": 0.04585, + "floor": 0.48963, + "mae": 0.0973, + "pearson": 0.8937, + "spearman": 0.8919 + }, + "probe_sd14_test": { + "real_acc": 99.8, + "fake_recall": 99.85, + "bacc": 99.83, + "auroc": 100.0, + "mean_score_real": 0.0028, + "mean_score_fake": 0.9977 + }, + "probe_synthbuster": { + "real_acc": 99.8, + "fake_recall": 81.27, + "bacc": 90.54, + "auroc": 99.3, + "mean_score_real": 0.0028, + "mean_score_fake": 0.8058 + }, + "probe_wildrf_DIAGNOSTIC": { + "real_acc": 97.6, + "fake_recall": 89.22, + "bacc": 93.41, + "auroc": 98.91, + "mean_score_real": 0.0246, + "mean_score_fake": 0.8783 + }, + "mix_fit_own_head": { + "bce": 0.53161, + "excess_bce": 0.04198, + "floor": 0.48963, + "mae": 0.0931, + "pearson": 0.9058, + "spearman": 0.905 + }, + "direct_head": "own", + "direct_sd14_test": { + "real_acc": 98.6, + "fake_recall": 99.85, + "bacc": 99.23, + "auroc": 99.99, + "mean_score_real": 0.1589, + "mean_score_fake": 0.9354 + }, + "direct_synthbuster": { + "real_acc": 98.6, + "fake_recall": 91.69, + "bacc": 95.14, + "auroc": 99.16, + "mean_score_real": 0.1589, + "mean_score_fake": 0.7918 + }, + "direct_wildrf_DIAGNOSTIC": { + "real_acc": 95.92, + "fake_recall": 97.28, + "bacc": 96.6, + "auroc": 99.22, + "mean_score_real": 0.1995, + "mean_score_fake": 0.8319 + }, + "select_score": 92.84 + }, + "r1e1": { + "total_dW": 2.2824, + "dW_over_released": 1.229, + "mix_fit_fresh_head": { + "bce": 0.50427, + "excess_bce": 0.01464, + "floor": 0.48963, + "mae": 0.0519, + "pearson": 0.9694, + "spearman": 0.9695 + }, + "probe_sd14_test": { + "real_acc": 99.9, + "fake_recall": 99.95, + "bacc": 99.92, + "auroc": 100.0, + "mean_score_real": 0.0014, + "mean_score_fake": 0.9993 + }, + "probe_synthbuster": { + "real_acc": 99.9, + "fake_recall": 79.1, + "bacc": 89.5, + "auroc": 99.29, + "mean_score_real": 0.0014, + "mean_score_fake": 0.7876 + }, + "probe_wildrf_DIAGNOSTIC": { + "real_acc": 98.24, + "fake_recall": 87.94, + "bacc": 93.09, + "auroc": 98.71, + "mean_score_real": 0.0213, + "mean_score_fake": 0.8675 + }, + "mix_fit_own_head": { + "bce": 0.5004, + "excess_bce": 0.01077, + "floor": 0.48963, + "mae": 0.0428, + "pearson": 0.9785, + "spearman": 0.9782 + }, + "direct_head": "own", + "direct_sd14_test": { + "real_acc": 99.8, + "fake_recall": 99.9, + "bacc": 99.85, + "auroc": 100.0, + "mean_score_real": 0.0423, + "mean_score_fake": 0.9668 + }, + "direct_synthbuster": { + "real_acc": 99.8, + "fake_recall": 79.72, + "bacc": 89.76, + "auroc": 99.07, + "mean_score_real": 0.0423, + "mean_score_fake": 0.7462 + }, + "direct_wildrf_DIAGNOSTIC": { + "real_acc": 98.16, + "fake_recall": 87.22, + "bacc": 92.69, + "auroc": 98.54, + "mean_score_real": 0.0834, + "mean_score_fake": 0.8126 + }, + "select_score": 89.63 + }, + "r1e2": { + "total_dW": 2.846, + "dW_over_released": 1.532, + "mix_fit_fresh_head": { + "bce": 0.49901, + "excess_bce": 0.00938, + "floor": 0.48963, + "mae": 0.0404, + "pearson": 0.981, + "spearman": 0.9812 + }, + "probe_sd14_test": { + "real_acc": 99.95, + "fake_recall": 99.95, + "bacc": 99.95, + "auroc": 100.0, + "mean_score_real": 0.0007, + "mean_score_fake": 0.9997 + }, + "probe_synthbuster": { + "real_acc": 99.95, + "fake_recall": 64.88, + "bacc": 82.41, + "auroc": 95.98, + "mean_score_real": 0.0007, + "mean_score_fake": 0.646 + }, + "probe_wildrf_DIAGNOSTIC": { + "real_acc": 98.8, + "fake_recall": 76.68, + "bacc": 87.74, + "auroc": 98.56, + "mean_score_real": 0.0116, + "mean_score_fake": 0.7638 + }, + "mix_fit_own_head": { + "bce": 0.4963, + "excess_bce": 0.00667, + "floor": 0.48963, + "mae": 0.0314, + "pearson": 0.9869, + "spearman": 0.9869 + }, + "direct_head": "own", + "direct_sd14_test": { + "real_acc": 99.85, + "fake_recall": 99.95, + "bacc": 99.9, + "auroc": 100.0, + "mean_score_real": 0.0287, + "mean_score_fake": 0.9777 + }, + "direct_synthbuster": { + "real_acc": 99.85, + "fake_recall": 74.2, + "bacc": 87.03, + "auroc": 98.13, + "mean_score_real": 0.0287, + "mean_score_fake": 0.7135 + }, + "direct_wildrf_DIAGNOSTIC": { + "real_acc": 98.32, + "fake_recall": 83.15, + "bacc": 90.73, + "auroc": 98.22, + "mean_score_real": 0.0576, + "mean_score_fake": 0.7977 + }, + "select_score": 84.72 + }, + "r1e3": { + "total_dW": 3.0923, + "dW_over_released": 1.665, + "mix_fit_fresh_head": { + "bce": 0.49712, + "excess_bce": 0.00749, + "floor": 0.48963, + "mae": 0.0356, + "pearson": 0.9852, + "spearman": 0.9852 + }, + "probe_sd14_test": { + "real_acc": 100.0, + "fake_recall": 99.95, + "bacc": 99.98, + "auroc": 100.0, + "mean_score_real": 0.0004, + "mean_score_fake": 0.9995 + }, + "probe_synthbuster": { + "real_acc": 100.0, + "fake_recall": 61.77, + "bacc": 80.89, + "auroc": 95.71, + "mean_score_real": 0.0004, + "mean_score_fake": 0.616 + }, + "probe_wildrf_DIAGNOSTIC": { + "real_acc": 99.28, + "fake_recall": 73.8, + "bacc": 86.54, + "auroc": 98.51, + "mean_score_real": 0.0077, + "mean_score_fake": 0.7356 + }, + "mix_fit_own_head": { + "bce": 0.49501, + "excess_bce": 0.00538, + "floor": 0.48963, + "mae": 0.028, + "pearson": 0.9896, + "spearman": 0.9895 + }, + "direct_head": "own", + "direct_sd14_test": { + "real_acc": 99.9, + "fake_recall": 99.95, + "bacc": 99.92, + "auroc": 100.0, + "mean_score_real": 0.0263, + "mean_score_fake": 0.98 + }, + "direct_synthbuster": { + "real_acc": 99.9, + "fake_recall": 67.68, + "bacc": 83.79, + "auroc": 97.44, + "mean_score_real": 0.0263, + "mean_score_fake": 0.67 + }, + "direct_wildrf_DIAGNOSTIC": { + "real_acc": 98.8, + "fake_recall": 78.51, + "bacc": 88.66, + "auroc": 97.87, + "mean_score_real": 0.0495, + "mean_score_fake": 0.7588 + }, + "select_score": 82.34 + }, + "r1e4": { + "total_dW": 3.1685, + "dW_over_released": 1.706, + "mix_fit_fresh_head": { + "bce": 0.49656, + "excess_bce": 0.00693, + "floor": 0.48963, + "mae": 0.034, + "pearson": 0.9863, + "spearman": 0.9863 + }, + "probe_sd14_test": { + "real_acc": 99.9, + "fake_recall": 99.95, + "bacc": 99.92, + "auroc": 100.0, + "mean_score_real": 0.0007, + "mean_score_fake": 0.9995 + }, + "probe_synthbuster": { + "real_acc": 99.9, + "fake_recall": 63.79, + "bacc": 81.85, + "auroc": 95.44, + "mean_score_real": 0.0007, + "mean_score_fake": 0.6362 + }, + "probe_wildrf_DIAGNOSTIC": { + "real_acc": 99.12, + "fake_recall": 75.64, + "bacc": 87.38, + "auroc": 98.49, + "mean_score_real": 0.0097, + "mean_score_fake": 0.7571 + }, + "mix_fit_own_head": { + "bce": 0.49467, + "excess_bce": 0.00504, + "floor": 0.48963, + "mae": 0.0269, + "pearson": 0.9901, + "spearman": 0.9901 + }, + "direct_head": "own", + "direct_sd14_test": { + "real_acc": 99.85, + "fake_recall": 99.95, + "bacc": 99.9, + "auroc": 100.0, + "mean_score_real": 0.0257, + "mean_score_fake": 0.9805 + }, + "direct_synthbuster": { + "real_acc": 99.85, + "fake_recall": 68.69, + "bacc": 84.27, + "auroc": 97.29, + "mean_score_real": 0.0257, + "mean_score_fake": 0.6766 + }, + "direct_wildrf_DIAGNOSTIC": { + "real_acc": 98.64, + "fake_recall": 78.99, + "bacc": 88.82, + "auroc": 97.85, + "mean_score_real": 0.0505, + "mean_score_fake": 0.7669 + }, + "select_score": 83.06 + } + }, + "r1_selected": "r1e0" +} \ No newline at end of file diff --git a/repro/cure_stage1/results/epoch_select_r2.json b/repro/cure_stage1/results/epoch_select_r2.json new file mode 100644 index 0000000000000000000000000000000000000000..803f29d47de9a7470a2d4eb58cd7dcc8d333a9d4 --- /dev/null +++ b/repro/cure_stage1/results/epoch_select_r2.json @@ -0,0 +1,548 @@ +{ + "rule": "select_score = mean(Synthbuster bacc of the stage-1 ratio head direct, Synthbuster bacc of the SD1.4 linear probe); argmax over R1 epochs, ties within 0.5 -> earlier epoch; R2: final epoch", + "released_total_dW": 1.8575520282872215, + "rows": { + "released": { + "total_dW": 1.8576, + "dW_over_released": 1.0, + "mix_fit_fresh_head": { + "bce": 0.51163, + "excess_bce": 0.022, + "floor": 0.48963, + "mae": 0.0643, + "pearson": 0.9539, + "spearman": 0.9537 + }, + "probe_sd14_test": { + "real_acc": 99.7, + "fake_recall": 99.95, + "bacc": 99.83, + "auroc": 100.0, + "mean_score_real": 0.003, + "mean_score_fake": 0.9992 + }, + "probe_synthbuster": { + "real_acc": 99.7, + "fake_recall": 90.37, + "bacc": 95.03, + "auroc": 99.15, + "mean_score_real": 0.003, + "mean_score_fake": 0.8978 + }, + "probe_wildrf_DIAGNOSTIC": { + "real_acc": 95.2, + "fake_recall": 98.08, + "bacc": 96.64, + "auroc": 99.28, + "mean_score_real": 0.0553, + "mean_score_fake": 0.9755 + }, + "direct_head": "fresh", + "direct_sd14_test": { + "real_acc": 99.6, + "fake_recall": 99.95, + "bacc": 99.78, + "auroc": 100.0, + "mean_score_real": 0.0584, + "mean_score_fake": 0.9545 + }, + "direct_synthbuster": { + "real_acc": 99.6, + "fake_recall": 91.14, + "bacc": 95.37, + "auroc": 98.59, + "mean_score_real": 0.0584, + "mean_score_fake": 0.8345 + }, + "direct_wildrf_DIAGNOSTIC": { + "real_acc": 92.57, + "fake_recall": 98.32, + "bacc": 95.44, + "auroc": 98.78, + "mean_score_real": 0.1462, + "mean_score_fake": 0.9049 + }, + "select_score": 95.2 + }, + "base": { + "mix_fit_fresh_head": { + "bce": 0.58778, + "excess_bce": 0.09815, + "floor": 0.48963, + "mae": 0.1486, + "pearson": 0.7623, + "spearman": 0.7614 + }, + "probe_sd14_test": { + "real_acc": 98.65, + "fake_recall": 98.9, + "bacc": 98.78, + "auroc": 99.93, + "mean_score_real": 0.0165, + "mean_score_fake": 0.9856 + }, + "probe_synthbuster": { + "real_acc": 98.65, + "fake_recall": 86.4, + "bacc": 92.53, + "auroc": 98.03, + "mean_score_real": 0.0165, + "mean_score_fake": 0.8578 + }, + "probe_wildrf_DIAGNOSTIC": { + "real_acc": 84.81, + "fake_recall": 97.36, + "bacc": 91.09, + "auroc": 98.65, + "mean_score_real": 0.1626, + "mean_score_fake": 0.9731 + }, + "direct_head": "fresh", + "direct_sd14_test": { + "real_acc": 95.15, + "fake_recall": 97.45, + "bacc": 96.3, + "auroc": 99.48, + "mean_score_real": 0.1877, + "mean_score_fake": 0.8734 + }, + "direct_synthbuster": { + "real_acc": 95.15, + "fake_recall": 77.86, + "bacc": 86.5, + "auroc": 93.97, + "mean_score_real": 0.1877, + "mean_score_fake": 0.6901 + }, + "direct_wildrf_DIAGNOSTIC": { + "real_acc": 88.17, + "fake_recall": 93.13, + "bacc": 90.65, + "auroc": 96.89, + "mean_score_real": 0.254, + "mean_score_fake": 0.8143 + }, + "select_score": 89.515 + }, + "orig": { + "total_dW": 3.1762, + "dW_over_released": 1.71, + "mix_fit_fresh_head": { + "bce": 0.4968, + "excess_bce": 0.00717, + "floor": 0.48963, + "mae": 0.0351, + "pearson": 0.9858, + "spearman": 0.9859 + }, + "probe_sd14_test": { + "real_acc": 99.9, + "fake_recall": 100.0, + "bacc": 99.95, + "auroc": 100.0, + "mean_score_real": 0.0011, + "mean_score_fake": 0.9995 + }, + "probe_synthbuster": { + "real_acc": 99.9, + "fake_recall": 62.0, + "bacc": 80.95, + "auroc": 96.27, + "mean_score_real": 0.0011, + "mean_score_fake": 0.6228 + }, + "probe_wildrf_DIAGNOSTIC": { + "real_acc": 99.12, + "fake_recall": 73.4, + "bacc": 86.26, + "auroc": 98.2, + "mean_score_real": 0.0099, + "mean_score_fake": 0.7346 + }, + "mix_fit_own_head": { + "bce": 0.49458, + "excess_bce": 0.00495, + "floor": 0.48963, + "mae": 0.0269, + "pearson": 0.9902, + "spearman": 0.9903 + }, + "direct_head": "own", + "direct_sd14_test": { + "real_acc": 99.9, + "fake_recall": 100.0, + "bacc": 99.95, + "auroc": 100.0, + "mean_score_real": 0.026, + "mean_score_fake": 0.9807 + }, + "direct_synthbuster": { + "real_acc": 99.9, + "fake_recall": 69.7, + "bacc": 84.8, + "auroc": 97.61, + "mean_score_real": 0.026, + "mean_score_fake": 0.6842 + }, + "direct_wildrf_DIAGNOSTIC": { + "real_acc": 98.48, + "fake_recall": 79.15, + "bacc": 88.82, + "auroc": 97.83, + "mean_score_real": 0.0529, + "mean_score_fake": 0.7629 + }, + "select_score": 82.875 + }, + "r2e0": { + "total_dW": 0.6809, + "dW_over_released": 0.367, + "mix_fit_fresh_head": { + "bce": 0.56721, + "excess_bce": 0.07758, + "floor": 0.48963, + "mae": 0.1313, + "pearson": 0.8163, + "spearman": 0.8161 + }, + "probe_sd14_test": { + "real_acc": 99.7, + "fake_recall": 99.5, + "bacc": 99.6, + "auroc": 99.99, + "mean_score_real": 0.0044, + "mean_score_fake": 0.9931 + }, + "probe_synthbuster": { + "real_acc": 99.7, + "fake_recall": 84.46, + "bacc": 92.08, + "auroc": 99.14, + "mean_score_real": 0.0044, + "mean_score_fake": 0.8367 + }, + "probe_wildrf_DIAGNOSTIC": { + "real_acc": 95.6, + "fake_recall": 96.01, + "bacc": 95.8, + "auroc": 99.21, + "mean_score_real": 0.0561, + "mean_score_fake": 0.9563 + }, + "mix_fit_own_head": { + "bce": 0.64301, + "excess_bce": 0.15338, + "floor": 0.48963, + "mae": 0.2098, + "pearson": 0.5518, + "spearman": 0.5517 + }, + "direct_head": "own", + "direct_sd14_test": { + "real_acc": 69.45, + "fake_recall": 94.9, + "bacc": 82.17, + "auroc": 93.59, + "mean_score_real": 0.449, + "mean_score_fake": 0.6853 + }, + "direct_synthbuster": { + "real_acc": 69.45, + "fake_recall": 93.32, + "bacc": 81.38, + "auroc": 91.84, + "mean_score_real": 0.449, + "mean_score_fake": 0.6576 + }, + "direct_wildrf_DIAGNOSTIC": { + "real_acc": 72.5, + "fake_recall": 93.13, + "bacc": 82.82, + "auroc": 92.42, + "mean_score_real": 0.4427, + "mean_score_fake": 0.6554 + }, + "select_score": 86.73 + }, + "r2e1": { + "total_dW": 1.7413, + "dW_over_released": 0.937, + "mix_fit_fresh_head": { + "bce": 0.51928, + "excess_bce": 0.02966, + "floor": 0.48963, + "mae": 0.0751, + "pearson": 0.9341, + "spearman": 0.9331 + }, + "probe_sd14_test": { + "real_acc": 99.75, + "fake_recall": 99.95, + "bacc": 99.85, + "auroc": 100.0, + "mean_score_real": 0.0028, + "mean_score_fake": 0.9988 + }, + "probe_synthbuster": { + "real_acc": 99.75, + "fake_recall": 85.0, + "bacc": 92.38, + "auroc": 99.47, + "mean_score_real": 0.0028, + "mean_score_fake": 0.8401 + }, + "probe_wildrf_DIAGNOSTIC": { + "real_acc": 97.36, + "fake_recall": 91.13, + "bacc": 94.25, + "auroc": 98.83, + "mean_score_real": 0.0334, + "mean_score_fake": 0.8994 + }, + "mix_fit_own_head": { + "bce": 0.51364, + "excess_bce": 0.02401, + "floor": 0.48963, + "mae": 0.0676, + "pearson": 0.9486, + "spearman": 0.9479 + }, + "direct_head": "own", + "direct_sd14_test": { + "real_acc": 99.55, + "fake_recall": 99.95, + "bacc": 99.75, + "auroc": 100.0, + "mean_score_real": 0.0869, + "mean_score_fake": 0.9508 + }, + "direct_synthbuster": { + "real_acc": 99.55, + "fake_recall": 89.04, + "bacc": 94.3, + "auroc": 99.29, + "mean_score_real": 0.0869, + "mean_score_fake": 0.7893 + }, + "direct_wildrf_DIAGNOSTIC": { + "real_acc": 96.48, + "fake_recall": 94.81, + "bacc": 95.65, + "auroc": 98.91, + "mean_score_real": 0.1419, + "mean_score_fake": 0.8332 + }, + "select_score": 93.34 + }, + "r2e2": { + "total_dW": 2.3384, + "dW_over_released": 1.259, + "mix_fit_fresh_head": { + "bce": 0.50426, + "excess_bce": 0.01463, + "floor": 0.48963, + "mae": 0.0516, + "pearson": 0.9695, + "spearman": 0.9694 + }, + "probe_sd14_test": { + "real_acc": 99.75, + "fake_recall": 99.95, + "bacc": 99.85, + "auroc": 100.0, + "mean_score_real": 0.0027, + "mean_score_fake": 0.9992 + }, + "probe_synthbuster": { + "real_acc": 99.75, + "fake_recall": 80.65, + "bacc": 90.2, + "auroc": 99.08, + "mean_score_real": 0.0027, + "mean_score_fake": 0.7988 + }, + "probe_wildrf_DIAGNOSTIC": { + "real_acc": 97.52, + "fake_recall": 88.58, + "bacc": 93.05, + "auroc": 98.62, + "mean_score_real": 0.0274, + "mean_score_fake": 0.8772 + }, + "mix_fit_own_head": { + "bce": 0.50116, + "excess_bce": 0.01153, + "floor": 0.48963, + "mae": 0.0444, + "pearson": 0.9766, + "spearman": 0.9768 + }, + "direct_head": "own", + "direct_sd14_test": { + "real_acc": 99.55, + "fake_recall": 99.95, + "bacc": 99.75, + "auroc": 100.0, + "mean_score_real": 0.045, + "mean_score_fake": 0.9655 + }, + "direct_synthbuster": { + "real_acc": 99.55, + "fake_recall": 82.98, + "bacc": 91.27, + "auroc": 99.06, + "mean_score_real": 0.045, + "mean_score_fake": 0.7761 + }, + "direct_wildrf_DIAGNOSTIC": { + "real_acc": 96.4, + "fake_recall": 90.58, + "bacc": 93.49, + "auroc": 98.23, + "mean_score_real": 0.0987, + "mean_score_fake": 0.8354 + }, + "select_score": 90.735 + }, + "r2e3": { + "total_dW": 2.5679, + "dW_over_released": 1.382, + "mix_fit_fresh_head": { + "bce": 0.50158, + "excess_bce": 0.01195, + "floor": 0.48963, + "mae": 0.0458, + "pearson": 0.9754, + "spearman": 0.9754 + }, + "probe_sd14_test": { + "real_acc": 99.75, + "fake_recall": 99.95, + "bacc": 99.85, + "auroc": 100.0, + "mean_score_real": 0.002, + "mean_score_fake": 0.9992 + }, + "probe_synthbuster": { + "real_acc": 99.75, + "fake_recall": 71.72, + "bacc": 85.73, + "auroc": 98.24, + "mean_score_real": 0.002, + "mean_score_fake": 0.7147 + }, + "probe_wildrf_DIAGNOSTIC": { + "real_acc": 98.24, + "fake_recall": 84.03, + "bacc": 91.13, + "auroc": 98.53, + "mean_score_real": 0.0175, + "mean_score_fake": 0.8311 + }, + "mix_fit_own_head": { + "bce": 0.49863, + "excess_bce": 0.009, + "floor": 0.48963, + "mae": 0.0376, + "pearson": 0.9821, + "spearman": 0.9816 + }, + "direct_head": "own", + "direct_sd14_test": { + "real_acc": 99.7, + "fake_recall": 99.9, + "bacc": 99.8, + "auroc": 100.0, + "mean_score_real": 0.0372, + "mean_score_fake": 0.9721 + }, + "direct_synthbuster": { + "real_acc": 99.7, + "fake_recall": 74.44, + "bacc": 87.07, + "auroc": 98.3, + "mean_score_real": 0.0372, + "mean_score_fake": 0.7199 + }, + "direct_wildrf_DIAGNOSTIC": { + "real_acc": 98.24, + "fake_recall": 84.74, + "bacc": 91.49, + "auroc": 98.25, + "mean_score_real": 0.0726, + "mean_score_fake": 0.8053 + }, + "select_score": 86.4 + }, + "r2e4": { + "total_dW": 2.6304, + "dW_over_released": 1.416, + "mix_fit_fresh_head": { + "bce": 0.50093, + "excess_bce": 0.0113, + "floor": 0.48963, + "mae": 0.0445, + "pearson": 0.977, + "spearman": 0.9769 + }, + "probe_sd14_test": { + "real_acc": 99.75, + "fake_recall": 99.95, + "bacc": 99.85, + "auroc": 100.0, + "mean_score_real": 0.0023, + "mean_score_fake": 0.9993 + }, + "probe_synthbuster": { + "real_acc": 99.75, + "fake_recall": 70.63, + "bacc": 85.19, + "auroc": 98.17, + "mean_score_real": 0.0023, + "mean_score_fake": 0.7085 + }, + "probe_wildrf_DIAGNOSTIC": { + "real_acc": 98.4, + "fake_recall": 81.95, + "bacc": 90.18, + "auroc": 98.41, + "mean_score_real": 0.0175, + "mean_score_fake": 0.8176 + }, + "mix_fit_own_head": { + "bce": 0.49809, + "excess_bce": 0.00846, + "floor": 0.48963, + "mae": 0.0364, + "pearson": 0.9831, + "spearman": 0.9829 + }, + "direct_head": "own", + "direct_sd14_test": { + "real_acc": 99.65, + "fake_recall": 99.95, + "bacc": 99.8, + "auroc": 100.0, + "mean_score_real": 0.0354, + "mean_score_fake": 0.973 + }, + "direct_synthbuster": { + "real_acc": 99.65, + "fake_recall": 77.39, + "bacc": 88.52, + "auroc": 98.45, + "mean_score_real": 0.0354, + "mean_score_fake": 0.7401 + }, + "direct_wildrf_DIAGNOSTIC": { + "real_acc": 97.68, + "fake_recall": 85.86, + "bacc": 91.77, + "auroc": 98.11, + "mean_score_real": 0.0754, + "mean_score_fake": 0.818 + }, + "select_score": 86.855 + } + } +} \ No newline at end of file diff --git a/repro/cure_stage1/results/epoch_select_r3.json b/repro/cure_stage1/results/epoch_select_r3.json new file mode 100644 index 0000000000000000000000000000000000000000..ececa2c6a46458c4bf105c0e16582023eef3d7c7 --- /dev/null +++ b/repro/cure_stage1/results/epoch_select_r3.json @@ -0,0 +1,480 @@ +{ + "rule": "select_score = mean(Synthbuster bacc of the stage-1 ratio head direct, Synthbuster bacc of the SD1.4 linear probe); argmax over R1 epochs, ties within 0.5 -> earlier epoch; R2: final epoch", + "released_total_dW": 1.8575520282872215, + "rows": { + "released": { + "total_dW": 1.8576, + "dW_over_released": 1.0, + "mix_fit_fresh_head": { + "bce": 0.51167, + "excess_bce": 0.02204, + "floor": 0.48963, + "mae": 0.0643, + "pearson": 0.9539, + "spearman": 0.9536 + }, + "probe_sd14_test": { + "real_acc": 99.7, + "fake_recall": 99.95, + "bacc": 99.83, + "auroc": 100.0, + "mean_score_real": 0.003, + "mean_score_fake": 0.9992 + }, + "probe_synthbuster": { + "real_acc": 99.7, + "fake_recall": 90.21, + "bacc": 94.95, + "auroc": 99.14, + "mean_score_real": 0.003, + "mean_score_fake": 0.8966 + }, + "probe_wildrf_DIAGNOSTIC": { + "real_acc": 95.2, + "fake_recall": 98.08, + "bacc": 96.64, + "auroc": 99.26, + "mean_score_real": 0.0549, + "mean_score_fake": 0.9749 + }, + "direct_head": "fresh", + "direct_sd14_test": { + "real_acc": 99.6, + "fake_recall": 99.95, + "bacc": 99.78, + "auroc": 100.0, + "mean_score_real": 0.0585, + "mean_score_fake": 0.9545 + }, + "direct_synthbuster": { + "real_acc": 99.6, + "fake_recall": 91.14, + "bacc": 95.37, + "auroc": 98.6, + "mean_score_real": 0.0585, + "mean_score_fake": 0.8346 + }, + "direct_wildrf_DIAGNOSTIC": { + "real_acc": 92.57, + "fake_recall": 98.32, + "bacc": 95.44, + "auroc": 98.79, + "mean_score_real": 0.1465, + "mean_score_fake": 0.9051 + }, + "select_score": 95.16 + }, + "base": { + "mix_fit_fresh_head": { + "bce": 0.58778, + "excess_bce": 0.09815, + "floor": 0.48963, + "mae": 0.1486, + "pearson": 0.7623, + "spearman": 0.7614 + }, + "probe_sd14_test": { + "real_acc": 98.75, + "fake_recall": 98.8, + "bacc": 98.78, + "auroc": 99.94, + "mean_score_real": 0.0159, + "mean_score_fake": 0.9856 + }, + "probe_synthbuster": { + "real_acc": 98.75, + "fake_recall": 86.32, + "bacc": 92.54, + "auroc": 97.99, + "mean_score_real": 0.0159, + "mean_score_fake": 0.8555 + }, + "probe_wildrf_DIAGNOSTIC": { + "real_acc": 85.61, + "fake_recall": 97.28, + "bacc": 91.45, + "auroc": 98.71, + "mean_score_real": 0.1555, + "mean_score_fake": 0.9732 + }, + "direct_head": "fresh", + "direct_sd14_test": { + "real_acc": 95.3, + "fake_recall": 97.45, + "bacc": 96.38, + "auroc": 99.48, + "mean_score_real": 0.1877, + "mean_score_fake": 0.8734 + }, + "direct_synthbuster": { + "real_acc": 95.3, + "fake_recall": 78.01, + "bacc": 86.66, + "auroc": 93.98, + "mean_score_real": 0.1877, + "mean_score_fake": 0.6902 + }, + "direct_wildrf_DIAGNOSTIC": { + "real_acc": 88.17, + "fake_recall": 93.05, + "bacc": 90.61, + "auroc": 96.89, + "mean_score_real": 0.2541, + "mean_score_fake": 0.8142 + }, + "select_score": 89.6 + }, + "r3e0": { + "total_dW": 1.243, + "dW_over_released": 0.669, + "mix_fit_fresh_head": { + "bce": 0.53893, + "excess_bce": 0.0493, + "floor": 0.48963, + "mae": 0.1012, + "pearson": 0.8848, + "spearman": 0.8829 + }, + "probe_sd14_test": { + "real_acc": 99.8, + "fake_recall": 99.8, + "bacc": 99.8, + "auroc": 99.99, + "mean_score_real": 0.0035, + "mean_score_fake": 0.9971 + }, + "probe_synthbuster": { + "real_acc": 99.8, + "fake_recall": 85.94, + "bacc": 92.87, + "auroc": 99.42, + "mean_score_real": 0.0035, + "mean_score_fake": 0.8497 + }, + "probe_wildrf_DIAGNOSTIC": { + "real_acc": 96.72, + "fake_recall": 91.77, + "bacc": 94.25, + "auroc": 98.72, + "mean_score_real": 0.0398, + "mean_score_fake": 0.9057 + }, + "mix_fit_own_head": { + "bce": 0.5431, + "excess_bce": 0.05347, + "floor": 0.48963, + "mae": 0.106, + "pearson": 0.8812, + "spearman": 0.881 + }, + "direct_head": "own", + "direct_sd14_test": { + "real_acc": 97.95, + "fake_recall": 99.85, + "bacc": 98.9, + "auroc": 99.98, + "mean_score_real": 0.2162, + "mean_score_fake": 0.9235 + }, + "direct_synthbuster": { + "real_acc": 97.95, + "fake_recall": 93.55, + "bacc": 95.75, + "auroc": 99.11, + "mean_score_real": 0.2162, + "mean_score_fake": 0.8166 + }, + "direct_wildrf_DIAGNOSTIC": { + "real_acc": 93.13, + "fake_recall": 98.16, + "bacc": 95.64, + "auroc": 99.24, + "mean_score_real": 0.263, + "mean_score_fake": 0.8519 + }, + "select_score": 94.31 + }, + "r3e1": { + "total_dW": 2.3348, + "dW_over_released": 1.257, + "mix_fit_fresh_head": { + "bce": 0.5086, + "excess_bce": 0.01897, + "floor": 0.48963, + "mae": 0.0596, + "pearson": 0.9589, + "spearman": 0.9586 + }, + "probe_sd14_test": { + "real_acc": 99.8, + "fake_recall": 99.95, + "bacc": 99.88, + "auroc": 100.0, + "mean_score_real": 0.0022, + "mean_score_fake": 0.9993 + }, + "probe_synthbuster": { + "real_acc": 99.8, + "fake_recall": 84.69, + "bacc": 92.25, + "auroc": 98.72, + "mean_score_real": 0.0022, + "mean_score_fake": 0.8408 + }, + "probe_wildrf_DIAGNOSTIC": { + "real_acc": 95.2, + "fake_recall": 94.17, + "bacc": 94.69, + "auroc": 98.7, + "mean_score_real": 0.0512, + "mean_score_fake": 0.9344 + }, + "mix_fit_own_head": { + "bce": 0.50422, + "excess_bce": 0.01459, + "floor": 0.48963, + "mae": 0.0525, + "pearson": 0.9701, + "spearman": 0.9701 + }, + "direct_head": "own", + "direct_sd14_test": { + "real_acc": 99.6, + "fake_recall": 99.95, + "bacc": 99.78, + "auroc": 99.99, + "mean_score_real": 0.0629, + "mean_score_fake": 0.9608 + }, + "direct_synthbuster": { + "real_acc": 99.6, + "fake_recall": 86.09, + "bacc": 92.85, + "auroc": 98.62, + "mean_score_real": 0.0629, + "mean_score_fake": 0.7958 + }, + "direct_wildrf_DIAGNOSTIC": { + "real_acc": 94.32, + "fake_recall": 94.73, + "bacc": 94.53, + "auroc": 98.38, + "mean_score_real": 0.1354, + "mean_score_fake": 0.8635 + }, + "select_score": 92.55 + }, + "r3e2": { + "total_dW": 2.9232, + "dW_over_released": 1.574, + "mix_fit_fresh_head": { + "bce": 0.50179, + "excess_bce": 0.01216, + "floor": 0.48963, + "mae": 0.0464, + "pearson": 0.9749, + "spearman": 0.975 + }, + "probe_sd14_test": { + "real_acc": 99.9, + "fake_recall": 99.95, + "bacc": 99.92, + "auroc": 100.0, + "mean_score_real": 0.001, + "mean_score_fake": 0.9992 + }, + "probe_synthbuster": { + "real_acc": 99.9, + "fake_recall": 70.24, + "bacc": 85.07, + "auroc": 96.35, + "mean_score_real": 0.001, + "mean_score_fake": 0.6952 + }, + "probe_wildrf_DIAGNOSTIC": { + "real_acc": 98.0, + "fake_recall": 83.07, + "bacc": 90.53, + "auroc": 98.35, + "mean_score_real": 0.0222, + "mean_score_fake": 0.8289 + }, + "mix_fit_own_head": { + "bce": 0.49828, + "excess_bce": 0.00865, + "floor": 0.48963, + "mae": 0.038, + "pearson": 0.9823, + "spearman": 0.9821 + }, + "direct_head": "own", + "direct_sd14_test": { + "real_acc": 99.9, + "fake_recall": 99.9, + "bacc": 99.9, + "auroc": 100.0, + "mean_score_real": 0.0339, + "mean_score_fake": 0.9709 + }, + "direct_synthbuster": { + "real_acc": 99.9, + "fake_recall": 74.36, + "bacc": 87.13, + "auroc": 97.31, + "mean_score_real": 0.0339, + "mean_score_fake": 0.7061 + }, + "direct_wildrf_DIAGNOSTIC": { + "real_acc": 97.84, + "fake_recall": 86.5, + "bacc": 92.17, + "auroc": 98.36, + "mean_score_real": 0.0708, + "mean_score_fake": 0.8072 + }, + "select_score": 86.1 + }, + "r3e3": { + "total_dW": 3.1654, + "dW_over_released": 1.704, + "mix_fit_fresh_head": { + "bce": 0.50005, + "excess_bce": 0.01042, + "floor": 0.48963, + "mae": 0.0428, + "pearson": 0.9787, + "spearman": 0.9787 + }, + "probe_sd14_test": { + "real_acc": 99.9, + "fake_recall": 99.95, + "bacc": 99.92, + "auroc": 100.0, + "mean_score_real": 0.001, + "mean_score_fake": 0.9992 + }, + "probe_synthbuster": { + "real_acc": 99.9, + "fake_recall": 65.89, + "bacc": 82.89, + "auroc": 96.33, + "mean_score_real": 0.001, + "mean_score_fake": 0.6647 + }, + "probe_wildrf_DIAGNOSTIC": { + "real_acc": 98.24, + "fake_recall": 78.12, + "bacc": 88.18, + "auroc": 97.81, + "mean_score_real": 0.0211, + "mean_score_fake": 0.7765 + }, + "mix_fit_own_head": { + "bce": 0.49691, + "excess_bce": 0.00728, + "floor": 0.48963, + "mae": 0.034, + "pearson": 0.9851, + "spearman": 0.9851 + }, + "direct_head": "own", + "direct_sd14_test": { + "real_acc": 99.9, + "fake_recall": 99.95, + "bacc": 99.92, + "auroc": 100.0, + "mean_score_real": 0.029, + "mean_score_fake": 0.9754 + }, + "direct_synthbuster": { + "real_acc": 99.9, + "fake_recall": 75.37, + "bacc": 87.63, + "auroc": 97.38, + "mean_score_real": 0.029, + "mean_score_fake": 0.7227 + }, + "direct_wildrf_DIAGNOSTIC": { + "real_acc": 96.56, + "fake_recall": 85.86, + "bacc": 91.21, + "auroc": 97.93, + "mean_score_real": 0.0723, + "mean_score_fake": 0.809 + }, + "select_score": 85.26 + }, + "r3e4": { + "total_dW": 3.2437, + "dW_over_released": 1.746, + "mix_fit_fresh_head": { + "bce": 0.49952, + "excess_bce": 0.00989, + "floor": 0.48963, + "mae": 0.0416, + "pearson": 0.9799, + "spearman": 0.9799 + }, + "probe_sd14_test": { + "real_acc": 99.9, + "fake_recall": 99.95, + "bacc": 99.92, + "auroc": 100.0, + "mean_score_real": 0.0011, + "mean_score_fake": 0.9992 + }, + "probe_synthbuster": { + "real_acc": 99.9, + "fake_recall": 64.96, + "bacc": 82.43, + "auroc": 95.98, + "mean_score_real": 0.0011, + "mean_score_fake": 0.6547 + }, + "probe_wildrf_DIAGNOSTIC": { + "real_acc": 98.24, + "fake_recall": 78.04, + "bacc": 88.14, + "auroc": 97.92, + "mean_score_real": 0.0209, + "mean_score_fake": 0.7743 + }, + "mix_fit_own_head": { + "bce": 0.49639, + "excess_bce": 0.00676, + "floor": 0.48963, + "mae": 0.0328, + "pearson": 0.9862, + "spearman": 0.9862 + }, + "direct_head": "own", + "direct_sd14_test": { + "real_acc": 99.9, + "fake_recall": 99.9, + "bacc": 99.9, + "auroc": 100.0, + "mean_score_real": 0.0274, + "mean_score_fake": 0.9766 + }, + "direct_synthbuster": { + "real_acc": 99.9, + "fake_recall": 73.27, + "bacc": 86.59, + "auroc": 97.07, + "mean_score_real": 0.0274, + "mean_score_fake": 0.7047 + }, + "direct_wildrf_DIAGNOSTIC": { + "real_acc": 97.36, + "fake_recall": 83.31, + "bacc": 90.33, + "auroc": 97.94, + "mean_score_real": 0.0648, + "mean_score_fake": 0.7945 + }, + "select_score": 84.51 + } + }, + "selected": "r3e0", + "r3_selected": "r3e0" +} \ No newline at end of file diff --git a/repro/cure_stage1/results/feature_analysis_284084.json b/repro/cure_stage1/results/feature_analysis_284084.json new file mode 100644 index 0000000000000000000000000000000000000000..72f74db1c0e80b6dc69fdfcb86e2507aedcaf207 --- /dev/null +++ b/repro/cure_stage1/results/feature_analysis_284084.json @@ -0,0 +1,1266 @@ +{ + "counts": { + "train_clean": 5144, + "test_clean": 4000, + "test_jpeg50": 2000, + "test_blur1": 2000, + "test_blur2": 2000, + "test_resize05": 2000, + "mix_train_after": 4000, + "mix_train_before": 4000, + "mix_train_noq70": 4000, + "mix_val_after": 2000, + "mix_val_before": 2000, + "mix_val_noq70": 2000, + "rf_grid_after": 12000, + "rf_grid_before": 12000, + "wild": 2503, + "extra_vs_real": 3287, + "test_jpeg95": 2000, + "mix_val_aug_gray": 2000, + "mix_val_aug_blur1": 2000, + "mix_val_aug_jpeg60": 2000, + "mix_train_native": 4000, + "mix_val_native": 2000 + }, + "ratio_regression": { + "base/after/fresh_head_val": { + "bce": 0.58778, + "excess_bce": 0.09815, + "floor": 0.48963, + "mae": 0.1485, + "pearson": 0.7623, + "spearman": 0.7614 + }, + "base/after/fresh_head_train": { + "bce": 0.54736, + "excess_bce": 0.04097, + "floor": 0.50639, + "mae": 0.0957, + "pearson": 0.9016, + "spearman": 0.9021 + }, + "base/before/fresh_head_val": { + "bce": 0.58079, + "excess_bce": 0.09116, + "floor": 0.48963, + "mae": 0.1423, + "pearson": 0.7841, + "spearman": 0.784 + }, + "base/before/fresh_head_train": { + "bce": 0.54513, + "excess_bce": 0.03874, + "floor": 0.50639, + "mae": 0.0927, + "pearson": 0.9084, + "spearman": 0.9087 + }, + "base/noq70/fresh_head_val": { + "bce": 0.56901, + "excess_bce": 0.07938, + "floor": 0.48963, + "mae": 0.1324, + "pearson": 0.8136, + "spearman": 0.8133 + }, + "base/noq70/fresh_head_train": { + "bce": 0.54183, + "excess_bce": 0.03544, + "floor": 0.50639, + "mae": 0.0885, + "pearson": 0.9161, + "spearman": 0.9165 + }, + "base/native/fresh_head_val": { + "bce": 0.5792, + "excess_bce": 0.08957, + "floor": 0.48963, + "mae": 0.1428, + "pearson": 0.7877, + "spearman": 0.788 + }, + "base/native/fresh_head_train": { + "bce": 0.54587, + "excess_bce": 0.03948, + "floor": 0.50639, + "mae": 0.094, + "pearson": 0.9052, + "spearman": 0.9054 + }, + "base/head_after_on_before_val": { + "bce": 0.58989, + "excess_bce": 0.10026, + "floor": 0.48963, + "mae": 0.1487, + "pearson": 0.7661, + "spearman": 0.7652 + }, + "base/head_after_on_noq70_val": { + "bce": 0.59559, + "excess_bce": 0.10596, + "floor": 0.48963, + "mae": 0.1543, + "pearson": 0.7662, + "spearman": 0.7657 + }, + "base/head_after_on_native_val": { + "bce": 0.60063, + "excess_bce": 0.111, + "floor": 0.48963, + "mae": 0.1579, + "pearson": 0.7448, + "spearman": 0.7424 + }, + "released/after/fresh_head_val": { + "bce": 0.51164, + "excess_bce": 0.02201, + "floor": 0.48963, + "mae": 0.0643, + "pearson": 0.9539, + "spearman": 0.9537 + }, + "released/after/fresh_head_train": { + "bce": 0.5169, + "excess_bce": 0.01051, + "floor": 0.50639, + "mae": 0.0452, + "pearson": 0.9759, + "spearman": 0.9759 + }, + "released/before/fresh_head_val": { + "bce": 0.51655, + "excess_bce": 0.02693, + "floor": 0.48963, + "mae": 0.0712, + "pearson": 0.9424, + "spearman": 0.9423 + }, + "released/before/fresh_head_train": { + "bce": 0.51774, + "excess_bce": 0.01135, + "floor": 0.50639, + "mae": 0.0475, + "pearson": 0.9741, + "spearman": 0.9742 + }, + "released/noq70/fresh_head_val": { + "bce": 0.51507, + "excess_bce": 0.02544, + "floor": 0.48963, + "mae": 0.0712, + "pearson": 0.9462, + "spearman": 0.9461 + }, + "released/noq70/fresh_head_train": { + "bce": 0.51769, + "excess_bce": 0.0113, + "floor": 0.50639, + "mae": 0.0483, + "pearson": 0.9747, + "spearman": 0.9747 + }, + "released/native/fresh_head_val": { + "bce": 0.52157, + "excess_bce": 0.03194, + "floor": 0.48963, + "mae": 0.0789, + "pearson": 0.9305, + "spearman": 0.9305 + }, + "released/native/fresh_head_train": { + "bce": 0.52084, + "excess_bce": 0.01445, + "floor": 0.50639, + "mae": 0.0543, + "pearson": 0.9662, + "spearman": 0.9666 + }, + "released/head_after_on_before_val": { + "bce": 0.51629, + "excess_bce": 0.02666, + "floor": 0.48963, + "mae": 0.0712, + "pearson": 0.9426, + "spearman": 0.9428 + }, + "released/head_after_on_noq70_val": { + "bce": 0.52871, + "excess_bce": 0.03908, + "floor": 0.48963, + "mae": 0.087, + "pearson": 0.9328, + "spearman": 0.9352 + }, + "released/head_after_on_native_val": { + "bce": 0.52269, + "excess_bce": 0.03306, + "floor": 0.48963, + "mae": 0.0804, + "pearson": 0.9273, + "spearman": 0.9272 + }, + "ours/after/fresh_head_val": { + "bce": 0.49681, + "excess_bce": 0.00718, + "floor": 0.48963, + "mae": 0.0351, + "pearson": 0.9857, + "spearman": 0.9859 + }, + "ours/after/fresh_head_train": { + "bce": 0.5101, + "excess_bce": 0.00371, + "floor": 0.50639, + "mae": 0.0255, + "pearson": 0.9918, + "spearman": 0.9917 + }, + "ours/after/trained_ratio_head_val": { + "bce": 0.49458, + "excess_bce": 0.00495, + "floor": 0.48963, + "mae": 0.0269, + "pearson": 0.9902, + "spearman": 0.9903 + }, + "ours/before/fresh_head_val": { + "bce": 0.50598, + "excess_bce": 0.01635, + "floor": 0.48963, + "mae": 0.0552, + "pearson": 0.966, + "spearman": 0.9664 + }, + "ours/before/fresh_head_train": { + "bce": 0.51363, + "excess_bce": 0.00724, + "floor": 0.50639, + "mae": 0.0374, + "pearson": 0.9838, + "spearman": 0.9837 + }, + "ours/before/trained_ratio_head_val": { + "bce": 0.55352, + "excess_bce": 0.06389, + "floor": 0.48963, + "mae": 0.1142, + "pearson": 0.9241, + "spearman": 0.9686 + }, + "ours/noq70/fresh_head_val": { + "bce": 0.50521, + "excess_bce": 0.01558, + "floor": 0.48963, + "mae": 0.0546, + "pearson": 0.9683, + "spearman": 0.969 + }, + "ours/noq70/fresh_head_train": { + "bce": 0.51334, + "excess_bce": 0.00695, + "floor": 0.50639, + "mae": 0.0368, + "pearson": 0.9846, + "spearman": 0.9845 + }, + "ours/noq70/trained_ratio_head_val": { + "bce": 0.54723, + "excess_bce": 0.0576, + "floor": 0.48963, + "mae": 0.1049, + "pearson": 0.9261, + "spearman": 0.9649 + }, + "ours/native/fresh_head_val": { + "bce": 0.51325, + "excess_bce": 0.02362, + "floor": 0.48963, + "mae": 0.0668, + "pearson": 0.9503, + "spearman": 0.9511 + }, + "ours/native/fresh_head_train": { + "bce": 0.51791, + "excess_bce": 0.01152, + "floor": 0.50639, + "mae": 0.0483, + "pearson": 0.9737, + "spearman": 0.9738 + }, + "ours/native/trained_ratio_head_val": { + "bce": 0.58514, + "excess_bce": 0.09551, + "floor": 0.48963, + "mae": 0.1392, + "pearson": 0.8773, + "spearman": 0.9412 + }, + "ours/head_after_on_before_val": { + "bce": 0.56135, + "excess_bce": 0.07172, + "floor": 0.48963, + "mae": 0.1176, + "pearson": 0.9208, + "spearman": 0.9571 + }, + "ours/head_after_on_noq70_val": { + "bce": 0.55926, + "excess_bce": 0.06963, + "floor": 0.48963, + "mae": 0.1131, + "pearson": 0.9165, + "spearman": 0.9461 + }, + "ours/head_after_on_native_val": { + "bce": 0.60025, + "excess_bce": 0.11062, + "floor": 0.48963, + "mae": 0.1461, + "pearson": 0.8715, + "spearman": 0.9256 + }, + "base/head_after_on_aug_gray_val": { + "bce": 0.62034, + "excess_bce": 0.13071, + "floor": 0.48963, + "mae": 0.1786, + "pearson": 0.6494, + "spearman": 0.6438 + }, + "base/head_after_on_aug_blur1_val": { + "bce": 0.59572, + "excess_bce": 0.10609, + "floor": 0.48963, + "mae": 0.1561, + "pearson": 0.7412, + "spearman": 0.7396 + }, + "base/head_after_on_aug_jpeg60_val": { + "bce": 0.59962, + "excess_bce": 0.10999, + "floor": 0.48963, + "mae": 0.1573, + "pearson": 0.7334, + "spearman": 0.7316 + }, + "released/head_after_on_aug_gray_val": { + "bce": 0.54857, + "excess_bce": 0.05894, + "floor": 0.48963, + "mae": 0.103, + "pearson": 0.8848, + "spearman": 0.8901 + }, + "released/head_after_on_aug_blur1_val": { + "bce": 0.51817, + "excess_bce": 0.02854, + "floor": 0.48963, + "mae": 0.0754, + "pearson": 0.9366, + "spearman": 0.9369 + }, + "released/head_after_on_aug_jpeg60_val": { + "bce": 0.51368, + "excess_bce": 0.02405, + "floor": 0.48963, + "mae": 0.0654, + "pearson": 0.9498, + "spearman": 0.9495 + }, + "ours/head_after_on_aug_gray_val": { + "bce": 0.51867, + "excess_bce": 0.02904, + "floor": 0.48963, + "mae": 0.0644, + "pearson": 0.9425, + "spearman": 0.9447 + }, + "ours/trained_ratio_head_on_aug_gray_val": { + "bce": 0.51459, + "excess_bce": 0.02496, + "floor": 0.48963, + "mae": 0.0563, + "pearson": 0.9491, + "spearman": 0.9504 + }, + "ours/head_after_on_aug_blur1_val": { + "bce": 0.50014, + "excess_bce": 0.01051, + "floor": 0.48963, + "mae": 0.0433, + "pearson": 0.9783, + "spearman": 0.9797 + }, + "ours/trained_ratio_head_on_aug_blur1_val": { + "bce": 0.49861, + "excess_bce": 0.00898, + "floor": 0.48963, + "mae": 0.038, + "pearson": 0.9825, + "spearman": 0.9834 + }, + "ours/head_after_on_aug_jpeg60_val": { + "bce": 0.49695, + "excess_bce": 0.00732, + "floor": 0.48963, + "mae": 0.0345, + "pearson": 0.987, + "spearman": 0.9871 + }, + "ours/trained_ratio_head_on_aug_jpeg60_val": { + "bce": 0.49473, + "excess_bce": 0.0051, + "floor": 0.48963, + "mae": 0.0276, + "pearson": 0.991, + "spearman": 0.991 + } + }, + "linear_probes": { + "base/genimage_probe_on_test_clean": { + "real_acc": 98.75, + "fake_recall": 98.8, + "bacc": 98.78, + "auroc": 99.94, + "mean_score_real": 0.016, + "mean_score_fake": 0.9856 + }, + "base/genimage_probe_on_wild": { + "real_acc": 85.29, + "fake_recall": 97.28, + "bacc": 91.29, + "auroc": 98.71, + "mean_score_real": 0.1559, + "mean_score_fake": 0.9732 + }, + "base/genimage_probe_on_test_jpeg50": { + "real_acc": 99.3, + "fake_recall": 90.9, + "bacc": 95.1, + "auroc": 99.72, + "mean_score_real": 0.0091, + "mean_score_fake": 0.9019 + }, + "base/genimage_probe_on_test_blur1": { + "real_acc": 97.8, + "fake_recall": 98.7, + "bacc": 98.25, + "auroc": 99.89, + "mean_score_real": 0.0268, + "mean_score_fake": 0.9831 + }, + "base/genimage_probe_on_test_blur2": { + "real_acc": 96.9, + "fake_recall": 93.9, + "bacc": 95.4, + "auroc": 99.29, + "mean_score_real": 0.04, + "mean_score_fake": 0.9314 + }, + "base/genimage_probe_on_test_resize05": { + "real_acc": 99.5, + "fake_recall": 97.2, + "bacc": 98.35, + "auroc": 99.92, + "mean_score_real": 0.0088, + "mean_score_fake": 0.9676 + }, + "base/genimage_probe_on_extra_vs_real": { + "real_acc": 98.75, + "fake_recall": 86.32, + "bacc": 92.54, + "auroc": 97.99, + "mean_score_real": 0.016, + "mean_score_fake": 0.856 + }, + "base/wild_5fold_cv_probe": { + "real_acc": 99.36, + "fake_recall": 97.84, + "bacc": 98.6, + "auroc": 99.88, + "mean_score_real": 0.0104, + "mean_score_fake": 0.9772 + }, + "released/genimage_probe_on_test_clean": { + "real_acc": 99.7, + "fake_recall": 99.95, + "bacc": 99.83, + "auroc": 100.0, + "mean_score_real": 0.003, + "mean_score_fake": 0.9992 + }, + "released/genimage_probe_on_wild": { + "real_acc": 95.36, + "fake_recall": 98.08, + "bacc": 96.72, + "auroc": 99.26, + "mean_score_real": 0.0547, + "mean_score_fake": 0.9746 + }, + "released/genimage_probe_on_test_jpeg50": { + "real_acc": 99.4, + "fake_recall": 100.0, + "bacc": 99.7, + "auroc": 100.0, + "mean_score_real": 0.005, + "mean_score_fake": 0.9992 + }, + "released/genimage_probe_on_test_blur1": { + "real_acc": 98.7, + "fake_recall": 100.0, + "bacc": 99.35, + "auroc": 99.99, + "mean_score_real": 0.0147, + "mean_score_fake": 0.9995 + }, + "released/genimage_probe_on_test_blur2": { + "real_acc": 98.6, + "fake_recall": 99.4, + "bacc": 99.0, + "auroc": 99.9, + "mean_score_real": 0.017, + "mean_score_fake": 0.991 + }, + "released/genimage_probe_on_test_resize05": { + "real_acc": 99.9, + "fake_recall": 99.6, + "bacc": 99.75, + "auroc": 99.99, + "mean_score_real": 0.0019, + "mean_score_fake": 0.9951 + }, + "released/genimage_probe_on_extra_vs_real": { + "real_acc": 99.7, + "fake_recall": 90.21, + "bacc": 94.95, + "auroc": 99.12, + "mean_score_real": 0.003, + "mean_score_fake": 0.8958 + }, + "released/wild_5fold_cv_probe": { + "real_acc": 99.12, + "fake_recall": 99.04, + "bacc": 99.08, + "auroc": 99.95, + "mean_score_real": 0.0099, + "mean_score_fake": 0.9881 + }, + "ours/genimage_probe_on_test_clean": { + "real_acc": 99.9, + "fake_recall": 100.0, + "bacc": 99.95, + "auroc": 100.0, + "mean_score_real": 0.0012, + "mean_score_fake": 0.9995 + }, + "ours/genimage_probe_on_wild": { + "real_acc": 99.12, + "fake_recall": 73.48, + "bacc": 86.3, + "auroc": 98.2, + "mean_score_real": 0.0099, + "mean_score_fake": 0.735 + }, + "ours/genimage_probe_on_test_jpeg50": { + "real_acc": 100.0, + "fake_recall": 100.0, + "bacc": 100.0, + "auroc": 100.0, + "mean_score_real": 0.0001, + "mean_score_fake": 0.9995 + }, + "ours/genimage_probe_on_test_blur1": { + "real_acc": 99.2, + "fake_recall": 99.8, + "bacc": 99.5, + "auroc": 100.0, + "mean_score_real": 0.0078, + "mean_score_fake": 0.9983 + }, + "ours/genimage_probe_on_test_blur2": { + "real_acc": 99.6, + "fake_recall": 98.5, + "bacc": 99.05, + "auroc": 99.91, + "mean_score_real": 0.0059, + "mean_score_fake": 0.9812 + }, + "ours/genimage_probe_on_test_resize05": { + "real_acc": 99.9, + "fake_recall": 99.2, + "bacc": 99.55, + "auroc": 100.0, + "mean_score_real": 0.0007, + "mean_score_fake": 0.9919 + }, + "ours/genimage_probe_on_extra_vs_real": { + "real_acc": 99.9, + "fake_recall": 62.08, + "bacc": 80.99, + "auroc": 96.28, + "mean_score_real": 0.0012, + "mean_score_fake": 0.6233 + }, + "ours/wild_5fold_cv_probe": { + "real_acc": 99.2, + "fake_recall": 98.72, + "bacc": 98.96, + "auroc": 99.9, + "mean_score_real": 0.0115, + "mean_score_fake": 0.9847 + } + }, + "detectors": { + "released_detector/test_clean": { + "real_acc": 99.7, + "fake_recall": 100.0, + "bacc": 99.85, + "auroc": 100.0, + "mean_score_real": 0.0046, + "mean_score_fake": 0.9993 + }, + "ours_detector/test_clean": { + "real_acc": 99.9, + "fake_recall": 100.0, + "bacc": 99.95, + "auroc": 100.0, + "mean_score_real": 0.0019, + "mean_score_fake": 0.9999 + }, + "ours_stage1_ratio_head_direct/test_clean": { + "real_acc": 99.9, + "fake_recall": 100.0, + "bacc": 99.95, + "auroc": 100.0, + "mean_score_real": 0.026, + "mean_score_fake": 0.9807 + }, + "base_fresh_ratio_head_after_direct/test_clean": { + "real_acc": 95.35, + "fake_recall": 97.45, + "bacc": 96.4, + "auroc": 99.48, + "mean_score_real": 0.1878, + "mean_score_fake": 0.8733 + }, + "released_fresh_ratio_head_after_direct/test_clean": { + "real_acc": 99.65, + "fake_recall": 99.95, + "bacc": 99.8, + "auroc": 100.0, + "mean_score_real": 0.0583, + "mean_score_fake": 0.9545 + }, + "ours_fresh_ratio_head_after_direct/test_clean": { + "real_acc": 99.8, + "fake_recall": 100.0, + "bacc": 99.9, + "auroc": 100.0, + "mean_score_real": 0.0239, + "mean_score_fake": 0.9801 + }, + "released_detector/wild": { + "real_acc": 94.48, + "fake_recall": 97.84, + "bacc": 96.16, + "auroc": 99.19, + "mean_score_real": 0.0556, + "mean_score_fake": 0.9716 + }, + "ours_detector/wild": { + "real_acc": 98.64, + "fake_recall": 76.52, + "bacc": 87.58, + "auroc": 95.5, + "mean_score_real": 0.0146, + "mean_score_fake": 0.7605 + }, + "ours_stage1_ratio_head_direct/wild": { + "real_acc": 98.48, + "fake_recall": 79.15, + "bacc": 88.82, + "auroc": 97.83, + "mean_score_real": 0.0529, + "mean_score_fake": 0.7629 + }, + "base_fresh_ratio_head_after_direct/wild": { + "real_acc": 88.33, + "fake_recall": 93.05, + "bacc": 90.69, + "auroc": 96.89, + "mean_score_real": 0.2541, + "mean_score_fake": 0.8143 + }, + "released_fresh_ratio_head_after_direct/wild": { + "real_acc": 92.57, + "fake_recall": 98.32, + "bacc": 95.44, + "auroc": 98.78, + "mean_score_real": 0.1466, + "mean_score_fake": 0.9053 + }, + "ours_fresh_ratio_head_after_direct/wild": { + "real_acc": 98.0, + "fake_recall": 81.63, + "bacc": 89.82, + "auroc": 97.58, + "mean_score_real": 0.0623, + "mean_score_fake": 0.7852 + }, + "released_detector/test_jpeg50": { + "real_acc": 99.3, + "fake_recall": 99.9, + "bacc": 99.6, + "auroc": 100.0, + "mean_score_real": 0.0082, + "mean_score_fake": 0.9986 + }, + "ours_detector/test_jpeg50": { + "real_acc": 100.0, + "fake_recall": 100.0, + "bacc": 100.0, + "auroc": 100.0, + "mean_score_real": 0.0003, + "mean_score_fake": 0.9999 + }, + "ours_stage1_ratio_head_direct/test_jpeg50": { + "real_acc": 100.0, + "fake_recall": 100.0, + "bacc": 100.0, + "auroc": 100.0, + "mean_score_real": 0.0233, + "mean_score_fake": 0.9849 + }, + "base_fresh_ratio_head_after_direct/test_jpeg50": { + "real_acc": 97.1, + "fake_recall": 89.3, + "bacc": 93.2, + "auroc": 98.47, + "mean_score_real": 0.163, + "mean_score_fake": 0.7541 + }, + "released_fresh_ratio_head_after_direct/test_jpeg50": { + "real_acc": 99.5, + "fake_recall": 100.0, + "bacc": 99.75, + "auroc": 100.0, + "mean_score_real": 0.0536, + "mean_score_fake": 0.9563 + }, + "ours_fresh_ratio_head_after_direct/test_jpeg50": { + "real_acc": 100.0, + "fake_recall": 100.0, + "bacc": 100.0, + "auroc": 100.0, + "mean_score_real": 0.0191, + "mean_score_fake": 0.9863 + }, + "released_detector/test_blur1": { + "real_acc": 98.1, + "fake_recall": 100.0, + "bacc": 99.05, + "auroc": 99.99, + "mean_score_real": 0.0218, + "mean_score_fake": 0.9993 + }, + "ours_detector/test_blur1": { + "real_acc": 99.2, + "fake_recall": 100.0, + "bacc": 99.6, + "auroc": 99.98, + "mean_score_real": 0.0097, + "mean_score_fake": 0.9995 + }, + "ours_stage1_ratio_head_direct/test_blur1": { + "real_acc": 98.9, + "fake_recall": 100.0, + "bacc": 99.45, + "auroc": 100.0, + "mean_score_real": 0.0503, + "mean_score_fake": 0.9758 + }, + "base_fresh_ratio_head_after_direct/test_blur1": { + "real_acc": 93.8, + "fake_recall": 96.7, + "bacc": 95.25, + "auroc": 99.2, + "mean_score_real": 0.1993, + "mean_score_fake": 0.8429 + }, + "released_fresh_ratio_head_after_direct/test_blur1": { + "real_acc": 98.2, + "fake_recall": 100.0, + "bacc": 99.1, + "auroc": 100.0, + "mean_score_real": 0.0838, + "mean_score_fake": 0.9547 + }, + "ours_fresh_ratio_head_after_direct/test_blur1": { + "real_acc": 98.8, + "fake_recall": 100.0, + "bacc": 99.4, + "auroc": 100.0, + "mean_score_real": 0.0432, + "mean_score_fake": 0.9765 + }, + "released_detector/test_blur2": { + "real_acc": 96.7, + "fake_recall": 99.0, + "bacc": 97.85, + "auroc": 99.83, + "mean_score_real": 0.0477, + "mean_score_fake": 0.9785 + }, + "ours_detector/test_blur2": { + "real_acc": 99.5, + "fake_recall": 98.1, + "bacc": 98.8, + "auroc": 99.84, + "mean_score_real": 0.0091, + "mean_score_fake": 0.97 + }, + "ours_stage1_ratio_head_direct/test_blur2": { + "real_acc": 99.6, + "fake_recall": 98.8, + "bacc": 99.2, + "auroc": 99.98, + "mean_score_real": 0.0693, + "mean_score_fake": 0.9234 + }, + "base_fresh_ratio_head_after_direct/test_blur2": { + "real_acc": 90.9, + "fake_recall": 91.6, + "bacc": 91.25, + "auroc": 97.2, + "mean_score_real": 0.2283, + "mean_score_fake": 0.7675 + }, + "released_fresh_ratio_head_after_direct/test_blur2": { + "real_acc": 96.4, + "fake_recall": 99.6, + "bacc": 98.0, + "auroc": 99.91, + "mean_score_real": 0.1339, + "mean_score_fake": 0.9171 + }, + "ours_fresh_ratio_head_after_direct/test_blur2": { + "real_acc": 99.4, + "fake_recall": 99.2, + "bacc": 99.3, + "auroc": 99.98, + "mean_score_real": 0.0627, + "mean_score_fake": 0.9409 + }, + "released_detector/test_resize05": { + "real_acc": 99.5, + "fake_recall": 99.7, + "bacc": 99.6, + "auroc": 99.99, + "mean_score_real": 0.0056, + "mean_score_fake": 0.9957 + }, + "ours_detector/test_resize05": { + "real_acc": 99.9, + "fake_recall": 99.6, + "bacc": 99.75, + "auroc": 99.95, + "mean_score_real": 0.0015, + "mean_score_fake": 0.9953 + }, + "ours_stage1_ratio_head_direct/test_resize05": { + "real_acc": 100.0, + "fake_recall": 99.6, + "bacc": 99.8, + "auroc": 100.0, + "mean_score_real": 0.0307, + "mean_score_fake": 0.9705 + }, + "base_fresh_ratio_head_after_direct/test_resize05": { + "real_acc": 96.4, + "fake_recall": 94.9, + "bacc": 95.65, + "auroc": 99.17, + "mean_score_real": 0.1718, + "mean_score_fake": 0.8125 + }, + "released_fresh_ratio_head_after_direct/test_resize05": { + "real_acc": 99.7, + "fake_recall": 99.9, + "bacc": 99.8, + "auroc": 100.0, + "mean_score_real": 0.0568, + "mean_score_fake": 0.9508 + }, + "ours_fresh_ratio_head_after_direct/test_resize05": { + "real_acc": 99.9, + "fake_recall": 99.8, + "bacc": 99.85, + "auroc": 100.0, + "mean_score_real": 0.0271, + "mean_score_fake": 0.974 + }, + "released_detector/extra_vs_real": { + "real_acc": 99.7, + "fake_recall": 88.03, + "bacc": 93.87, + "auroc": 97.99, + "mean_score_real": 0.0046, + "mean_score_fake": 0.8764 + }, + "ours_detector/extra_vs_real": { + "real_acc": 99.9, + "fake_recall": 65.81, + "bacc": 82.86, + "auroc": 92.31, + "mean_score_real": 0.0019, + "mean_score_fake": 0.6586 + }, + "ours_stage1_ratio_head_direct/extra_vs_real": { + "real_acc": 99.9, + "fake_recall": 69.7, + "bacc": 84.8, + "auroc": 97.61, + "mean_score_real": 0.026, + "mean_score_fake": 0.6842 + }, + "base_fresh_ratio_head_after_direct/extra_vs_real": { + "real_acc": 95.35, + "fake_recall": 78.01, + "bacc": 86.68, + "auroc": 93.96, + "mean_score_real": 0.1878, + "mean_score_fake": 0.6901 + }, + "released_fresh_ratio_head_after_direct/extra_vs_real": { + "real_acc": 99.65, + "fake_recall": 91.06, + "bacc": 95.36, + "auroc": 98.59, + "mean_score_real": 0.0583, + "mean_score_fake": 0.8346 + }, + "ours_fresh_ratio_head_after_direct/extra_vs_real": { + "real_acc": 99.8, + "fake_recall": 72.73, + "bacc": 86.26, + "auroc": 97.79, + "mean_score_real": 0.0239, + "mean_score_fake": 0.7075 + }, + "released_detector/wild_facebook": { + "real_acc": 91.25, + "fake_recall": 99.38, + "bacc": 95.31, + "auroc": 98.92, + "mean_score_real": 0.0837, + "mean_score_fake": 0.9831 + }, + "ours_detector/wild_facebook": { + "real_acc": 98.12, + "fake_recall": 66.25, + "bacc": 82.19, + "auroc": 92.73, + "mean_score_real": 0.0201, + "mean_score_fake": 0.6573 + }, + "released_detector/wild_reddit": { + "real_acc": 95.6, + "fake_recall": 97.6, + "bacc": 96.6, + "auroc": 99.27, + "mean_score_real": 0.0468, + "mean_score_fake": 0.9691 + }, + "ours_detector/wild_reddit": { + "real_acc": 98.27, + "fake_recall": 81.07, + "bacc": 89.67, + "auroc": 96.36, + "mean_score_real": 0.0178, + "mean_score_fake": 0.8072 + }, + "released_detector/wild_twitter": { + "real_acc": 93.55, + "fake_recall": 97.66, + "bacc": 95.6, + "auroc": 99.2, + "mean_score_real": 0.0616, + "mean_score_fake": 0.9718 + }, + "ours_detector/wild_twitter": { + "real_acc": 99.71, + "fake_recall": 71.35, + "bacc": 85.53, + "auroc": 94.68, + "mean_score_real": 0.0051, + "mean_score_fake": 0.7065 + }, + "released_detector/extra_dalle2": { + "real_acc": 99.7, + "fake_recall": 72.73, + "bacc": 86.21, + "auroc": 97.19, + "mean_score_real": 0.0046, + "mean_score_fake": 0.7066 + }, + "ours_detector/extra_dalle2": { + "real_acc": 99.9, + "fake_recall": 33.57, + "bacc": 66.73, + "auroc": 82.23, + "mean_score_real": 0.0019, + "mean_score_fake": 0.3355 + }, + "released_detector/extra_dalle3": { + "real_acc": 99.7, + "fake_recall": 99.3, + "bacc": 99.5, + "auroc": 99.97, + "mean_score_real": 0.0046, + "mean_score_fake": 0.9919 + }, + "ours_detector/extra_dalle3": { + "real_acc": 99.9, + "fake_recall": 61.54, + "bacc": 80.72, + "auroc": 96.58, + "mean_score_real": 0.0019, + "mean_score_fake": 0.6194 + }, + "released_detector/extra_firefly": { + "real_acc": 99.7, + "fake_recall": 51.05, + "bacc": 75.37, + "auroc": 88.45, + "mean_score_real": 0.0046, + "mean_score_fake": 0.5183 + }, + "ours_detector/extra_firefly": { + "real_acc": 99.9, + "fake_recall": 10.49, + "bacc": 55.19, + "auroc": 73.45, + "mean_score_real": 0.0019, + "mean_score_fake": 0.1154 + }, + "released_detector/extra_glide": { + "real_acc": 99.7, + "fake_recall": 87.41, + "bacc": 93.56, + "auroc": 98.31, + "mean_score_real": 0.0046, + "mean_score_fake": 0.8526 + }, + "ours_detector/extra_glide": { + "real_acc": 99.9, + "fake_recall": 52.45, + "bacc": 76.17, + "auroc": 89.21, + "mean_score_real": 0.0019, + "mean_score_fake": 0.529 + }, + "released_detector/extra_midjourney-v5": { + "real_acc": 99.7, + "fake_recall": 84.62, + "bacc": 92.16, + "auroc": 98.01, + "mean_score_real": 0.0046, + "mean_score_fake": 0.8511 + }, + "ours_detector/extra_midjourney-v5": { + "real_acc": 99.9, + "fake_recall": 50.35, + "bacc": 75.12, + "auroc": 90.6, + "mean_score_real": 0.0019, + "mean_score_fake": 0.5102 + }, + "released_detector/extra_stable-diffusion-1-3": { + "real_acc": 99.7, + "fake_recall": 100.0, + "bacc": 99.85, + "auroc": 100.0, + "mean_score_real": 0.0046, + "mean_score_fake": 0.9993 + }, + "ours_detector/extra_stable-diffusion-1-3": { + "real_acc": 99.9, + "fake_recall": 100.0, + "bacc": 99.95, + "auroc": 99.99, + "mean_score_real": 0.0019, + "mean_score_fake": 0.9968 + }, + "released_detector/extra_stable-diffusion-1-4": { + "real_acc": 99.7, + "fake_recall": 100.0, + "bacc": 99.85, + "auroc": 100.0, + "mean_score_real": 0.0046, + "mean_score_fake": 0.999 + }, + "ours_detector/extra_stable-diffusion-1-4": { + "real_acc": 99.9, + "fake_recall": 100.0, + "bacc": 99.95, + "auroc": 99.99, + "mean_score_real": 0.0019, + "mean_score_fake": 0.9995 + }, + "released_detector/extra_stable-diffusion-2": { + "real_acc": 99.7, + "fake_recall": 97.9, + "bacc": 98.8, + "auroc": 99.98, + "mean_score_real": 0.0046, + "mean_score_fake": 0.9811 + }, + "ours_detector/extra_stable-diffusion-2": { + "real_acc": 99.9, + "fake_recall": 90.91, + "bacc": 95.4, + "auroc": 99.01, + "mean_score_real": 0.0019, + "mean_score_fake": 0.8964 + }, + "released_detector/extra_stable-diffusion-xl": { + "real_acc": 99.7, + "fake_recall": 99.3, + "bacc": 99.5, + "auroc": 99.99, + "mean_score_real": 0.0046, + "mean_score_fake": 0.9876 + }, + "ours_detector/extra_stable-diffusion-xl": { + "real_acc": 99.9, + "fake_recall": 93.01, + "bacc": 96.45, + "auroc": 99.76, + "mean_score_real": 0.0019, + "mean_score_fake": 0.9255 + } + }, + "geometry": { + "released/drift_from_base": { + "cos_real": 0.4094, + "cos_fake": 0.3842, + "relL2_real": 1.8588, + "relL2_fake": 3.4439 + }, + "ours/drift_from_base": { + "cos_real": 0.2346, + "cos_fake": 0.0884, + "relL2_real": 2.807, + "relL2_fake": 3.0025 + }, + "base/mean_diff_norm_train": 18.3995, + "base/cohen_d_along_train_meandiff/train_clean": 1.632, + "base/cohen_d_along_train_meandiff/test_clean": 1.568, + "base/cohen_d_along_train_meandiff/wild": 1.805, + "base/cohen_d_along_train_meandiff/test_jpeg50": 0.845, + "base/cohen_d_along_train_meandiff/test_blur1": 1.276, + "base/cohen_d_along_train_meandiff/test_blur2": 0.96, + "base/cohen_d_along_train_meandiff/test_resize05": 1.253, + "base/cohen_d_along_train_meandiff/extra_vs_real": 1.165, + "released/mean_diff_norm_train": 148.76, + "released/cohen_d_along_train_meandiff/train_clean": 11.574, + "released/cohen_d_along_train_meandiff/test_clean": 11.463, + "released/cohen_d_along_train_meandiff/wild": 4.253, + "released/cohen_d_along_train_meandiff/test_jpeg50": 11.166, + "released/cohen_d_along_train_meandiff/test_blur1": 7.788, + "released/cohen_d_along_train_meandiff/test_blur2": 6.097, + "released/cohen_d_along_train_meandiff/test_resize05": 11.945, + "released/cohen_d_along_train_meandiff/extra_vs_real": 5.336, + "ours/mean_diff_norm_train": 149.1798, + "ours/cohen_d_along_train_meandiff/train_clean": 16.719, + "ours/cohen_d_along_train_meandiff/test_clean": 16.646, + "ours/cohen_d_along_train_meandiff/wild": 3.084, + "ours/cohen_d_along_train_meandiff/test_jpeg50": 19.349, + "ours/cohen_d_along_train_meandiff/test_blur1": 12.107, + "ours/cohen_d_along_train_meandiff/test_blur2": 8.846, + "ours/cohen_d_along_train_meandiff/test_resize05": 14.137, + "ours/cohen_d_along_train_meandiff/extra_vs_real": 2.662, + "cos_meandiff_released_ours": -0.6183, + "cos_meandiff_released_base": 0.2775, + "cos_meandiff_ours_base": -0.4588, + "cka_test_clean/released_vs_ours": 0.9709, + "cka_wild/released_vs_ours": 0.7099, + "cka_test_clean/released_vs_base": 0.2726, + "cka_wild/released_vs_base": 0.4089, + "cka_test_clean/ours_vs_base": 0.2594, + "cka_wild/ours_vs_base": 0.2829, + "base/rel_feature_change/jpeg50": 0.2726, + "released/rel_feature_change/jpeg50": 0.1321, + "ours/rel_feature_change/jpeg50": 0.1237, + "base/rel_feature_change/blur1": 0.212, + "released/rel_feature_change/blur1": 0.1613, + "ours/rel_feature_change/blur1": 0.1651, + "base/rel_feature_change/blur2": 0.389, + "released/rel_feature_change/blur2": 0.3218, + "ours/rel_feature_change/blur2": 0.3318, + "base/rel_feature_change/resize05": 0.2144, + "released/rel_feature_change/resize05": 0.1359, + "ours/rel_feature_change/resize05": 0.137, + "base/stage2_mu_after": { + "rel_dist_to_released_mu_pct": 78.8009, + "cos_to_released_mu": 0.6728672, + "split_half_rel_dist_pct": 1.9395 + }, + "base/stage2_mu_before": { + "rel_dist_to_released_mu_pct": 86.7142, + "cos_to_released_mu": 0.5323849, + "split_half_rel_dist_pct": 2.0219 + }, + "base/stage2_mu_after_vs_before_rel_dist_pct": 15.1944, + "released/stage2_mu_after": { + "rel_dist_to_released_mu_pct": 0.5892, + "cos_to_released_mu": 0.9999852, + "split_half_rel_dist_pct": 0.9729 + }, + "released/stage2_mu_before": { + "rel_dist_to_released_mu_pct": 3.5923, + "cos_to_released_mu": 0.9994409, + "split_half_rel_dist_pct": 0.9593 + }, + "released/stage2_mu_after_vs_before_rel_dist_pct": 3.3821, + "ours/stage2_mu_after": { + "rel_dist_to_released_mu_pct": 72.0414, + "cos_to_released_mu": 0.6959862, + "split_half_rel_dist_pct": 0.5817 + }, + "ours/stage2_mu_before": { + "rel_dist_to_released_mu_pct": 66.4954, + "cos_to_released_mu": 0.7472688, + "split_half_rel_dist_pct": 0.7177 + }, + "ours/stage2_mu_after_vs_before_rel_dist_pct": 10.1239, + "base/format_probe_q95_vs_q50_5fold": { + "real_acc": 79.0, + "fake_recall": 77.65, + "bacc": 78.33, + "auroc": 85.59, + "mean_score_real": 0.2205, + "mean_score_fake": 0.7697 + }, + "base/format_shift_norm_over_source_shift_norm": 0.2251, + "released/format_probe_q95_vs_q50_5fold": { + "real_acc": 83.85, + "fake_recall": 82.9, + "bacc": 83.38, + "auroc": 89.96, + "mean_score_real": 0.1727, + "mean_score_fake": 0.821 + }, + "released/format_shift_norm_over_source_shift_norm": 0.0253, + "ours/format_probe_q95_vs_q50_5fold": { + "real_acc": 89.6, + "fake_recall": 90.7, + "bacc": 90.15, + "auroc": 95.1, + "mean_score_real": 0.1157, + "mean_score_fake": 0.8867 + }, + "ours/format_shift_norm_over_source_shift_norm": 0.0285 + } +} \ No newline at end of file diff --git a/repro/cure_stage1/results/lora_norms.json b/repro/cure_stage1/results/lora_norms.json new file mode 100644 index 0000000000000000000000000000000000000000..c4436e45fcb14bd6c1ad1609c0f3dd7937440a6e --- /dev/null +++ b/repro/cure_stage1/results/lora_norms.json @@ -0,0 +1,1488 @@ +{ + "kaiming_init_reference": { + "A_fro": 4.628111163534226, + "A_maxabs": 0.031249797135085806, + "A_sv_max_over_min": 1.650846014804368 + }, + "update_budget_sum_lr": { + "1gpu_x64": { + "steps_per_epoch": 2531, + "sum_lr": 0.06707100000000002 + }, + "2gpu_x64": { + "steps_per_epoch": 1265, + "sum_lr": 0.03352200000000002 + }, + "3gpu_x64": { + "steps_per_epoch": 843, + "sum_lr": 0.022338999999999977 + }, + "4gpu_x64": { + "steps_per_epoch": 632, + "sum_lr": 0.016747500000000012 + }, + "8gpu_x64": { + "steps_per_epoch": 316, + "sum_lr": 0.008373500000000011 + } + }, + "summary": { + "A_fro": { + "released_mean": 4.652863686254364, + "ours_mean": 4.681981024726441, + "released_max": 4.682921531786212, + "ours_max": 4.75323823474063 + }, + "B_fro": { + "released_mean": 0.16884258959727064, + "ours_mean": 0.25149650664825385, + "released_max": 0.3359598930869299, + "ours_max": 0.40338821354725446 + }, + "dW_fro": { + "released_mean": 0.23527673628929094, + "ours_mean": 0.4084646910874638, + "released_max": 0.4868928894776204, + "ours_max": 0.8183537105871604 + }, + "dW_spec": { + "released_mean": 0.18285671975282772, + "ours_mean": 0.33627445457042815, + "released_max": 0.4630053314334476, + "ours_max": 0.797867657777559 + }, + "dW_stable_rank": { + "released_mean": 2.346713783542899, + "ours_mean": 1.8938233831786662, + "released_max": 9.39907927291769, + "ours_max": 6.462571321616863 + }, + "dW_rel_base": { + "released_mean": 0.007500369709863929, + "ours_mean": 0.013163056304548995, + "released_max": 0.019384190446890753, + "ours_max": 0.03258031596222431 + }, + "B_maxabs": { + "released_mean": 0.002564815850443362, + "ours_mean": 0.005069045248092152, + "released_max": 0.004261312074959278, + "ours_max": 0.008334793150424957 + }, + "B_rms": { + "released_mean": 0.0006595413656143322, + "ours_mean": 0.0009824082290947318, + "released_max": 0.001312343332370804, + "ours_max": 0.0015757352091689478 + }, + "A_maxabs": { + "released_mean": 0.03437311225570738, + "ours_mean": 0.03799367890072366, + "released_max": 0.03612973168492317, + "ours_max": 0.04303603246808052 + }, + "A_sv_max_over_min": { + "released_mean": 1.7356546752525919, + "ours_mean": 1.9945734944931355, + "released_max": 1.9882016419306252, + "ours_max": 2.4994831758954903 + }, + "dW_fro_ratio_released_over_ours_mean": 0.5911711776626712, + "top8_left_overlap_mean": 0.20335853371174814, + "random_top8_overlap": 0.0078125 + }, + "per_layer": [ + { + "layer": 0, + "proj": "q", + "released": { + "A_fro": 4.616816876912798, + "B_fro": 0.04751180698539471, + "dW_fro": 0.056935459354003404, + "dW_spec": 0.02152190486271904, + "dW_stable_rank": 6.998488337449383, + "dW_rel_base": 0.0024506432977844063, + "B_maxabs": 0.0007434023427776992, + "B_rms": 0.0001855929960366961, + "A_maxabs": 0.031838320195674896, + "A_sv_max_over_min": 1.6107133572849126 + }, + "ours": { + "A_fro": 4.601553035205177, + "B_fro": 0.05967388533917014, + "dW_fro": 0.07063148402561006, + "dW_spec": 0.0277840567078267, + "dW_stable_rank": 6.462571321616863, + "dW_rel_base": 0.0030401541482910103, + "B_maxabs": 0.001191936549730599, + "B_rms": 0.00023310111460613178, + "A_maxabs": 0.03243866190314293, + "A_sv_max_over_min": 1.6107942116129537 + }, + "top8_left_overlap": 0.20653443970140872 + }, + { + "layer": 0, + "proj": "v", + "released": { + "A_fro": 4.619737919094768, + "B_fro": 0.05625718790935058, + "dW_fro": 0.06796515292933886, + "dW_spec": 0.03965977152283419, + "dW_stable_rank": 2.936785187553334, + "dW_rel_base": 0.002661813966881989, + "B_maxabs": 0.0011537878308445215, + "B_rms": 0.00021975464027089884, + "A_maxabs": 0.03329477831721306, + "A_sv_max_over_min": 1.6108181269267527 + }, + "ours": { + "A_fro": 4.641262933759018, + "B_fro": 0.10374537854967364, + "dW_fro": 0.134940275081147, + "dW_spec": 0.10044625208703822, + "dW_stable_rank": 1.8047444247279907, + "dW_rel_base": 0.005284853979205028, + "B_maxabs": 0.002357867080718279, + "B_rms": 0.0004052553849596598, + "A_maxabs": 0.0370076447725296, + "A_sv_max_over_min": 1.661661906785132 + }, + "top8_left_overlap": 0.06790250770174752 + }, + { + "layer": 1, + "proj": "q", + "released": { + "A_fro": 4.624949628691554, + "B_fro": 0.04625594013483002, + "dW_fro": 0.05524908689583558, + "dW_spec": 0.01802114780089138, + "dW_stable_rank": 9.39907927291769, + "dW_rel_base": 0.0017558549712935712, + "B_maxabs": 0.0008677332662045956, + "B_rms": 0.00018068726615167786, + "A_maxabs": 0.03202127665281296, + "A_sv_max_over_min": 1.602269972440166 + }, + "ours": { + "A_fro": 4.606826791777231, + "B_fro": 0.057596569619215034, + "dW_fro": 0.06873892491396559, + "dW_spec": 0.028028125175233697, + "dW_stable_rank": 6.014747136156743, + "dW_rel_base": 0.0021845715434015522, + "B_maxabs": 0.0010024101939052343, + "B_rms": 0.00022498660007505685, + "A_maxabs": 0.032629676163196564, + "A_sv_max_over_min": 1.6493200549378753 + }, + "top8_left_overlap": 0.11361706281547779 + }, + { + "layer": 1, + "proj": "v", + "released": { + "A_fro": 4.614624169893496, + "B_fro": 0.055208176908597584, + "dW_fro": 0.06618799304865848, + "dW_spec": 0.03838435859750993, + "dW_stable_rank": 2.973376121218027, + "dW_rel_base": 0.0023373174163012675, + "B_maxabs": 0.0009855972602963448, + "B_rms": 0.00021565694104920752, + "A_maxabs": 0.032808128744363785, + "A_sv_max_over_min": 1.6319384743701988 + }, + "ours": { + "A_fro": 4.651399304182567, + "B_fro": 0.09433343405668719, + "dW_fro": 0.12440612786366088, + "dW_spec": 0.09220902433032654, + "dW_stable_rank": 1.820273691645806, + "dW_rel_base": 0.004393192722078322, + "B_maxabs": 0.002179326256737113, + "B_rms": 0.0003684899767839307, + "A_maxabs": 0.035752102732658386, + "A_sv_max_over_min": 1.6786600242423342 + }, + "top8_left_overlap": 0.058482260530498445 + }, + { + "layer": 2, + "proj": "q", + "released": { + "A_fro": 4.617834372753603, + "B_fro": 0.04728841811130969, + "dW_fro": 0.056355813605379466, + "dW_spec": 0.019764773848089737, + "dW_stable_rank": 8.130059972183307, + "dW_rel_base": 0.001862526744097667, + "B_maxabs": 0.0008350464631803334, + "B_rms": 0.00018472038324730169, + "A_maxabs": 0.03200902044773102, + "A_sv_max_over_min": 1.6068112088431163 + }, + "ours": { + "A_fro": 4.59636517583885, + "B_fro": 0.06429534372902304, + "dW_fro": 0.07663390307391844, + "dW_spec": 0.038791466096726575, + "dW_stable_rank": 3.902738953676251, + "dW_rel_base": 0.002532705764470356, + "B_maxabs": 0.0013293115189298987, + "B_rms": 0.0002511536864414938, + "A_maxabs": 0.033134691417217255, + "A_sv_max_over_min": 1.632677625437667 + }, + "top8_left_overlap": 0.15348534898839 + }, + { + "layer": 2, + "proj": "v", + "released": { + "A_fro": 4.629462810793332, + "B_fro": 0.054919472858477675, + "dW_fro": 0.06582997481754821, + "dW_spec": 0.03505440076322749, + "dW_stable_rank": 3.5266493700778327, + "dW_rel_base": 0.0021711327429033843, + "B_maxabs": 0.0010537353809922934, + "B_rms": 0.00021452919085342647, + "A_maxabs": 0.032651547342538834, + "A_sv_max_over_min": 1.6551846250234976 + }, + "ours": { + "A_fro": 4.647780811567939, + "B_fro": 0.09872740755443851, + "dW_fro": 0.12874044497326384, + "dW_spec": 0.09023244687956607, + "dW_stable_rank": 2.035656717639942, + "dW_rel_base": 0.004245977553418344, + "B_maxabs": 0.002417901763692498, + "B_rms": 0.000385653935759521, + "A_maxabs": 0.035952672362327576, + "A_sv_max_over_min": 1.6706427061525815 + }, + "top8_left_overlap": 0.05375469558618225 + }, + { + "layer": 3, + "proj": "q", + "released": { + "A_fro": 4.609223016295966, + "B_fro": 0.04744041155592963, + "dW_fro": 0.0558778632587257, + "dW_spec": 0.02624859211660898, + "dW_stable_rank": 4.5317667901475485, + "dW_rel_base": 0.0018967443411380337, + "B_maxabs": 0.0008252811385318637, + "B_rms": 0.00018531410764034863, + "A_maxabs": 0.03227716684341431, + "A_sv_max_over_min": 1.6448844668085072 + }, + "ours": { + "A_fro": 4.622845549994239, + "B_fro": 0.0683626743877876, + "dW_fro": 0.08306414650578192, + "dW_spec": 0.052484385442252666, + "dW_stable_rank": 2.5047649733350617, + "dW_rel_base": 0.0028195682627806945, + "B_maxabs": 0.0014955645892769098, + "B_rms": 0.00026704169682729306, + "A_maxabs": 0.03276772052049637, + "A_sv_max_over_min": 1.6419924758344155 + }, + "top8_left_overlap": 0.15763016687812045 + }, + { + "layer": 3, + "proj": "v", + "released": { + "A_fro": 4.631036750569762, + "B_fro": 0.06577211701686718, + "dW_fro": 0.07919252529173161, + "dW_spec": 0.050627113259039534, + "dW_stable_rank": 2.4468201842250346, + "dW_rel_base": 0.0025354899257339567, + "B_maxabs": 0.0012759922537952662, + "B_rms": 0.00025692233209713563, + "A_maxabs": 0.033410947769880295, + "A_sv_max_over_min": 1.6127852179340518 + }, + "ours": { + "A_fro": 4.643734818843002, + "B_fro": 0.11623001945183255, + "dW_fro": 0.16540165240337545, + "dW_spec": 0.138089802829016, + "dW_stable_rank": 1.4346847066767232, + "dW_rel_base": 0.005295628871836147, + "B_maxabs": 0.002271530916914344, + "B_rms": 0.0004540235134837174, + "A_maxabs": 0.03552257642149925, + "A_sv_max_over_min": 1.7679075203518464 + }, + "top8_left_overlap": 0.0926288128861813 + }, + { + "layer": 4, + "proj": "q", + "released": { + "A_fro": 4.619264404400871, + "B_fro": 0.04518954992603001, + "dW_fro": 0.054129390063745036, + "dW_spec": 0.030283314116872753, + "dW_stable_rank": 3.194916146556977, + "dW_rel_base": 0.0018250385388798984, + "B_maxabs": 0.0007395719876512885, + "B_rms": 0.00017652167939855276, + "A_maxabs": 0.03181371092796326, + "A_sv_max_over_min": 1.6208269488163767 + }, + "ours": { + "A_fro": 4.605693379614301, + "B_fro": 0.0662781710619433, + "dW_fro": 0.0808880516496883, + "dW_spec": 0.05767528506498117, + "dW_stable_rank": 1.9669315651774004, + "dW_rel_base": 0.0027272395166792183, + "B_maxabs": 0.0014987523900344968, + "B_rms": 0.00025889910571071366, + "A_maxabs": 0.03275950998067856, + "A_sv_max_over_min": 1.613977758913129 + }, + "top8_left_overlap": 0.10976003086270175 + }, + { + "layer": 4, + "proj": "v", + "released": { + "A_fro": 4.634969736018699, + "B_fro": 0.06291207223309458, + "dW_fro": 0.07604805629804129, + "dW_spec": 0.0617116785286861, + "dW_stable_rank": 1.5185934367330425, + "dW_rel_base": 0.0022953881453668195, + "B_maxabs": 0.0010587056167423725, + "B_rms": 0.00024575028216052377, + "A_maxabs": 0.03293832391500473, + "A_sv_max_over_min": 1.6360358715425882 + }, + "ours": { + "A_fro": 4.6507257685756604, + "B_fro": 0.09987637675058075, + "dW_fro": 0.14006779443904724, + "dW_spec": 0.1260383878921724, + "dW_stable_rank": 1.2350112138314113, + "dW_rel_base": 0.004227720872220984, + "B_maxabs": 0.0019573024474084377, + "B_rms": 0.00039014209668195227, + "A_maxabs": 0.034916505217552185, + "A_sv_max_over_min": 1.7630788710247718 + }, + "top8_left_overlap": 0.0850079750909889 + }, + { + "layer": 5, + "proj": "q", + "released": { + "A_fro": 4.6392426760062815, + "B_fro": 0.05125072827181559, + "dW_fro": 0.06170366811507025, + "dW_spec": 0.042919045263747964, + "dW_stable_rank": 2.066911396408254, + "dW_rel_base": 0.002069410591749609, + "B_maxabs": 0.0011911287438124418, + "B_rms": 0.00020019815731177812, + "A_maxabs": 0.032001495361328125, + "A_sv_max_over_min": 1.6249798716479498 + }, + "ours": { + "A_fro": 4.60099715962124, + "B_fro": 0.05763939261482985, + "dW_fro": 0.06834747026873289, + "dW_spec": 0.03944314896568671, + "dW_stable_rank": 3.0026293810662574, + "dW_rel_base": 0.0022922296714944063, + "B_maxabs": 0.0011275504948571324, + "B_rms": 0.00022515387740167737, + "A_maxabs": 0.03218047320842743, + "A_sv_max_over_min": 1.5964969112810332 + }, + "top8_left_overlap": 0.1356392711980154 + }, + { + "layer": 5, + "proj": "v", + "released": { + "A_fro": 4.640285538830404, + "B_fro": 0.07249910176342043, + "dW_fro": 0.09445116347533306, + "dW_spec": 0.08404668611563595, + "dW_stable_rank": 1.262913005211245, + "dW_rel_base": 0.0027461570959486314, + "B_maxabs": 0.001265113358385861, + "B_rms": 0.0002831996162633585, + "A_maxabs": 0.033572375774383545, + "A_sv_max_over_min": 1.6759696030852695 + }, + "ours": { + "A_fro": 4.634294869372501, + "B_fro": 0.11071096174713349, + "dW_fro": 0.15502616355261303, + "dW_spec": 0.139578404120462, + "dW_stable_rank": 1.2335976753841962, + "dW_rel_base": 0.004507368500641968, + "B_maxabs": 0.0019891930278390646, + "B_rms": 0.00043246469432473673, + "A_maxabs": 0.036528829485177994, + "A_sv_max_over_min": 1.7289794299294046 + }, + "top8_left_overlap": 0.06814468257061806 + }, + { + "layer": 6, + "proj": "q", + "released": { + "A_fro": 4.627620822672516, + "B_fro": 0.05034702769884749, + "dW_fro": 0.06035311031417818, + "dW_spec": 0.032192259280451795, + "dW_stable_rank": 3.5147658587596164, + "dW_rel_base": 0.0019254023620212505, + "B_maxabs": 0.0013460245681926608, + "B_rms": 0.00019666807694862124, + "A_maxabs": 0.032396554946899414, + "A_sv_max_over_min": 1.6021068765030435 + }, + "ours": { + "A_fro": 4.599240735837259, + "B_fro": 0.0738794846912624, + "dW_fro": 0.08901604247683195, + "dW_spec": 0.05062648148016376, + "dW_stable_rank": 3.091584165531627, + "dW_rel_base": 0.0028398155049585375, + "B_maxabs": 0.0021478296257555485, + "B_rms": 0.00028859173707524116, + "A_maxabs": 0.033526353538036346, + "A_sv_max_over_min": 1.6169600053314204 + }, + "top8_left_overlap": 0.1839483528615636 + }, + { + "layer": 6, + "proj": "v", + "released": { + "A_fro": 4.632726828438277, + "B_fro": 0.09139546667143834, + "dW_fro": 0.11810354308163684, + "dW_spec": 0.09365002157685887, + "dW_stable_rank": 1.590413631998596, + "dW_rel_base": 0.0035308936147933692, + "B_maxabs": 0.0016285221790894866, + "B_rms": 0.00035701354168530235, + "A_maxabs": 0.03371445834636688, + "A_sv_max_over_min": 1.6285070688200656 + }, + "ours": { + "A_fro": 4.6829956869914895, + "B_fro": 0.17767721520934004, + "dW_fro": 0.28990897861662096, + "dW_spec": 0.26002864365455347, + "dW_stable_rank": 1.2430281114113835, + "dW_rel_base": 0.008667290876795491, + "B_maxabs": 0.004749807063490152, + "B_rms": 0.0006940516219114787, + "A_maxabs": 0.03798654302954674, + "A_sv_max_over_min": 2.066722460152314 + }, + "top8_left_overlap": 0.19619098761078843 + }, + { + "layer": 7, + "proj": "q", + "released": { + "A_fro": 4.6126945265613895, + "B_fro": 0.061453730448005464, + "dW_fro": 0.07360571257612641, + "dW_spec": 0.0527781191508611, + "dW_stable_rank": 1.9449803785966204, + "dW_rel_base": 0.0024463768333793613, + "B_maxabs": 0.0015145998913794756, + "B_rms": 0.00024005363456251918, + "A_maxabs": 0.033577390015125275, + "A_sv_max_over_min": 1.6360588963242229 + }, + "ours": { + "A_fro": 4.623709309924344, + "B_fro": 0.13518737704924072, + "dW_fro": 0.1857959078180681, + "dW_spec": 0.15945958226521403, + "dW_stable_rank": 1.3575975471465296, + "dW_rel_base": 0.0061751566381850675, + "B_maxabs": 0.00406270008534193, + "B_rms": 0.0005280756915985924, + "A_maxabs": 0.03662105277180672, + "A_sv_max_over_min": 1.6705164402744068 + }, + "top8_left_overlap": 0.22870001695771475 + }, + { + "layer": 7, + "proj": "v", + "released": { + "A_fro": 4.668619735932703, + "B_fro": 0.13977911859349296, + "dW_fro": 0.20410008430096727, + "dW_spec": 0.1813028357423351, + "dW_stable_rank": 1.267293403724983, + "dW_rel_base": 0.0059471615948718266, + "B_maxabs": 0.0024150304961949587, + "B_rms": 0.0005460121820058266, + "A_maxabs": 0.034628357738256454, + "A_sv_max_over_min": 1.8293321978431454 + }, + "ours": { + "A_fro": 4.694909160728407, + "B_fro": 0.22881487341905338, + "dW_fro": 0.43559065363362415, + "dW_spec": 0.4137697340335894, + "dW_stable_rank": 1.1082549119942184, + "dW_rel_base": 0.01269243966874113, + "B_maxabs": 0.004675381351262331, + "B_rms": 0.0008938080992931694, + "A_maxabs": 0.03870387002825737, + "A_sv_max_over_min": 2.3808004961734786 + }, + "top8_left_overlap": 0.2590646759278692 + }, + { + "layer": 8, + "proj": "q", + "released": { + "A_fro": 4.625957067272938, + "B_fro": 0.08550018421176768, + "dW_fro": 0.10670693880480801, + "dW_spec": 0.07383797641007597, + "dW_stable_rank": 2.0884580212943162, + "dW_rel_base": 0.0039031748342120147, + "B_maxabs": 0.002487513003870845, + "B_rms": 0.00033398509457721457, + "A_maxabs": 0.034794747829437256, + "A_sv_max_over_min": 1.6134113119240665 + }, + "ours": { + "A_fro": 4.723176814170086, + "B_fro": 0.23570195635881674, + "dW_fro": 0.4588331864436278, + "dW_spec": 0.426413782156584, + "dW_stable_rank": 1.1578363438791066, + "dW_rel_base": 0.016783408525138783, + "B_maxabs": 0.005881292279809713, + "B_rms": 0.0009207107670266223, + "A_maxabs": 0.041415736079216, + "A_sv_max_over_min": 2.46735334925301 + }, + "top8_left_overlap": 0.32125072498924695 + }, + { + "layer": 8, + "proj": "v", + "released": { + "A_fro": 4.661939788254256, + "B_fro": 0.1803322585471803, + "dW_fro": 0.2676780920176477, + "dW_spec": 0.22494061025575318, + "dW_stable_rank": 1.416086941630665, + "dW_rel_base": 0.00759561014809465, + "B_maxabs": 0.002673073671758175, + "B_rms": 0.0007044228849499153, + "A_maxabs": 0.03535711020231247, + "A_sv_max_over_min": 1.90612191609918 + }, + "ours": { + "A_fro": 4.732778891452358, + "B_fro": 0.2945067825288971, + "dW_fro": 0.5712857798967249, + "dW_spec": 0.5298597112581809, + "dW_stable_rank": 1.1624787720858984, + "dW_rel_base": 0.016210755368652463, + "B_maxabs": 0.006316737737506628, + "B_rms": 0.0011504171192534944, + "A_maxabs": 0.041030336171388626, + "A_sv_max_over_min": 2.4994831758954903 + }, + "top8_left_overlap": 0.3178529158845697 + }, + { + "layer": 9, + "proj": "q", + "released": { + "A_fro": 4.648199592206015, + "B_fro": 0.11847177214709974, + "dW_fro": 0.16186528913083048, + "dW_spec": 0.13502433300347572, + "dW_stable_rank": 1.4370880347937147, + "dW_rel_base": 0.005487858602026807, + "B_maxabs": 0.0027729140128940344, + "B_rms": 0.0004627803599496045, + "A_maxabs": 0.035016197711229324, + "A_sv_max_over_min": 1.7237388921550125 + }, + "ours": { + "A_fro": 4.703042188069486, + "B_fro": 0.25439189137431567, + "dW_fro": 0.411962911975533, + "dW_spec": 0.31236877780765776, + "dW_stable_rank": 1.7393260518863658, + "dW_rel_base": 0.013967134166569918, + "B_maxabs": 0.005796635989099741, + "B_rms": 0.0009937183256809152, + "A_maxabs": 0.039818309247493744, + "A_sv_max_over_min": 2.030457644213066 + }, + "top8_left_overlap": 0.3346401072543442 + }, + { + "layer": 9, + "proj": "v", + "released": { + "A_fro": 4.67611042578014, + "B_fro": 0.2084326034927523, + "dW_fro": 0.30812868669333476, + "dW_spec": 0.2528175281844669, + "dW_stable_rank": 1.4854221786275459, + "dW_rel_base": 0.009411859461269902, + "B_maxabs": 0.0031006138306111097, + "B_rms": 0.0008141898573935551, + "A_maxabs": 0.03544095903635025, + "A_sv_max_over_min": 1.8987210150653924 + }, + "ours": { + "A_fro": 4.728602975090747, + "B_fro": 0.3166009999787973, + "dW_fro": 0.5854141529375535, + "dW_spec": 0.5336479126721183, + "dW_stable_rank": 1.2034188373364028, + "dW_rel_base": 0.017881605874529576, + "B_maxabs": 0.006051195319741964, + "B_rms": 0.0012367226561671636, + "A_maxabs": 0.04119574651122093, + "A_sv_max_over_min": 2.4387687400776694 + }, + "top8_left_overlap": 0.3543202569778196 + }, + { + "layer": 10, + "proj": "q", + "released": { + "A_fro": 4.658127169514071, + "B_fro": 0.14412209660742037, + "dW_fro": 0.19239489809672156, + "dW_spec": 0.1486083014806008, + "dW_stable_rank": 1.6761039968508609, + "dW_rel_base": 0.006371694640867266, + "B_maxabs": 0.00314528401941061, + "B_rms": 0.0005629769398727314, + "A_maxabs": 0.03477674722671509, + "A_sv_max_over_min": 1.6370656775416563 + }, + "ours": { + "A_fro": 4.708744418557556, + "B_fro": 0.2690636077560196, + "dW_fro": 0.43095468590663416, + "dW_spec": 0.36325744587916714, + "dW_stable_rank": 1.407453853802582, + "dW_rel_base": 0.014272268598658478, + "B_maxabs": 0.006693244446069002, + "B_rms": 0.0010510297177969447, + "A_maxabs": 0.03934284672141075, + "A_sv_max_over_min": 2.0319378437169675 + }, + "top8_left_overlap": 0.4163924483663913 + }, + { + "layer": 10, + "proj": "v", + "released": { + "A_fro": 4.661730373097835, + "B_fro": 0.21996470576633595, + "dW_fro": 0.3239947477163881, + "dW_spec": 0.27123095277930037, + "dW_stable_rank": 1.4269128227837717, + "dW_rel_base": 0.009975794639854424, + "B_maxabs": 0.0032341398764401674, + "B_rms": 0.0008592371318997411, + "A_maxabs": 0.03574129566550255, + "A_sv_max_over_min": 1.8379040824726562 + }, + "ours": { + "A_fro": 4.701491722736972, + "B_fro": 0.33281537380783016, + "dW_fro": 0.5180754943578443, + "dW_spec": 0.40818898742030274, + "dW_stable_rank": 1.610881273438881, + "dW_rel_base": 0.015951538647098563, + "B_maxabs": 0.007233545184135437, + "B_rms": 0.0013000600539368242, + "A_maxabs": 0.04303603246808052, + "A_sv_max_over_min": 2.1280241190590097 + }, + "top8_left_overlap": 0.37050628959787957 + }, + { + "layer": 11, + "proj": "q", + "released": { + "A_fro": 4.656548976201495, + "B_fro": 0.15574946176250495, + "dW_fro": 0.21808525012154567, + "dW_spec": 0.17965266474633412, + "dW_stable_rank": 1.4736191635646385, + "dW_rel_base": 0.007430431980901073, + "B_maxabs": 0.0031588664278388023, + "B_rms": 0.000608396335009778, + "A_maxabs": 0.035617806017398834, + "A_sv_max_over_min": 1.766941833197115 + }, + "ours": { + "A_fro": 4.709556497355729, + "B_fro": 0.28505169725148344, + "dW_fro": 0.4722130921854764, + "dW_spec": 0.4084066460628508, + "dW_stable_rank": 1.3368739042953108, + "dW_rel_base": 0.01608887928009628, + "B_maxabs": 0.0065499865449965, + "B_rms": 0.0011134831923885985, + "A_maxabs": 0.040489841252565384, + "A_sv_max_over_min": 2.1443403661752596 + }, + "top8_left_overlap": 0.37581494975187313 + }, + { + "layer": 11, + "proj": "v", + "released": { + "A_fro": 4.671885116713033, + "B_fro": 0.241013077346283, + "dW_fro": 0.3387443141787298, + "dW_spec": 0.24904293306081066, + "dW_stable_rank": 1.850101620563904, + "dW_rel_base": 0.01036915405862166, + "B_maxabs": 0.0037241217214614153, + "B_rms": 0.0009414573333839096, + "A_maxabs": 0.03601916879415512, + "A_sv_max_over_min": 1.8392485407244823 + }, + "ours": { + "A_fro": 4.687340524134074, + "B_fro": 0.33319250853597315, + "dW_fro": 0.50447490219958, + "dW_spec": 0.39371437226934175, + "dW_stable_rank": 1.6417861672354221, + "dW_rel_base": 0.015442260609739852, + "B_maxabs": 0.0068617090582847595, + "B_rms": 0.0013015332364686308, + "A_maxabs": 0.039359964430332184, + "A_sv_max_over_min": 2.028934267203766 + }, + "top8_left_overlap": 0.3802652701416878 + }, + { + "layer": 12, + "proj": "q", + "released": { + "A_fro": 4.662914959925063, + "B_fro": 0.1723990755392414, + "dW_fro": 0.22866070175607156, + "dW_spec": 0.1605479089505311, + "dW_stable_rank": 2.0284941380815917, + "dW_rel_base": 0.0074922874617519815, + "B_maxabs": 0.0028961109928786755, + "B_rms": 0.0006734338888251555, + "A_maxabs": 0.03515966236591339, + "A_sv_max_over_min": 1.662440674934652 + }, + "ours": { + "A_fro": 4.711606223842427, + "B_fro": 0.30153570485296655, + "dW_fro": 0.4693116336262972, + "dW_spec": 0.36556177013444957, + "dW_stable_rank": 1.648166553382798, + "dW_rel_base": 0.015377446326669821, + "B_maxabs": 0.006194704212248325, + "B_rms": 0.0011778738470818889, + "A_maxabs": 0.04067410156130791, + "A_sv_max_over_min": 2.032109468557661 + }, + "top8_left_overlap": 0.4337983548161485 + }, + { + "layer": 12, + "proj": "v", + "released": { + "A_fro": 4.671104933335228, + "B_fro": 0.2365337939918842, + "dW_fro": 0.3209473519078329, + "dW_spec": 0.2219674489467793, + "dW_stable_rank": 2.090686967073919, + "dW_rel_base": 0.01020531814289049, + "B_maxabs": 0.0032833765726536512, + "B_rms": 0.0009239601327807891, + "A_maxabs": 0.03524421900510788, + "A_sv_max_over_min": 1.791917967591343 + }, + "ours": { + "A_fro": 4.699593687783953, + "B_fro": 0.3266232407889657, + "dW_fro": 0.488670072968922, + "dW_spec": 0.36845020228548037, + "dW_stable_rank": 1.7590325954552526, + "dW_rel_base": 0.015538478606888447, + "B_maxabs": 0.005700128618627787, + "B_rms": 0.0012758720343318843, + "A_maxabs": 0.038839977234601974, + "A_sv_max_over_min": 1.9862637701461494 + }, + "top8_left_overlap": 0.3564060722885894 + }, + { + "layer": 13, + "proj": "q", + "released": { + "A_fro": 4.673800402115354, + "B_fro": 0.197714173026895, + "dW_fro": 0.2887324556531643, + "dW_spec": 0.2438788995838259, + "dW_stable_rank": 1.4016602444155404, + "dW_rel_base": 0.01047344085836541, + "B_maxabs": 0.0032997687812894583, + "B_rms": 0.0007723209883863011, + "A_maxabs": 0.03612973168492317, + "A_sv_max_over_min": 1.8628863260764574 + }, + "ours": { + "A_fro": 4.751525614785652, + "B_fro": 0.35168120140459624, + "dW_fro": 0.6761759024401429, + "dW_spec": 0.6147594906246361, + "dW_stable_rank": 1.2097869472869585, + "dW_rel_base": 0.02452751045267219, + "B_maxabs": 0.006544614210724831, + "B_rms": 0.0013737546929866902, + "A_maxabs": 0.04037390649318695, + "A_sv_max_over_min": 2.466688278305037 + }, + "top8_left_overlap": 0.365937755868129 + }, + { + "layer": 13, + "proj": "v", + "released": { + "A_fro": 4.669674427016957, + "B_fro": 0.23233608910493433, + "dW_fro": 0.29996625346603223, + "dW_spec": 0.1646688022112752, + "dW_stable_rank": 3.3183496471510394, + "dW_rel_base": 0.008846374048769791, + "B_maxabs": 0.0030378729570657015, + "B_rms": 0.0009075628480661412, + "A_maxabs": 0.035144317895174026, + "A_sv_max_over_min": 1.7183359627119699 + }, + "ours": { + "A_fro": 4.6843791215508634, + "B_fro": 0.3509589974470077, + "dW_fro": 0.4910404980995974, + "dW_spec": 0.3023349754635421, + "dW_stable_rank": 2.6378970416379874, + "dW_rel_base": 0.014481388719865351, + "B_maxabs": 0.0060363891534507275, + "B_rms": 0.001370933583777358, + "A_maxabs": 0.038132477551698685, + "A_sv_max_over_min": 1.8073350194120565 + }, + "top8_left_overlap": 0.33049314370479177 + }, + { + "layer": 14, + "proj": "q", + "released": { + "A_fro": 4.678904408293563, + "B_fro": 0.22320374297455997, + "dW_fro": 0.3268110013898444, + "dW_spec": 0.24923807359256375, + "dW_stable_rank": 1.7193510717437026, + "dW_rel_base": 0.011867969525177944, + "B_maxabs": 0.003347159596160054, + "B_rms": 0.0008718896209943683, + "A_maxabs": 0.03574639558792114, + "A_sv_max_over_min": 1.8122983005669944 + }, + "ours": { + "A_fro": 4.75323823474063, + "B_fro": 0.3670989449206388, + "dW_fro": 0.6180672123151763, + "dW_spec": 0.49114758772511524, + "dW_stable_rank": 1.5836068810255906, + "dW_rel_base": 0.022444785545998873, + "B_maxabs": 0.006903012283146381, + "B_rms": 0.0014339802535962298, + "A_maxabs": 0.04123922064900398, + "A_sv_max_over_min": 2.2113275796286413 + }, + "top8_left_overlap": 0.3329414620087564 + }, + { + "layer": 14, + "proj": "v", + "released": { + "A_fro": 4.673969324129511, + "B_fro": 0.25400167569662097, + "dW_fro": 0.346044123350801, + "dW_spec": 0.218507183395586, + "dW_stable_rank": 2.50802302218914, + "dW_rel_base": 0.01040458448979317, + "B_maxabs": 0.003284860635176301, + "B_rms": 0.0009921940456899172, + "A_maxabs": 0.03539847955107689, + "A_sv_max_over_min": 1.7098169820545372 + }, + "ours": { + "A_fro": 4.7026938162673595, + "B_fro": 0.36350628081827335, + "dW_fro": 0.5513132953053517, + "dW_spec": 0.36351771194443916, + "dW_stable_rank": 2.3000950297366445, + "dW_rel_base": 0.016576457666168155, + "B_maxabs": 0.005865687970072031, + "B_rms": 0.001419946409446367, + "A_maxabs": 0.03924895450472832, + "A_sv_max_over_min": 2.007137143742926 + }, + "top8_left_overlap": 0.24997393391503805 + }, + { + "layer": 15, + "proj": "q", + "released": { + "A_fro": 4.67911237891643, + "B_fro": 0.22914584184460526, + "dW_fro": 0.3317807656941088, + "dW_spec": 0.263988256840268, + "dW_stable_rank": 1.5795493297461876, + "dW_rel_base": 0.011304059193959909, + "B_maxabs": 0.0033041327260434628, + "B_rms": 0.0008951009447054827, + "A_maxabs": 0.035740770399570465, + "A_sv_max_over_min": 1.8150781644026401 + }, + "ours": { + "A_fro": 4.732283876694337, + "B_fro": 0.3670056443780035, + "dW_fro": 0.6583609223817387, + "dW_spec": 0.5869520044505565, + "dW_stable_rank": 1.2581224438747762, + "dW_rel_base": 0.022430929116772982, + "B_maxabs": 0.005982635542750359, + "B_rms": 0.0014336157983515627, + "A_maxabs": 0.03996624797582626, + "A_sv_max_over_min": 2.292239172595656 + }, + "top8_left_overlap": 0.3281546306566401 + }, + { + "layer": 15, + "proj": "v", + "released": { + "A_fro": 4.680774706090587, + "B_fro": 0.24064124629404934, + "dW_fro": 0.3252921227282345, + "dW_spec": 0.2104956115590807, + "dW_stable_rank": 2.388146698436158, + "dW_rel_base": 0.010107609516215576, + "B_maxabs": 0.00313766160979867, + "B_rms": 0.0009400048683361216, + "A_maxabs": 0.03508337587118149, + "A_sv_max_over_min": 1.729356655386493 + }, + "ours": { + "A_fro": 4.704381450800655, + "B_fro": 0.35944647124497936, + "dW_fro": 0.5061822637426181, + "dW_spec": 0.3057949650593463, + "dW_stable_rank": 2.740016553543433, + "dW_rel_base": 0.01572830175853609, + "B_maxabs": 0.00676813255995512, + "B_rms": 0.0014040877783006854, + "A_maxabs": 0.038753267377614975, + "A_sv_max_over_min": 1.8135416890633689 + }, + "top8_left_overlap": 0.24906532858047847 + }, + { + "layer": 16, + "proj": "q", + "released": { + "A_fro": 4.671018826590018, + "B_fro": 0.228431283570609, + "dW_fro": 0.32937702542798475, + "dW_spec": 0.271629704964411, + "dW_stable_rank": 1.4703884494751784, + "dW_rel_base": 0.010982494883300439, + "B_maxabs": 0.0033927997574210167, + "B_rms": 0.0008923097014476851, + "A_maxabs": 0.03515665605664253, + "A_sv_max_over_min": 1.838332751636995 + }, + "ours": { + "A_fro": 4.7303145038871035, + "B_fro": 0.33838766015449345, + "dW_fro": 0.6248027683394556, + "dW_spec": 0.5661480573338342, + "dW_stable_rank": 1.2179398694129255, + "dW_rel_base": 0.020832944245105855, + "B_maxabs": 0.006886254530400038, + "B_rms": 0.0013218267974784788, + "A_maxabs": 0.04029260575771332, + "A_sv_max_over_min": 2.4122694136429983 + }, + "top8_left_overlap": 0.3008513567844136 + }, + { + "layer": 16, + "proj": "v", + "released": { + "A_fro": 4.6692518054391785, + "B_fro": 0.23465311677387157, + "dW_fro": 0.3068412448973453, + "dW_spec": 0.17985690809483487, + "dW_stable_rank": 2.9105376775716594, + "dW_rel_base": 0.009520574206382897, + "B_maxabs": 0.003445505630224943, + "B_rms": 0.0009166137373979288, + "A_maxabs": 0.035127438604831696, + "A_sv_max_over_min": 1.7039173152270868 + }, + "ours": { + "A_fro": 4.694693489069972, + "B_fro": 0.34278207902709196, + "dW_fro": 0.4843878506782972, + "dW_spec": 0.28999213584184536, + "dW_stable_rank": 2.7900632078622807, + "dW_rel_base": 0.015029434776918236, + "B_maxabs": 0.006820421665906906, + "B_rms": 0.0013389924961995632, + "A_maxabs": 0.039260175079107285, + "A_sv_max_over_min": 1.880769047125306 + }, + "top8_left_overlap": 0.18824827025540974 + }, + { + "layer": 17, + "proj": "q", + "released": { + "A_fro": 4.668064939845395, + "B_fro": 0.21433189182866344, + "dW_fro": 0.30546254046235055, + "dW_spec": 0.2597724918019092, + "dW_stable_rank": 1.3827052067657022, + "dW_rel_base": 0.009769467515130671, + "B_maxabs": 0.0036577736027538776, + "B_rms": 0.0008372339524557093, + "A_maxabs": 0.03576235473155975, + "A_sv_max_over_min": 1.8153145621172373 + }, + "ours": { + "A_fro": 4.698447917866276, + "B_fro": 0.30868407980972257, + "dW_fro": 0.5132230053271001, + "dW_spec": 0.4589607145379652, + "dW_stable_rank": 1.2504352411056079, + "dW_rel_base": 0.016414174618503915, + "B_maxabs": 0.006218411028385162, + "B_rms": 0.001205797186756718, + "A_maxabs": 0.03895125165581703, + "A_sv_max_over_min": 2.0734877031966166 + }, + "top8_left_overlap": 0.23692331459682991 + }, + { + "layer": 17, + "proj": "v", + "released": { + "A_fro": 4.666302553778905, + "B_fro": 0.24800714740161825, + "dW_fro": 0.3285484327746419, + "dW_spec": 0.19741237606165782, + "dW_stable_rank": 2.7698104427746673, + "dW_rel_base": 0.010483220411215218, + "B_maxabs": 0.003428172320127487, + "B_rms": 0.0009687779195375645, + "A_maxabs": 0.035078227519989014, + "A_sv_max_over_min": 1.6526909874660678 + }, + "ours": { + "A_fro": 4.695086095843626, + "B_fro": 0.3300858295378568, + "dW_fro": 0.4803141166202727, + "dW_spec": 0.3285984294511219, + "dW_stable_rank": 2.1365828352829928, + "dW_rel_base": 0.015325712281215546, + "B_maxabs": 0.006770361680537462, + "B_rms": 0.0012893977716322397, + "A_maxabs": 0.03833319991827011, + "A_sv_max_over_min": 1.9137887387512496 + }, + "top8_left_overlap": 0.10793887845219421 + }, + { + "layer": 18, + "proj": "q", + "released": { + "A_fro": 4.674383149789867, + "B_fro": 0.18955895435615563, + "dW_fro": 0.28255600469862246, + "dW_spec": 0.24954572663094962, + "dW_stable_rank": 1.2820613501438767, + "dW_rel_base": 0.009146161803494169, + "B_maxabs": 0.003684591967612505, + "B_rms": 0.0007404646654537262, + "A_maxabs": 0.03485814854502678, + "A_sv_max_over_min": 1.875156969971088 + }, + "ours": { + "A_fro": 4.657428455549306, + "B_fro": 0.2611962800985785, + "dW_fro": 0.42493069108102444, + "dW_spec": 0.39554697609296696, + "dW_stable_rank": 1.1540910199181462, + "dW_rel_base": 0.013754741684017708, + "B_maxabs": 0.005143564194440842, + "B_rms": 0.0010202979691350644, + "A_maxabs": 0.038111984729766846, + "A_sv_max_over_min": 1.9844477595621817 + }, + "top8_left_overlap": 0.09093204255774158 + }, + { + "layer": 18, + "proj": "v", + "released": { + "A_fro": 4.664460575978037, + "B_fro": 0.24192573121651642, + "dW_fro": 0.3242032313906945, + "dW_spec": 0.2661094642326817, + "dW_stable_rank": 1.4842738539907312, + "dW_rel_base": 0.01027511909909668, + "B_maxabs": 0.0030409493483603, + "B_rms": 0.0009450223875645089, + "A_maxabs": 0.03461172431707382, + "A_sv_max_over_min": 1.6797676182604608 + }, + "ours": { + "A_fro": 4.707922399274956, + "B_fro": 0.3281363651781288, + "dW_fro": 0.508240064473346, + "dW_spec": 0.3780587115330356, + "dW_stable_rank": 1.80725441797556, + "dW_rel_base": 0.016107881377354145, + "B_maxabs": 0.005359678529202938, + "B_rms": 0.0012817826764770525, + "A_maxabs": 0.037735454738140106, + "A_sv_max_over_min": 2.0621129637079507 + }, + "top8_left_overlap": 0.05505504359878938 + }, + { + "layer": 19, + "proj": "q", + "released": { + "A_fro": 4.682921531786212, + "B_fro": 0.23387719284151598, + "dW_fro": 0.36988090705880877, + "dW_spec": 0.3267591947131069, + "dW_stable_rank": 1.281351240812646, + "dW_rel_base": 0.012313887155954134, + "B_maxabs": 0.003465847112238407, + "B_rms": 0.0009135827845371663, + "A_maxabs": 0.0351845845580101, + "A_sv_max_over_min": 1.9882016419306252 + }, + "ours": { + "A_fro": 4.721601660026325, + "B_fro": 0.35478905913042713, + "dW_fro": 0.6886938912274801, + "dW_spec": 0.6447452214037009, + "dW_stable_rank": 1.140975180967226, + "dW_rel_base": 0.02292764697968526, + "B_maxabs": 0.007767080329358578, + "B_rms": 0.0013858947622282169, + "A_maxabs": 0.03884023800492287, + "A_sv_max_over_min": 2.386590622774603 + }, + "top8_left_overlap": 0.14766539617873958 + }, + { + "layer": 19, + "proj": "v", + "released": { + "A_fro": 4.660640030110583, + "B_fro": 0.25320158791808384, + "dW_fro": 0.3344631767828588, + "dW_spec": 0.2405212055732002, + "dW_stable_rank": 1.933703471361322, + "dW_rel_base": 0.010245196468310475, + "B_maxabs": 0.003420374821871519, + "B_rms": 0.0009890687028050059, + "A_maxabs": 0.035205695778131485, + "A_sv_max_over_min": 1.7304771038620201 + }, + "ours": { + "A_fro": 4.728172901389899, + "B_fro": 0.3390995780708922, + "dW_fro": 0.5606638959830488, + "dW_spec": 0.4574389325332632, + "dW_stable_rank": 1.5022386519434585, + "dW_rel_base": 0.017174123089681505, + "B_maxabs": 0.005774960853159428, + "B_rms": 0.0013246077268394075, + "A_maxabs": 0.03834664076566696, + "A_sv_max_over_min": 2.198589197304873 + }, + "top8_left_overlap": 0.06768329073433443 + }, + { + "layer": 20, + "proj": "q", + "released": { + "A_fro": 4.670872862400902, + "B_fro": 0.21602120789334261, + "dW_fro": 0.3276620562144532, + "dW_spec": 0.2837975523001789, + "dW_stable_rank": 1.3330149304088728, + "dW_rel_base": 0.010912075124269005, + "B_maxabs": 0.003065309952944517, + "B_rms": 0.0008438328433333624, + "A_maxabs": 0.035112760961055756, + "A_sv_max_over_min": 1.9449679088066643 + }, + "ours": { + "A_fro": 4.7388185040889335, + "B_fro": 0.3504792049615157, + "dW_fro": 0.6727381747903759, + "dW_spec": 0.6295489767128797, + "dW_stable_rank": 1.1419132190517016, + "dW_rel_base": 0.022404087879713378, + "B_maxabs": 0.006782268639653921, + "B_rms": 0.0013690593943809066, + "A_maxabs": 0.04005171358585358, + "A_sv_max_over_min": 2.348526675741941 + }, + "top8_left_overlap": 0.1825737204667017 + }, + { + "layer": 20, + "proj": "v", + "released": { + "A_fro": 4.663532035967386, + "B_fro": 0.259733256936655, + "dW_fro": 0.3542974474559018, + "dW_spec": 0.2955087646502708, + "dW_stable_rank": 1.4374584962838906, + "dW_rel_base": 0.010577677020487794, + "B_maxabs": 0.0030952664092183113, + "B_rms": 0.0010145830349087975, + "A_maxabs": 0.03459753468632698, + "A_sv_max_over_min": 1.6694251983652642 + }, + "ours": { + "A_fro": 4.709027623268846, + "B_fro": 0.3278852354668789, + "dW_fro": 0.5522256553336751, + "dW_spec": 0.492524620524488, + "dW_stable_rank": 1.2571215415799553, + "dW_rel_base": 0.016486894462523244, + "B_maxabs": 0.006273651495575905, + "B_rms": 0.001280801701042482, + "A_maxabs": 0.039154693484306335, + "A_sv_max_over_min": 2.131861052711194 + }, + "top8_left_overlap": 0.046777743382038994 + }, + { + "layer": 21, + "proj": "q", + "released": { + "A_fro": 4.680400632831871, + "B_fro": 0.22530758177028198, + "dW_fro": 0.3277239169671515, + "dW_spec": 0.2773069509166255, + "dW_stable_rank": 1.39667308024082, + "dW_rel_base": 0.011537084811544175, + "B_maxabs": 0.0031925062648952007, + "B_rms": 0.0008801077412901576, + "A_maxabs": 0.034677933901548386, + "A_sv_max_over_min": 1.7803730934357405 + }, + "ours": { + "A_fro": 4.706526397478453, + "B_fro": 0.3306530035748056, + "dW_fro": 0.5889505193499518, + "dW_spec": 0.5552971758538787, + "dW_stable_rank": 1.1248812781918593, + "dW_rel_base": 0.020733220066524588, + "B_maxabs": 0.007283303886651993, + "B_rms": 0.001291613295214071, + "A_maxabs": 0.03987135738134384, + "A_sv_max_over_min": 2.197882209609604 + }, + "top8_left_overlap": 0.1481015506236908 + }, + { + "layer": 21, + "proj": "v", + "released": { + "A_fro": 4.659775449915181, + "B_fro": 0.2617731509835771, + "dW_fro": 0.353633708502142, + "dW_spec": 0.2705677794490134, + "dW_stable_rank": 1.7082646584879446, + "dW_rel_base": 0.009730709012949904, + "B_maxabs": 0.0031577879562973976, + "B_rms": 0.001022551371029587, + "A_maxabs": 0.03450462222099304, + "A_sv_max_over_min": 1.7873972464336854 + }, + "ours": { + "A_fro": 4.693048318151366, + "B_fro": 0.32670954956677317, + "dW_fro": 0.4992472677544355, + "dW_spec": 0.3662682747044672, + "dW_stable_rank": 1.85794471972781, + "dW_rel_base": 0.013737462722672756, + "B_maxabs": 0.006138852797448635, + "B_rms": 0.001276209177995191, + "A_maxabs": 0.03935762122273445, + "A_sv_max_over_min": 2.039395481937002 + }, + "top8_left_overlap": 0.05536416949634671 + }, + { + "layer": 22, + "proj": "q", + "released": { + "A_fro": 4.659299079287088, + "B_fro": 0.2644974013230981, + "dW_fro": 0.39969042635537433, + "dW_spec": 0.3721318668148002, + "dW_stable_rank": 1.153596071850734, + "dW_rel_base": 0.014875477969384803, + "B_maxabs": 0.0030496064573526382, + "B_rms": 0.0010331929739183412, + "A_maxabs": 0.03458824008703232, + "A_sv_max_over_min": 1.876019591383753 + }, + "ours": { + "A_fro": 4.694687796096555, + "B_fro": 0.3196766830580932, + "dW_fro": 0.49909145636834806, + "dW_spec": 0.35161359317910035, + "dW_stable_rank": 2.014786157669938, + "dW_rel_base": 0.018574935686136457, + "B_maxabs": 0.0058739096857607365, + "B_rms": 0.0012487370431956636, + "A_maxabs": 0.040661394596099854, + "A_sv_max_over_min": 1.9426610708567345 + }, + "top8_left_overlap": 0.1460097900851709 + }, + { + "layer": 22, + "proj": "v", + "released": { + "A_fro": 4.655360428477874, + "B_fro": 0.26230134419115064, + "dW_fro": 0.3502834885422721, + "dW_spec": 0.26831320312471163, + "dW_stable_rank": 1.7043361068327068, + "dW_rel_base": 0.008819179453187012, + "B_maxabs": 0.003077468369156122, + "B_rms": 0.001024614625746671, + "A_maxabs": 0.03486386686563492, + "A_sv_max_over_min": 1.7117645856865458 + }, + "ours": { + "A_fro": 4.668582777226769, + "B_fro": 0.32122282599746194, + "dW_fro": 0.4514524203088764, + "dW_spec": 0.34874123903352816, + "dW_stable_rank": 1.6757813737896057, + "dW_rel_base": 0.0113663362376817, + "B_maxabs": 0.006189781706780195, + "B_rms": 0.0012547766640525714, + "A_maxabs": 0.038417328149080276, + "A_sv_max_over_min": 1.793272170691932 + }, + "top8_left_overlap": 0.08674089969041812 + }, + { + "layer": 23, + "proj": "q", + "released": { + "A_fro": 4.665255701469547, + "B_fro": 0.2998214331358845, + "dW_fro": 0.4868928894776204, + "dW_spec": 0.4630053314334476, + "dW_stable_rank": 1.1058465838357274, + "dW_rel_base": 0.019384190446890753, + "B_maxabs": 0.0038891455624252558, + "B_rms": 0.0011711774731870373, + "A_maxabs": 0.03436434641480446, + "A_sv_max_over_min": 1.9353844963614453 + }, + "ours": { + "A_fro": 4.711634930348679, + "B_fro": 0.40338821354725446, + "dW_fro": 0.8183537105871604, + "dW_spec": 0.797867657777559, + "dW_stable_rank": 1.0520112642482073, + "dW_rel_base": 0.03258031596222431, + "B_maxabs": 0.007862861268222332, + "B_rms": 0.0015757352091689478, + "A_maxabs": 0.03895733505487442, + "A_sv_max_over_min": 2.440515155840319 + }, + "top8_left_overlap": 0.10508509820729753 + }, + { + "layer": 23, + "proj": "v", + "released": { + "A_fro": 4.636053473812544, + "B_fro": 0.3359598930869299, + "dW_fro": 0.4798452547453252, + "dW_spec": 0.45827051982683253, + "dW_stable_rank": 1.0963735965144734, + "dW_rel_base": 0.0097406569059533, + "B_maxabs": 0.004261312074959278, + "B_rms": 0.001312343332370804, + "A_maxabs": 0.03485041484236717, + "A_sv_max_over_min": 1.7677262540612126 + }, + "ours": { + "A_fro": 4.640324867435946, + "B_fro": 0.36644680325743445, + "dW_fro": 0.5294556558966466, + "dW_spec": 0.49076153262833544, + "dW_stable_rank": 1.163906666926923, + "dW_rel_base": 0.01074772718913909, + "B_maxabs": 0.008334793150424957, + "B_rms": 0.0014314328252243373, + "A_maxabs": 0.03600774332880974, + "A_sv_max_over_min": 1.796227946735499 + }, + "top8_left_overlap": 0.10695412008314521 + } + ] +} \ No newline at end of file diff --git a/repro/probe_task2/official_runs_summary.json b/repro/probe_task2/official_runs_summary.json new file mode 100644 index 0000000000000000000000000000000000000000..1abffcf04426732fa374340fd916912bfbce2b9b --- /dev/null +++ b/repro/probe_task2/official_runs_summary.json @@ -0,0 +1,302 @@ +{ + "probe_official_dino_synthwildx_66753.json": { + "variant": "dino", + "batch_size": 4, + "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/probe/DINOv2_best_model_step_34999.pth", + "torch": "2.11.0+cu126", + "device": "cuda", + "subsets": { + "dalle3": { + "n_real": 413, + "n_fake": 392, + "full": { + "acc": 97.3913043478261, + "fake_acc": 99.23469387755102, + "real_acc": 95.64164648910412, + "ap": 99.32060777960963, + "bacc": 97.43817018332757 + }, + "official": { + "acc": 97.5765306122449, + "fake_acc": 99.23469387755102, + "real_acc": 95.91836734693877, + "ap": 99.33794737824222, + "n_real": 392, + "n_fake": 392, + "bacc": 97.5765306122449 + }, + "sec": 288.14118337631226, + "n_p_exactly_0.5": 0 + }, + "firefly": { + "n_real": 413, + "n_fake": 473, + "full": { + "acc": 97.06546275395034, + "fake_acc": 98.30866807610994, + "real_acc": 95.64164648910412, + "ap": 97.73509241904287, + "bacc": 96.97515728260703 + }, + "official": { + "acc": 97.21549636803874, + "fake_acc": 98.78934624697337, + "real_acc": 95.64164648910412, + "ap": 97.52259541283286, + "n_real": 413, + "n_fake": 413, + "bacc": 97.21549636803874 + }, + "sec": 453.96343088150024, + "n_p_exactly_0.5": 0 + }, + "midjourney_v5": { + "n_real": 413, + "n_fake": 435, + "full": { + "acc": 97.52358490566037, + "fake_acc": 99.3103448275862, + "real_acc": 95.64164648910412, + "ap": 99.33874577941279, + "bacc": 97.47599565834517 + }, + "official": { + "acc": 97.45762711864407, + "fake_acc": 99.27360774818402, + "real_acc": 95.64164648910412, + "ap": 99.28710387989716, + "n_real": 413, + "n_fake": 413, + "bacc": 97.45762711864407 + }, + "sec": 289.85088324546814, + "n_p_exactly_0.5": 0 + } + } + }, + "probe_official_dino_wildrf_66753.json": { + "variant": "dino", + "batch_size": 4, + "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/probe/DINOv2_best_model_step_34999.pth", + "torch": "2.11.0+cu126", + "device": "cuda", + "subsets": { + "facebook": { + "n_real": 160, + "n_fake": 160, + "full": { + "acc": 98.75, + "fake_acc": 99.375, + "real_acc": 98.125, + "ap": 99.91279426954243, + "bacc": 98.75 + }, + "official": { + "acc": 98.75, + "fake_acc": 99.375, + "real_acc": 98.125, + "ap": 99.91279426954243, + "n_real": 160, + "n_fake": 160, + "bacc": 98.75 + }, + "sec": 95.98293161392212, + "n_p_exactly_0.5": 0 + }, + "reddit": { + "n_real": 750, + "n_fake": 750, + "full": { + "acc": 93.33333333333333, + "fake_acc": 92.26666666666667, + "real_acc": 94.39999999999999, + "ap": 98.40668646247475, + "bacc": 93.33333333333333 + }, + "official": { + "acc": 93.33333333333333, + "fake_acc": 92.26666666666667, + "real_acc": 94.39999999999999, + "ap": 98.40668646247475, + "n_real": 750, + "n_fake": 750, + "bacc": 93.33333333333333 + }, + "sec": 1604.3685626983643, + "n_p_exactly_0.5": 0 + }, + "twitter": { + "n_real": 144, + "n_fake": 277, + "full": { + "acc": 98.33729216152018, + "fake_acc": 97.83393501805054, + "real_acc": 99.30555555555556, + "ap": 99.89951054760652, + "bacc": 98.56974528680306 + }, + "official": { + "acc": 98.26388888888889, + "fake_acc": 97.22222222222221, + "real_acc": 99.30555555555556, + "ap": 99.7034962070625, + "n_real": 144, + "n_fake": 144, + "bacc": 98.26388888888889 + }, + "sec": 190.89450860023499, + "n_p_exactly_0.5": 0 + } + } + }, + "probe_official_resnet_synthwildx_66753.json": { + "variant": "resnet", + "batch_size": 4, + "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/probe/ResNet50_best_model_step_19343.pth", + "torch": "2.11.0+cu126", + "device": "cuda", + "subsets": { + "dalle3": { + "n_real": 413, + "n_fake": 392, + "full": { + "acc": 89.68944099378882, + "fake_acc": 90.3061224489796, + "real_acc": 89.10411622276028, + "ap": 97.31166823216985, + "bacc": 89.70511933586994 + }, + "official": { + "acc": 89.9234693877551, + "fake_acc": 90.3061224489796, + "real_acc": 89.54081632653062, + "ap": 97.5101521756668, + "n_real": 392, + "n_fake": 392, + "bacc": 89.9234693877551 + }, + "sec": 89.89981245994568, + "n_p_exactly_0.5": 0 + }, + "firefly": { + "n_real": 413, + "n_fake": 473, + "full": { + "acc": 54.06320541760722, + "fake_acc": 23.46723044397463, + "real_acc": 89.10411622276028, + "ap": 64.21946843465771, + "bacc": 56.285673333367455 + }, + "official": { + "acc": 56.05326876513317, + "fake_acc": 23.002421307506054, + "real_acc": 89.10411622276028, + "ap": 60.72654590588502, + "n_real": 413, + "n_fake": 413, + "bacc": 56.05326876513317 + }, + "sec": 71.28153395652771, + "n_p_exactly_0.5": 0 + }, + "midjourney_v5": { + "n_real": 413, + "n_fake": 435, + "full": { + "acc": 79.36320754716981, + "fake_acc": 70.11494252873564, + "real_acc": 89.10411622276028, + "ap": 90.1230627190098, + "bacc": 79.60952937574797 + }, + "official": { + "acc": 79.29782082324455, + "fake_acc": 69.49152542372882, + "real_acc": 89.10411622276028, + "ap": 89.4198404579261, + "n_real": 413, + "n_fake": 413, + "bacc": 79.29782082324455 + }, + "sec": 38.00030064582825, + "n_p_exactly_0.5": 0 + } + } + }, + "probe_official_resnet_wildrf_66753.json": { + "variant": "resnet", + "batch_size": 4, + "ckpt": "/local/ssalehid/cache/ivi/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/ckpts/probe/ResNet50_best_model_step_19343.pth", + "torch": "2.11.0+cu126", + "device": "cuda", + "subsets": { + "facebook": { + "n_real": 160, + "n_fake": 160, + "full": { + "acc": 87.8125, + "fake_acc": 93.125, + "real_acc": 82.5, + "ap": 95.2455251583609, + "bacc": 87.8125 + }, + "official": { + "acc": 87.8125, + "fake_acc": 93.125, + "real_acc": 82.5, + "ap": 95.2455251583609, + "n_real": 160, + "n_fake": 160, + "bacc": 87.8125 + }, + "sec": 43.95567750930786, + "n_p_exactly_0.5": 0 + }, + "reddit": { + "n_real": 750, + "n_fake": 750, + "full": { + "acc": 72.86666666666667, + "fake_acc": 56.13333333333333, + "real_acc": 89.60000000000001, + "ap": 81.03946276195629, + "bacc": 72.86666666666667 + }, + "official": { + "acc": 72.86666666666667, + "fake_acc": 56.13333333333333, + "real_acc": 89.60000000000001, + "ap": 81.03946276195629, + "n_real": 750, + "n_fake": 750, + "bacc": 72.86666666666667 + }, + "sec": 658.3460166454315, + "n_p_exactly_0.5": 0 + }, + "twitter": { + "n_real": 144, + "n_fake": 277, + "full": { + "acc": 81.71021377672209, + "fake_acc": 76.17328519855594, + "real_acc": 92.36111111111111, + "ap": 94.87560773775566, + "bacc": 84.26719815483352 + }, + "official": { + "acc": 82.29166666666666, + "fake_acc": 72.22222222222221, + "real_acc": 92.36111111111111, + "ap": 90.67780268647668, + "n_real": 144, + "n_fake": 144, + "bacc": 82.29166666666666 + }, + "sec": 63.55457925796509, + "n_p_exactly_0.5": 0 + } + } + } +} \ No newline at end of file diff --git a/repro/probe_task2/official_vs_synthscope.json b/repro/probe_task2/official_vs_synthscope.json new file mode 100644 index 0000000000000000000000000000000000000000..00de949aed498b6598ce76ddcd0ecd7e0b1a6385 --- /dev/null +++ b/repro/probe_task2/official_vs_synthscope.json @@ -0,0 +1,286 @@ +{ + "probe_wildrf": { + "rows": { + "facebook": { + "n_synthscope": 320, + "n_official": 320, + "n_common": 320, + "only_synthscope": [], + "n_only_synthscope": 0, + "n_only_official": 0, + "synthscope_bacc_all": 98.75, + "official_bacc_all": 98.75, + "synthscope_bacc_common": 98.75, + "official_bacc_common": 98.75, + "official_overall_acc_balanced_subsample": 98.75, + "official_subsample_n": [ + 160, + 160 + ], + "official_ap": 99.91, + "max_abs_dP": 2.7120113372802734e-06, + "mean_abs_dP": 4.451856057130499e-08, + "flips_at_0.5": 0 + }, + "reddit": { + "n_synthscope": 1500, + "n_official": 1500, + "n_common": 1500, + "only_synthscope": [], + "n_only_synthscope": 0, + "n_only_official": 0, + "synthscope_bacc_all": 93.33, + "official_bacc_all": 93.33, + "synthscope_bacc_common": 93.33, + "official_bacc_common": 93.33, + "official_overall_acc_balanced_subsample": 93.33, + "official_subsample_n": [ + 750, + 750 + ], + "official_ap": 98.41, + "max_abs_dP": 3.039836883544922e-06, + "mean_abs_dP": 1.281230288441293e-07, + "flips_at_0.5": 0 + }, + "twitter": { + "n_synthscope": 683, + "n_official": 421, + "n_common": 421, + "only_synthscope": [ + "jfif" + ], + "n_only_synthscope": 262, + "n_only_official": 0, + "synthscope_bacc_all": 98.68, + "official_bacc_all": 98.57, + "synthscope_bacc_common": 98.57, + "official_bacc_common": 98.57, + "official_overall_acc_balanced_subsample": 98.26, + "official_subsample_n": [ + 144, + 144 + ], + "official_ap": 99.7, + "max_abs_dP": 1.564621925354004e-06, + "mean_abs_dP": 5.026400456898525e-08, + "flips_at_0.5": 0 + } + }, + "official_mean_bacc_all": 96.88, + "official_mean_overall_acc": 96.78, + "synthscope_mean": 96.92 + }, + "probe_synthwildx": { + "rows": { + "dalle3": { + "n_synthscope": 805, + "n_official": 805, + "n_common": 805, + "only_synthscope": [], + "n_only_synthscope": 0, + "n_only_official": 0, + "synthscope_bacc_all": 97.44, + "official_bacc_all": 97.44, + "synthscope_bacc_common": 97.44, + "official_bacc_common": 97.44, + "official_overall_acc_balanced_subsample": 97.58, + "official_subsample_n": [ + 392, + 392 + ], + "official_ap": 99.34, + "max_abs_dP": 4.7907233238220215e-06, + "mean_abs_dP": 7.362098625415693e-08, + "flips_at_0.5": 0 + }, + "firefly": { + "n_synthscope": 886, + "n_official": 886, + "n_common": 886, + "only_synthscope": [], + "n_only_synthscope": 0, + "n_only_official": 0, + "synthscope_bacc_all": 96.98, + "official_bacc_all": 96.98, + "synthscope_bacc_common": 96.98, + "official_bacc_common": 96.98, + "official_overall_acc_balanced_subsample": 97.22, + "official_subsample_n": [ + 413, + 413 + ], + "official_ap": 97.52, + "max_abs_dP": 4.7907233238220215e-06, + "mean_abs_dP": 8.706809170008059e-08, + "flips_at_0.5": 0 + }, + "midjourney_v5": { + "n_synthscope": 848, + "n_official": 848, + "n_common": 848, + "only_synthscope": [], + "n_only_synthscope": 0, + "n_only_official": 0, + "synthscope_bacc_all": 97.48, + "official_bacc_all": 97.48, + "synthscope_bacc_common": 97.48, + "official_bacc_common": 97.48, + "official_overall_acc_balanced_subsample": 97.46, + "official_subsample_n": [ + 413, + 413 + ], + "official_ap": 99.29, + "max_abs_dP": 4.7907233238220215e-06, + "mean_abs_dP": 7.980291761583121e-08, + "flips_at_0.5": 0 + } + }, + "official_mean_bacc_all": 97.3, + "official_mean_overall_acc": 97.42, + "synthscope_mean": 97.3 + }, + "probe_resnet_wildrf": { + "rows": { + "facebook": { + "n_synthscope": 320, + "n_official": 320, + "n_common": 320, + "only_synthscope": [], + "n_only_synthscope": 0, + "n_only_official": 0, + "synthscope_bacc_all": 87.81, + "official_bacc_all": 87.81, + "synthscope_bacc_common": 87.81, + "official_bacc_common": 87.81, + "official_overall_acc_balanced_subsample": 87.81, + "official_subsample_n": [ + 160, + 160 + ], + "official_ap": 95.25, + "max_abs_dP": 0.0006741583347320557, + "mean_abs_dP": 4.756571124744369e-05, + "flips_at_0.5": 0 + }, + "reddit": { + "n_synthscope": 1500, + "n_official": 1500, + "n_common": 1500, + "only_synthscope": [], + "n_only_synthscope": 0, + "n_only_official": 0, + "synthscope_bacc_all": 72.87, + "official_bacc_all": 72.87, + "synthscope_bacc_common": 72.87, + "official_bacc_common": 72.87, + "official_overall_acc_balanced_subsample": 72.87, + "official_subsample_n": [ + 750, + 750 + ], + "official_ap": 81.04, + "max_abs_dP": 0.0013099312782287598, + "mean_abs_dP": 2.5016618089163482e-05, + "flips_at_0.5": 0 + }, + "twitter": { + "n_synthscope": 683, + "n_official": 421, + "n_common": 421, + "only_synthscope": [ + "jfif" + ], + "n_only_synthscope": 262, + "n_only_official": 0, + "synthscope_bacc_all": 84.2, + "official_bacc_all": 84.27, + "synthscope_bacc_common": 84.27, + "official_bacc_common": 84.27, + "official_overall_acc_balanced_subsample": 82.29, + "official_subsample_n": [ + 144, + 144 + ], + "official_ap": 90.68, + "max_abs_dP": 0.0005781650543212891, + "mean_abs_dP": 3.790549008671256e-05, + "flips_at_0.5": 0 + } + }, + "official_mean_bacc_all": 81.65, + "official_mean_overall_acc": 80.99, + "synthscope_mean": 81.63 + }, + "probe_resnet_synthwildx": { + "rows": { + "dalle3": { + "n_synthscope": 805, + "n_official": 805, + "n_common": 805, + "only_synthscope": [], + "n_only_synthscope": 0, + "n_only_official": 0, + "synthscope_bacc_all": 89.71, + "official_bacc_all": 89.71, + "synthscope_bacc_common": 89.71, + "official_bacc_common": 89.71, + "official_overall_acc_balanced_subsample": 89.92, + "official_subsample_n": [ + 392, + 392 + ], + "official_ap": 97.51, + "max_abs_dP": 0.0004710555076599121, + "mean_abs_dP": 2.5517945806929693e-05, + "flips_at_0.5": 0 + }, + "firefly": { + "n_synthscope": 886, + "n_official": 886, + "n_common": 886, + "only_synthscope": [], + "n_only_synthscope": 0, + "n_only_official": 0, + "synthscope_bacc_all": 56.29, + "official_bacc_all": 56.29, + "synthscope_bacc_common": 56.29, + "official_bacc_common": 56.29, + "official_overall_acc_balanced_subsample": 56.05, + "official_subsample_n": [ + 413, + 413 + ], + "official_ap": 60.73, + "max_abs_dP": 0.0004710555076599121, + "mean_abs_dP": 2.393783120733831e-05, + "flips_at_0.5": 0 + }, + "midjourney_v5": { + "n_synthscope": 848, + "n_official": 848, + "n_common": 848, + "only_synthscope": [], + "n_only_synthscope": 0, + "n_only_official": 0, + "synthscope_bacc_all": 79.61, + "official_bacc_all": 79.61, + "synthscope_bacc_common": 79.61, + "official_bacc_common": 79.61, + "official_overall_acc_balanced_subsample": 79.3, + "official_subsample_n": [ + 413, + 413 + ], + "official_ap": 89.42, + "max_abs_dP": 0.0004710555076599121, + "mean_abs_dP": 4.6747759318710655e-05, + "flips_at_0.5": 0 + } + }, + "official_mean_bacc_all": 75.2, + "official_mean_overall_acc": 75.09, + "synthscope_mean": 75.2 + } +} \ No newline at end of file diff --git a/repro/probe_task2/paper_vs_synthscope.json b/repro/probe_task2/paper_vs_synthscope.json new file mode 100644 index 0000000000000000000000000000000000000000..38c995f0ea9c009856069dda286791ab2cb4915e --- /dev/null +++ b/repro/probe_task2/paper_vs_synthscope.json @@ -0,0 +1,534 @@ +{ + "paper_missing": { + "chameleon": { + "probe": 86.6, + "probe_resnet": 74.0 + }, + "aigi_quality_paradox": { + "probe": 92.9, + "probe_resnet": 87.7 + } + }, + "benchmarks": { + "genimage_val100k": { + "probe": { + "rows": [ + { + "subset": "midjourney", + "paper": 98.8, + "synthscope": 98.73, + "real_acc": 98.57, + "fake_acc": 98.9, + "ap": 99.86 + }, + { + "subset": "sdv1.4", + "paper": 99.4, + "synthscope": 99.41, + "real_acc": 98.85, + "fake_acc": 99.97, + "ap": 100.0 + }, + { + "subset": "sdv1.5", + "paper": 99.4, + "synthscope": 99.39, + "real_acc": 98.9, + "fake_acc": 99.87, + "ap": 99.99 + }, + { + "subset": "adm", + "paper": 91.0, + "synthscope": 93.22, + "real_acc": 98.55, + "fake_acc": 87.88, + "ap": 99.32 + }, + { + "subset": "glide", + "paper": 92.1, + "synthscope": 93.86, + "real_acc": 99.07, + "fake_acc": 88.65, + "ap": 99.47 + }, + { + "subset": "wukong", + "paper": 99.5, + "synthscope": 99.33, + "real_acc": 98.68, + "fake_acc": 99.97, + "ap": 100.0 + }, + { + "subset": "vqdm", + "paper": 98.9, + "synthscope": 98.76, + "real_acc": 98.62, + "fake_acc": 98.9, + "ap": 99.88 + }, + { + "subset": "biggan", + "paper": 95.0, + "synthscope": 97.07, + "real_acc": 98.75, + "fake_acc": 95.38, + "ap": 99.65 + } + ], + "paper_avg_table1": 96.8, + "paper_mean_of_listed": 96.76, + "synthscope_mean": 97.47, + "synthscope_map": 99.77, + "tag": "probe_genimage_val100k", + "data_root": "/local/ssalehid/cache/data029/GenImage_val_full/test", + "extra_subsets_in_run": [] + }, + "probe_resnet": { + "rows": [ + { + "subset": "midjourney", + "paper": 90.7, + "synthscope": 90.73, + "real_acc": 98.67, + "fake_acc": 82.8, + "ap": 98.63 + }, + { + "subset": "sdv1.4", + "paper": 99.4, + "synthscope": 99.36, + "real_acc": 98.72, + "fake_acc": 100.0, + "ap": 100.0 + }, + { + "subset": "sdv1.5", + "paper": 99.2, + "synthscope": 99.24, + "real_acc": 98.6, + "fake_acc": 99.89, + "ap": 99.99 + }, + { + "subset": "adm", + "paper": 60.0, + "synthscope": 58.94, + "real_acc": 98.52, + "fake_acc": 19.37, + "ap": 85.17 + }, + { + "subset": "glide", + "paper": 63.0, + "synthscope": 63.01, + "real_acc": 98.78, + "fake_acc": 27.23, + "ap": 85.76 + }, + { + "subset": "wukong", + "paper": 99.4, + "synthscope": 99.41, + "real_acc": 98.87, + "fake_acc": 99.95, + "ap": 100.0 + }, + { + "subset": "vqdm", + "paper": 66.9, + "synthscope": 66.9, + "real_acc": 98.72, + "fake_acc": 35.08, + "ap": 90.07 + }, + { + "subset": "biggan", + "paper": 49.4, + "synthscope": 49.41, + "real_acc": 98.82, + "fake_acc": 0.0, + "ap": 33.88 + } + ], + "paper_avg_table1": 78.4, + "paper_mean_of_listed": 78.5, + "synthscope_mean": 78.38, + "synthscope_map": 86.69, + "tag": "probe_resnet_genimage_val100k", + "data_root": "/local/ssalehid/cache/data029/GenImage_val_full/test", + "extra_subsets_in_run": [] + } + }, + "synthbuster_coco": { + "probe": { + "rows": [ + { + "subset": "dalle2", + "paper": 94.6, + "synthscope": 93.47, + "real_acc": 99.54, + "fake_acc": 87.4, + "ap": 98.65 + }, + { + "subset": "dalle3", + "paper": 99.4, + "synthscope": 99.57, + "real_acc": 99.54, + "fake_acc": 99.6, + "ap": 99.93 + }, + { + "subset": "firefly", + "paper": 99.5, + "synthscope": 99.77, + "real_acc": 99.54, + "fake_acc": 100.0, + "ap": 99.64 + }, + { + "subset": "glide", + "paper": 86.7, + "synthscope": 92.22, + "real_acc": 99.54, + "fake_acc": 84.9, + "ap": 98.54 + }, + { + "subset": "midjourney-v5", + "paper": 99.5, + "synthscope": 99.77, + "real_acc": 99.54, + "fake_acc": 100.0, + "ap": 99.99 + }, + { + "subset": "stable-diffusion-1-3", + "paper": 99.5, + "synthscope": 99.72, + "real_acc": 99.54, + "fake_acc": 99.9, + "ap": 99.99 + }, + { + "subset": "stable-diffusion-1-4", + "paper": 99.5, + "synthscope": 99.77, + "real_acc": 99.54, + "fake_acc": 100.0, + "ap": 100.0 + }, + { + "subset": "stable-diffusion-2", + "paper": 99.5, + "synthscope": 99.77, + "real_acc": 99.54, + "fake_acc": 100.0, + "ap": 99.99 + }, + { + "subset": "stable-diffusion-xl", + "paper": 99.5, + "synthscope": 99.72, + "real_acc": 99.54, + "fake_acc": 99.9, + "ap": 99.99 + } + ], + "paper_avg_table1": 97.5, + "paper_mean_of_listed": 97.52, + "synthscope_mean": 98.2, + "synthscope_map": 99.64, + "tag": "probe_synthbuster_coco", + "data_root": "/local/ssalehid/66755/tmp/layouts/Synthbuster_coco", + "extra_subsets_in_run": [] + }, + "probe_resnet": { + "rows": [ + { + "subset": "dalle2", + "paper": 48.3, + "synthscope": 52.97, + "real_acc": 99.14, + "fake_acc": 6.8, + "ap": 60.83 + }, + { + "subset": "dalle3", + "paper": 90.2, + "synthscope": 94.82, + "real_acc": 99.14, + "fake_acc": 90.5, + "ap": 98.14 + }, + { + "subset": "firefly", + "paper": 46.9, + "synthscope": 51.57, + "real_acc": 99.14, + "fake_acc": 4.0, + "ap": 42.22 + }, + { + "subset": "glide", + "paper": 57.4, + "synthscope": 62.07, + "real_acc": 99.14, + "fake_acc": 25.0, + "ap": 67.67 + }, + { + "subset": "midjourney-v5", + "paper": 93.2, + "synthscope": 97.82, + "real_acc": 99.14, + "fake_acc": 96.5, + "ap": 99.48 + }, + { + "subset": "stable-diffusion-1-3", + "paper": 94.9, + "synthscope": 99.57, + "real_acc": 99.14, + "fake_acc": 100.0, + "ap": 100.0 + }, + { + "subset": "stable-diffusion-1-4", + "paper": 94.9, + "synthscope": 99.57, + "real_acc": 99.14, + "fake_acc": 100.0, + "ap": 100.0 + }, + { + "subset": "stable-diffusion-2", + "paper": 93.1, + "synthscope": 97.72, + "real_acc": 99.14, + "fake_acc": 96.3, + "ap": 99.33 + }, + { + "subset": "stable-diffusion-xl", + "paper": 93.0, + "synthscope": 97.67, + "real_acc": 99.14, + "fake_acc": 96.2, + "ap": 99.41 + } + ], + "paper_avg_table1": 79.1, + "paper_mean_of_listed": 79.1, + "synthscope_mean": 83.75, + "synthscope_map": 85.23, + "tag": "probe_resnet_synthbuster_coco", + "data_root": "/local/ssalehid/66755/tmp/layouts/Synthbuster_coco", + "extra_subsets_in_run": [] + } + }, + "synthwildx": { + "probe": { + "rows": [ + { + "subset": "dalle3", + "paper": 96.5, + "synthscope": 97.44, + "real_acc": 95.64, + "fake_acc": 99.23, + "ap": 99.32 + }, + { + "subset": "firefly", + "paper": 96.4, + "synthscope": 96.98, + "real_acc": 95.64, + "fake_acc": 98.31, + "ap": 97.74 + }, + { + "subset": "midjourney_v5", + "paper": 96.5, + "synthscope": 97.48, + "real_acc": 95.64, + "fake_acc": 99.31, + "ap": 99.34 + } + ], + "paper_avg_table1": 96.4, + "paper_mean_of_listed": 96.47, + "synthscope_mean": 97.3, + "synthscope_map": 98.8, + "tag": "probe_synthwildx", + "data_root": "/local/ssalehid/cache/data029/SynthWildX/test", + "extra_subsets_in_run": [] + }, + "probe_resnet": { + "rows": [ + { + "subset": "dalle3", + "paper": 90.3, + "synthscope": 89.71, + "real_acc": 89.1, + "fake_acc": 90.31, + "ap": 97.31 + }, + { + "subset": "firefly", + "paper": 56.7, + "synthscope": 56.29, + "real_acc": 89.1, + "fake_acc": 23.47, + "ap": 64.22 + }, + { + "subset": "midjourney_v5", + "paper": 79.7, + "synthscope": 79.61, + "real_acc": 89.1, + "fake_acc": 70.11, + "ap": 90.12 + } + ], + "paper_avg_table1": 75.6, + "paper_mean_of_listed": 75.57, + "synthscope_mean": 75.2, + "synthscope_map": 83.88, + "tag": "probe_resnet_synthwildx", + "data_root": "/local/ssalehid/cache/data029/SynthWildX/test", + "extra_subsets_in_run": [] + } + }, + "wildrf": { + "probe": { + "rows": [ + { + "subset": "facebook", + "paper": 98.4, + "synthscope": 98.75, + "real_acc": 98.12, + "fake_acc": 99.37, + "ap": 99.91 + }, + { + "subset": "reddit", + "paper": 93.4, + "synthscope": 93.33, + "real_acc": 94.4, + "fake_acc": 92.27, + "ap": 98.41 + }, + { + "subset": "twitter", + "paper": 99.0, + "synthscope": 98.68, + "real_acc": 99.12, + "fake_acc": 98.25, + "ap": 99.77 + } + ], + "paper_avg_table1": 96.9, + "paper_mean_of_listed": 96.93, + "synthscope_mean": 96.92, + "synthscope_map": 99.36, + "tag": "probe_wildrf", + "data_root": "/local/ssalehid/cache/data029/WildRF/test", + "extra_subsets_in_run": [] + }, + "probe_resnet": { + "rows": [ + { + "subset": "facebook", + "paper": 87.8, + "synthscope": 87.81, + "real_acc": 82.5, + "fake_acc": 93.12, + "ap": 95.24 + }, + { + "subset": "reddit", + "paper": 72.9, + "synthscope": 72.87, + "real_acc": 89.6, + "fake_acc": 56.13, + "ap": 81.04 + }, + { + "subset": "twitter", + "paper": 83.3, + "synthscope": 84.2, + "real_acc": 89.74, + "fake_acc": 78.65, + "ap": 92.08 + } + ], + "paper_avg_table1": 81.3, + "paper_mean_of_listed": 81.33, + "synthscope_mean": 81.63, + "synthscope_map": 89.45, + "tag": "probe_resnet_wildrf", + "data_root": "/local/ssalehid/cache/data029/WildRF/test", + "extra_subsets_in_run": [] + } + }, + "aigibench": { + "probe": { + "rows": [ + { + "subset": "CommunityAI", + "paper": 89.8, + "synthscope": 90.38, + "real_acc": 97.17, + "fake_acc": 83.6, + "ap": 97.08 + }, + { + "subset": "SocialRF", + "paper": 89.9, + "synthscope": 89.38, + "real_acc": 89.87, + "fake_acc": 88.9, + "ap": 95.84 + } + ], + "paper_avg_table1": 89.9, + "paper_mean_of_listed": 89.85, + "synthscope_mean": 89.88, + "synthscope_map": 96.46, + "tag": "probe_aigibench", + "data_root": "/local/ssalehid/66790/tmp/layouts/aigibench", + "extra_subsets_in_run": [] + }, + "probe_resnet": { + "rows": [ + { + "subset": "CommunityAI", + "paper": 71.0, + "synthscope": 70.99, + "real_acc": 87.1, + "fake_acc": 54.88, + "ap": 80.28 + }, + { + "subset": "SocialRF", + "paper": 69.9, + "synthscope": 69.88, + "real_acc": 84.2, + "fake_acc": 55.57, + "ap": 79.31 + } + ], + "paper_avg_table1": 70.4, + "paper_mean_of_listed": 70.45, + "synthscope_mean": 70.44, + "synthscope_map": 79.8, + "tag": "probe_resnet_aigibench", + "data_root": "/local/ssalehid/66790/tmp/layouts/aigibench", + "extra_subsets_in_run": [] + } + } + } +} \ No newline at end of file diff --git a/repro/probe_task2/probe_bench_record.py b/repro/probe_task2/probe_bench_record.py new file mode 100644 index 0000000000000000000000000000000000000000..5ecc5a98c2582a1873c0988ce4205fc203d3e028 --- /dev/null +++ b/repro/probe_task2/probe_bench_record.py @@ -0,0 +1,86 @@ +"""(Copy of vina_bench_record.py for PROBE; the video mode is unused.) +Run SynthScope's benchmark/bench_eval.py or bench_eval_video.py UNCHANGED and also save the per-file P(fake) it +computed, so the scores can be compared file by file with the official evaluate_dino.py / evaluate_resnet.py and the +scores can be compared file by file with the official eval.py (--analysis CSV). + +The wrapper only observes: bench_eval's own `score`/`metrics` (image) or the engine's `predict_video_clip` (video) are +wrapped to record their inputs/outputs; bench_eval writes its JSON and MASTER_RESULTS.jsonl line itself. + + python vina_bench_record.py image -- --model probe --benchmark pergen --data D --tag T + python vina_bench_record.py video -- --model vina_video --benchmark genvideo --data D --tag T +""" +import json +import os +import sys +import time +from pathlib import Path + +W = Path(os.environ.get("PROBE_WT", "/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/probe_wt")) +sys.path[:0] = [str(W / "benchmark"), str(W / "interface"), str(W)] + + +def run_image(argv, out): + import bench_eval as be + gens, cur, rec = [], {}, [] + orig_discover, orig_score, orig_metrics = be.discover, be.score, be.metrics + + def discover(*a, **k): + res = orig_discover(*a, **k) + gens.extend(name for name, _, _ in res) + return res + + def score(det, model, spec, paths, bs, **kw): + t0 = time.time() + probs, kept = orig_score(det, model, spec, paths, bs, **kw) + cur.update(paths=[str(paths[i]) for i in kept], probs=probs.tolist(), sec=time.time() - t0) + return probs, kept + + def metrics(fake_probs, labels): + rec.append({"name": gens[len(rec)], "paths": cur["paths"], "probs": cur["probs"], + "labels": labels.tolist(), "sec": cur["sec"]}) + return orig_metrics(fake_probs, labels) + + be.discover, be.score, be.metrics = discover, score, metrics + rc = be.main(argv) + n = sum(len(r["paths"]) for r in rec) + sec = sum(r["sec"] for r in rec) + Path(out).write_text(json.dumps({"argv": argv, "gens": rec}) + "\n") + print(f"[record] {n} scored images in {sec:.0f} s ({n / max(sec, 1e-9):.2f} img/s incl. decode) -> {out}", + flush=True) + return rc + + +def run_video(argv, out): + import bench_eval_video as bv + from backend import engine as engine_mod + rec = [] + cls = type(engine_mod.get_engine()) + orig, orig_prob = cls.predict_video_clip, cls._video_fake_prob + last = {} + + def _video_fake_prob(self, *a, **k): # the unrounded P(fake) (predict_video_clip rounds to 6 decimals) + p = orig_prob(self, *a, **k) + last["raw"] = float(p.reshape(-1)[0]) + return p + + def predict_video_clip(self, spec, path, *a, **k): + t0 = time.time() + last.clear() + res = orig(self, spec, path, *a, **k) + rec.append({"path": str(path), "prob": float(res["fake_probability"]), "prob_raw": last.get("raw"), + "sec": time.time() - t0}) + return res + + cls.predict_video_clip, cls._video_fake_prob = predict_video_clip, _video_fake_prob + rc = bv.main(argv) + sec = sum(r["sec"] for r in rec) + Path(out).write_text(json.dumps({"argv": argv, "videos": rec}) + "\n") + print(f"[record] {len(rec)} scored videos in {sec:.0f} s ({len(rec) / max(sec, 1e-9):.3f} clips/s incl. ffmpeg)" + f" -> {out}", flush=True) + return rc + + +if __name__ == "__main__": + mode, out, sep, *rest = sys.argv[1:] + assert sep == "--" and mode in ("image", "video"), __doc__ + sys.exit((run_image if mode == "image" else run_video)(rest, out)) diff --git a/repro/probe_task2/probe_official_eval.py b/repro/probe_task2/probe_official_eval.py new file mode 100644 index 0000000000000000000000000000000000000000..e6e5ab4008b7d7f018c5647ce3ef992fd1a8c42f --- /dev/null +++ b/repro/probe_task2/probe_official_eval.py @@ -0,0 +1,118 @@ +"""PROBE official-protocol evaluation (Task 2 parity reference). + +Runs the UNMODIFIED official evaluate_dino.py / evaluate_resnet.py code path (EvaluateDataset, collate_fn, evaluate) +on =, subsets, one subset at a time as separate `python evaluate_*.py --root_list real fake` +invocations would (global seed 42 re-applied before every subset, so the `fake_equal_real` random subsample is the one +the official script draws). README settings: DINOv2 crop 336 / ResNet crop 224, ImageNet normalisation, pad_mode 'repeat' +(dino) / 'pad' (resnet) as in the official __main__, no augmentation. Only the backbone path (local copy of +facebook/dinov2-with-registers-large, hard-coded to a lab path in the official class) and the batch size are set from outside. + +Per subset it scores EVERY file once (fake_equal_real=False dataset, official `evaluate`) and reports + full : bAcc = (real_acc + fake_acc)/2 over all files (= the paper's metric and bench_eval's `acc`), AP, pooled accuracy + official : the numbers the official script prints ("Overall Accuracy" = pooled accuracy, fake/real acc, AP) on the + class-balanced random subsample (fake_equal_real=True dataset built by the official class, seed 42); + computed from the same per-file P with the same sklearn calls as `evaluate`. +and stores the per-file P(fake) so SynthScope's bench_eval scores can be compared file by file. +usage: python probe_official_eval.py {dino|resnet} OUT_JSON BATCH_SIZE NAME=REAL_DIR,FAKE_DIR ... +env: PROBE_REF (official Detector dir), PROBE_CKPTS (dir with DINOv2_best_model_step_34999.pth, ResNet50_best_model_step_19343.pth, + dinov2-with-registers-large/), PROBE_WORKERS +""" +import json +import os +import random +import sys +import time + +import numpy as np +import torch +from sklearn.metrics import accuracy_score, average_precision_score +from torch.utils.data import DataLoader + +REF = os.environ["PROBE_REF"] +CK = os.environ["PROBE_CKPTS"] +variant, out_path, bs = sys.argv[1], os.path.abspath(sys.argv[2]), int(sys.argv[3]) +subsets = [a.split("=", 1) for a in sys.argv[4:]] +sys.path.insert(0, REF) +os.chdir(REF) +if variant == "dino": + import evaluate_dino as E + from model.dino_classifier import dino_classifier + crop, pad_mode = 336, "repeat" +else: + import evaluate_resnet as E + from model.resnet50 import resnet50 + crop, pad_mode = 224, "pad" +device = torch.device("cuda" if torch.cuda.is_available() else "cpu") +E.device = device +params = dict(blur_prob=0.0, blur_sig_min=0.0, blur_sig_max=3.0, blur_sig=0.0, jpeg_prob=0.0, jpeg_quality_min=60, + jpeg_quality_max=100, jpeg_quality=100, cutout_prob=0.0, cutout_ratio_min=0.1, cutout_ratio_max=0.5, + noise_prob=0.0, noise_std_min=0.0, noise_std_max=50.0, noise_std=0.0, resize_prob=0.0, + resize_scale_min=0.5, resize_scale_max=2.0, resize_scale=1.0, pad_mode=pad_mode) + +if variant == "dino": + det = dino_classifier(model_name=CK + "/dinov2-with-registers-large", classifier_type="linear") + ckpt = CK + "/DINOv2_best_model_step_34999.pth" +else: + det = resnet50(num_classes=1, classifier_type="linear") + ckpt = CK + "/ResNet50_best_model_step_19343.pth" +print(det.load_state_dict(torch.load(ckpt, map_location="cpu")["model_state_dict"], strict=True), flush=True) +det = det.to(device).eval() + + +def seed_like_fresh_process(): # the module-level seeding of evaluate_*.py, as at the start of a new invocation + torch.manual_seed(42) + np.random.seed(42) + random.seed(42) + + +def make_ds(real, fake, equal): + kw = dict(root_list=[real, fake], crop_size=crop, fake_equal_real=equal, data_augment_params=params) + if variant == "dino": + kw["normalization"] = "imagenet" + else: + kw["model"] = "cnn" + return E.EvaluateDataset(**kw) + + +def official_metrics(y_true, y_pred): # the formulas of evaluate_*.py + fm, rm = y_true == 1, y_true == 0 + return {"acc": accuracy_score(y_true, y_pred > 0.5) * 100, + "fake_acc": accuracy_score(y_true[fm], y_pred[fm] > 0.5) * 100 if fm.any() else 0.0, + "real_acc": accuracy_score(y_true[rm], y_pred[rm] > 0.5) * 100 if rm.any() else 0.0, + "ap": average_precision_score(y_true, y_pred) * 100 if len(np.unique(y_true)) > 1 else 0.0} + + +res = {"variant": variant, "batch_size": bs, "ckpt": ckpt, "torch": torch.__version__, "device": str(device), + "ref": REF, "subsets": {}} +for name, spec in subsets: + real, fake = spec.split(",") + seed_like_fresh_process() + ds_off = make_ds(real, fake, True) # what the official script evaluates by default + off_paths = set(ds_off.image_paths) + ds_all = make_ds(real, fake, False) # every file + E.dataset = ds_all + dl = DataLoader(ds_all, batch_size=bs, shuffle=False, num_workers=int(os.environ.get("PROBE_WORKERS", 4)), + collate_fn=E.collate_fn) + t0 = time.time() + _, _, _, _, y_true, y_pred, _ = E.evaluate(det, dl) # the official evaluate(), unchanged + sec = time.time() - t0 + y_true, y_pred = np.asarray(y_true), np.asarray(y_pred) + full = official_metrics(y_true, y_pred) + full["bacc"] = (full["fake_acc"] + full["real_acc"]) / 2 + sel = np.array([p in off_paths for p in ds_all.image_paths]) + off = official_metrics(y_true[sel], y_pred[sel]) + off["n_real"], off["n_fake"] = int((y_true[sel] == 0).sum()), int((y_true[sel] == 1).sum()) + off["bacc"] = (off["fake_acc"] + off["real_acc"]) / 2 + n_bad = sum(1 for p in y_pred if p == 0.5) + res["subsets"][name] = {"n_real": int((y_true == 0).sum()), "n_fake": int((y_true == 1).sum()), "full": full, + "official": off, "sec": sec, "n_p_exactly_0.5": n_bad, + "paths": ds_all.image_paths, "labels": y_true.tolist(), "probs": y_pred.tolist()} + print(f"\nOFFICIAL {variant} {name}: files {len(y_true)} ({sec:.0f}s) | full bAcc {full['bacc']:.2f} " + f"(real {full['real_acc']:.2f} fake {full['fake_acc']:.2f} pooled {full['acc']:.2f} AP {full['ap']:.2f}) | " + f"official-style subsample {off['n_real']}+{off['n_fake']}: Overall {off['acc']:.2f} " + f"real {off['real_acc']:.2f} fake {off['fake_acc']:.2f} AP {off['ap']:.2f} bAcc {off['bacc']:.2f}", flush=True) + json.dump(res, open(out_path, "w")) +names = list(res["subsets"]) +mean = lambda key, k2: sum(res["subsets"][n][key][k2] for n in names) / len(names) +print(f"OFFICIAL {variant} MEAN over {len(names)} subsets: full bAcc {mean('full', 'bacc'):.2f} | official-style Overall " + f"{mean('official', 'acc'):.2f} (bAcc {mean('official', 'bacc'):.2f}) -> {out_path}", flush=True) diff --git a/repro/probe_task2/probe_task2_official_cmp.py b/repro/probe_task2/probe_task2_official_cmp.py new file mode 100644 index 0000000000000000000000000000000000000000..c28c9fcd27ffcef1034067b54f01074d9935e936 --- /dev/null +++ b/repro/probe_task2/probe_task2_official_cmp.py @@ -0,0 +1,43 @@ +"""Official evaluate_{dino,resnet}.py vs SynthScope bench_eval on the same files (WildRF, SynthWildX): per subset bAcc of both, +file-set differences, per-file P(fake) differences. usage: python probe_task2_official_cmp.py SCORES_DIR OFFICIAL_DIR JOBID OUT_JSON BENCH_RESULTS_DIR""" +import json +import sys + +import numpy as np + +SC, OF, JOB, OUT, BR = sys.argv[1:6] # BR = /repro/bench_results +res = {} +for model, v in (("probe", "dino"), ("probe_resnet", "resnet")): + for bench in ("wildrf", "synthwildx"): + sc = json.load(open(f"{SC}/{model}_{bench}.json")) + of = json.load(open(f"{OF}/probe_official_{v}_{bench}_{JOB}.json")) + ours = {g["name"]: dict(zip(g["paths"], zip(g["probs"], g["labels"]))) for g in sc["gens"]} + rows = {} + for name, o in of["subsets"].items(): + s = ours[name] + op = dict(zip(o["paths"], zip(o["probs"], o["labels"]))) + common = sorted(set(s) & set(op)) + a = np.array([s[p][0] for p in common]); b = np.array([op[p][0] for p in common]); y = np.array([s[p][1] for p in common]) + def bacc(p, yy): + return ((p[yy == 0] < 0.5).mean() + (p[yy == 1] >= 0.5).mean()) * 50 + sy = np.array([x[1] for x in s.values()]); sp = np.array([x[0] for x in s.values()]) + rows[name] = {"n_synthscope": len(s), "n_official": len(op), "n_common": len(common), + "only_synthscope": sorted({p.rsplit('.', 1)[-1].lower() for p in set(s) - set(op)}), "n_only_synthscope": len(set(s) - set(op)), + "n_only_official": len(set(op) - set(s)), + "synthscope_bacc_all": round(float(bacc(sp, sy)), 2), "official_bacc_all": round(o["full"]["bacc"], 2), + "synthscope_bacc_common": round(float(bacc(a, y)), 2), "official_bacc_common": round(float(bacc(b, y)), 2), + "official_overall_acc_balanced_subsample": round(o["official"]["acc"], 2), + "official_subsample_n": [o["official"]["n_real"], o["official"]["n_fake"]], + "official_ap": round(o["official"]["ap"], 2), + "max_abs_dP": float(np.abs(a - b).max()), "mean_abs_dP": float(np.abs(a - b).mean()), + "flips_at_0.5": int(((a >= 0.5) != (b >= 0.5)).sum())} + res[f"{model}_{bench}"] = {"rows": rows, "official_mean_bacc_all": round(float(np.mean([r["official_bacc_all"] for r in rows.values()])), 2), + "official_mean_overall_acc": round(float(np.mean([r["official_overall_acc_balanced_subsample"] for r in rows.values()])), 2), + "synthscope_mean": json.load(open(f"{BR}/{model}_{bench}.json"))["means"]["acc"]} +json.dump(res, open(OUT, "w"), indent=1) +for k, r in res.items(): + print(f"\n## {k}: SynthScope mean {r['synthscope_mean']} | official bAcc(all files) {r['official_mean_bacc_all']} | official Overall (seed-42 balanced) {r['official_mean_overall_acc']}") + for n, x in r["rows"].items(): + print(f" {n}: SS {x['synthscope_bacc_all']} (n={x['n_synthscope']}) | OFF bAcc {x['official_bacc_all']} (n={x['n_official']}) | OFF Overall {x['official_overall_acc_balanced_subsample']} " + f"subsample {x['official_subsample_n']} | common n={x['n_common']}: SS {x['synthscope_bacc_common']} OFF {x['official_bacc_common']} " + f"maxdP {x['max_abs_dP']:.2e} flips {x['flips_at_0.5']} | only-SS {x['n_only_synthscope']} {x['only_synthscope']}") diff --git a/repro/probe_task2/probe_task2_table.py b/repro/probe_task2/probe_task2_table.py new file mode 100644 index 0000000000000000000000000000000000000000..5265831204c9f8116f24722f4775db966447ec99 --- /dev/null +++ b/repro/probe_task2/probe_task2_table.py @@ -0,0 +1,54 @@ +"""PROBE Task 2: paper (Tables 1-4) vs official-code-on-our-data vs SynthScope bench_eval, from the saved result JSONs. +Prints markdown tables and writes .json. Paper numbers are PROBE-DINOv2 / PROBE-ResNet50 bAcc from arXiv 2605.24906. +usage: python probe_task2_table.py WT_DIR SCORES_DIR OFFICIAL_DIR OUT_JSON""" +import glob +import json +import os +import sys + +import numpy as np + +WT, SCORES, OFF, OUT = sys.argv[1:5] +BR = WT + "/repro/bench_results" + +# paper bAcc per subset (Tables 2, 3, 4), in the order of the paper's columns; subset names map to our folder names +PAPER = { + "genimage_val100k": {"order": ["midjourney", "sdv1.4", "sdv1.5", "adm", "glide", "wukong", "vqdm", "biggan"], "avg_table1": {"probe": 96.8, "probe_resnet": 78.4}, + "probe": [98.8, 99.4, 99.4, 91.0, 92.1, 99.5, 98.9, 95.0], "probe_resnet": [90.7, 99.4, 99.2, 60.0, 63.0, 99.4, 66.9, 49.4]}, + "synthbuster_coco": {"order": ["dalle2", "dalle3", "firefly", "glide", "midjourney-v5", "stable-diffusion-1-3", "stable-diffusion-1-4", "stable-diffusion-2", "stable-diffusion-xl"], + "avg_table1": {"probe": 97.5, "probe_resnet": 79.1}, + "probe": [94.6, 99.4, 99.5, 86.7, 99.5, 99.5, 99.5, 99.5, 99.5], "probe_resnet": [48.3, 90.2, 46.9, 57.4, 93.2, 94.9, 94.9, 93.1, 93.0]}, + "synthwildx": {"order": ["dalle3", "firefly", "midjourney_v5"], "avg_table1": {"probe": 96.4, "probe_resnet": 75.6}, + "probe": [96.5, 96.4, 96.5], "probe_resnet": [90.3, 56.7, 79.7]}, + "wildrf": {"order": ["facebook", "reddit", "twitter"], "avg_table1": {"probe": 96.9, "probe_resnet": 81.3}, + "probe": [98.4, 93.4, 99.0], "probe_resnet": [87.8, 72.9, 83.3]}, + "aigibench": {"order": ["CommunityAI", "SocialRF"], "avg_table1": {"probe": 89.9, "probe_resnet": 70.4}, + "probe": [89.8, 89.9], "probe_resnet": [71.0, 69.9]}, +} +MISSING = {"chameleon": {"probe": 86.6, "probe_resnet": 74.0}, "aigi_quality_paradox": {"probe": 92.9, "probe_resnet": 87.7}} +out = {"paper_missing": MISSING, "benchmarks": {}} +for bench, p in PAPER.items(): + out["benchmarks"][bench] = {} + for model in ("probe", "probe_resnet"): + f = f"{BR}/{model}_{bench}.json" + if not os.path.exists(f): + print(f"| {bench} | {model} | NOT RUN |") + continue + d = json.load(open(f)) + per = d["per_generator"] + rows = [] + for name, pv in zip(p["order"], p[model]): + m = per.get(name) + rows.append({"subset": name, "paper": pv, "synthscope": m["acc"] if m else None, + "real_acc": m["real_acc"] if m else None, "fake_acc": m["fake_acc"] if m else None, "ap": m["ap"] if m else None}) + out["benchmarks"][bench][model] = {"rows": rows, "paper_avg_table1": p["avg_table1"][model], "paper_mean_of_listed": round(float(np.mean(p[model])), 2), + "synthscope_mean": d["means"]["acc"], "synthscope_map": d["means"]["map"], "tag": d["tag"], "data_root": d["data_root"], + "extra_subsets_in_run": sorted(set(per) - set(p["order"]))} +json.dump(out, open(OUT, "w"), indent=1) +for bench, bm in out["benchmarks"].items(): + for model, r in bm.items(): + print(f"\n### {bench} / {model} (tag {r['tag']}) paper Table1 avg {r['paper_avg_table1']} | SynthScope mean {r['synthscope_mean']}") + print("| subset | paper | SynthScope | real | fake |") + print("|---|---|---|---|---|") + for x in r["rows"]: + print(f"| {x['subset']} | {x['paper']} | {x['synthscope']} | {x['real_acc']} | {x['fake_acc']} |") diff --git a/repro/waverep_official_parity_genvideo180.json b/repro/waverep_official_parity_genvideo180.json new file mode 100644 index 0000000000000000000000000000000000000000..d258504700d73f0d92e5163164056092b3f3aba1 --- /dev/null +++ b/repro/waverep_official_parity_genvideo180.json @@ -0,0 +1,58 @@ +{ + "G1": { + "official_rows": 180, + "compared": 180, + "missing_in_ours": [], + "official_nan": 0, + "max_abs_logit_diff": 1.0248080758445965e-05, + "mean_abs_logit_diff": 1.7069871762565641e-06, + "max_abs_prob_diff": 2.1448522281031224e-06, + "worst": [ + [ + 1.0248080758445965e-05, + "WildScrape/1_fake/00002_T1.mp4" + ], + [ + 8.98731485987625e-06, + "WildScrape/1_fake/00006_D3.mp4" + ], + [ + 8.861494675271864e-06, + "HotShot/1_fake/00003_hotshot_4.mp4" + ] + ], + "sign_agree": 180, + "logit_range": [ + -8.89874092116952, + 10.816624581813812 + ] + }, + "G4": { + "official_rows": 180, + "compared": 180, + "missing_in_ours": [], + "official_nan": 0, + "max_abs_logit_diff": 1.0536868095378793e-05, + "mean_abs_logit_diff": 1.4127489889597219e-06, + "max_abs_prob_diff": 1.0311529782258688e-06, + "worst": [ + [ + 1.0536868095378793e-05, + "HotShot/1_fake/00006_hotshot_7.mp4" + ], + [ + 8.364375114311429e-06, + "HotShot/1_fake/00005_hotshot_6.mp4" + ], + [ + 7.367748976250255e-06, + "HotShot/1_fake/00002_hotshot_3.mp4" + ] + ], + "sign_agree": 180, + "logit_range": [ + -8.121102714538575, + 10.78410802781582 + ] + } +} \ No newline at end of file diff --git a/synthscope/hub.py b/synthscope/hub.py index 041b9b04793f8a6f6b3bf696dd3c84da1486a99b..8ba5c32a5de8bc1a7f7873c8642edaa9a9f1839f 100644 --- a/synthscope/hub.py +++ b/synthscope/hub.py @@ -7,6 +7,7 @@ License safety (see LICENSES.md): by default ``push`` uploads only **SynthScope- which are this project's to redistribute. Checkpoints derived from authors' **official released weights** (``ckpt_kind`` starting with ``official_`` — e.g. FatFormer, AIDE, NPR) are skipped unless you pass ``--include-official`` AND have confirmed the upstream license permits it. +Keys in ``NEVER_REDISTRIBUTE`` (licence unclear or not granted) are refused even with ``--include-official``. """ from __future__ import annotations @@ -23,6 +24,20 @@ DEFAULT_REPO = os.environ.get("SYNTHSCOPE_HUB_REPO", "SMSD75/synthscope-checkpoi # checkpoint dir. Safe to redistribute (produced by this project). AUX_FILES = ["d3_calibration.json", "stall_params_genvideo.npz"] +# Detectors whose official weights must never be uploaded: the upstream licence is unclear (no LICENSE / empty licence +# field) or redistribution was not granted. These are the "unclear" / "not redistributed" rows of LICENSES.md; ``push`` +# refuses them even with ``--include-official``. Edit this one constant when a licence is clarified (and LICENSES.md with +# it). B-Free and WaveRep (GRIP, nonprofit use) are not listed: they stay under the ``official_*`` rule. +NEVER_REDISTRIBUTE = { + "probe": "PROBE weights: licence unclear (empty ModelScope licence field, no LICENSE in the repo)", + "probe_resnet": "PROBE weights: licence unclear (empty ModelScope licence field, no LICENSE in the repo)", + "vina": "VINA weights: licence unclear (no licence tag on the HF repo, no LICENSE in the code repo)", + "vina_video": "VINA weights: licence unclear (no licence tag on the HF repo, no LICENSE in the code repo)", + "mirror": "MIRROR weights: licence unclear (README MIT badge but no LICENSE file)", + "ltf": "LTF weights: no licence tag on the HF model card; terms not confirmed by the authors", + "vib_net_official": "VIB-Net official checkpoints: restricted download, weights licence not verified, not redistributed", +} + def _ckpt_dir() -> Path: return _config.CHECKPOINTS_DIR @@ -90,6 +105,10 @@ def _select(keys: list[str] | None, include_official: bool): wanted = set(keys) specs = [s for s in specs if s.key in wanted] for s in specs: + if s.key in NEVER_REDISTRIBUTE: # checked first: refused whether or not the file exists and whatever the flags + skipped.append((s.key, f"REFUSED, never redistributed even with --include-official: " + f"{NEVER_REDISTRIBUTE[s.key]} (see LICENSES.md)")) + continue path = ckpt_dir / s.checkpoint if not path.exists(): skipped.append((s.key, "no local checkpoint")) diff --git a/tests/test_aide_smoke.py b/tests/test_aide_smoke.py index 1dae4ed06ceaba8bd8f1ce13de63672de4912ded..ae96277ae11d1a9023c848edb9abbdf9c5cb4f3b 100644 --- a/tests/test_aide_smoke.py +++ b/tests/test_aide_smoke.py @@ -6,7 +6,7 @@ Exercises, without any download (tiny ``convnext_base`` trunk, random ResNet-50s * ``DCT_base_Rec_Module`` picks 4 distinct native-res patches, * ``HPF`` (30 SRM kernels) shape + frozen weights, * ``SynthScopeAIDEModel`` forward / compute_loss on a ``[B, 5, 3, 256, 256]`` batch + backward, -* the ConvNeXt trunk stays frozen. +* the trainable set is the official one (two ResNet-50 streams + fc); the ConvNeXt trunk and convnext_proj stay frozen. """ from __future__ import annotations @@ -84,9 +84,17 @@ def main() -> None: trunk = [n for n, p in model.named_parameters() if p.requires_grad and "openclip_convnext_xxl" in n] assert not trunk, f"convnext leaked into trainable params: {trunk[:3]}" - for prefix in ("net.model_min", "net.model_max", "net.fc", "net.convnext_proj"): + # The official trainable set: the two ResNet-50 streams and the fc head. convnext_proj is computed inside torch.no_grad() + # in the official forward, so it keeps its random initialization (frozen here too); the ResNets' own fc heads are unused. + for prefix in ("net.model_min", "net.model_max", "net.fc"): assert any(n.startswith(prefix) and p.requires_grad for n, p in model.named_parameters()), f"missing trainable module: {prefix}" + frozen = [n for n, p in model.named_parameters() if p.requires_grad and + (n.startswith("net.convnext_proj") or n.startswith("net.hpf") + or n.startswith("net.model_min.fc") or n.startswith("net.model_max.fc"))] + assert not frozen, f"must be frozen: {frozen}" + trainable = {n.split(".")[1] for n, p in model.named_parameters() if p.requires_grad} + assert trainable == {"model_min", "model_max", "fc"}, trainable bsz = 2 images = torch.rand(bsz, 5, 3, 256, 256) # the 5-view stack the transform produces @@ -111,6 +119,13 @@ def main() -> None: assert not no_grad, f"trainable params with no grad: {no_grad[:5]}" print(f" train loss = {out['loss'].item():.4f} | backward OK") + print("[5] registry remap_aide: official keys get net., a trained checkpoint's keys are kept ...") + from interface.backend.registry import remap_aide + assert set(remap_aide({"fc.weight": 0, "module.model_min.conv1.weight": 1})) == {"net.fc.weight", "net.model_min.conv1.weight"} + trained = model.state_dict() + assert list(remap_aide(trained)) == list(trained), "a SynthScope-trained state dict must pass through remap_aide unchanged" + print(" OK") + print("\nAll AIDE smoke checks passed.") diff --git a/tests/test_bench_eval_video_cache.py b/tests/test_bench_eval_video_cache.py new file mode 100644 index 0000000000000000000000000000000000000000..eed19a162de4b6f07f4be3611cb49a7e5c18d164 --- /dev/null +++ b/tests/test_bench_eval_video_cache.py @@ -0,0 +1,327 @@ +"""CPU unit test of benchmark/bench_eval_video.py's score cache, sharding and metrics (mock engine, no weights, no video). + +Checks: +* the shard partition: ``unique_videos`` lists each real pool once (the same pool hard-linked per generator) and every + fake; the slices ``jobs[k::n]`` are disjoint and cover everything, +* cache resume: a second ``score_videos`` (also through a fresh ``ScoreCache`` that re-reads the files) calls the engine + zero times; ``scores..jsonl`` is only created on the first write, +* ``cache_meta.json``: written by the first use; a different model key, checkpoint hash, frame count or format is refused + with a clear error; ``--cache-only`` refuses a cache without one, +* the raw logit ranks AP / AUROC only when every record has one (saturated, tied probabilities are separated by it), and a + detector without ``logit`` gets exactly the old torchmetrics numbers, +* decode failures (``VideoDecodeError``) are counted and cached; any other exception (OOM, I/O) is counted separately, + not cached and retried; a legacy error record (no ``kind``) is classified by its message; a failing raw score of a + training-free detector drops the video from the raw list only, +* the real reader ``media.cv2_frames``: a missing / unopenable file is an OSError (not cached, retried), an empty file a + decode failure (cached), +* ``main`` end to end with the mock engine: two shards, then a ``--cache-only`` aggregation with the same JSON means and + no ``scores.agg*.jsonl``; the output JSON carries limit / reals / ckpt_sha256 / failed_to_decode / failed_other. +""" + +from __future__ import annotations + +import importlib.util +import json +import math +import os +import sys +import tempfile +from pathlib import Path + +import numpy as np +import torch + +ROOT = Path(__file__).resolve().parents[1] +sys.path[:0] = [str(ROOT), str(ROOT / "interface"), str(ROOT / "benchmark")] + +from backend import media # noqa: E402 +from backend.media import VideoDecodeError # noqa: E402 + +_spec = importlib.util.spec_from_file_location("bench_eval_video", ROOT / "benchmark" / "bench_eval_video.py") +bev = importlib.util.module_from_spec(_spec) +_spec.loader.exec_module(bev) + + +class MockSpec: + key, checkpoint, num_frames, video_sampler, transform = "mockdet", "mock.pth", 8, "mock_sampler", "T0" + fps, frame_size, window_center, video_norm = None, 112, False, None + + +class MockEngine: + """predict_video_clip reads the score from the file name: ``__.mp4``; ``decode`` / ``oom`` / ``rawfail`` in + the name make it fail the way the real engine would.""" + device = "cpu" + + def __init__(self, ckpt, with_logit=True, raw=False): + self.ckpt, self.with_logit, self.raw, self.calls, self.oom_seen = ckpt, with_logit, raw, [], set() + + def checkpoint_path(self, spec): + return self.ckpt + + def _get_model(self, spec): + class M: + pass + m = M() + if self.raw: + m.score = lambda x: x + return m + + def predict_video_clip(self, spec, path): + self.calls.append(Path(path).name) + name = Path(path).stem + if "decode" in name: + raise VideoDecodeError("Could not decode any frames from the video.") + if "oom" in name: + raise RuntimeError("CUDA out of memory") + logit = float(name.split("__")[1]) + res = {"fake_probability": round(1 / (1 + math.exp(-logit)), 6)} + if self.with_logit: + res["logit"] = round(logit, 6) + return res + + def video_raw_score(self, spec, path): + if "rawfail" in Path(path).stem: + raise RuntimeError("no raw score") + return float(Path(path).stem.split("__")[1]) + + +def make_tree(root: Path, spec): + """root//{0_real,1_fake}/*.mp4 (empty files); reals shared by name between the generators (as hard links).""" + names = {} + for g in ("genA", "genB"): + for cls, items in (("0_real", [f"r{i}__{-3 - i}" for i in range(6)]), + ("1_fake", [f"f{g}{i}__{2 + i}" for i in range(6)] + [f"{g}_decode__0"])): + d = root / g / cls + d.mkdir(parents=True, exist_ok=True) + for n in items: + (d / f"{n}.mp4").write_bytes(b"") + names[(g, cls)] = sorted(d.glob("*.mp4")) + return names + + +def test_shards_and_resume(): + with tempfile.TemporaryDirectory() as tmp: + tmp = Path(tmp) + ckpt = tmp / "mock.pth" + ckpt.write_bytes(b"weights-v1") + names = make_tree(tmp / "data", MockSpec) + gens = bev.discover("pergen", tmp / "data", None, None) + pool_key = lambda reals: (len(reals), reals[0].name, reals[-1].name) # noqa: E731 + jobs = bev.unique_videos(gens, pool_key) + # genA and genB have identical real file names (same pool key) -> counted once + assert len(jobs) == 6 + 7 + 7, len(jobs) + parts = [jobs[k::3] for k in range(3)] + assert sorted(sum(parts, []), key=str) == sorted(jobs, key=str) + assert sum(len(p) for p in parts) == len(set(sum(parts, []))) + + eng, meta = MockEngine(ckpt), None + meta = bev.cache_meta(eng, MockSpec) + cdir = tmp / "cache" + c1 = bev.ScoreCache(cdir, "0of3", meta) + assert not list(cdir.glob("scores.*.jsonl")), "scores file must only be created by the first write" + recs, bad, other = bev.score_videos(eng, MockSpec, parts[0], False, c1) + assert bad == sum("decode" in p.name for p in parts[0]) and other == 0 + n_calls = len(eng.calls) + assert n_calls == len(parts[0]) and (cdir / "scores.0of3.jsonl").exists() + # resume: through a fresh cache that re-reads the file, nothing is scored again (decode failures are cached too) + eng2 = MockEngine(ckpt) + c2 = bev.ScoreCache(cdir, "agg", meta) + recs2, bad2, other2 = bev.score_videos(eng2, MockSpec, parts[0], False, c2) + assert eng2.calls == [] and ([r['p'] for r in recs2], bad2, other2) == ([r['p'] for r in recs], bad, other) + assert not (cdir / "scores.agg.jsonl").exists() + # cache-only: refuses an uncached video, loudly + c3 = bev.ScoreCache(cdir, "agg3", meta, write_meta=False) + c3.only = True + try: + bev.score_videos(eng2, MockSpec, parts[1], False, c3) + raise AssertionError("cache-only must refuse an uncached video") + except SystemExit as e: + assert "not in the score cache" in str(e) + + +def test_cache_meta_refusal(): + with tempfile.TemporaryDirectory() as tmp: + tmp = Path(tmp) + ckpt = tmp / "mock.pth" + ckpt.write_bytes(b"weights-v1") + eng = MockEngine(ckpt) + meta = bev.cache_meta(eng, MockSpec) + assert meta["ckpt_sha256"] and meta["model"] == "mockdet" and meta["spec"]["num_frames"] == 8 + d = tmp / "c" + bev.ScoreCache(d, "a", meta) # first use writes cache_meta.json + assert json.loads((d / "cache_meta.json").read_text())["ckpt_sha256"] == meta["ckpt_sha256"] + bev.ScoreCache(d, "b", meta) # same setup: fine + + def refused(m, what): + try: + bev.ScoreCache(d, "c", m) + except SystemExit as e: + assert "different setup" in str(e) and what in str(e), str(e) + return + raise AssertionError(f"a cache written for another {what} must be refused") + + refused(dict(meta, model="otherdet"), "model") + ckpt.write_bytes(b"weights-v2-retrained") + refused(bev.cache_meta(eng, MockSpec), "ckpt_sha256") + refused(dict(meta, spec=dict(meta["spec"], num_frames=16)), "num_frames") + refused(dict(meta, spec=dict(meta["spec"], transform="T1")), "transform") + refused(dict(meta, cache_format=bev.CACHE_FORMAT + 1), "cache_format") + try: # aggregation of a cache of unknown origin + bev.ScoreCache(tmp / "nometa", "x", meta, write_meta=False) + raise AssertionError("a cache without cache_meta.json must be refused when it may not write one") + except SystemExit as e: + assert "no cache_meta.json" in str(e) + + +def test_ranking_and_metrics(): + # probabilities saturate at 1.0 / 0.0 after the 6 dp rounding; the logits still rank + logits = [-30.0, -25.0, -20.0, 20.0, 25.0, 30.0, -21.0, 22.0] + labels = torch.tensor([0, 0, 0, 1, 1, 1, 1, 0]) # the last two are misranked on purpose + recs = [{"p": round(1 / (1 + math.exp(-l)), 6), "logit": l} for l in logits] + probs = torch.tensor([r["p"] for r in recs]) + assert len(set(probs.tolist())) == 2, "the rounded probabilities must tie in this case" + rank = bev.rank_scores(recs) + assert rank is not None and rank.dtype == np.float64 + by_prob, by_logit = bev.metrics(probs, labels), bev.metrics(probs, labels, rank) + assert by_logit["auroc"] != by_prob["auroc"] and by_logit["acc"] == by_prob["acc"] # accuracy always thresholds P(fake) + # sklearn on the logit == the exact AUROC from a pairwise count + pos, neg = rank[labels.numpy() == 1], rank[labels.numpy() == 0] + exact = np.mean([(p > n) + 0.5 * (p == n) for p in pos for n in neg]) * 100 + assert abs(by_logit["auroc"] - round(exact, 2)) < 0.006, (by_logit, exact) + # ranking by logit only when EVERY record has one + assert bev.rank_scores([{"p": 0.5}] + recs) is None and bev.rank_scores([]) is None + # no logit: identical to the old torchmetrics path (the code of the previous bench_eval_video.metrics, inline) + from torchmetrics.functional import auroc, average_precision + rng = np.random.default_rng(0) + y = torch.tensor((rng.random(300) < 0.4).astype(int)) + p = torch.round(torch.tensor(1 / (1 + np.exp(-(rng.normal(0, 3, 300) + 2 * (y.numpy() - 0.5)))), dtype=torch.float32) * 1e6) / 1e6 + new = bev.metrics(p, y) + old = {"ap": round(float(average_precision(p, y, task="binary")) * 100, 2), + "ap_real": round(float(average_precision(1 - p, 1 - y, task="binary")) * 100, 2), + "auroc": round(float(auroc(p, y, task="binary")) * 100, 2)} + assert all(new[k] == v for k, v in old.items()), (new, old) + assert new == bev.metrics(p, y, None) + + +def test_failure_kinds(): + with tempfile.TemporaryDirectory() as tmp: + tmp = Path(tmp) + ckpt = tmp / "mock.pth" + ckpt.write_bytes(b"w") + eng = MockEngine(ckpt) + meta = bev.cache_meta(eng, MockSpec) + paths = [tmp / n for n in ("ok__1.0.mp4", "bad_decode__0.mp4", "bad_oom__0.mp4")] + cache = bev.ScoreCache(tmp / "c", "t", meta) + recs, bad, other = bev.score_videos(eng, MockSpec, paths, False, cache) + assert (len(recs), bad, other) == (1, 1, 1) + assert recs[0]["logit"] == 1.0 and "err" not in recs[0] + lines = [json.loads(line) for line in (tmp / "c" / "scores.t.jsonl").read_text().splitlines()] + kinds = {r["k"].split("/")[-1]: r.get("kind") for r in lines} + assert kinds == {"ok__1.0.mp4": None, "bad_decode__0.mp4": "decode"}, kinds # the OOM is not cached + eng.calls.clear() + bev.score_videos(eng, MockSpec, paths, False, cache) + assert eng.calls == ["bad_oom__0.mp4"], eng.calls # only the non-decode failure retried + # a legacy error record (written before "kind" existed) is classified by the decoder's message + assert bev.is_decode_error({"err": "ValueError: Could not decode any frames from the video."}) + assert not bev.is_decode_error({"err": "RuntimeError: CUDA out of memory"}) + assert bev.is_decode_error({"err": "x", "kind": "decode"}) and not bev.is_decode_error({"p": 0.5}) + # training-free detector: a failing raw score keeps the video (it only leaves the raw list) + eng_raw = MockEngine(ckpt, with_logit=False, raw=True) + cache2 = bev.ScoreCache(tmp / "c2", "t", bev.cache_meta(eng_raw, MockSpec)) + recs, bad, other = bev.score_videos(eng_raw, MockSpec, [tmp / "a__2.0.mp4", tmp / "rawfail__1.0.mp4"], True, cache2) + assert (len(recs), bad, other) == (2, 0, 0) + assert "raw" in recs[0] and "raw" not in recs[1] and "raw_err" in recs[1] + assert bev.rank_scores(recs) is None # no logit: P(fake) ranking + + +def test_missing_file_is_not_a_decode_failure(): + """The real reader (media.cv2_frames) separates I/O problems from decode failures: a missing or unopenable file is an + OSError (not cached, retried), an empty file is a VideoDecodeError (cached).""" + class ReaderEngine(MockEngine): + def predict_video_clip(self, spec, path): # the engine's check: no frame -> VideoDecodeError + self.calls.append(Path(path).name) + if not list(media.cv2_frames(path, limit=1)): + raise VideoDecodeError("Could not decode any frames from the video.") + return {"fake_probability": 0.5, "logit": 0.0} + + with tempfile.TemporaryDirectory() as tmp: + tmp = Path(tmp) + ckpt = tmp / "mock.pth" + ckpt.write_bytes(b"w") + missing, empty, garbage = tmp / "missing.mp4", tmp / "empty.mp4", tmp / "garbage.mp4" + empty.write_bytes(b"") + garbage.write_bytes(b"this is not a video file") + for p, exc in ((missing, FileNotFoundError), (garbage, OSError), (empty, VideoDecodeError)): + try: + list(media.cv2_frames(p)) + raise AssertionError(f"{p.name}: expected {exc.__name__}") + except exc as e: + assert exc is VideoDecodeError or not isinstance(e, VideoDecodeError), p.name + assert issubclass(FileNotFoundError, OSError) and not issubclass(VideoDecodeError, OSError) + eng = ReaderEngine(ckpt) + cache = bev.ScoreCache(tmp / "c", "t", bev.cache_meta(eng, MockSpec)) + recs, bad, other = bev.score_videos(eng, MockSpec, [missing, garbage, empty], False, cache) + assert (len(recs), bad, other) == (0, 1, 2), (bad, other) # only the empty file is a decode failure + lines = [json.loads(line) for line in (tmp / "c" / "scores.t.jsonl").read_text().splitlines()] + assert {r["k"].split("/")[-1]: r["kind"] for r in lines} == {"empty.mp4": "decode"} # missing / unopenable: not cached + eng.calls.clear() + bev.score_videos(eng, MockSpec, [missing, garbage, empty], False, cache) + assert sorted(eng.calls) == ["garbage.mp4", "missing.mp4"], eng.calls # retried; the decode failure is not + + +def test_list_out_needs_shard_and_base(): + for extra in ([], ["--shard", "0/2"], ["--base", "/x"]): + try: + bev.main(["-m", "waverep", "--benchmark", "pergen", "--data", "/nonexistent", "--list-out", "l.txt"] + extra) + raise AssertionError(f"--list-out {extra}: expected an argparse error") + except SystemExit as e: + assert e.code == 2, (extra, e.code) # parser.error, not an AttributeError / TypeError + + +def test_main_end_to_end(): + with tempfile.TemporaryDirectory() as tmp: + tmp = Path(tmp) + ckpt = tmp / "mock.pth" + ckpt.write_bytes(b"weights") + make_tree(tmp / "data", MockSpec) + eng = MockEngine(ckpt) + bev.get_engine, bev.get_spec = (lambda: eng), (lambda key: MockSpec) + (tmp / "repro").mkdir() + bev.REPRO, bev.RESULTS_LOG = tmp / "repro", tmp / "repro" / "MASTER_RESULTS.jsonl" + common = ["-m", "waverep", "--benchmark", "pergen", "--data", str(tmp / "data"), "--cache-dir", str(tmp / "cache")] + for k in range(3): + assert bev.main(common + ["--tag", "t", "--shard", f"{k}/3"]) == 0 + n_scored = len(eng.calls) + assert n_scored == 6 + 7 + 7, n_scored # shared real pool scored once + eng.calls.clear() + out1 = tmp / "agg1.json" + assert bev.main(common + ["--tag", "t_full", "--cache-only", "--out", str(out1)]) == 0 + assert eng.calls == [], "aggregation must not score" + assert not list((tmp / "cache").glob("scores.agg*.jsonl")), "aggregation must not leave empty score files" + res = json.loads(out1.read_text()) + assert res["failed_to_decode"] == {"fake": 2, "real_unique": 0} and res["failed_other"] == {"fake": 0, "real_unique": 0} + assert res["limit"] is None and res["reals"] is None and res["ckpt_sha256"] == bev.cache_meta(eng, MockSpec)["ckpt_sha256"] + for g in res["per_generator"].values(): + assert g["rank_by"] == "logit" and g["n_real"] == 6 and g["n_fake"] == 6 and g["failed_fake"] == 1 + assert g["auroc"] == 100.0, g # every fake logit (2..7) outranks every real logit (-3..-8) + out2 = tmp / "agg2.json" + assert bev.main(common + ["--tag", "t_full2", "--cache-only", "--out", str(out2)]) == 0 + assert json.loads(out2.read_text())["means"] == res["means"] + # a retrained checkpoint into the same cache dir is refused + ckpt.write_bytes(b"retrained") + try: + bev.main(common + ["--tag", "t_full3", "--cache-only", "--out", str(tmp / "x.json")]) + raise AssertionError("expected the cache_meta refusal") + except SystemExit as e: + assert "different setup" in str(e) + + +if __name__ == "__main__": + test_shards_and_resume() + test_cache_meta_refusal() + test_ranking_and_metrics() + test_failure_kinds() + test_missing_file_is_not_a_decode_failure() + test_list_out_needs_shard_and_base() + test_main_end_to_end() + print("OK") diff --git a/tests/test_cure_recipe.py b/tests/test_cure_recipe.py new file mode 100644 index 0000000000000000000000000000000000000000..0564029aabb62831b962e4a47f2b3d38bb89fefb --- /dev/null +++ b/tests/test_cure_recipe.py @@ -0,0 +1,344 @@ +"""CPU checks of the CuRe training recipe (no download: the PE Core base is not fetched, the backbone is random). + +* [A] stage-1 data: a validation item is exactly ``(1 - a) x_r + a x_g`` of the endpoints it names, each preprocessed by + the CuRe eval pipeline (a PNG fake gets the JPEG q96 step); training draws (partner, a) differ between epochs and + between items; a ~ U(0, 1), +* [B] stage-1 model: trainable = the 96 LoRA tensors + the ratio head; the loss is BCE with the soft target a; gradients + reach the LoRA and the ratio head; the optimizer groups carry weight decay 0.1 (LoRA) / 0.01 (head), +* [C] gradient checkpointing gives the same features and the same LoRA gradients as the plain forward, +* [D] the trainer's timm_cosine run with conf/trainer/image/cure.yaml: the logged lr at every optimizer step equals the + intended schedule (linear warmup from 0 over 2 epochs to 1e-5, then cosine to 1e-6 over 3 epochs) and the AdamW + groups keep their own weight decays, +* [E] stage-2 math (Eq. 6-10) on random features against a direct numpy computation (np.polyfit slopes, covariances, + the eigenvalues of B^-1 C_F) and scipy.linalg.eigh(C_F, B), +* [G] R3 augmentation (models/image/cure/train_augment.py): disabled it equals the eval pipeline bit for bit; enabled it is + deterministic in the seed, varies with the seed, leaves the caller's global RNGs untouched; in the train dataset the + pair / ratio draws are those of the recipe and both endpoints use the same seed; validation is not augmented, +* [F] the export has exactly the released adapter's 100 keys / shapes and loads into a fresh model like it; the + normalisation fit recovers known (lambda_s, lambda_m, eps). +""" +from __future__ import annotations + +import contextlib +import io +import math +import os +import re +import sys +import tempfile +from pathlib import Path + +import numpy as np +import scipy.linalg +import torch +from omegaconf import OmegaConf +from PIL import Image + +ROOT = Path(__file__).resolve().parents[1] +sys.path[:0] = [str(ROOT)] + +from dataset import CuReEndpoints, CuReMixDataset, cure_mix # noqa: E402 +from models.image.cure import subspace as S # noqa: E402 +from models.image.cure.cure import SynthScopeCuReModel # noqa: E402 +from models.image.cure.preprocess import SRC_FORMAT_KEY, CuReTransform # noqa: E402 +from models.image.cure.train_augment import CuReDDAEndpoint # noqa: E402 +from models.image.cure.train_stages import draw_pairs, fit_normalisation # noqa: E402 +from trainer import SynthScopeModelTrainer # noqa: E402 + +RELEASED_ADAPTER = Path(os.environ.get("SYNTHSCOPE_CURE_ADAPTER", + "/ivi/zfs/s0/original_homes/ssalehi/SynthScope_shared/cure_ref/CuRe/weights/cure_adapter.pt")) + + +def model_config(**model) -> OmegaConf: + return OmegaConf.create({"ModelConfig": {"model_type": "cure", "load_base_backbone": False, **model}, + "TrainerConfig": {}}) + + +def write_genimage(root: Path, n=4) -> None: + """A tiny GenImage-layout split: JPEG reals, PNG fakes, various sizes.""" + rng = np.random.default_rng(0) + for split in ("train", "test"): + for cls, ext in (("real", "JPEG"), ("fake", "png")): + (root / split / cls).mkdir(parents=True) + for i in range(n): + arr = rng.integers(0, 256, (300 + 37 * i, 420 - 23 * i, 3), dtype=np.uint8) + Image.fromarray(arr).save(root / split / cls / f"{cls}_{i}.{ext}", quality=90) + + +def test_mix_dataset() -> None: + print("[A] stage-1 mixing data ...") + tf = CuReTransform() + with tempfile.TemporaryDirectory() as tmp: + write_genimage(Path(tmp)) + ep = CuReEndpoints(tmp, "test", tf) + val = CuReMixDataset(ep, "val", val_pairs=3, seed=5) + assert len(val) == 3 + for idx in range(3): + g = torch.Generator().manual_seed(5 * 1_000_003 + idx) + fake_idx = int(torch.randint(len(ep.fakes), (), generator=g)) + alpha = float(torch.rand((), generator=g)) + x, a, _ = val[idx] + real_img = Image.open(ep.reals[idx]).convert("RGB") + fake_img = Image.open(ep.fakes[fake_idx]).convert("RGB") + fake_img.info[SRC_FORMAT_KEY] = "PNG" + expected = cure_mix(tf(real_img), tf(fake_img), alpha) + assert float(a) == np.float32(alpha) and torch.allclose(x, expected, atol=1e-6), idx + # the PNG hint changes the fake's preprocessing (the JPEG q96 re-encoding): it must be applied + plain = tf(Image.open(ep.fakes[0]).convert("RGB")) + assert not torch.equal(plain, ep.load(ep.fakes[0])), "PNG fakes must get the JPEG q96 step" + assert torch.equal(tf(Image.open(ep.reals[0]).convert("RGB")), ep.load(ep.reals[0])) + # the stage-2 parity control (no final JPEG q70) differs from the default + img = Image.open(ep.reals[0]).convert("RGB") + ctrl, base = CuReTransform(eval_jpeg_quality=None)(img), tf(img) + assert ctrl.shape == base.shape and not torch.equal(ctrl, base) and bool(torch.isfinite(ctrl).all()) + assert torch.equal(CuReTransform(eval_jpeg_quality=70)(img), base) + + train = CuReMixDataset(CuReEndpoints(tmp, "train", tf), "train") + loader = torch.utils.data.DataLoader(train, batch_size=4, shuffle=True, num_workers=2) + torch.manual_seed(0) + epochs = [torch.cat([b[1] for b in loader]) for _ in range(2)] + assert all(len(a) == 4 for a in epochs) and not torch.equal(epochs[0].sort().values, epochs[1].sort().values) + assert len(set(epochs[0].tolist())) == 4, "every item draws its own ratio" + big = torch.tensor([float(torch.rand(())) for _ in range(20000)]) + assert big.min() >= 0 and big.max() < 1 and abs(float(big.mean()) - 0.5) < 0.01 + print(" val items = (1-a) x_r + a x_g of the CuRe-preprocessed endpoints (PNG fake -> JPEG q96); " + "train draws change every epoch") + + +def test_train_augment() -> None: + print("[G] R3 DDA-style endpoint augmentation ...") + tf = CuReTransform() + with tempfile.TemporaryDirectory() as tmp: + write_genimage(Path(tmp)) + ep = CuReEndpoints(tmp, "train", tf) + off, on = CuReDDAEndpoint(augment=False), CuReDDAEndpoint(augment=True) + for p, fmt in ((ep.reals[1], "JPEG"), (ep.fakes[2], "PNG")): + img = Image.open(p).convert("RGB"); img.info[SRC_FORMAT_KEY] = fmt + assert torch.equal(off(img, 7), tf(img)), "augment=False must equal the eval pipeline" + states = (torch.get_rng_state(), np.random.get_state()[1].copy()) + a, b, c = on(img, 11), on(img, 11), on(img, 12) + assert torch.equal(torch.get_rng_state(), states[0]) and np.array_equal(np.random.get_state()[1], states[1]) + assert torch.equal(a, b) and not torch.equal(a, c) and a.shape == (3, 336, 336) and bool(torch.isfinite(a).all()) + # dataset: recipe draws unchanged, one seed per pair shared by both endpoints, val not augmented + seen = [] + class Spy(CuReDDAEndpoint): + def __call__(self, img, seed=None): + seen.append(seed); return super().__call__(img, seed) + aug = CuReMixDataset(CuReEndpoints(tmp, "train", tf, augment=Spy(augment=True)), "train") + plain = CuReMixDataset(CuReEndpoints(tmp, "train", tf), "train") + _, a1, _ = aug[0]; _, a0, _ = plain[0] + assert len(seen) == 2 and seen[0] == seen[1] and seen[0] is not None, seen + val = CuReMixDataset(CuReEndpoints(tmp, "test", tf, augment=Spy(augment=True)), "val", val_pairs=2, seed=5) + n = len(seen); val[0] + assert len(seen) == n, "validation must not be augmented" + for idx in range(2): + torch.manual_seed(idx) + x1 = aug[idx]; torch.manual_seed(idx); x0 = plain[idx] + assert float(x1[1]) == float(x0[1]), "the augmentation seed is drawn after the recipe's draws" + print(" off == eval pipeline; seeded, deterministic, RNG-neutral; one shared seed per pair; val un-augmented") + + +def test_ratio_stage(model: SynthScopeCuReModel) -> None: + print("[B] stage-1 model: trainable set, BCE soft target, optimizer groups ...") + trainable = [n for n, p in model.named_parameters() if p.requires_grad] + assert len(trainable) == 98 and sum("lora_" in n for n in trainable) == 96, len(trainable) + assert {n for n in trainable if "lora_" not in n} == {"ratio_head.weight", "ratio_head.bias"} + assert not model.head.weight.requires_grad + groups = model.optimizer_param_groups() + assert [len(g["params"]) for g in groups] == [96, 2] and [g["weight_decay"] for g in groups] == [0.1, 0.01] + images = torch.randn(2, 3, 336, 336) * 0.5 + alpha = torch.tensor([0.25, 0.9]) + model.train() + out = model.compute_loss((images, alpha, torch.zeros(2))) + logits = model.ratio_head(model.features(images)).squeeze(-1) + p = torch.sigmoid(logits) + manual = -(alpha * torch.log(p) + (1 - alpha) * torch.log(1 - p)).mean() + assert torch.allclose(out["loss"], manual, atol=1e-5) and torch.allclose(out["outputs"], p, atol=1e-6) + out["loss"].backward() + attn = model.backbone.transformer.resblocks[0].attn + assert attn.lora_B_q.grad is not None and attn.lora_B_q.grad.abs().sum() > 0 # B = 0 at init: only B moves first + assert model.ratio_head.weight.grad.abs().sum() > 0 + model.zero_grad(set_to_none=True) + print(f" {len(trainable)} trainable tensors (96 LoRA + ratio head), loss {float(out['loss'].detach()):.4f} = manual BCE") + + +def test_grad_checkpointing(model: SynthScopeCuReModel) -> None: + print("[C] gradient checkpointing == plain forward (features and LoRA gradients) ...") + torch.manual_seed(1) + for name, p in model.named_parameters(): # non-zero LoRA B so that every LoRA tensor gets a gradient + if "lora_B" in name: + p.data.normal_(std=0.01) + images = torch.randn(1, 3, 336, 336) * 0.5 + model.train() + results = [] + for ckpt in (False, True): + model.grad_checkpointing = ckpt + model.zero_grad(set_to_none=True) + feats = model.features(images) + feats.square().sum().backward() + grads = {n: p.grad.clone() for n, p in model.named_parameters() if "lora_" in n} + results.append((feats.detach(), grads)) + model.grad_checkpointing = False + (f0, g0), (f1, g1) = results + assert torch.equal(f0, f1), float((f0 - f1).abs().max()) + worst = max(float((g0[n] - g1[n]).abs().max() / (g0[n].abs().max() + 1e-12)) for n in g0) + assert worst < 1e-5, worst + with torch.no_grad(): + model.eval() + assert torch.equal(model.features(images), model.backbone(images)) + model.zero_grad(set_to_none=True) + print(f" features identical, LoRA gradients equal (max relative diff {worst:.1e}) over 96 tensors") + + +class TinyRatio(torch.nn.Module): + """A stand-in with CuRe's interface: optimizer_param_groups with two weight decays, BCE on a soft target.""" + + def __init__(self): + super().__init__() + self.lora_A = torch.nn.Linear(4, 4) + self.ratio_head = torch.nn.Linear(4, 1) + + def optimizer_param_groups(self): + return [{"params": list(self.lora_A.parameters()), "weight_decay": 0.1}, + {"params": list(self.ratio_head.parameters()), "weight_decay": 0.01}] + + def compute_loss(self, batch): + x, a, _ = batch + logits = self.ratio_head(self.lora_A(x)).squeeze(-1) + return {"loss": torch.nn.functional.binary_cross_entropy_with_logits(logits, a), "outputs": torch.sigmoid(logits)} + + +class TinyData: + def train_dataloader(self): + g = torch.Generator().manual_seed(0) + return torch.utils.data.DataLoader(list(zip(torch.randn(40, 4, generator=g), torch.rand(40, generator=g), + torch.zeros(40))), batch_size=4) + + val_dataloader = train_dataloader + + def test_dataloader(self): + return None + + +def intended_lr(t: int, n_iter: int, epochs=5, warmup_epochs=2, lr=1e-5, min_lr=1e-6) -> float: + """The paper's schedule as read here: linear warmup from 0 over 2 epochs, then cosine from lr to min_lr over the rest + (index t = the optimizer steps done before the update that sets the lr).""" + w, total = warmup_epochs * n_iter, epochs * n_iter + if t < w: + return lr * t / w + return min_lr + 0.5 * (lr - min_lr) * (1 + math.cos(math.pi * (t - w) / (total - w))) + + +def test_trainer_schedule() -> None: + print("[D] trainer timm_cosine with conf/trainer/image/cure.yaml: lr per step, weight-decay groups ...") + SynthScopeModelTrainer._build_model = lambda self, config: TinyRatio() + trainer_cfg = OmegaConf.load(ROOT / "conf" / "trainer" / "image" / "cure.yaml") + trainer_cfg.pop("defaults") + with tempfile.TemporaryDirectory() as tmp: + trainer_cfg.save_path = tmp + trainer_cfg.timm_cosine.log_every = 1 + cfg = OmegaConf.create({"TrainerConfig": trainer_cfg, "metrics": [], "logger": {"type": None}}) + trainer = SynthScopeModelTrainer(cfg, TinyData()) + assert [g["weight_decay"] for g in trainer.optimizer.param_groups] == [0.1, 0.01] + out = io.StringIO() + with contextlib.redirect_stdout(out): + trainer.train() + assert sorted(p.name for p in Path(tmp).glob("model_*.pth")) == \ + ["model_0.pth", "model_1.pth", "model_2.pth", "model_3.pth", "model_4.pth", "model_best.pth", "model_last.pth"] + lines = re.findall(r"epoch (\d+) step (\d+)/(\d+): loss [\d.]+, lr ([\d.e+-]+)", out.getvalue()) + n_iter = int(lines[0][2]) + assert n_iter == 10 and len(lines) == 50, (n_iter, len(lines)) + worst = 0.0 + for e, k, _, lr in lines: + t = int(e) * n_iter + int(k) - 1 # the trainer calls step_update(epoch * n_iter + k) after step k + 1 + want = intended_lr(t, n_iter) + worst = max(worst, abs(float(lr) - want)) + assert abs(float(lr) - want) <= 5e-4 * max(want, 1e-6) + 1e-12, (e, k, lr, want) + peak = [float(lr) for e, k, _, lr in lines if int(e) * n_iter + int(k) - 1 == 2 * n_iter][0] + # (the log prints 4 significant digits) + assert abs(peak - 1e-5) < 1e-9 and abs(float(lines[-1][3]) - intended_lr(5 * n_iter - 1, n_iter)) < 1e-9 + print(f" 50 logged steps match the schedule (max |diff| {worst:.1e}); peak {peak:.3e} after 2 epochs, " + f"last {float(lines[-1][3]):.3e} (floor 1e-6)") + + +def test_subspace_math() -> None: + print("[E] stage-2 math vs numpy / scipy ...") + rng = np.random.default_rng(0) + n, d, k = 300, 24, 6 + grid = np.array(S.GRID) + z = {t: rng.normal(size=(n, 6, d)) + (grid[None, :, None] * rng.normal(size=(n, 1, d)) * (3 if t == "RF" else 1)) + for t in ("RF", "RR", "FF")} + summ = {t: S.trajectory_summary(torch.from_numpy(z[t])) for t in z} + for t in z: + slopes = np.polyfit(grid, z[t].transpose(1, 0, 2).reshape(6, -1), 1)[0].reshape(n, d) + assert np.allclose(summ[t][0].numpy(), slopes, atol=1e-10) and np.allclose(summ[t][1].numpy(), z[t].mean(1)) + stats = S.statistics(summ["RF"][0], summ["RR"][0], summ["FF"][0], summ["RF"][1]) + b = {t: np.polyfit(grid, z[t].transpose(1, 0, 2).reshape(6, -1), 1)[0].reshape(n, d) for t in z} + c_f = b["RF"].T @ b["RF"] / n + c_m = b["RR"].T @ b["RR"] / n + b["FF"].T @ b["FF"] / n + c_s = np.cov(z["RF"].mean(1), rowvar=False, bias=True) + for name, ref in (("C_F", c_f), ("C_M", c_m), ("C_S", c_s)): + assert np.allclose(stats[name].numpy(), ref / np.trace(ref), atol=1e-12), name + assert np.allclose(stats["mu"].numpy(), z["RF"].reshape(-1, d).mean(0)) + ls, lm, eps = 0.7, 1.3, 1e-3 + w, gam = S.solve(stats["C_F"], stats["C_M"], stats["C_S"], k=k, lambda_s=ls, lambda_m=lm, eps=eps) + cf, cm, cs = (stats[x].numpy() for x in ("C_F", "C_M", "C_S")) + bmat = ls * cs + lm * cm + eps * np.eye(d) + eig = np.sort(np.linalg.eigvals(np.linalg.solve(bmat, cf)).real)[::-1][:k] # the direct (non-symmetric) solve + assert np.allclose(gam.numpy(), eig, rtol=1e-8), (gam.numpy(), eig) + sg, sv = scipy.linalg.eigh(cf, bmat) + assert np.allclose(gam.numpy(), sg[::-1][:k], rtol=1e-8) + wn = w.numpy() + assert np.allclose(cf @ wn, bmat @ wn @ np.diag(gam.numpy()), atol=1e-10) # Eq. 10 + assert np.allclose(wn.T @ bmat @ wn, np.eye(k), atol=1e-10) # B-orthonormal + assert np.allclose(np.abs(np.sum(wn * sv[:, ::-1][:, :k], axis=0)) / np.linalg.norm(wn, axis=0) / + np.linalg.norm(sv[:, ::-1][:, :k], axis=0), 1, atol=1e-8) # same vectors as scipy + assert abs(S.subspace_overlap(w, torch.from_numpy(sv[:, ::-1][:, :k].copy())) - 1) < 1e-10 + pairs = draw_pairs(50, 7, 7, True, torch.Generator().manual_seed(0)) + assert (pairs[:, 0] != pairs[:, 1]).all() and pairs.max() < 7 + print(f" slopes = polyfit, C_F/C_M/C_S/mu exact; top-{k} eigenvalues = numpy eig(B^-1 C_F) = scipy eigh; " + f"W^T B W = I") + + +def test_export(model: SynthScopeCuReModel) -> None: + print("[F] export: the released adapter's keys, loads like it; normalisation fit ...") + adapter = model.adapter_state_dict() + assert len(adapter) == 100 and not any(k.startswith("ratio_head") for k in adapter) + assert adapter["W"].shape == (1024, 128) and adapter["mu"].shape == (1024,) and adapter["head.weight"].shape == (2, 128) + if RELEASED_ADAPTER.is_file(): + ref = torch.load(RELEASED_ADAPTER, map_location="cpu", weights_only=True) + assert set(ref) == set(adapter) and all(ref[k].shape == adapter[k].shape and ref[k].dtype == adapter[k].dtype + for k in ref) + print(f" same 100 keys, shapes and dtypes as {RELEASED_ADAPTER.name}") + fresh = SynthScopeCuReModel(model_config()) + missing, unexpected = fresh.load_state_dict(adapter, strict=False) + assert not unexpected and not any("lora_" in k or k in ("mu", "W") or k.startswith("head.") for k in missing) + assert all(torch.equal(fresh.state_dict()[k], v) for k, v in adapter.items()) + # (lambda_s, lambda_m, eps) are recovered from a W solved with them + rng = np.random.default_rng(1) + mats = [torch.from_numpy(np.cov(rng.normal(size=(400, 40)) * rng.uniform(0.2, 3, 40), rowvar=False)) for _ in range(3)] + mats = [S.trace_normalised(m) for m in mats] + w, _ = S.solve(mats[0], mats[1], mats[2], k=40, lambda_s=0.5, lambda_m=2.0, eps=1e-3) + fit = fit_normalisation(w, mats[2], mats[1]) + assert abs(fit["lambda_s"] - 0.5) < 1e-6 and abs(fit["lambda_m"] - 2.0) < 1e-6 and abs(fit["eps"] - 1e-3) < 1e-8, fit + print(f" 100 tensors, reload exact; fit recovers lambda_s 0.5 / lambda_m 2.0 / eps 1e-3 ({fit})") + + +def main() -> None: + torch.manual_seed(0) + test_mix_dataset() + test_train_augment() + test_subspace_math() + test_trainer_schedule() + if os.environ.get("CURE_RECIPE_SKIP_MODEL"): # the ViT-L parts take a few CPU minutes + print("model checks skipped (CURE_RECIPE_SKIP_MODEL)") + return + model = SynthScopeCuReModel(model_config(training_stage="ratio")) + test_ratio_stage(model) + test_grad_checkpointing(model) + test_export(model) + print("ALL CURE RECIPE CHECKS PASSED") + + +if __name__ == "__main__": + main() diff --git a/tests/test_hf_key_compat.py b/tests/test_hf_key_compat.py new file mode 100644 index 0000000000000000000000000000000000000000..c040b689b935c08ed03dbd2f5cee80e1e62e53d8 --- /dev/null +++ b/tests/test_hf_key_compat.py @@ -0,0 +1,224 @@ +"""Tests for the transformers parameter-name compatibility of checkpoint loading (interface/backend/hf_compat.py). + +Run as a script (``python tests/test_hf_key_compat.py``), CPU only. + +Always runs: +* the rename table maps an older-release state dict onto a newer-release model and the reverse, only when exact; +* anything inexact (shape mismatch, collision, unrelated unknown keys, an already-matching dict) is left untouched; +* ``engine._load_checkpoint`` loads an official-kind checkpoint in either naming, and still raises on a real mismatch; +* the table matches the installed ``transformers``: a tiny ``Dinov2Model`` built from its config, with its keys renamed + to the other release's names, translates back to exactly the model's keys and loads strictly. + +Skipped cleanly when ``$SYNTHSCOPE_CKPT_DIR/pgc.pth`` or the DINOv2-L config is not available: +* every ``backbone.*`` tensor of the real PGC checkpoint resolves onto the installed DINOv2-L (built on the meta device). +""" + +from __future__ import annotations + +import dataclasses +import os +import sys +import tempfile +from pathlib import Path + +import torch +import transformers +from torch import nn +from transformers import AutoConfig, AutoModel, Dinov2Config, Dinov2Model + +ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) +sys.path[:0] = [ROOT, os.path.join(ROOT, "benchmark")] + +from interface.backend import config, engine # noqa: E402 +from interface.backend.hf_compat import HF_RENAMES, translate_hf_keys # noqa: E402 +from interface.backend.registry import get_spec, remap_pgc # noqa: E402 + +OLD_TO_NEW = { + "attention.attention.query": "attention.q_proj", + "attention.attention.key": "attention.k_proj", + "attention.attention.value": "attention.v_proj", + "attention.output.dense": "attention.o_proj", +} + + +def _layer(prefix: str, names, dim: int = 4) -> dict: + """The attention tensors of one DINOv2 layer under ``prefix`` with the given module names (the older release's: the keys of OLD_TO_NEW).""" + out = {} + for module in names: + out[f"{prefix}.{module}.weight"] = torch.randn(dim, dim) + out[f"{prefix}.{module}.bias"] = torch.randn(dim) + out[f"{prefix}.layernorm.weight"] = torch.randn(dim) + return out + + +def _with_other_names(sd: dict, mapping: dict) -> dict: + """Rename ``sd`` keys by ``mapping`` (module name fragments), for the test ground truth.""" + out = {} + for k, v in sd.items(): + for a, b in mapping.items(): + k = k.replace(a, b) + out[k] = v + return out + + +def test_table() -> None: + print("[A] rename table, both directions ...") + assert dict((a.strip("."), b.strip(".")) for a, b in HF_RENAMES) == OLD_TO_NEW, HF_RENAMES + prefix = "backbone.encoder.layer.0" + old = _layer(prefix, OLD_TO_NEW) + new = _with_other_names(old, OLD_TO_NEW) + assert set(old) != set(new) and len(old) == len(new) == 9 + # older checkpoint -> newer model + out, note = translate_hf_keys(old, new) + assert set(out) == set(new) and "older -> newer" in note and "8 key" in note, (sorted(out), note) + for k in old: + assert out[_with_other_names({k: 0}, OLD_TO_NEW).popitem()[0]] is old[k], k + # newer checkpoint -> older model + out, note = translate_hf_keys(new, old) + assert set(out) == set(old) and "newer -> older" in note, (sorted(out), note) + for k in old: + assert torch.equal(out[k], old[k]), k + # already matching: untouched, no note + for sd in (old, new): + out, note = translate_hf_keys(sd, sd) + assert out is sd and note == "", note + # LoRA-wrapped projection (PGC with lora_targets on q/v) renames the same way + wrapped = {f"{prefix}.attention.attention.query.original_layer.weight": torch.zeros(4, 4)} + out, _ = translate_hf_keys(wrapped, {f"{prefix}.attention.q_proj.original_layer.weight": torch.zeros(4, 4)}) + assert list(out) == [f"{prefix}.attention.q_proj.original_layer.weight"], list(out) + print(" OK") + + +def test_inexact_is_untouched() -> None: + print("[B] inexact renames are left for the strict check ...") + prefix = "backbone.encoder.layer.0" + old = _layer(prefix, OLD_TO_NEW) + new = _with_other_names(old, OLD_TO_NEW) + # shape mismatch on one tensor + bad_shape = dict(new) + bad_shape[f"{prefix}.attention.q_proj.weight"] = torch.zeros(5, 4) + out, note = translate_hf_keys(old, bad_shape) + assert out is old and note == "", note + # collision: the state dict already has the target name + clash = dict(old) + clash[f"{prefix}.attention.q_proj.weight"] = torch.zeros(4, 4) + out, note = translate_hf_keys(clash, dict(new, **{f"{prefix}.attention.q_proj.weight": torch.zeros(4, 4)})) + assert out is clash and note == "", note + # the rename lands on no model key (a different layout) + out, note = translate_hf_keys(old, {"other.weight": torch.zeros(1)}) + assert out is old and note == "", note + # unrelated unknown keys are not touched + out, note = translate_hf_keys({"x.y": torch.zeros(1)}, {"a.b": torch.zeros(1)}) + assert set(out) == {"x.y"} and note == "", (out, note) + print(" OK") + + +class _TinyAttn(nn.Module): + """Named like the transformers <= 5.5.4 DINOv2 attention (``attention.attention.{query,key,value}``).""" + + def __init__(self, newer: bool): + super().__init__() + self.attention = nn.Module() + names = ("q_proj", "k_proj", "v_proj", "o_proj") if newer else ("query", "key", "value") + if newer: + for n in names: + setattr(self.attention, n, nn.Linear(4, 4)) + else: + self.attention.attention = nn.Module() + for n in names: + setattr(self.attention.attention, n, nn.Linear(4, 4)) + self.attention.output = nn.Module() + self.attention.output.dense = nn.Linear(4, 4) + + +class _Tiny(nn.Module): + def __init__(self, newer: bool): + super().__init__() + self.backbone = nn.Module() + self.backbone.layer = _TinyAttn(newer) + self.head = nn.Linear(4, 1) + + +def test_engine_loader() -> None: + print("[C] engine._load_checkpoint loads either naming (official kind, strict) ...") + base = get_spec("pgc") + with tempfile.TemporaryDirectory() as tmp: + for ckpt_newer, model_newer in ((False, True), (True, False), (False, False), (True, True)): + path = Path(tmp) / f"c_{int(ckpt_newer)}_{int(model_newer)}.pth" + src = _Tiny(ckpt_newer) + torch.save({"model": src.state_dict()}, path) + spec = dataclasses.replace(base, key="tiny", checkpoint=str(path), ckpt_kind="official_tiny", remap=remap_pgc) + dst = _Tiny(model_newer) + status = engine._load_checkpoint(dst, spec) + translated = ckpt_newer != model_newer + assert "missing=0, unexpected=0" in status and ("translated" in status) == translated, status + # the loaded tensors are the checkpoint's, matched by position in the layer + s, d = list(src.state_dict().values()), list(dst.state_dict().values()) + assert all(torch.equal(a, b) for a, b in zip(sorted(s, key=lambda t: t.sum().item()), + sorted(d, key=lambda t: t.sum().item()))), status + # a genuine mismatch is still raised by the strict check + bad = Path(tmp) / "bad.pth" + torch.save({"model": {"wrap." + k: v for k, v in _Tiny(False).state_dict().items()}}, bad) + spec = dataclasses.replace(base, key="tiny", checkpoint=str(bad), ckpt_kind="official_tiny", remap=None) + try: + engine._load_checkpoint(_Tiny(True), spec) + raise AssertionError("a real mismatch must still raise") + except RuntimeError: + pass + print(" OK") + + +def test_table_matches_installed_transformers() -> None: + print("[D] table matches the installed transformers Dinov2Model ...") + + cfg = Dinov2Config(hidden_size=32, num_hidden_layers=2, num_attention_heads=2, intermediate_size=64, image_size=28, + patch_size=14) + model = Dinov2Model(cfg) + msd = model.state_dict() + uses_old = any(".attention.attention.query." in k for k in msd) + uses_new = any(".attention.q_proj." in k for k in msd) + assert uses_old != uses_new, "Dinov2Model uses neither (or both) known attention namings: extend HF_RENAMES" + other = _with_other_names(msd, OLD_TO_NEW if uses_old else {b: a for a, b in OLD_TO_NEW.items()}) + assert set(other) != set(msd) + out, note = translate_hf_keys(other, msd) + assert set(out) == set(msd) and note, note + assert all(torch.equal(out[k], msd[k]) for k in msd) + model.load_state_dict(out, strict=True) + print(f" OK (transformers {transformers.__version__} names its DINOv2 attention " + f"{'attention.attention.query/key/value + output.dense' if uses_old else 'q/k/v/o_proj'}; {note})") + + +def test_real_pgc_checkpoint() -> None: + print("[E] real pgc.pth backbone keys resolve onto the installed DINOv2-L ...") + ckpt = config.CHECKPOINTS_DIR / get_spec("pgc").checkpoint + if not ckpt.exists(): + print(f" SKIP (no checkpoint at {ckpt})") + return + try: + with torch.device("meta"): + backbone = AutoModel.from_config(AutoConfig.from_pretrained("facebook/dinov2-large")) + except Exception as e: # noqa: BLE001 (config not cached and not downloadable) + print(f" SKIP (cannot build DINOv2-L: {type(e).__name__})") + return + raw = torch.load(str(ckpt), map_location="cpu", weights_only=False) + sd = remap_pgc(raw["model"] if "model" in raw else raw) + model_keys = {"backbone." + k: v for k, v in backbone.state_dict().items()} + out, note = translate_hf_keys(sd, model_keys) + bb_unknown = [k for k in out if k.startswith("backbone.") and ".lora" not in k and ".original_layer" not in k + and k not in model_keys] + # the LoRA-wrapped fc1/fc2 are not in the plain backbone; every other backbone tensor must have been matched + assert not bb_unknown, bb_unknown[:5] + print(f" OK ({sum(k.startswith('backbone.') for k in out)} backbone tensors; {note or 'no rename needed'})") + + +def main() -> None: + test_table() + test_inexact_is_untouched() + test_engine_loader() + test_table_matches_installed_transformers() + test_real_pgc_checkpoint() + print("ALL PASSED") + + +if __name__ == "__main__": + main() diff --git a/tests/test_hub_blocklist.py b/tests/test_hub_blocklist.py new file mode 100644 index 0000000000000000000000000000000000000000..6a6d7948e41c9b01b5037ed4204f126dc89a9064 --- /dev/null +++ b/tests/test_hub_blocklist.py @@ -0,0 +1,72 @@ +"""``synthscope.hub.push`` refuses detectors whose weights must not be redistributed (CPU, dry runs only, no network). + +* every key of ``NEVER_REDISTRIBUTE`` is a registry key and has a LICENSES.md row, +* with a dummy checkpoint for every registered detector in a temp ``$SYNTHSCOPE_CKPT_DIR`` and ``--include-official``, + a dry-run push selects none of them and says why, while GRIP's ``bfree`` (non-profit, ``official_*`` rule) and + SynthScope-trained detectors are still selected, +* without ``--include-official`` the blocked keys stay refused (not merely "official"). +""" + +from __future__ import annotations + +import contextlib +import io +import os +import re +import sys +import tempfile +from pathlib import Path + +ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) +sys.path[:0] = [ROOT, os.path.join(ROOT, "interface")] + +from interface.backend.registry import MODELS # noqa: E402 +from synthscope import hub # noqa: E402 + + +def _dry_run(ckpt_dir: Path, **kw): + hub._ckpt_dir = lambda: ckpt_dir + out = io.StringIO() + with contextlib.redirect_stdout(out): + summary = hub.push(repo_id="test/none", dry_run=True, **kw) + return summary, out.getvalue() + + +def test_blocklist_is_consistent() -> None: + licenses = Path(ROOT, "LICENSES.md").read_text() + for key in hub.NEVER_REDISTRIBUTE: + assert key in MODELS, key + assert re.search(rf"`{key}`", licenses), f"{key} has no LICENSES.md row" + assert "bfree" not in hub.NEVER_REDISTRIBUTE and "waverep" not in hub.NEVER_REDISTRIBUTE + print(f" {len(hub.NEVER_REDISTRIBUTE)} blocked keys, all registered and listed in LICENSES.md") + + +def test_dry_run_push() -> None: + original = hub._ckpt_dir + try: + with tempfile.TemporaryDirectory() as tmp: + for spec in MODELS.values(): + if spec.checkpoint: + Path(tmp, spec.checkpoint).write_bytes(b"x") + for flag in (True, False): + summary, text = _dry_run(Path(tmp), include_official=flag) + assert summary["dry_run"] + refused = {k for k, why in summary["skipped"] if why.startswith("REFUSED")} + assert refused == set(hub.NEVER_REDISTRIBUTE), refused + assert not refused & set(summary["uploaded"]) + assert "REFUSED" in text and "even with --include-official" in text + summary, _ = _dry_run(Path(tmp), include_official=True) + assert "bfree" in summary["uploaded"] and "clip" in summary["uploaded"], summary["uploaded"] + summary, _ = _dry_run(Path(tmp), include_official=False) + assert "bfree" not in summary["uploaded"] and "clip" in summary["uploaded"] + summary, text = _dry_run(Path(tmp), keys=["probe", "ltf"], include_official=True) + assert summary["uploaded"] == [] and len(summary["skipped"]) == 2, summary + finally: + hub._ckpt_dir = original + print(" dry-run push (with and without --include-official): blocked keys refused, bfree/clip handled as before") + + +if __name__ == "__main__": + test_blocklist_is_consistent() + test_dry_run_push() + print("hub blocklist test passed") diff --git a/tests/test_model_transforms.py b/tests/test_model_transforms.py index fb820120045214e5c150120ecbab269c3b298dc0..b1f2a4b185689a29d072a00619a0df291ca41176 100644 --- a/tests/test_model_transforms.py +++ b/tests/test_model_transforms.py @@ -2,7 +2,8 @@ * every ``conf/model/image/*.yaml`` has a non-empty ``eval_transform_list``, and every ``*_transform_list`` of every model and dataset config builds through ``AIGITransformations``; malformed names raise ``Invalid transform name``, -* each image detector's registry transform is its model config's ``eval_transform_list`` (one source of truth), +* each image detector's (and per-frame video detector's, e.g. WaveRep) registry transform is its model config's + ``eval_transform_list`` (one source of truth), * the output shape of every eval pipeline on a 300x200 image, * eval path == inference path: the test transform ``dataset.resolve_transforms`` builds, on ``dataset._decode_rgb`` (the training loaders), equals the registry transform on ``bench_eval._open_rgb`` (benchmarks / web UI) exactly, on @@ -11,6 +12,9 @@ * pixel parity with hand-written torchvision pipelines (the official eval code) for CLIP, NPR, PGC (incl. zero padding), OmniAID v1, DDA, SAFE (v1) and VINA (v2, bicubic short-side resize), * a model's train / val / test outputs have the same per-sample rank, +* AIDE's ``aide_blur`` + ``aide_jpeg`` draw the same random numbers and give the same pixels as the official kornia + ``Perturbations`` container (and leave an image with a side that is not a multiple of 16 the shape kornia's JPEG would + reject), * ``without_resize`` drops only resize / crop steps and refuses pipelines that resize inside, * ``to_dtype`` equals ``to_tensor`` on a PIL image and ``ToDtype(float32, scale=True)`` on a uint8 tensor, exactly, * ``resolve_transforms`` reports a DatasetConfig list shadowed by the model's only when it was overridden (differs from @@ -52,7 +56,8 @@ IMAGE_MODELS = sorted((CONF / "model" / "image").glob("*.yaml")) TRAINING_KEYS = ("train_transform_list", "val_transform_list", "test_transform_list") # (width, height) of the PNG test images: smaller than every crop, non-square both ways, square, long side > 1024. SIZES = [(300, 200), (200, 150), (150, 260), (512, 512), (1300, 900)] -# Each image model's eval output on a 300x200 image (bfree / spai: native resolution; ltf: global view + 2 tiles). +# Each image model's eval output on a 300x200 image (bfree / spai: native resolution; ltf: global view + 2 tiles; probe: +# repeat-tiled to 600x400, one 336 patch; probe_resnet: one 224 patch of the black-padded square). EXPECTED_SHAPES = { "adapted_dino": (3, 224, 224), "aide": (5, 3, 256, 256), "bfree": (3, 200, 300), "clip": (3, 224, 224), "cnn": (3, 224, 224), "co_spy": (3, 384, 384), "cure": (3, 336, 336), "d3qe": (3, 256, 256), @@ -60,7 +65,7 @@ EXPECTED_SHAPES = { "effort_ufd": (3, 224, 224), "fat_former": (3, 224, 224), "ltf": (3, 3, 224, 224), "mirror": (3, 224, 224), "moejepa": (3, 256, 256), "npr": (3, 256, 256), "omniaid": (3, 336, 336), "omniaid_genimage": (3, 336, 336), "omniaid_v1": (3, 336, 336), "pgc": (3, 224, 224), - "safe": (3, 256, 256), + "probe": (1, 3, 336, 336), "probe_resnet": (1, 3, 224, 224), "safe": (3, 256, 256), "spai": (3, 200, 300), "vib_net": (3, 224, 224), "vib_net_official": (3, 224, 224), "vina": (3, 256, 256), } # The official eval code as torchvision pipelines (PIL in). @@ -170,14 +175,17 @@ def test_registry_matches_config() -> None: print("[B] registry transform == the model config's eval_transform_list ...") n = 0 for spec in list_specs(): - configs = [o.split("=", 1)[1] for o in spec.overrides if o.startswith("model@ModelConfig=image/")] - if not configs: + # image configs, and the video configs with per-frame eval preprocessing (WaveRep) + configs = [o.split("=", 1)[1] for o in spec.overrides + if o.startswith(("model@ModelConfig=image/", "model@ModelConfig=video/"))] + lists = transform_lists(CONF / "model" / f"{configs[0]}.yaml") if configs else {} + expected = lists.get("eval_transform_list") + if not expected: continue - expected = transform_lists(CONF / "model" / f"{configs[0]}.yaml")["eval_transform_list"] assert isinstance(spec.transform, AIGITransformations), (spec.key, type(spec.transform)) assert list(spec.transform.transform_list) == expected, (spec.key, spec.transform.transform_list, expected) n += 1 - print(f" {n} image specs") + print(f" {n} specs (image models and per-frame video models)") def test_eval_shapes() -> None: @@ -262,6 +270,38 @@ def test_training_lists_on_tensor() -> None: print(f" {len(lists)} lists") +def test_aide_perturbations() -> None: + print("[K] aide_blur + aide_jpeg == the official kornia Perturbations ...") + import kornia.augmentation as K + official = K.container.ImageSequential(K.RandomGaussianBlur(kernel_size=(3, 3), sigma=(0.1, 3.0), p=0.1), + K.RandomJPEG(jpeg_quality=(30, 100), p=0.1)) + ours = AIGITransformations(["aide_blur", "aide_jpeg"]) + uint8 = torch.randint(0, 256, (3, 96, 128), generator=torch.Generator().manual_seed(1), dtype=torch.uint8) + pil = TF.to_pil_image(uint8) + base = TF.to_tensor(pil) + changed = 0 + for seed in range(300): + torch.manual_seed(seed) + want = official(base)[0] + torch.manual_seed(seed) + assert torch.equal(ours(pil), want), seed # PIL in (val path) + torch.manual_seed(seed) + assert torch.equal(ours(uint8), want), seed # uint8 tensor in (train path) + changed += int(not torch.equal(want, base)) + assert 40 < changed < 80, changed # 1 - 0.9^2 = 19% of 300 (a fixed draw: 57) + odd = torch.randint(0, 256, (3, 100, 131), dtype=torch.uint8) # not a multiple of 16: kornia's JPEG would raise + jpeg_only = AIGITransformations(["aide_jpeg"]) + hits = 0 + for seed in range(200): + torch.manual_seed(seed) + out = jpeg_only(odd) + assert out.shape == (3, 100, 131) and out.dtype == torch.float32 and 0 <= out.min() and out.max() <= 1 + hits += int(not torch.equal(out, odd.float().div(255))) + assert 5 < hits < 40, hits # about 10% of 200 + train = AIGITransformations(["aide_blur", "aide_jpeg", "aide_five_view_train"])(odd) + assert tuple(train.shape) == (5, 3, 256, 256) + + def test_without_resize() -> None: print("[H] without_resize ...") tf = AIGITransformations(["resize_short_256", "center_crop_224", "to_dtype", "normalize_clip"], pil_input=True) @@ -315,6 +355,7 @@ if __name__ == "__main__": test_golden() test_split_ranks() test_training_lists_on_tensor() + test_aide_perturbations() test_without_resize() test_to_dtype() test_shadow_warning() diff --git a/tests/test_native_res_batch.py b/tests/test_native_res_batch.py new file mode 100644 index 0000000000000000000000000000000000000000..24c58e15c60b70a7d7f5515581acfd65f5ba0f36 --- /dev/null +++ b/tests/test_native_res_batch.py @@ -0,0 +1,96 @@ +"""Native-resolution specs are scored one image at a time (CPU, no downloads). + +* ``ModelSpec.eval_batch_size`` is 1 for every ``native_res`` spec (LTF, B-Free, SPAI, PROBE, ...) and the requested size + otherwise, +* ``benchmark/evaluate.py`` ``score`` on images of different sizes: a ``native_res`` spec with a batch size of 8 scores them + (each forward pass sees one image), a fixed-size spec stacks them in batches of 8. +""" + +from __future__ import annotations + +import dataclasses +import os +import sys +import tempfile +from pathlib import Path +from types import SimpleNamespace + +import numpy as np +import torch +from PIL import Image + +ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) +sys.path[:0] = [ROOT, os.path.join(ROOT, "interface")] + +from benchmark import evaluate # noqa: E402 +from backend.registry import MODELS, get_spec # noqa: E402 + +SIZES = [(40, 30), (64, 64), (33, 90), (50, 20), (70, 70)] + + +class _Engine: + """Stands in for the inference engine: records the batch sizes it is called with.""" + device = "cpu" + + def __init__(self): + self.batch_sizes = [] + + def _get_model(self, spec): + return None + + def _fake_prob(self, model, spec, x): + self.batch_sizes.append(x.shape[0]) + return x.flatten(1).mean(1) + + +class _Detector: + def __init__(self, spec): + self.spec = spec + self._engine = _Engine() + + def _ensure_weights(self): + pass + + +def _score(spec, paths, fixed_size: bool): + # fixed-size transform: stackable; native transform: keeps the image size (variable-size tensors) + def transform(img): + t = torch.from_numpy(np.array(img)).permute(2, 0, 1).float() / 255 + return t[:, :20, :20] if fixed_size else t + spec = dataclasses.replace(spec, transform=transform) + det = _Detector(spec) + probs = evaluate.score(det, paths, 8) + return probs, det._engine.batch_sizes + + +def test_batch_size_rule() -> None: + native = [k for k, s in MODELS.items() if s.native_res] + assert {"ltf", "bfree", "spai", "probe", "probe_resnet"} <= set(native), native + for key, spec in MODELS.items(): + assert spec.eval_batch_size(32) == (1 if spec.native_res else 32), key + print(f" eval_batch_size: 1 for the {len(native)} native_res specs, unchanged for the other {len(MODELS) - len(native)}") + + +def test_score_variable_sizes() -> None: + with tempfile.TemporaryDirectory() as tmp: + paths = [] + for i, (w, h) in enumerate(SIZES): + path = os.path.join(tmp, f"{i}.png") + Image.new("RGB", (w, h), (10 * i, 20, 30)).save(path) + paths.append(path) + paths = [Path(p) for p in paths] + native = get_spec("probe") + assert native.native_res + probs, batches = _score(native, paths, fixed_size=False) + assert batches == [1] * len(SIZES) and probs.shape == (len(SIZES),), batches + fixed = get_spec("clip") + assert not fixed.native_res + probs, batches = _score(fixed, paths, fixed_size=True) + assert batches == [5] and probs.shape == (len(SIZES),), batches + print(" evaluate.score: variable-size images scored one at a time for probe; clip stacks them in one batch of 5") + + +if __name__ == "__main__": + test_batch_size_rule() + test_score_variable_sizes() + print("native-res batch test passed") diff --git a/tests/test_pgc_load.py b/tests/test_pgc_load.py index 25f7b7c314df961b4a4b552bc1d4340ffde2012c..4546d32e505109480a26f6eb1c5d0f3e0230a0b1 100644 --- a/tests/test_pgc_load.py +++ b/tests/test_pgc_load.py @@ -34,6 +34,7 @@ ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) sys.path[:0] = [ROOT, os.path.join(ROOT, "benchmark")] from interface.backend import config, engine # noqa: E402 +from interface.backend.hf_compat import translate_hf_keys # noqa: E402 from interface.backend.registry import get_spec, remap_pgc # noqa: E402 _PARITY_ENV = os.environ.get("SYNTHSCOPE_PGC_PARITY_REF") @@ -141,8 +142,9 @@ def test_official_checkpoint_loads_exactly() -> object: assert not recs, [r.getMessage() for r in recs] assert "missing=0, unexpected=0" in status, status raw = torch.load(str(config.CHECKPOINTS_DIR / spec.checkpoint), map_location="cpu", weights_only=False) - sd = spec.remap(raw["model"] if "model" in raw else raw) msd = model.state_dict() + # the checkpoint holds transformers 5.5.4 DINOv2 names; the loader maps them onto the installed release's names + sd, _ = translate_hf_keys(spec.remap(raw["model"] if "model" in raw else raw), msd) assert set(sd) <= set(msd), sorted(set(sd) - set(msd))[:5] assert all(torch.equal(msd[k], v) for k, v in sd.items()), "a loaded tensor differs from the checkpoint" lora_b = max(v.abs().max().item() for k, v in msd.items() if k.endswith("lora_B")) diff --git a/tests/test_probe_smoke.py b/tests/test_probe_smoke.py new file mode 100644 index 0000000000000000000000000000000000000000..0d9262065d13c417a129a3130b931db47cb1e8ce --- /dev/null +++ b/tests/test_probe_smoke.py @@ -0,0 +1,272 @@ +"""Smoke test for the PROBE integration (CPU, no downloads). + +Checks: +* the registry transforms of ``probe`` (``probe_pad_repeat_336``, ``to_dtype``, ``normalize_imagenet``, + ``sliding_patches_336``) and ``probe_resnet`` (``probe_pad_224``, ..., ``sliding_patches_224``) equal the official + evaluate_dino.py / evaluate_resnet.py preprocessing written out independently (repeat-tiling or black-square padding, + ToTensor + ImageNet Normalize, row-major non-overlapping patches; edge pixels past the last full patch dropped) on + small, exact-size, non-square and large images, bit for bit, +* a tiny-backbone ``SynthScopePROBEModel``: official key layout (``backbone.embeddings.*``, + ``backbone.encoder.layer.*``, ``fc.*``), ``forward`` on a [B, N, 3, S, S] patch bag = the mean of the official + ``dino_classifier`` patch logits, [B, 1], independent of ``patch_chunk_size``; a [B, 3, S, S] batch is one patch + each; ``compute_loss`` + backward, +* ``SynthScopePROBEResNetModel`` = the official ``resnet50(num_classes=1, classifier_type='linear')`` key for key, + same patch-mean forward, +* the engine: ``_fake_prob`` = sigmoid(mean patch logit) for both keys, the strict ``official_probe`` load through + ``remap_probe`` (``{"model_state_dict": ...}``) accepts the exact state dict and raises on a missing or an unexpected + key, the model-input preview handles a patch bag, the input notes, +* the patch-bag preview and ``input_size``: the real patch grid (rows x columns) and the padded image size of + ``predict_image`` for both keys, equal to the official padding + unfold on small, exact, non-square and wide images + (scores unchanged: ``p_fake`` is the engine's ``_fake_prob`` of the transform output), +* the full-size models (built on the meta device) have exactly the keys and shapes of the released checkpoints, if + ``$SYNTHSCOPE_CKPT_DIR/probe.pth`` / ``probe_resnet.pth`` exist (skipped otherwise). +""" + +from __future__ import annotations + +import dataclasses +import os +import sys +import tempfile + +import numpy as np +import torch +import torchvision.transforms as T +from omegaconf import OmegaConf +from PIL import Image + +ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) +sys.path[:0] = [ROOT, os.path.join(ROOT, "interface")] + +from backend.engine import Engine, _load_checkpoint, patch_layout # noqa: E402 +from backend.hf_compat import HF_RENAMES, translate_hf_keys # noqa: E402 +from backend.registry import get_spec, input_note, remap_probe # noqa: E402 +from models.image.probe.official.dino_classifier import DINOV2_REG_LARGE, dino_classifier # noqa: E402 +from models.image.probe.official.resnet50 import resnet50 # noqa: E402 +from models.image.probe.probe import SynthScopePROBEModel, SynthScopePROBEResNetModel # noqa: E402 + +TINY = {"hidden_size": 64, "num_hidden_layers": 2, "num_attention_heads": 4} +IMAGENET = T.Normalize((0.485, 0.456, 0.406), (0.229, 0.224, 0.225)) +# (width, height): under the crop both ways, exact, one side under, non-square, large; also a grayscale image +SIZES = [(128, 96), (180, 120), (224, 224), (336, 336), (300, 1200), (335, 700), (336, 500), (513, 700), (1258, 833), + (2048, 1365)] + + +def known_key(sd: dict, key: str) -> bool: + """``key`` is in ``sd`` under the naming of either transformers release (attention.attention.query vs attention.q_proj).""" + if key in sd: + return True + return any((a in key and key.replace(a, b, 1) in sd) or (b in key and key.replace(b, a, 1) in sd) + for a, b in HF_RENAMES) + + +def other_naming(sd: dict) -> dict: + """``sd`` with the attention parameters renamed to the other transformers release's names (what a checkpoint saved + under that release holds).""" + out = {} + for k, v in sd.items(): + for a, b in HF_RENAMES: + if a in k: + k = k.replace(a, b, 1) + break + if b in k: + k = k.replace(b, a, 1) + break + out[k] = v + return out + + +def noise_image(size: tuple[int, int], mode: str = "RGB") -> Image.Image: + gen = torch.Generator().manual_seed(size[0] * 7 + size[1]) + arr = torch.randint(0, 256, (size[1], size[0], 3), generator=gen, dtype=torch.uint8).numpy() + return Image.fromarray(arr, "RGB").convert(mode).convert("RGB") + + +def official_patches(img: Image.Image, ps: int, mode: str) -> torch.Tensor: + """The official test-time preprocessing, written out: pad_image (repeat tiling / black square), ToTensor + + ImageNet Normalize on the whole image, then the row-major non-overlapping ps x ps patches.""" + w, h = img.size + if w < ps or h < ps: + if mode == "repeat": + arr = np.tile(np.asarray(img), (-(-ps // h), -(-ps // w), 1)) + img = Image.fromarray(arr) + else: + canvas = Image.new("RGB", (ps, ps)) + canvas.paste(img, ((ps - w) // 2, (ps - h) // 2)) + img = canvas + x = IMAGENET(T.ToTensor()(img)) + rows, cols = x.shape[1] // ps, x.shape[2] // ps + return torch.stack([x[:, r * ps:(r + 1) * ps, c * ps:(c + 1) * ps] for r in range(rows) for c in range(cols)]) + + +def tiny_model(chunk: int = 0) -> SynthScopePROBEModel: + cfg = {"ModelConfig": {"model_type": "probe", "backbone_config": TINY, "patch_chunk_size": chunk}} + return SynthScopePROBEModel(OmegaConf.create(cfg)).eval() + + +def test_transforms() -> None: + print("[A] registry transforms == the official evaluate_dino.py / evaluate_resnet.py preprocessing ...") + for key, ps, mode in (("probe", 336, "repeat"), ("probe_resnet", 224, "pad")): + tf = get_spec(key).transform + expected = ([f"probe_pad_repeat_{ps}"] if mode == "repeat" else [f"probe_pad_{ps}"]) + \ + ["to_dtype", "normalize_imagenet", f"sliding_patches_{ps}"] + assert list(tf.transform_list) == expected, (key, tf.transform_list) + assert get_spec(key).native_res, key + for size in SIZES: + for img in (noise_image(size), noise_image(size, "L")): + x = tf(img) + want = official_patches(img, ps, mode) + assert x.shape == want.shape and torch.equal(x, want), (key, size, tuple(x.shape), tuple(want.shape)) + assert x.shape[0] == max(1, size[0] // ps) * max(1, size[1] // ps) or mode == "pad", (key, size) + # 'pad' with one long side: a single centered patch (the long side is cut) + assert tf(noise_image((300, 200))).shape[0] == 1 + print(f" {len(SIZES)} sizes x RGB / grayscale, both variants, bit-exact") + + +def test_dino_model() -> None: + print("[B] tiny PROBE-DINOv2: key layout, patch-mean forward, chunking, loss ...") + torch.manual_seed(0) + model = tiny_model() + sd = model.state_dict() + for k in ("backbone.embeddings.cls_token", "backbone.embeddings.register_tokens", "backbone.embeddings.mask_token", + "backbone.encoder.layer.0.attention.attention.query.weight", + "backbone.encoder.layer.1.layer_scale2.lambda1", + "backbone.layernorm.weight", "fc.weight", "fc.bias"): + assert known_key(sd, k), k + assert tuple(sd["fc.weight"].shape) == (1, TINY["hidden_size"]) + # the vendored official class with the same config and weights + official = dino_classifier(model_name=dict(DINOV2_REG_LARGE, **TINY)).eval() + official.load_state_dict(sd, strict=True) + bag = torch.randn(2, 3, 3, 28, 28) + with torch.no_grad(): + out = model(bag) + want = official(bag.flatten(0, 1)).view(2, 3, 1).mean(dim=1) + assert out.shape == (2, 1) and torch.allclose(out, want, atol=1e-6), (out, want) + for chunk in (1, 2, 5): + other = tiny_model(chunk) + other.load_state_dict(sd, strict=True) + assert torch.allclose(other(bag), out, atol=1e-6), chunk + single = model(bag[:, 0]) + assert single.shape == (2, 1) and torch.allclose(single, official(bag[:, 0]), atol=1e-6) + model.train() + loss = model.compute_loss((torch.randn(2, 3, 28, 28), torch.tensor([0, 1]))) + assert torch.isfinite(loss["loss"]) and loss["outputs"].shape == (2, 2) + assert torch.equal(loss["outputs"][:, 0], -loss["outputs"][:, 1]) + loss["loss"].backward() + assert model.fc.weight.grad is not None + print(f" {len(sd)} tensors, [B, N, 3, S, S] -> [B, 1] = mean official patch logit, chunk-invariant") + + +def test_resnet_model() -> None: + print("[C] PROBE-ResNet50 = the official resnet50(num_classes=1, classifier_type='linear') ...") + torch.manual_seed(0) + model = SynthScopePROBEResNetModel(OmegaConf.create({"ModelConfig": {"model_type": "probe_resnet", + "patch_chunk_size": 2}})).eval() + official = resnet50(num_classes=1, classifier_type="linear").eval() + assert {k: v.shape for k, v in model.state_dict().items()} == {k: v.shape for k, v in official.state_dict().items()} + official.load_state_dict(model.state_dict(), strict=True) + bag = torch.randn(1, 3, 3, 64, 64) + with torch.no_grad(): + assert torch.allclose(model(bag), official(bag[0]).mean(dim=0, keepdim=True), atol=1e-6) + print(f" {len(official.state_dict())} tensors, same names and shapes; patch-mean forward") + + +def test_engine() -> None: + print("[D] engine: P(fake) = sigmoid(mean patch logit), strict official load, preview, notes ...") + engine = Engine(device="cpu") + model = tiny_model() + spec = get_spec("probe") + bag = torch.randn(1, 4, 3, 28, 28) + with torch.no_grad(): + p = engine._fake_prob(model, spec, bag) + assert p.shape == (1,) and torch.allclose(p, torch.sigmoid(model(bag)[:, 0])) + sd = {k: v.clone() for k, v in model.state_dict().items()} + assert remap_probe({"model_state_dict": sd}) is sd and remap_probe(sd) is sd + with tempfile.TemporaryDirectory() as tmp: + for case in ("exact", "renamed", "missing", "unexpected"): + # "renamed": the attention parameters under the other transformers release's names, as a checkpoint saved + # with that release holds them; the engine maps them onto this release's names (hf_compat) and loads strictly + ckpt = other_naming(sd) if case == "renamed" else dict(sd) + if case == "renamed": + assert set(ckpt) != set(sd) + if case == "missing": + ckpt.pop("fc.bias") + elif case == "unexpected": + ckpt["head.weight"] = torch.zeros(1) + path = os.path.join(tmp, f"{case}.pth") + torch.save({"model_state_dict": ckpt}, path) + target = tiny_model() + try: + status = _load_checkpoint(target, dataclasses.replace(spec, checkpoint=path)) + except RuntimeError as e: + assert case != "exact" and "checkpoint mismatch" in str(e), (case, e) + continue + assert case in ("exact", "renamed") and "missing=0, unexpected=0" in status, (case, status) + with torch.no_grad(): + assert torch.equal(target(bag), model(bag)) + url = engine._model_input_data_url(spec, spec.transform(noise_image((700, 513))).unsqueeze(0)) + assert url.startswith("data:image/png;base64,") + for key in ("probe", "probe_resnet"): + assert "patches" in input_note(get_spec(key))["label"], key + print(" exact and renamed-key loads pass, missing / unexpected keys raise; preview of a 2-patch bag renders") + + +def test_patch_layout() -> None: + print("[F] patch-bag preview: real nH x nW layout and padded input_size ...") + engine = Engine(device="cpu") + tiny = tiny_model() + engine._get_model = lambda spec: tiny + for key, ps, mode in (("probe", 336, "repeat"), ("probe_resnet", 224, "pad")): + spec = get_spec(key) + for size in ((128, 96), (200, 100), (ps, ps), (1700, 700), (300, 1200), (900, 400)): + pil = noise_image(size) + n = official_patches(pil, ps, mode).shape[0] + layout = patch_layout(spec, pil, n) + assert layout is not None, (key, size) + (w, h), (rows, cols) = layout + assert rows * cols == n and rows == h // ps and cols == w // ps, (key, size, layout) + if size[0] >= ps and size[1] >= ps: + assert (w, h) == size, (key, size, layout) # nothing to pad + assert patch_layout(spec, pil, n + 1) is None + if n > 12: + continue # the model run below stays tiny + res = engine.predict_image(spec, pil) + assert res["input_size"] == [w, h] and res["input_grid"] == [rows, cols] and res["input_patches"] == n, \ + (key, size, res["input_size"], res["input_grid"]) + x = spec.transform(pil).unsqueeze(0) + with torch.no_grad(): + assert abs(res["fake_probability"] - float(engine._fake_prob(tiny, spec, x))) < 1e-6, (key, size) + url = engine._model_input_data_url(spec, x, max_side=10**6, cols=cols) + import base64, io + img = Image.open(io.BytesIO(base64.b64decode(url.split(",", 1)[1]))) + assert img.size == (cols * ps, rows * ps), (key, size, img.size, (cols, rows)) + print(f" {key} {size}: input_size {res['input_size']}, {rows}x{cols} = {n} patches") + assert patch_layout(get_spec("clip"), noise_image((64, 64)), 1) is None + print(" other detectors are not patch bags: no layout") + + +def test_released_layout() -> None: + ckpt_dir = os.environ.get("SYNTHSCOPE_CKPT_DIR", "") + for key, cls in (("probe", SynthScopePROBEModel), ("probe_resnet", SynthScopePROBEResNetModel)): + path = os.path.join(ckpt_dir, f"{key}.pth") + if not os.path.isfile(path): + print(f"[E] {key}: released checkpoint layout skipped ($SYNTHSCOPE_CKPT_DIR/{key}.pth not found)") + continue + print(f"[E] {key}: full-size model (meta device) vs the released checkpoint ...") + with torch.device("meta"): + model = cls(OmegaConf.create({"ModelConfig": {"model_type": key}})) + ours = {k: tuple(v.shape) for k, v in model.state_dict().items()} + released = remap_probe(torch.load(path, map_location="cpu", weights_only=False, mmap=True)) + released, _ = translate_hf_keys(released, model.state_dict()) # the names of this transformers release + assert ours == {k: tuple(v.shape) for k, v in released.items()}, key + print(f" {len(ours)} tensors: same names and shapes") + + +if __name__ == "__main__": + test_transforms() + test_dino_model() + test_resnet_model() + test_engine() + test_patch_layout() + test_released_layout() + print("PROBE smoke test passed") diff --git a/tests/test_timm_cosine_select.py b/tests/test_timm_cosine_select.py new file mode 100644 index 0000000000000000000000000000000000000000..58a1daf57d6093cd9f4c826014ab05c1df762329 --- /dev/null +++ b/tests/test_timm_cosine_select.py @@ -0,0 +1,94 @@ +"""CPU check of ``trainer.SynthScopeModelTrainer._train_with_timm_cosine`` with ``select: accuracy`` (AIDE's recipe). + +A tiny linear model and scripted validation results, no data or GPU: + +* ``model_best.pth`` follows the validation ACCURACY (first epoch of the highest value, strict improvement), not the + validation loss: the scripted losses rise every epoch, so a loss-selecting run would keep only epoch 0, +* ``save_all`` keeps every epoch and ``model_last.pth``; ``val_losses.json`` holds ``val_accuracy`` and the best epoch, +* the learning rate follows the half-cosine from lr to min_lr, with the first step at the base lr, +* the header line reports the effective batch (processes x micro-batch x accumulation), not 0. +""" + +from __future__ import annotations + +import contextlib +import io +import json +import os +import sys +import tempfile + +import torch +from accelerate import Accelerator +from omegaconf import OmegaConf + +sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) + +from trainer import SynthScopeModelTrainer + +ACCURACIES = [0.60, 0.90, 0.90, 0.80, 0.95] # real = fake = accuracy; the tie at epoch 2 is not an improvement +LOSSES = [0.1, 0.2, 0.3, 0.4, 0.5] # rising: a loss-selecting run would keep epoch 0 only +MICRO, ACCUM, EPOCHS = 8, 32, len(ACCURACIES) # effective batch 256 on one process + + +class _Logger: + def log_metrics(self, *args, **kwargs): + pass + + def finish(self): + pass + + +def build(save_path: str) -> SynthScopeModelTrainer: + cfg = OmegaConf.create({"TrainerConfig": { + "epochs": EPOCHS, "lr": 5e-4, "save": True, "save_path": save_path, + "timm_cosine": {"warmup_epochs": 0, "warmup_lr": 0.0, "min_lr": 1e-6, "grad_accum_steps": ACCUM, + "save_all": True, "select": "accuracy", "log_every": 1}}}) + trainer = SynthScopeModelTrainer.__new__(SynthScopeModelTrainer) + trainer.config = cfg + trainer.accelerator = Accelerator(cpu=True) + model = torch.nn.Linear(4, 2) + optimizer = torch.optim.AdamW(model.parameters(), lr=5e-4) + data = torch.utils.data.TensorDataset(torch.randn(MICRO * ACCUM * 2, 4)) # 2 optimizer steps per epoch + loader = torch.utils.data.DataLoader(data, batch_size=MICRO) + trainer.model, trainer.optimizer, trainer.train_loader = trainer.accelerator.prepare(model, optimizer, loader) + trainer.global_step, trainer.logger = 0, _Logger() + trainer.train_step = lambda batch: (trainer.model(batch[0]) ** 2).mean() + epochs_done = iter(range(EPOCHS)) + + def val(): + epoch = next(epochs_done) + return LOSSES[epoch], {"real_accuracy": ACCURACIES[epoch], "fake_accuracy": ACCURACIES[epoch]} + + trainer.val = val + trainer.saved = [] + trainer._save_model = lambda tag, path: trainer.saved.append(str(tag)) + return trainer + + +def main() -> None: + with tempfile.TemporaryDirectory() as save_path: + trainer = build(save_path) + out = io.StringIO() + with contextlib.redirect_stdout(out): + trainer._train_with_timm_cosine(trainer.config.TrainerConfig.timm_cosine) + log = out.getvalue() + best = [i for i, tag in enumerate(trainer.saved) if tag == "best"] + # per epoch the saves are: last, , and best when the accuracy improved + assert trainer.saved == ["last", "0", "best", "last", "1", "best", "last", "2", "last", "3", "last", "4", "best"], trainer.saved + assert len(best) == 3 + with open(f"{save_path}/val_losses.json") as f: + record = json.load(f) + assert record["val_accuracy"] == ACCURACIES and record["best_epoch"] == 4 and record["val_loss"] == LOSSES, record + with open(f"{save_path}/train_state/progress.json") as f: + assert json.load(f)["val_accuracy"] == ACCURACIES + assert "effective batch 256" in log, log + assert "lr 0.0005 -> 1e-06 over 5 epochs" in log, log + lrs = [float(line.split("lr ")[1].split()[0]) for line in log.splitlines() if " step " in line and "lr " in line] + assert abs(lrs[0] - 5e-4) < 5e-7 and lrs == sorted(lrs, reverse=True) and lrs[-1] < 5e-5, lrs # first step ~ base lr, then down + print(f"best-model saves follow the accuracy; effective batch and lr logged ({lrs[0]:.3e} -> {lrs[-1]:.3e})") + print("timm_cosine select-accuracy checks passed") + + +if __name__ == "__main__": + main() diff --git a/tests/test_trainer_ddp.py b/tests/test_trainer_ddp.py index fb3ee27203874858413c0e508ea83bb36f8d0f83..19b0fdecc55346c1fbf5ec7555285ee10c1732c4 100644 --- a/tests/test_trainer_ddp.py +++ b/tests/test_trainer_ddp.py @@ -1,12 +1,16 @@ -"""DDP gradients through the trainer equal single-process gradients (CPU, gloo, 2 processes; no GPU, no data, no download). +"""DDP training through the trainer equals single-process training (CPU, gloo, 2 processes; no GPU, no data, no download). ``SynthScopeModelTrainer`` calls ``model.compute_loss(batch)``, which a ``DistributedDataParallel`` wrapper does not have; ``_compute_loss`` runs it through the wrapper's ``forward`` so the gradient reducer fires. Checked here, with a tiny model -(a trainable linear layer with unused-in-loss frozen parameters, like a frozen backbone): - -* one optimizer step over a global batch of 16 (2 processes x micro-batch 4 x accumulation 2) gives the weights of one - single-process step over the same 16 samples, and both ranks hold identical weights, -* the same with accumulation 1 (2 x 8), +(a trainable linear layer behind frozen parameters, like a frozen backbone), on a global batch of 16 samples per step: + +* ``train_epoch`` (no accumulation): 2 processes x 8 equal one process x 16, and both ranks hold identical weights; the same + with accumulation (2 processes x micro-batch 4 x accumulation 2), +* ``_train_with_timm_cosine`` (AIDE's path, with accumulation, 2 epochs): 2 processes x micro-batch 4 x accumulation 2 give + the weights of one process x 16, of one process x 4 x accumulation 4, and of the same DDP run with ``no_sync`` disabled; + the non-stepping micro-batches run under ``accelerator.no_sync`` (counted), the ranks stay identical, +* ``_train_with_step_budget`` (PGC/DDA path) with a final partial accumulation (5 micro-batches, accumulation 2): the last + micro-batch syncs, so the ranks agree and match one process x 8, * evaluation (``torch.no_grad`` + ``eval()``) works through the wrapper, and the inner module's ``forward`` is restored. Run as a script: python tests/test_trainer_ddp.py @@ -14,17 +18,20 @@ Run as a script: python tests/test_trainer_ddp.py from __future__ import annotations +import contextlib import os import socket import sys +import tempfile from pathlib import Path import torch import torch.multiprocessing as mp +from omegaconf import OmegaConf ROOT = Path(__file__).resolve().parents[1] sys.path.insert(0, str(ROOT)) -N, FEAT = 16, 4 +N, FEAT = 32, 4 # samples; one epoch is 2 global steps of 16 class Tiny(torch.nn.Module): @@ -44,13 +51,20 @@ class Tiny(torch.nn.Module): return {"loss": torch.nn.functional.cross_entropy(out, y), "outputs": out} +class _Logger: + def log_metrics(self, *args, **kwargs): + pass + + def finish(self): + pass + + def data(): torch.manual_seed(0) return torch.randn(N, FEAT), torch.randint(0, 2, (N,)), torch.zeros(N, dtype=torch.long) -def run(micro, accum): - """Train one epoch with the trainer's own train_epoch on whatever process layout accelerate detects.""" +def build(micro): from accelerate import Accelerator from trainer import SynthScopeModelTrainer x, y, f = data() @@ -59,21 +73,50 @@ def run(micro, accum): t.accelerator = Accelerator(cpu=True) t.model = Tiny() t.optimizer = torch.optim.SGD([p for p in t.model.parameters() if p.requires_grad], lr=0.1) - t.scheduler, t.use_metrics, t.global_step = None, False, 0 + t.scheduler, t.use_metrics, t.global_step, t.logger = None, False, 0, _Logger() t.model, t.optimizer, t.train_loader = t.accelerator.prepare(t.model, t.optimizer, loader) - t.train_epoch(accum=accum) + t.no_sync_calls = 0 + return t + + +def count_no_sync(t, enabled): + """Count the accelerator.no_sync calls; with ``enabled=False`` they do nothing (the all-reduce runs on every micro-batch).""" + real = t.accelerator.no_sync + + def no_sync(model): + t.no_sync_calls += 1 + return real(model) if enabled else contextlib.nullcontext() + + t.accelerator.no_sync = no_sync + + +def run(mode, micro, accum, no_sync=True): + t = build(micro) + count_no_sync(t, no_sync) + t.val = lambda: (0.0, {}) + t._save_model = lambda *args: None + if mode == "train_epoch": + t.train_epoch(accum=accum) + elif mode == "timm_cosine": + t.config = OmegaConf.create({"TrainerConfig": {"epochs": 2, "lr": 0.1, "save": False, "save_path": "unused"}}) + t._train_with_timm_cosine(OmegaConf.create({"warmup_epochs": 0, "warmup_lr": 0.0, "min_lr": 0.01, + "grad_accum_steps": accum, "log_every": 1000})) + else: + t.config = OmegaConf.create({"TrainerConfig": {"epochs": 1, "save_path": "unused"}}) + t._train_with_step_budget(OmegaConf.create({"grad_accum_steps": accum, "max_steps": 5, "save_every": 1000})) inner = t.accelerator.unwrap_model(t.model) assert "forward" not in inner.__dict__, "the inner forward was not restored" t.model.eval() + x, y, f = data() with torch.no_grad(): - val = t._compute_loss((x[:4], y[:4], f[:4]))["loss"].item() - return inner.head.weight.detach().clone(), t.global_step, val + t._compute_loss((x[:4], y[:4], f[:4])) + return inner.head.weight.detach().clone(), inner.head.bias.detach().clone(), t.global_step, t.no_sync_calls -def worker(rank, world, port, micro, accum, out): +def worker(rank, world, port, mode, micro, accum, no_sync, out): os.environ.update(RANK=str(rank), LOCAL_RANK=str(rank), WORLD_SIZE=str(world), MASTER_ADDR="127.0.0.1", MASTER_PORT=str(port)) - w, steps, val = run(micro, accum) - torch.save({"w": w, "steps": steps, "val": val}, f"{out}.{rank}") + w, b, steps, calls = run(mode, micro, accum, no_sync) + torch.save({"w": w, "b": b, "steps": steps, "calls": calls}, f"{out}.{rank}") def free_port(): @@ -82,21 +125,51 @@ def free_port(): return s.getsockname()[1] -def check(micro, accum, tmp): - ref_w, ref_steps, _ = run(N, 1) # single process, one batch of 16 - out = f"{tmp}/r{micro}_{accum}" - mp.spawn(worker, args=(2, free_port(), micro, accum, out), nprocs=2, join=True) +def ddp(mode, micro, accum, tmp, no_sync=True): + out = f"{tmp}/{mode}_{micro}_{accum}_{int(no_sync)}" + mp.spawn(worker, args=(2, free_port(), mode, micro, accum, no_sync, out), nprocs=2, join=True) r0, r1 = torch.load(f"{out}.0"), torch.load(f"{out}.1") - assert r0["steps"] == r1["steps"] == ref_steps == 1, (r0["steps"], r1["steps"], ref_steps) - assert torch.equal(r0["w"], r1["w"]), "the ranks diverged" - assert (r0["w"] - ref_w).abs().max() < 1e-6, (r0["w"], ref_w) + assert torch.equal(r0["w"], r1["w"]) and torch.equal(r0["b"], r1["b"]), f"{mode}: the ranks diverged" + assert r0["steps"] == r1["steps"] and r0["calls"] == r1["calls"] + return r0 + + +def close(a, b, what): + err = max((a["w"] - b["w"]).abs().max().item(), (a["b"] - b["b"]).abs().max().item()) + assert err < 1e-6, f"{what}: max difference {err}" + + +def single(mode, micro, accum): + w, b, steps, calls = run(mode, micro, accum) + return {"w": w, "b": b, "steps": steps, "calls": calls} def test_ddp_equals_single_process(): - import tempfile with tempfile.TemporaryDirectory() as tmp: - check(micro=4, accum=2, tmp=tmp) # 2 procs x 4 x 2 = 16 - check(micro=8, accum=1, tmp=tmp) # 2 procs x 8 x 1 = 16 + # train_epoch, no accumulation: 2 x 8 = 16 + ref = single("train_epoch", 16, 1) + got = ddp("train_epoch", 8, 1, tmp) + assert got["steps"] == ref["steps"] == 2 + close(got, ref, "train_epoch") + # train_epoch with accumulation (lr_step / FatFormer path): 2 procs x 4 x 2 = 16 + got = ddp("train_epoch", 4, 2, tmp) + assert got["steps"] == ref["steps"] == 2 + close(got, ref, "train_epoch with accumulation") + # timm_cosine with accumulation, 2 epochs x 2 steps: 2 procs x 4 x 2 = 16 + ref = single("timm_cosine", 16, 1) + assert ref["steps"] == 4 and ref["calls"] == 0 + assert single("timm_cosine", 4, 4)["steps"] == 4 + close(single("timm_cosine", 4, 4), ref, "timm_cosine, one process x 4 x 4") + with_sync = ddp("timm_cosine", 4, 2, tmp, no_sync=True) + without = ddp("timm_cosine", 4, 2, tmp, no_sync=False) + assert with_sync["steps"] == without["steps"] == 4 + assert with_sync["calls"] == 4 == 2 * 2 * (2 - 1), with_sync["calls"] # epochs x steps x non-stepping micro-batches + close(with_sync, ref, "timm_cosine, 2 procs x 4 x 2 vs one process x 16") + close(with_sync, without, "timm_cosine, with vs without no_sync") + # step_budget: 5 micro-batches of 8 (a final partial accumulation) = 3 optimizer steps + ref = single("step_budget", 8, 2) + got = ddp("step_budget", 4, 2, tmp) + close(got, ref, "step_budget with a partial last accumulation") if __name__ == "__main__": diff --git a/tests/test_waverep_smoke.py b/tests/test_waverep_smoke.py new file mode 100644 index 0000000000000000000000000000000000000000..fcb5a63c8f58a2c895e6ca3fefd87881782f93ab --- /dev/null +++ b/tests/test_waverep_smoke.py @@ -0,0 +1,352 @@ +"""Smoke test for the WaveRep integration (CPU, no downloads). + +Checks: +* the registry transform (``center_crop_504``, ``to_dtype``, ``normalize_imagenet``) is bit-exact with the official + ``create_transform(504)`` (vendored demo/utils.py: torchvision ``CenterCrop((504, 504))``, ``ToTensor``, ImageNet + ``Normalize``) on frames smaller than the crop (zero padding), non-square both ways and larger, +* ``media.cv2_frames`` yields exactly the frames of the official ``ReadVideoIteratorCV`` (same count and pixels, with + and without a limit) on a synthetic clip written with OpenCV, +* ``SynthScopeWaveRepModel``: the official timm model (``vit_base_patch14_reg4_dinov2``, one output) under + ``model.``; ``forward`` [B, 3, H, W] -> [B] finite logits = the official ``model(x)[:, -1]``; [B, T, ...] -> the + mean of its frame logits, independent of ``frame_batch``; a flat timm state dict and the Lightning + ``{"state_dict": {"model.*"}}`` form both load strictly through ``remap_waverep`` with identical outputs; + ``compute_loss`` (BCE with logits, outputs [-logit, logit]) + backward, +* the ``waverep`` / ``waverep_g4`` specs: official kind, 64 frames, cv2 sampler, sigmoid; the engine's + ``predict_video_clip`` is sigmoid(mean of the per-frame logits of the first 64 frames) and equals the official + ``evaluate`` on the official reader + transform (a tiny one-block ViT stands in for the 86M one); ``video_clip`` + stacks the same inputs; the input note; the ``synthscope`` API refuses a still image, +* with ``$SYNTHSCOPE_CKPT_DIR/waverep.pth`` / ``waverep_g4.pth`` (the released weights_dinov2_G{1,4}.ckpt): the engine + loads them strictly (0 missing / 0 unexpected, no transformers key translation) and every tensor equals the file's + (skipped otherwise). +The vendored official_utils.py (demo/utils.py) imports pandas and tqdm, which SynthScope does not depend on: without +them the official reader, transform and per-frame loop are compared in their written-out form instead. +""" + +from __future__ import annotations + +import dataclasses +import os +import sys +import tempfile + +import cv2 +import numpy as np +import timm +import torch +import torchvision.transforms as T +from omegaconf import OmegaConf +from PIL import Image + +ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) +sys.path[:0] = [ROOT, os.path.join(ROOT, "interface")] + +from backend import config as backend_config # noqa: E402 +from backend import media # noqa: E402 +from backend.engine import Engine, _load_checkpoint # noqa: E402 +from backend.hf_compat import translate_hf_keys # noqa: E402 +from backend.registry import get_spec, input_note, remap_waverep # noqa: E402 +from models.video.waverep.waverep import SynthScopeWaveRepModel # noqa: E402 +from synthscope.api import Detector # noqa: E402 +try: # the vendored official demo/utils.py imports pandas and tqdm, which SynthScope does not depend on + from models.video.waverep import official_utils as official # noqa: E402 +except ImportError as e: + official, OFFICIAL_MISSING = None, f"{type(e).__name__}: {e}" + +KEYS = ("waverep", "waverep_g4") +# A one-block ViT with the official layout (registers, one output) for fast CPU checks at the real 504 input. +TINY = {"embed_dim": 48, "depth": 1, "num_heads": 2} +# The official create_transform(504) (demo/utils.py), written out so the check runs without pandas. +OFFICIAL_TRANSFORM = T.Compose([T.CenterCrop((504, 504)), T.ToTensor(), + T.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])]) + + +def noise_image(size: tuple[int, int]) -> Image.Image: + gen = torch.Generator().manual_seed(size[0] * 7 + size[1]) + arr = torch.randint(0, 256, (size[1], size[0], 3), generator=gen, dtype=torch.uint8) + return Image.fromarray(arr.numpy(), "RGB") + + +def model_with(crop: int = 504, tiny: bool = True, frame_batch: int = 16) -> SynthScopeWaveRepModel: + cfg = OmegaConf.create({"ModelConfig": {"model_type": "waverep", "crop_size": crop, "frame_batch": frame_batch}}) + model = SynthScopeWaveRepModel(cfg) + if tiny: # the same timm class and key layout, one narrow block + model.model = timm.create_model("vit_base_patch14_reg4_dinov2", num_classes=1, pretrained=False, img_size=crop, + **TINY) + # timm starts the head at zero and DINOv2's LayerScale at 1e-5: give the random net an input-dependent output + torch.nn.init.normal_(model.model.head.weight, std=1.0) + for block in model.model.blocks: + block.ls1.gamma.data.fill_(1.0) + block.ls2.gamma.data.fill_(1.0) + return model.eval() + + +def write_clip(path: str, n: int, size=(160, 120)) -> None: + """A clip of ``n`` frames whose brightness encodes the frame number (OpenCV mp4v).""" + writer = cv2.VideoWriter(path, cv2.VideoWriter_fourcc(*"mp4v"), 8.0, size) + assert writer.isOpened(), "OpenCV cannot write mp4v" + rng = np.random.default_rng(0) + for i in range(n): + frame = np.full((size[1], size[0], 3), (i * 3) % 256, np.uint8) + frame[: size[1] // 2] = rng.integers(0, 256, (size[1] // 2, size[0], 3), dtype=np.uint8) + writer.write(frame) + writer.release() + + +def official_reader(path: str, limit=None): + """The official ReadVideoIteratorCV loop (demo/utils.py) written out: every cv2 frame, BGR -> RGB, PIL.""" + cap = cv2.VideoCapture(path) + idx = 0 + while cap.isOpened(): + ret, frame = cap.read() + if not ret: + break + yield Image.fromarray(cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)) + idx += 1 + if limit and idx >= limit: + break + cap.release() + + +@torch.no_grad() +def reference_logits(timm_model, clip: str, limit) -> torch.Tensor: + """Per-frame logits as the official demo computes them: the vendored ``evaluate`` (one frame at a time) on the + official reader + transform, or, without pandas, the same loop written out.""" + if official is not None: + reader = official.ReadVideoIteratorCV(clip, transform=official.create_transform(504), limit=limit) + return torch.tensor(official.evaluate(timm_model, reader, "cpu")["logit"].to_numpy(), dtype=torch.float64) + return torch.tensor([timm_model(OFFICIAL_TRANSFORM(f)[None])[0, -1].item() for f in official_reader(clip, limit)], + dtype=torch.float64) + + +def test_transform() -> None: + print("[A] registry transform == the official create_transform(504) ...") + tf = get_spec("waverep").transform + assert list(tf.transform_list) == ["center_crop_504", "to_dtype", "normalize_imagenet"] + assert get_spec("waverep_g4").transform is tf + goldens = [OFFICIAL_TRANSFORM] + ([official.create_transform(504)] if official is not None else []) + for size in [(298, 224), (256, 256), (503, 505), (504, 504), (512, 320), (672, 384), (1280, 720), (2160, 544)]: + img = noise_image(size) + x = tf(img) + assert x.shape == (3, 504, 504) and x.dtype == torch.float32, size + assert all(torch.equal(x, golden(img)) for golden in goldens), size # bit-exact, incl. the zero padding + print(f" 8 sizes equal the official torchvision v1 pipeline" + f"{'' if official is not None else ' (written out; vendored file skipped: ' + OFFICIAL_MISSING + ')'}") + + +def test_reader() -> None: + print("[B] media.cv2_frames == the official ReadVideoIteratorCV ...") + with tempfile.TemporaryDirectory() as tmp: + clip = os.path.join(tmp, "clip.mp4") + write_clip(clip, 70) + ours = list(media.cv2_frames(clip)) + vendored = official.ReadVideoIteratorCV if official is not None else None + ref = [f for _, f in vendored(clip)] if vendored else list(official_reader(clip)) + assert len(ours) == len(ref) == 70 + assert all(o.mode == "RGB" and np.array_equal(np.asarray(o), np.asarray(r)) for o, r in zip(ours, ref)) + limited = list(media.cv2_frames(clip, limit=64)) + ref64 = [f for _, f in vendored(clip, limit=64)] if vendored else list(official_reader(clip, 64)) + assert len(limited) == len(ref64) == 64 + assert all(np.array_equal(np.asarray(o), np.asarray(r)) for o, r in zip(limited, ref64)) + try: + list(media.cv2_frames(os.path.join(tmp, "missing.mp4"))) + raise AssertionError("a missing file must raise FileNotFoundError") + except FileNotFoundError: + pass + empty = os.path.join(tmp, "empty.mp4") + open(empty, "wb").close() + try: + list(media.cv2_frames(empty)) + raise AssertionError("an empty file must raise VideoDecodeError") + except media.VideoDecodeError: + pass + junk = os.path.join(tmp, "junk.mp4") + with open(junk, "wb") as fh: + fh.write(b"not a video") + try: + list(media.cv2_frames(junk)) + raise AssertionError("an unopenable file must raise OSError") + except OSError: + pass + print(" 70 frames bit-exact, limit 64 -> the first 64; missing -> FileNotFoundError, unopenable -> OSError, " + "empty -> VideoDecodeError") + + +def test_model_and_loader() -> None: + print("[C] model: official layout, forward, clips, strict loads, loss ...") + full = SynthScopeWaveRepModel(OmegaConf.create({"ModelConfig": {"model_type": "waverep"}})) + assert type(full.model).__name__ == "VisionTransformer" and full.model.num_reg_tokens == 4 + assert full.model.patch_embed.img_size == (504, 504) and full.model.head.out_features == 1 + assert sum(p.numel() for p in full.parameters()) > 80e6 + del full + torch.manual_seed(0) + model = model_with(crop=56, tiny=False) # the full ViT-B/14 at a 4x4 patch grid: quick on CPU + images = torch.randn(6, 3, 56, 56) + with torch.no_grad(): + logits = model(images) + assert torch.equal(logits, model.model(images)[:, -1]) + clip = model(images.view(2, 3, 3, 56, 56)) + model.frame_batch = 2 + clip2 = model(images.view(2, 3, 3, 56, 56)) + assert logits.shape == (6,) and torch.isfinite(logits).all() + assert clip.shape == (2,) and torch.allclose(clip, logits.view(2, 3).mean(dim=1), atol=1e-6) + assert torch.allclose(clip2, clip, atol=1e-6) + + flat = {k[len("model."):]: v.clone() for k, v in model.state_dict().items()} + lightning = {"state_dict": {"model." + k: v for k, v in flat.items()}, "epoch": 3} + for released in (flat, lightning): + restored = model_with(crop=56, tiny=False) + restored.load_state_dict(remap_waverep(released), strict=True) + with torch.no_grad(): + assert torch.equal(restored(images), logits) + + labels = torch.tensor([0, 1, 0, 1, 1, 0]) + model.train() + model.zero_grad() + out = model.compute_loss((images, labels)) + assert torch.isfinite(out["loss"]) and out["outputs"].shape == (6, 2) + assert torch.equal(out["outputs"][:, 0], -out["outputs"][:, 1]) + out["loss"].backward() + assert model.model.head.weight.grad is not None and model.model.patch_embed.proj.weight.grad is not None + print(f" {len(flat)} tensors, logits {tuple(logits.shape)}, clip mean (frame_batch 16 / 2), flat + Lightning " + f"strict loads, loss outputs (6, 2) + backward") + + +def test_strict_load_rejects_mismatch() -> None: + print("[C2] the strict official load raises on a dropped key, an extra key and a wrong shape ...") + spec = get_spec("waverep") + assert spec.ckpt_kind.startswith("official") + model = model_with(crop=56, tiny=False) + flat = {k[len("model."):]: v.clone() for k, v in model.state_dict().items()} + dropped = {k: v for k, v in flat.items() if k != "head.weight"} + extra = dict(flat, bogus=torch.zeros(1)) + reshaped = dict(flat, **{"head.weight": torch.zeros(2, flat["head.weight"].shape[1])}) + saved = backend_config.CHECKPOINTS_DIR + try: + with tempfile.TemporaryDirectory() as tmp: + backend_config.CHECKPOINTS_DIR = type(saved)(tmp) + path = os.path.join(tmp, spec.checkpoint) + torch.save(flat, path) + assert "(missing=0, unexpected=0)" in _load_checkpoint(model_with(crop=56, tiny=False), spec) # control + for name, sd, needle in (("dropped key", dropped, "missing=['model.head.weight']"), + ("extra key", extra, "unexpected=['model.bogus']"), + ("wrong shape", reshaped, "size mismatch")): + torch.save(sd, path) + try: + _load_checkpoint(model_with(crop=56, tiny=False), spec) + except RuntimeError as e: + assert needle in str(e), (name, str(e)[:300]) + else: + raise AssertionError(f"a {name} must make the strict official load raise") + finally: + backend_config.CHECKPOINTS_DIR = saved + print(" dropped key / extra key / wrong shape -> RuntimeError (control checkpoint loads strictly)") + + +def test_specs_and_engine() -> None: + print("[D] specs, engine video path == official evaluate, input note, API image guard ...") + for key in KEYS: + spec = get_spec(key) + assert spec.modality == "video" and spec.predict_kind == "video" and spec.ckpt_kind == "official_waverep" + assert (spec.video_sampler, spec.num_frames, spec.video_prob, spec.weights) == ("cv2_frames", 64, "sigmoid", + "official") + assert spec.overrides == ["model@ModelConfig=video/waverep"] and spec.remap is remap_waverep + assert (get_spec("waverep").checkpoint, get_spec("waverep_g4").checkpoint) == ("waverep.pth", "waverep_g4.pth") + note = input_note(get_spec("waverep")) + assert note["label"] == "The first 64 frames, center 504", note + assert input_note(dataclasses.replace(get_spec("waverep"), num_frames=0))["label"] == "Every frame, center 504" + + torch.manual_seed(0) + model = model_with() + engine = Engine(device="cpu") + with tempfile.TemporaryDirectory() as tmp: + clip = os.path.join(tmp, "clip.mp4") + write_clip(clip, 70, size=(640, 480)) + for spec, n in ((get_spec("waverep"), 64), (dataclasses.replace(get_spec("waverep"), key="waverep_all", + num_frames=0), 70)): + engine._cache[spec.key] = model + ref = reference_logits(model.model, clip, spec.num_frames or None) # the official takes the timm model + assert len(ref) == n + logits = engine.video_frame_logits(spec, clip) + assert logits.shape == (n,) + assert torch.allclose(logits.double(), ref, atol=1e-5), spec.key + res = engine.predict_video_clip(spec, clip) + want = float(torch.sigmoid(ref.mean())) + assert res["num_frames"] == n and abs(res["fake_probability"] - round(want, 6)) < 2e-6, (res, want) + print(f" {n} frames: official logits mean {ref.mean():.4f} std {ref.std():.4f}") + assert ref.std() > 0.01 # frames score differently (a non-trivial comparison) + assert abs(res["logit"] - float(ref.mean())) < 1e-5 + stacked = engine.video_clip(spec, clip) + assert stacked.shape == (n, 3, 504, 504) + assert torch.equal(stacked[0], get_spec("waverep").transform(next(media.cv2_frames(clip)))) + with torch.no_grad(): # the generic clip path (model(clip) -> mean) agrees + p = engine._video_fake_prob(model, spec, stacked) + assert abs(float(p) - want) < 1e-5 + broken = os.path.join(tmp, "broken.mp4") + with open(broken, "wb") as fh: + fh.write(b"not a video" * 100) + try: + engine.predict_video_clip(get_spec("waverep"), broken) + except OSError as e: # an unopenable file is an I/O error, not a decode verdict + assert "could not open" in str(e) and not isinstance(e, media.VideoDecodeError), e + else: + raise AssertionError("a broken clip was scored") + empty = os.path.join(tmp, "empty0.mp4") + open(empty, "wb").close() + try: + engine.predict_video_clip(get_spec("waverep"), empty) + except media.VideoDecodeError as e: # a 0-byte file is a (cached) decode failure + assert "empty" in str(e), e + else: + raise AssertionError("an empty clip was scored") + try: + engine.predict_video_clip(get_spec("waverep"), os.path.join(tmp, "missing.mp4")) + except FileNotFoundError: + pass + else: + raise AssertionError("a missing clip was scored") + open(os.path.join(tmp, "waverep.pth"), "wb").close() + api = Detector(get_spec("waverep"), checkpoint=os.path.join(tmp, "waverep.pth"), device="cpu") + try: + api.predict(noise_image((300, 200))) + except ValueError as e: + assert "video-only detector" in str(e), e + else: + raise AssertionError("waverep scored a still image") + ref_name = "evaluate" if official is not None else "loop (written out)" + print(f" 64 / 70 frame logits == official {ref_name}, P(fake) {res['fake_probability']:.4f}; note " + f"'{note['label']}'; broken clip -> error; API image guard") + + +def test_released_checkpoints() -> None: + ckpt_dir = os.environ.get("SYNTHSCOPE_CKPT_DIR", "") + if not all(os.path.isfile(os.path.join(ckpt_dir, get_spec(k).checkpoint)) for k in KEYS): + print("[E] released checkpoints: skipped ($SYNTHSCOPE_CKPT_DIR/waverep.pth, waverep_g4.pth not found)") + return + print("[E] released checkpoints: strict engine load, every tensor equal ...") + saved = backend_config.CHECKPOINTS_DIR + backend_config.CHECKPOINTS_DIR = type(saved)(ckpt_dir) + try: + for key in KEYS: + spec = get_spec(key) + model = SynthScopeWaveRepModel(OmegaConf.create({"ModelConfig": {"model_type": "waverep"}})) + status = _load_checkpoint(model, spec) + assert "(missing=0, unexpected=0)" in status and "translated" not in status, status + released = torch.load(os.path.join(ckpt_dir, spec.checkpoint), map_location="cpu", weights_only=False) + sd = model.state_dict() + assert translate_hf_keys(remap_waverep(released), sd)[1] == "" + assert set(sd) == {"model." + k for k in released} + assert all(torch.equal(sd["model." + k], v) for k, v in released.items()) + print(f" {key}: {status}") + finally: + backend_config.CHECKPOINTS_DIR = saved + + +if __name__ == "__main__": + torch.set_num_threads(min(8, os.cpu_count() or 1)) + test_transform() + test_reader() + test_model_and_loader() + test_strict_load_rejects_mismatch() + test_specs_and_engine() + test_released_checkpoints() + print("OK") diff --git a/trainer.py b/trainer.py index a7452c2256e1b7780048939958e3dbbc8e2509f2..85918315634eb6ca166ab1a5676a4d112965bcc9 100644 --- a/trainer.py +++ b/trainer.py @@ -23,11 +23,13 @@ from models.image.bfree.bfree import SynthScopeBFreeModel from models.image.d3qe.d3qe import SynthScopeD3QEModel from models.image.ltf.ltf import SynthScopeLTFModel from models.image.mirror.mirror import SynthScopeMIRRORModel +from models.image.probe.probe import SynthScopePROBEModel, SynthScopePROBEResNetModel from models.image.vina.vina import SynthScopeVINAModel from models.video.d3.d3 import SynthScopeD3Model from models.video.split.split import SynthScopeSPLITModel from models.video.restrav.restrav import SynthScopeReStraVModel from models.video.stall.stall import SynthScopeSTALLModel +from models.video.waverep.waverep import SynthScopeWaveRepModel from metrics import AIGIMetrics from dataset import AIGIDatasetModule from omegaconf import DictConfig @@ -35,6 +37,7 @@ from accelerate import Accelerator from transformers import get_scheduler from timm.scheduler.cosine_lr import CosineLRScheduler import json +from contextlib import nullcontext import os from logger import build_logger from tqdm import tqdm @@ -42,6 +45,10 @@ from tqdm import tqdm class SynthScopeModelTrainer: def __init__(self, config: DictConfig, dataset_module: AIGIDatasetModule): self.model = self._build_model(config) + # TrainerConfig.sync_batchnorm: batch statistics over all processes' micro-batches (a recipe whose official + # per-GPU batch does not fit one GPU keeps the BatchNorm batch it was tuned with). Only in a multi-process run. + if config.TrainerConfig.get("sync_batchnorm", False) and int(os.environ.get("WORLD_SIZE", "1")) > 1: + self.model = torch.nn.SyncBatchNorm.convert_sync_batchnorm(self.model) self.optimizer = torch.optim.AdamW( self._param_groups(config), lr=config.TrainerConfig.lr, @@ -124,6 +131,10 @@ class SynthScopeModelTrainer: return SynthScopeMIRRORModel(config) if model_type == "vina": return SynthScopeVINAModel(config) + if model_type == "probe": + return SynthScopePROBEModel(config) + if model_type == "probe_resnet": + return SynthScopePROBEResNetModel(config) if model_type == "d3": return SynthScopeD3Model(config) if model_type == "split": @@ -132,6 +143,8 @@ class SynthScopeModelTrainer: return SynthScopeReStraVModel(config) if model_type == "stall": return SynthScopeSTALLModel(config) + if model_type == "waverep": + return SynthScopeWaveRepModel(config) if model_type == "cnn": return SynthScopeCNNModel(config) if model_type == "adapted_dino": @@ -151,7 +164,13 @@ class SynthScopeModelTrainer: def _param_groups(self, config): """The trainable parameters; with ``TrainerConfig.no_weight_decay_1d`` the biases and 1-D parameters (norms, ...) - get no weight decay, as in the BEiT/MFM-style fine-tuning optimizers (SPAI's ``get_finetune_param_groups``).""" + get no weight decay, as in the BEiT/MFM-style fine-tuning optimizers (SPAI's ``get_finetune_param_groups``). A model + with an ``optimizer_param_groups()`` method that returns groups (e.g. CuRe stage 1: its own weight decay for the + LoRA tensors and for the head) uses those.""" + model_groups = getattr(self.model, "optimizer_param_groups", None) + groups = model_groups() if callable(model_groups) else None + if groups is not None: + return groups if not config.TrainerConfig.get("no_weight_decay_1d", False): return self._filter_trainable_parameters() named = [(n, p) for n, p in self.model.named_parameters() if p.requires_grad] @@ -334,7 +353,7 @@ class SynthScopeModelTrainer: real = [v for k, v in metrics_dict.items() if k.startswith("real_accuracy")] fake = [v for k, v in metrics_dict.items() if k.startswith("fake_accuracy")] if not real or not fake: - raise ValueError("the plateau schedule needs metrics=[real_accuracy,fake_accuracy]") + raise ValueError("validation accuracy (the plateau schedule, timm_cosine select: accuracy) needs metrics=[real_accuracy,fake_accuracy]") return (sum(real) / len(real) + sum(fake) / len(fake)) / 2 def _train_with_plateau(self, plateau): @@ -432,8 +451,12 @@ class SynthScopeModelTrainer: self.optimizer.zero_grad() while step < max_steps: for batch in tqdm(self.train_loader, desc="Training"): - loss = self.train_step(batch) - self.accelerator.backward(loss / accum) + # the micro-batches that do not step skip the DDP gradient all-reduce (a null context off DDP); the last + # micro-batch of the budget syncs, so a final partial accumulation is reduced too + at_step = (step + 1) % accum == 0 or step + 1 >= max_steps + with (nullcontext() if at_step else self.accelerator.no_sync(self.model)): + loss = self.train_step(batch) + self.accelerator.backward(loss / accum) running += loss.detach().item() step += 1 if step % accum == 0: @@ -468,42 +491,64 @@ class SynthScopeModelTrainer: schedule counts official steps, so a smaller GPU follows the same LR curve. Validation after every epoch; as in the official code, a checkpoint is kept whenever the validation loss improves (``model_.pth``, the selected one also as ``model_best.pth``; ``save_all`` keeps every epoch, as the official ``--save-all``), plus - ``model_last.pth``; the losses go to ``val_losses.json``. After + ``model_last.pth``; the losses go to ``val_losses.json``. With ``select: accuracy`` the selected epoch is the + first with the highest validation accuracy instead (AIDE's ``max_accuracy``; needs ``metrics=[real_accuracy, + fake_accuracy]``, a balanced validation set makes it the plain accuracy), and the accuracies are logged to + ``val_losses.json`` as ``val_accuracy``. After every epoch the full training state (model, optimizer, loss scaler, RNGs) is saved to ``/train_state``, - and a rerun with the same ``save_path`` resumes after the last finished epoch (runs longer than a job limit).""" + and a rerun with the same ``save_path`` resumes after the last finished epoch (runs longer than a job limit). + With ``warmup_prefix: true`` the cosine starts after the warmup, from the peak lr (MAE-style "N warmup epochs, + then cosine to min_lr", e.g. CuRe); by default (SPAI) the warmup overlaps the start of one cosine over all steps. + ``log_every`` (default 100) is the number of optimizer steps between loss / lr lines (the first step is logged).""" cfg = self.config.TrainerConfig accum = int(sched.get("grad_accum_steps", 1)) n_iter = len(self.train_loader) // accum - scheduler = CosineLRScheduler(getattr(self.optimizer, "optimizer", self.optimizer), t_initial=int(cfg.epochs * n_iter), + warmup_t = int(float(sched.warmup_epochs) * n_iter) + prefix = bool(sched.get("warmup_prefix", False)) + scheduler = CosineLRScheduler(getattr(self.optimizer, "optimizer", self.optimizer), + t_initial=int(cfg.epochs * n_iter) - (warmup_t if prefix else 0), lr_min=float(sched.min_lr), warmup_lr_init=float(sched.warmup_lr), - warmup_t=int(float(sched.warmup_epochs) * n_iter), cycle_limit=1, t_in_epochs=False) + warmup_t=warmup_t, warmup_prefix=prefix, cycle_limit=1, t_in_epochs=False) save_all = bool(sched.get("save_all", False)) + log_every = int(sched.get("log_every", 100)) # optimizer steps between loss / lr lines + micro = self.train_loader.batch_sampler.batch_size # DataLoaderShard.batch_size is None after prepare() + self.accelerator.print(f"timm_cosine: {len(self.train_loader)} micro-batches per process and epoch -> {n_iter} optimizer steps per epoch " + f"({self.accelerator.num_processes} processes x micro-batch {micro} x accumulation {accum} " + f"= effective batch {self.accelerator.num_processes * micro * accum}), " + f"lr {cfg.lr} -> {sched.min_lr} over {cfg.epochs} epochs") history, start = [], 0 # validation loss per epoch; None where it was not measured on this validation set + by_accuracy = str(sched.get("select", "loss")) == "accuracy" + accuracies = [] # validation accuracy per epoch (select: accuracy) state_dir, log_path = f"{cfg.save_path}/train_state", f"{cfg.save_path}/val_losses.json" if cfg.save and os.path.isfile(f"{state_dir}/progress.json"): with open(f"{state_dir}/progress.json") as f: progress = json.load(f) self.accelerator.load_state(state_dir) history, start = progress["val_loss"], progress["epoch"] + 1 + accuracies = progress.get("val_accuracy", []) self.global_step = start * n_iter self.accelerator.print(f"Resuming after epoch {progress['epoch']}") measured = lambda: [v for v in history if v is not None] best = min(measured(), default=float("inf")) + best_accuracy = max(accuracies, default=float("-inf")) for epoch in range(start, cfg.epochs): self.model.train() self.optimizer.zero_grad() total, k = 0.0, 0 for idx, batch in enumerate(tqdm(self.train_loader, desc=f"Training epoch {epoch}")): - loss = self.train_step(batch) - self.accelerator.backward(loss / accum) + at_step = (idx + 1) % accum == 0 + # the micro-batches that do not step skip the DDP gradient all-reduce (a null context off DDP) + with (nullcontext() if at_step else self.accelerator.no_sync(self.model)): + loss = self.train_step(batch) + self.accelerator.backward(loss / accum) total += loss.detach().item() - if (idx + 1) % accum == 0: + if at_step: self.optimizer.step() self.optimizer.zero_grad() scheduler.step_update(epoch * n_iter + k) k += 1 self.global_step += 1 - if k % 100 == 0: + if k == 1 or k % log_every == 0: self.accelerator.print(f"epoch {epoch} step {k}/{n_iter}: loss {total / (idx + 1):.4f}, " f"lr {self.optimizer.param_groups[0]['lr']:.3e}") if k == n_iter: @@ -514,20 +559,29 @@ class SynthScopeModelTrainer: best_epoch = history.index(min(measured())) self.accelerator.print(f"Epoch {epoch}, Val Loss: {val_loss:.4f} (best {history[best_epoch]:.4f} at epoch {best_epoch}), " f"Val Metrics: {val_metrics_dict}") + if by_accuracy: + accuracies.append(self._val_accuracy(val_metrics_dict)) + improved = accuracies[-1] > best_accuracy # strictly greater: the earliest of equal epochs, as AIDE + best_accuracy = max(accuracies) + best_epoch = accuracies.index(best_accuracy) + self.accelerator.print(f"Epoch {epoch}, Val Accuracy: {accuracies[-1]:.4f} (best {best_accuracy:.4f} at epoch {best_epoch})") + else: + improved = val_loss < best if cfg.save: self._save_model("last", cfg.save_path) - if save_all or val_loss < best: # the official --save-all keeps every epoch + if save_all or improved: # the official --save-all keeps every epoch self._save_model(epoch, cfg.save_path) - if val_loss < best: - best = val_loss + if improved: + best = min(best, val_loss) self._save_model("best", cfg.save_path) if self.accelerator.is_main_process: with open(log_path, "w") as f: - json.dump({"val_loss": history, "best_epoch": best_epoch}, f, indent=1) + json.dump({"val_loss": history, **({"val_accuracy": accuracies} if by_accuracy else {}), + "best_epoch": best_epoch}, f, indent=1) self.accelerator.save_state(state_dir) if self.accelerator.is_main_process: with open(f"{state_dir}/progress.json", "w") as f: - json.dump({"epoch": epoch, "val_loss": history}, f) + json.dump({"epoch": epoch, "val_loss": history, "val_accuracy": accuracies}, f) self.logger.finish() def train(self): diff --git a/transformations.py b/transformations.py index db91f1154fd3c676b027a3ddad58c2805900654e..e0e8221388ce6dbf1ee642f63eb66a7ff6975dc3 100644 --- a/transformations.py +++ b/transformations.py @@ -18,13 +18,14 @@ from models.image.effort.preprocess import Cv2SquareResize from models.image.ltf.preprocess import LTFViews from models.image.mirror.preprocess import MirrorEvalTransform from models.image.moejepa.preprocess import VJEPA2ImageTransform +from models.image.probe.preprocess import ProbePad, SlidingPatches IMAGENET_MEAN, IMAGENET_STD = [0.485, 0.456, 0.406], [0.229, 0.224, 0.225] CLIP_MEAN, CLIP_STD = [0.48145466, 0.4578275, 0.40821073], [0.26862954, 0.26130258, 0.27577711] DINOV3_MEAN, DINOV3_STD = [0.430, 0.411, 0.296], [0.213, 0.156, 0.143] SQUARE_RESIZES = (224, 256, 336, 512) # resize_: both sides to n (aspect not kept) SHORT_RESIZES = (256, 384, 448) # resize_short_: shorter side to n -CROPS = (224, 256, 336, 384, 448) # center_crop_ (zero-padded when the image is smaller) +CROPS = (224, 256, 336, 384, 448, 504) # center_crop_ (zero-padded when the image is smaller) # The sized resize / crop names and their allowed sizes; a resize may end in "_bicubic" (default: bilinear). _SIZED = re.compile(r"(resize_short|resize|center_crop)_([1-9]\d*)(_bicubic)?") _SIZES = {"resize_short": SHORT_RESIZES, "resize": SQUARE_RESIZES, "center_crop": CROPS} @@ -117,6 +118,44 @@ class ToFloat: return "ToFloat()" +class AIDEPerturbation: + """AIDE's training perturbations (official ``data/datasets.py``): ``Perturbations = ImageSequential(RandomGaussianBlur( + (3, 3), sigma=(0.1, 3.0), p=0.1), RandomJPEG((30, 100), p=0.1))`` from kornia, applied to the ``ToTensor`` image at + NATIVE resolution before the DCT patch selection. ``kind`` is ``"blur"`` or ``"jpeg"``: the two steps are separate + transform names (``aide_blur``, ``aide_jpeg``), and in this order they draw the same random numbers as the + sequential container (tests/test_model_transforms.py checks it). Takes a PIL image or a uint8 / float ``[3, H, W]`` + tensor and returns a float ``[3, H, W]`` tensor in [0, 1]. + + kornia's JPEG codec raises on a side that is not a multiple of 16, which most ImageNet reals are (500x375, ...): the + official code would crash on those images, so a selected image is edge-padded to a multiple of 16 and cropped back + after the codec (a JPEG encoder pads the same way), and an image whose sides are multiples of 16 is untouched. + kornia (the official ``kornia==0.7.2``) is imported when the step is built, so only AIDE training needs it.""" + + def __init__(self, kind: str): + if kind not in ("blur", "jpeg"): + raise ValueError(f"AIDEPerturbation kind must be 'blur' or 'jpeg', got {kind!r}") + import kornia.augmentation as K + self.kind = kind + self.aug = (K.RandomGaussianBlur(kernel_size=(3, 3), sigma=(0.1, 3.0), p=0.1) if kind == "blur" + else K.RandomJPEG(jpeg_quality=(30, 100), p=0.1)) + + def __call__(self, image): + if isinstance(image, Image.Image): + x = TF.to_tensor(image) + else: # uint8 tensor: exactly ToTensor's /255; float: unchanged + x = image.float().div(255) if image.dtype == torch.uint8 else image + if self.kind == "jpeg": + h, w = x.shape[-2:] + pad_h, pad_w = -h % 16, -w % 16 + if pad_h or pad_w: + x = torch.nn.functional.pad(x[None], (0, pad_w, 0, pad_h), mode="replicate")[0] + return self.aug(x)[0, :, :h, :w].contiguous() + return self.aug(x)[0] + + def __repr__(self): + return f"AIDEPerturbation({self.kind!r})" + + class TranslateDuplicate: """``translate_duplicate_``: a PIL image whose shorter side is below ``size`` is tiled with copies of itself until both sides reach ``size`` (ceil(size / side) copies per axis, pasted from the top-left corner); larger images pass unchanged. @@ -231,6 +270,10 @@ class AIGITransformations: return v2.RandomApply([v2.ColorJitter(brightness=0.15, contrast=0.15, saturation=0.15, hue=0.05)], p=0.2) elif transform_name == "random_mask_safe": return RandomMask(ratio=(0.0, 0.75), patch_size=16, p=0.5) + elif transform_name in ("aide_blur", "aide_jpeg"): + # AIDE training: kornia Gaussian blur (3x3, sigma 0.1-3, p 0.1) then JPEG (QF 30-100, p 0.1) at native + # resolution, as the official Perturbations; goes before aide_five_view_train. + return AIDEPerturbation(transform_name.removeprefix("aide_")) elif transform_name == "aide_five_view": # AIDE native-resolution 5-view preprocessing: PIL/tensor -> [5,3,256,256] (DCT patch # selection at native res, then resize the selected patches). Must be the LAST transform. @@ -257,6 +300,15 @@ class AIGITransformations: return VJEPA2ImageTransform() elif transform_name == "ltf_views": # LTF: global view + native-res 224 tiles, [1 + tiles, 3, 224, 224] return LTFViews() + # PROBE (official evaluate_dino.py / evaluate_resnet.py): pad_image to the crop size ('repeat' tiles a small + # image with copies of itself, 'pad' pastes it on a black square), then the normalized image's non-overlapping + # patches. + elif transform_name == "probe_pad_repeat_336": # PIL out + return ProbePad(336, "repeat") + elif transform_name == "probe_pad_224": # PIL out + return ProbePad(224, "pad") + elif transform_name in ("sliding_patches_336", "sliding_patches_224"): # [3, H, W] -> [N, 3, n, n] + return SlidingPatches(int(transform_name.rsplit("_", 1)[1])) else: raise ValueError(f"Invalid transform name: {transform_name}")