mirror of
https://github.com/wiltodelta/remove-ai-watermarks.git
synced 2026-08-31 01:30:35 +02:00
Tiled diffusion was never provider-oracle calibrated with verified text restoration: the tiled VAE donor path ran anyway and produced results no oracle had certified. The combination is now rejected at both the pipeline and the engine seam (ValueError with the reason), and the CLI help no longer implies support. The invisible help is generalized and the metadata container list corrected (MKA/OGA/Opus/AAC). scripts/contentseal_transforms.py reproduces the deterministic crop, resize, and JPEG variants of the Content Seal corpus from manifest.csv, hash-verifying every output; its README gains scripts/README.md context and new data tests. The corpus README is honest about the one crop the daily oracle limit left unchecked, and the eval CSVs carry the updated verdicts. The byte-scan SynthID suppression hoists its soft-binding lookup so the guard is computed once. Staged on top of 0.33.1; no version bump in this commit.
70 lines
2.6 KiB
Python
70 lines
2.6 KiB
Python
"""Tests for the Content Seal oracle corpus layout.
|
|
|
|
Mirrors the synthid corpus guard: the manifest is the source of truth for
|
|
which binaries exist, and every recorded hash must match the file it names.
|
|
Derived rows are recipes, not stored files, so only originals are checked
|
|
against disk.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import csv
|
|
import hashlib
|
|
import re
|
|
from pathlib import Path
|
|
|
|
CORPUS_DIR = Path(__file__).resolve().parent.parent / "data" / "contentseal"
|
|
MANIFEST = CORPUS_DIR / "manifest.csv"
|
|
ORIGINALS = CORPUS_DIR / "originals"
|
|
|
|
_SHA256 = re.compile(r"^[0-9a-f]{64}$")
|
|
_VALID_VERDICTS = {"detected", "not_detected", ""}
|
|
_VALID_ORIGINS = {"meta-model-api", "derived", "meta-blog-cdn", "synthetic-local"}
|
|
|
|
|
|
def _manifest_rows() -> list[dict[str, str]]:
|
|
with open(MANIFEST, newline="") as f:
|
|
return list(csv.DictReader(f))
|
|
|
|
|
|
def test_manifest_original_rows_match_binaries_and_hashes() -> None:
|
|
rows = [r for r in _manifest_rows() if r["file"]]
|
|
stored = {path.name for path in ORIGINALS.iterdir() if path.is_file()}
|
|
assert {r["file"].removeprefix("originals/") for r in rows} == stored
|
|
|
|
for row in rows:
|
|
digest = hashlib.sha256((CORPUS_DIR / row["file"]).read_bytes()).hexdigest()
|
|
assert digest == row["sha256"], row["file"]
|
|
|
|
|
|
def test_manifest_rows_are_well_formed() -> None:
|
|
rows = _manifest_rows()
|
|
assert len({row["sha256"] for row in rows}) == len(rows), "duplicate sha256"
|
|
|
|
for row in rows:
|
|
assert _SHA256.match(row["sha256"]), row["name"]
|
|
assert row["origin"].split(":")[0] in _VALID_ORIGINS, row["name"]
|
|
assert row["oracle_verdict"] in _VALID_VERDICTS, row["name"]
|
|
# Every oracle verdict must carry its check timestamp.
|
|
if row["oracle_verdict"]:
|
|
assert row["checked_at_utc"], row["name"]
|
|
# Detection rows must name the oracle attribution.
|
|
if row["oracle_verdict"] == "detected":
|
|
assert "Muse Image 1" in row["oracle_attribution"], row["name"]
|
|
|
|
|
|
def test_default_pipeline_clearance_is_recorded() -> None:
|
|
"""The verified claim that the default profile clears Content Seal must stay."""
|
|
rows = {row["name"]: row for row in _manifest_rows()}
|
|
for name in ("fox_modal_invisible", "text_modal_invisible"):
|
|
assert rows[name]["oracle_verdict"] == "not_detected", name
|
|
|
|
|
|
def test_deterministic_transforms_reproduce_recorded_hashes(tmp_path: Path) -> None:
|
|
from scripts.contentseal_transforms import reproduce_transforms
|
|
|
|
outputs = reproduce_transforms(tmp_path)
|
|
|
|
assert len(outputs) == 8
|
|
assert all(path.is_file() for path in outputs)
|