Spaces:
Sleeping
Download docs/ADD_DETECTOR.md from SMSD75/SynthScope: direct link, hf CLI and curl.
- Browser
- Download file 4.31 kB
-
https://huggingface.co/spaces/SMSD75/SynthScope/resolve/main/docs/ADD_DETECTOR.md
- Command line
-
hf download hf://spaces/SMSD75/SynthScope/docs/ADD_DETECTOR.md
-
curl -L -o ADD_DETECTOR.md https://huggingface.co/spaces/SMSD75/SynthScope/resolve/main/docs/ADD_DETECTOR.md
Adding a detector to SynthScope (the repo rules)
This is the checklist to follow (for people and for the daily arXiv agent) to incorporate a new AI-generated-content detector cleanly and verify that SynthScope reproduces the paper's results. Keep the code style and structure consistent with the existing detectors (PGC, SAFE, Co-Spy, AIDE, β¦).
When to integrate
Only integrate a paper that satisfies both rules: (1) a solid public GitHub repo, and (2) solid results vs previous methods. If the architecture is unclear, weights aren't released, or the benchmark data can't be obtained, do not commit broken code β note "integration pending: " for the maintainers and stop.
Files to add (one detector = key <k>, e.g. pgc)
models/<modality>/<k>/<k>.pyβclass SynthScope<Name>Model(nn.Module):__init__(self, config: DictConfig)β build the architecture; respectconfig.ModelConfig.forward(self, images) -> logitsβ raw logits (NOT probabilities). Do model-specific preprocessing (e.g. residual/DWT/DCT) inside forward where the official model does.compute_loss(self, batch) -> {"loss", "outputs"}β used by training.- Imports + helper classes at module top-level (repo rule: no nested defs/imports).
- Add
models/<modality>/<k>/__init__.pyand aREADME.md(see structure below).
conf/model/image/<k>.yaml(orvideo/):defaults: [/model/default, _self_], thenmodel_type: <k>plus any model knobs. Addconf/dataset/.../conf/trainer/...only if a new recipe is needed.- Dispatch β add a branch in
trainer.py_build_model(theif model_type == "<k>": return SynthScope<Name>Model(config)chain, ~line 69+). The interface lazy-imports bymodel_typeininterface/backend/engine.pyβ mirror it if needed. - Interface registry β
interface/backend/registry.py_add(ModelSpec(...)):key,name,paper,modality(image|video),overrides=["model@ModelConfig=image/<k>"],predict_kind:ce(logitsβsoftmax[:,1]),bce(sigmoid),bce_npr,vib, orvideo,checkpoint="<k>.pth",ckpt_kind:synthscope(our trained weights, strict load) orofficial_<k>+ aremap=remap_<k>function (rename official keys β our module names) for the authors' released weights,transform: the eval preprocessing β match the official eval exactly (resize vs crop, norm vs none). Add atf_*helper if needed. (Getting this wrong silently tanks results β see SAFE: a resize destroyed the high-freq signal.)weights:"official"|"synthscope_trained"|"training_free"(shown in the web UI badge).
- Per-model
README.mdβ mirrormodels/image/pgc/README.md: short method explanation + official-repo/paper links, the pipeline, "SynthScope adaptations", and a results table in the Paper / SynthScope_official / SynthScope_train schema.
Verify reproduction (required)
Run the detector on the paper's own benchmark(s) and compare to the paper's reported numbers:
python benchmark/bench_eval.py --model <k> --benchmark {forensynths|ufd|pergen|pool} --data <root> \
--ckpt <official-or-trained.pth> --bs 32 --device cuda --tag <k>_repro
- Loading official weights with
--ckptchecks architecture fidelity (should match the paper). - Mismatched
load_state_dictkeys β write aremap_<k>; near-chance/all-fake β check the transform (preprocessing) and the head-name mapping first. - Record per-generator AP/AUROC; update
repro/AGGREGATED_BENCHMARK.md,repro/RESULTS_SUMMARY.md, the repo README table, and the per-model README β all in the Paper / SynthScope_official / SynthScope_train schema.
Git workflow (keep main clean)
- Do the integration on a branch:
git checkout -b detector/<k>. Commit the model + conf + registry + README + repro results. Push the branch and surface it for review β do NOT auto-merge tomain. - End commit messages with the repo's
Co-Authored-Bytrailer. - Never commit weights (
*.pth),.env, or caches (already gitignored).
Tests
Add a smoke test under tests/ like tests/test_<k>_smoke.py (mirror tests/test_aide_smoke.py):
build the model, run a dummy forward, assert output shape + finite logits.