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

1616 from __future__ import annotations
1717
1818 import argparse
19+import contextlib
1920 import json
2021 import os
2122 import sys
9091 return 2
9192 rgb = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
9293
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))
95100
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+ )
100105 except Exception as e:
101106 print(f"scorer error: {e}", file=sys.stderr)
102107 return 1

The check that tells the two apart

failpass·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