Photo curation pipeline (1/3): cheap local pre-filters (blur, exposure, aspect, dedupe) #5
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Goal
Add a zero-model, deterministic pre-filter stage to the clock-photo ingest pipeline that enriches per-image metadata with quality metrics, stage-local verdicts and reasons (blur, exposure, resolution, aspect, duplicates). Stage 1 does not remove images or decide final use; the final pipeline combines stage evidence under an explicit selection policy. Measure real batch throughput rather than promise milliseconds.
This is stage 1 of a 3-stage photo-curation pipeline. Overall goal: only photos that look good as a living-room TV wallpaper (the full-screen clock background) should make it into clock photo sets. Companion stages, filed as separate issues: stage 2 = Clef decision-model judge (local M1), stage 3 = LAION aesthetic predictor baseline. Work on this issue independently; do not implement the other stages.
Why
The clock background renders full-screen on a TV over AirPlay. Junk photos (motion blur, under/over-exposure, tiny archival scans, duplicates) waste model-judge time and degrade the kiosk. Cheap heuristics kill most of this for free, with no model download and no network.
What to build
A maintainer-run Python script under
scripts/(follow the style ofscripts/discover-clock-photos.py: argparse, stdlib-first,ROOT/MANIFESTconstants, self-documenting docstring with usage examples). It scans a photo set (or the whole manifest) and writes per-photo verdicts + reasons to a JSON sidecar, written atomically (temp file beside the target +mv— see the atomic-write rule in.wiki/wiki/references/task-routing.md→ "Clock photos").Filters to evaluate (keep it simple; calibrate thresholds on the existing pool):
imagehashaverage/phash) against the set.Deps: Pillow + numpy (+
imagehash;opencv-python-headlessonly if a numpy Laplacian is inadequate). No torch, no ML stack or model downloads. Scorer is offline; original acquisition is explicitly invoked network work. Measure actual throughput.Where it plugs in
Current ingest flow (see
scripts/discover-clock-photos.pydocstring):discover-clock-photos.py(Openverse discovery) →fetch-clock-photos.sh(build-time download) →--clock-photo-probe(Vision segmentation fillsclockY/depth) →gen-photo-credits.py.Required ingest route: discover → acquire/retain full-resolution originals → stage-1 metadata → later-stage evidence → final selection policy → selected render-asset preparation / Vision bake → final output manifest + credits. Stage 1 recommends; a future explicit consumer policy may skip model/Vision work for unusable originals. Existing probe/bake and runtime selection remain unchanged in the draft.
Original acquisition is included in this issue and PR #10: explicit maintainer command
scripts/fetch-clock-originals.py new-york, separate ignored worktree-local storage and hashed atomic download receipts, resume/retry, no build hook or app/shared-cache mutations. Include all 518 New York entries (505 download URLs plus 13 seeds resolved from Commons File pages). Retain raw bytes without resizing/reencoding. Acquisition and analysis resource limits must produce honest error evidence, not silently reduced originals.Repo context (read first)
AGENTS.md— product constraints + source-control workflow: work in a git worktree under.worktrees/on afeat/…branch (e.g.git worktree add .worktrees/<short> -b feat/<short>); commit freely on the branch; runmake test(selftest + jstest) before proposing a merge; never merge/fast-forward/push tomainwithout explicit operator confirmation; push to remote only when asked..wiki/_index.md+.wiki/wiki/references/task-routing.md— canonical routing; the "Clock photos" section documents the manifest, the probe, the atomic-write rule, and the on-demand image push path. (Note: the wiki says the manifest lives atResources/photos/manifest.json; the actual path isSources/TVDashboard/Resources/photos/manifest.json.)Sources/TVDashboard/Resources/photos/manifest.json— per-photofile/caption/credit/date/author/license/source/downloadUrl/clockY/depth. ReadSources/TVDashboard/Clock/ClockPhotoLibrary.swiftto see how it is loaded and whether adding a curation field needs tolerant decoding (the config tolerant-decode gotcha in task-routing applies toDashboardConfig; check the manifest loader too)..wiki/(and commit the change on your feature branch) if you introduce a durable route, convention, or decision.Decisions already made (do not re-litigate)
Acceptance criteria
make teststill passes.Metadata location / schema decisions (operator confirmed 2026-10-15)
.photo-curation/prefilter.json(explicit per-set output paths allowed), not a runtime Application Support cache or committed pool output.docs/photo-prefilter.schema.json. Records join on(set_id, file, sha256)with report-level analysis/config/provenance. Metrics and stage-local verdict/reasons remain distinct from final eligibility.useand generates output membership. The stage-evidence merger/final policy is not yet implemented. Missing/error/stale evidence must not imply eligibility..photo-curation/originals/<set>/anddownloads.json, schemadocs/photo-original-download.schema.json. Original and derived asset hashes/dimensions must not be conflated.Current New York prepared-pool evidence
Analysis v2 scanned all 518 local prepared images and the built app resource copy read-only; reports identical including byte hashes. 518 decoded, 0 errors, 0 pass / 518 reject / 0 review. Times 5.483s / 5.511s (~94 images/s). Every image fails resolution because build fetch downsizes to 1280px long edge (510 exactly 1280px; largest long edge 1687px, max oriented width 1280px). This does NOT prove originals are low-res.
Other overlapping flags: crop review 193, extreme crop 1, dark exposure 6, crushed shadows 3, blown highlights 1, low contrast 1, low blur metric 1, near duplicate 7, exact duplicates 0. Ignoring resolution solely as a diagnostic: 317 pass / 200 review / 1 reject, not eligible outputs. See repository docs for distributions/commands.
Full-resolution acquisition is authorized and running as part of PR #10; original-byte analysis and real flagged-image review remain pending. Scorer limits (32MiB/40M pixels) can yield errors for large originals. Runtime preparation also has a separate 1600px/q0.7 limit; no render change is included so far.
Planning update — awaiting operator approval
Planning for this stage is complete; every recommendation below is unapproved. No implementation, tests, inference, or calibration has begun, and no repository, app, or cache state was modified.
Proposed scope. One maintainer-run
scripts/prefilter-clock-photos.pyin the style ofscripts/discover-clock-photos.py(argparse,ROOT/MANIFESTconstants, usage docstring). It readsSources/TVDashboard/Resources/photos/manifest.jsonplus on-disk bytes and writes per-photo verdicts atomically (temp beside target +mv). Deps: Pillow + numpy only; compute a small deterministic aHash/dHash directly, since upstreamimagehashpulls in SciPy and OpenCV is unnecessary. Pipeline per image: EXIF transpose → long-edge check (≥1100, matchingMIN_LONG_EDGE) → 16:9 center-cover-crop loss estimate → Laplacian variance (blur) → mean luminance / blown-highlight / crushed-shadow stats → near-duplicate hash distance within the set. Verdictspass/reject/review/errorwith machine-readable reasons;reviewstays a real borderline bucket,errorfor undecodable bytes. Thresholds are selected only after pooled/per-set distributions are shown.Shared contract (reconciled with #6/#7). Stage-owned, gitignored sidecars under worktree-local
.photo-curation/— not bundled resources; keyed by set/file/SHA256 with schema + config provenance and pass/reject/review/error; only a fresh pass advances a photo. Commit schemas/tests/docs, never generated pool results. Default here is report-only: source photos, manifest, quarantine/deletion, and display-time filtering all stay unchanged, preserving offline display.Key findings / unresolved risks.
MIN_LONG_EDGE/MIN_SHORT_EDGE, aspect 0.5–2.0), so blur/exposure/dedupe are the genuinely new filters.ClockPhotoLibrary.availablePhotosprunes only missing files,--clock-photo-probesegments every on-disk file, and neither reads sidecars. Sidecars are runtime-safe (manifest loader ignores unknown keys).Validation still needed (after approval). Model-free: fetch the missing photos, run the pass over the full pool, publish distributions/proposed cuts, re-run to prove deterministic identical output. GUI-capable
make testseparately scheduled. #6/#7 env/model work stays serialized and separately approved.Questions for the operator
reviewmass as a loosen signal.Companion stages #6 and #7 consume this sidecar contract; see those issues for model-specific scope.
add deps appropriately to pyproject. this can be a batch job. I dont understand 2,3, 4. otherwise LGTM
Implementation is beginning as a conservative, report-only draft. To clarify questions 2/3/4: (2) scoring photos alone does not stop Vision work; a separately, explicitly opted-in selection before the probe would skip non-passing photos. A heuristic pass is not operator approval. (3) threshold tuning means looking at which real photos each cutoff flags and their score distributions, rather than choosing unexplained constants. (4) a new worktree has only 13 seed photos out of 649 manifest entries, so full calibration needs more local image bytes. I will add Pillow + numpy appropriately to pyproject in an isolated env, use provisional thresholds, and test synthetic/seed inputs first. No deletion, final threshold policy, bulk fetch, or resource-heavy/GUI run is assumed approved.
Initial draft published: #10 (WIP #10, main <- feat/photo-prefilters, commit
3b0bff5). Report-only Pillow + numpy scorer, locked optional pyproject extra, atomic worktree-local evidence, distributions, schema/docs/wiki and synthetic tests are implemented. No source-photo/manifest/runtime/UI changes.Actual validation: 10 model-free synthetic tests passed; locked isolated env sync, py_compile and diff checks passed. Repeat reports were byte-identical. Final seed-only runs: 0.187s / 0.174s, 649 entries but only 13 decoded seeds and 636 missing inputs recorded as errors; decoded verdicts 7 pass / 2 reject / 4 review. This is not full-pool calibration or throughput evidence.
Pending: provision additional local bytes under separately scheduled permission, inspect real flagged photos/distributions and review provisional cutoffs. The explicit pre-Vision fresh-pass selection hook is deferred in this initial draft; existing probe/bake still process all present files, so report generation alone does not stop segmentation. Heuristic pass does not imply manual approval. make test, GUI/physical checks and real Vision runs were not run. Running main-checkout dashboard was left untouched; no fetch/build/launch/quit or shared runtime-cache/config writes. Draft is not complete or merge-ready; #6/#7 remain paused. Detailed commands/contracts and follow-up checklist are in the repository docs.
Operator scope update: source resolution must be checked before photos become eligible for TV display. Replace discovery floors (~1100px) with EXIF-oriented source width >=1920 and height >=1080, matching the current AirPlay desktop and ensuring 16:9 cover requires no upscaling. Test exact boundaries, panorama/portrait cases and orientation before thumbnailing. Implemented in draft PR #10 as analysis v2. Report-only evidence does not yet enforce runtime eligibility; fresh-pass ingest selection remains an acceptance gap. Separately, current runtime encoding can reduce >350KB sources to 1600px/quality 0.7 and is not changed by this request.
Original acquisition is now implemented locally as part of #5/PR #10: separate raw-byte storage, hashed atomic receipts, safe resume, all 518 New York identities including seeds. Batch is running; a supervisor retries failures and runs the final scorer afterwards. Partial original scan: 283 decoded, 169 pass / 32 reject / 82 review; 235 errors mostly not-yet-downloaded (216), with 3 byte-limit, 7 invalid EXIF and 9 unsafe/undecodable. Not final calibration. All 15 synthetic tests pass. Local changes are staged but commit/push currently blocked: configured signing agent refuses commit signatures. PR body refreshed to distinguish local implementation from remote diff.
Original acquisition and full-pool stage-1 analysis for New York are complete and pushed in PR #10 (commit
13865ae):• Acquisition: all 518 New York identities (505 download URLs + 13 seeds) downloaded and verified to .photo-curation/originals/new-york/ (2.9 GiB), 0 errors.
• Analysis of original bytes (31.461s, ~16.5 images/s): 487/518 decoded, 279 pass (53.9%), 60 reject (11.6%), 148 review (28.6%), 31 error (6.0%). Full report in .photo-curation/new-york-originals-v2.json.
• In contrast to the prepared assets where fetch downsized 100% of photos to 1280px (causing 100% resolution failure), only 58 original photos (11.2%) fail the 1080p requirement.
• 31 input errors reflect analysis bounds on raw files (9 files >32 MiB like 213 MiB Brooklyn Bridge TIFF; 8 invalid EXIF orientation; 14 unsafe/undecodable decompressed limits).
• All 15 synthetic unit tests pass. Commit-signing issue resolved; changes pushed to PR #10.