Whole file
guillaumemeyer/watermarks-remover
The author described this change as “fix: macOS portability — pure --json stdout for the SynthID scorer, BSD realpath probe (#70)”. It counts as a record because the check below fails on the code as it stood at 1eeda9be8 and passes on 97c32d58f, with nothing else changed between the two runs.
Fix saved2026-08-15
Sharing licenceMIT · LICENSE
Change size+11 −6
What the code was meant to do, written into the code itself as a save note
fix: macOS portability — pure --json stdout for the SynthID scorer, BSD realpath probe (#70)
The change
| 16 | 16 | from __future__ import annotations | |
| 17 | 17 | ||
| 18 | 18 | import argparse | |
| 19 | + | import contextlib | |
| 19 | 20 | import json | |
| 20 | 21 | import os | |
| 21 | 22 | import sys | |
| ⋯ | |||
| 90 | 91 | return 2 | |
| 91 | 92 | rgb = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) | |
| 92 | 93 | ||
| 93 | - | codebook_v4 = SpectralCodebookV4() | |
| 94 | - | codebook_v4.load(str(codebook)) | |
| 94 | + | # Upstream prints progress ("CodebookV4 loaded: ...") straight to | |
| 95 | + | # stdout, which corrupts --json for any caller that parses us | |
| 96 | + | # (image_meta.py json.loads our stdout). Keep stdout ours alone. | |
| 97 | + | with contextlib.redirect_stdout(sys.stderr): | |
| 98 | + | codebook_v4 = SpectralCodebookV4() | |
| 99 | + | codebook_v4.load(str(codebook)) | |
| 95 | 100 | ||
| 96 | - | extractor = RobustSynthIDExtractor() | |
| 97 | - | result = extractor.detect_from_v4_codebook( | |
| 98 | - | rgb, codebook_v4, model=args.model | |
| 99 | - | ) | |
| 101 | + | extractor = RobustSynthIDExtractor() | |
| 102 | + | result = extractor.detect_from_v4_codebook( | |
| 103 | + | rgb, codebook_v4, model=args.model | |
| 104 | + | ) | |
| 100 | 105 | except Exception as e: | |
| 101 | 106 | print(f"scorer error: {e}", file=sys.stderr) | |
| 102 | 107 | return 1 | |
The check that tells the two apart
fail→pass·tests/test_synthid_stdout_purity.py::test_json_stdout_survives_noisy_upstream
Check file tests/test_synthid_stdout_purity.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.
Origin and history
The code before it1eeda9be89bb6ec6ef67aba15afbe49ffbe187a4
Broken version dated2026-08-15
Moduleservice.scripts.score_synthid
Units changedmain
Fingerprint74a09f83eb73ffce
Checked2026-08-18 by goldset/0.1
Every field above is generated by our program. None of it is written by hand.
Other bugs found in guillaumemeyer/watermarks-remover
- 2026-08-17run_synthid_score
- 2026-08-17fix: validate clean option types (#111)
- 2026-08-14fix: preserve mixed-case CMS generator meta tags (#42)
- 2026-08-13safe_write_bytes
- 2026-08-12fix: c2patool "No claim found" reported as a C2PA manifest (#3)