Files
remove-ai-watermarks/scripts/openai_provenance_check.py
Victor Kuznetsov 16bc9879e9 Ship chroma-zimage: Apache-2.0 Chroma1 global stage with measured four-cohort oracle floors
Extract TwoStageZImagePipeline shared base from QwenZImagePipeline so all three
profiles are siblings, not a chain. Add ChromaZImagePipeline on that base with
diffusers ChromaImg2ImgPipeline bf16, neutral calibrated prompt, guidance 5.0,
four effective steps with Diffusers truncation compensation, no Canny.
Flat vendor floors from the 2026-08-29/30 oracle calibration across OpenAI
(0.09), Microsoft InvisMark (0.125), Google (0.40), Meta Content Seal (0.17),
seed-stability verified on Meta, full-path face-stage interaction clean through
the Gemini oracle. Research record in docs/chroma1-engine-research.md with the
matched-strength addendum showing Chroma1 regenerates better per unit strength
but its boundaries scatter wider than qwen's. Fix text-manifest guard to reject
chroma-zimage at the boundary, update all profile references from 'both' to
'all three' across src, docs, README, and python-api.
2026-08-30 16:37:20 -07:00

77 lines
2.2 KiB
Python
Executable File

#!/usr/bin/env python3
"""One-shot OpenAI Content Provenance oracle check per file.
Usage: python3 scripts/openai_provenance_check.py FILE [FILE...]
Prints ``basename<TAB>synthid_outcome`` per file (DETECTED / NOT_DETECTED).
Reads OPENAI_API_KEY from the environment or the main checkout's .env.
This is the documented programmatic twin of openai.com/verify and reports the
SynthID and C2PA outcomes separately, which the web page collapses.
"""
from __future__ import annotations
import json
import os
import pathlib
import sys
import urllib.request
import uuid
API_URL = "https://api.openai.com/v1/content_provenance_checks"
def _api_key() -> str:
key = os.environ.get("OPENAI_API_KEY")
if key:
return key
env_file = pathlib.Path.home() / "Documents/GitHub/remove-ai-watermarks/.env"
if env_file.exists():
for line in env_file.read_text().splitlines():
if line.startswith("OPENAI_API_KEY="):
return line.split("=", 1)[1].strip()
raise SystemExit("no OPENAI_API_KEY in env and no main-checkout .env")
def check(path: pathlib.Path) -> str:
boundary = uuid.uuid4().hex
payload = path.read_bytes()
body = b"".join(
(
f"--{boundary}\r\n"
f'Content-Disposition: form-data; name="file"; filename="{path.name}"\r\n'
"Content-Type: image/png\r\n\r\n".encode(),
payload,
f"\r\n--{boundary}--\r\n".encode(),
)
)
request = urllib.request.Request(
API_URL,
data=body,
headers={
"Authorization": f"Bearer {_api_key()}",
"Content-Type": f"multipart/form-data; boundary={boundary}",
},
)
with urllib.request.urlopen(request, timeout=120) as response:
data = json.load(response)
for entry in data.get("results", []):
if entry.get("type") == "synthid":
return str(entry.get("outcome", "?")).upper()
return "NO_SYNTHID_ENTRY"
def main() -> None:
for name in sys.argv[1:]:
path = pathlib.Path(name)
try:
outcome = check(path)
except Exception as exc:
outcome = f"ERROR:{exc}"
print(f"{path.name}\t{outcome}", flush=True)
if __name__ == "__main__":
main()