Photo curation pipeline (3/3): fast LAION aesthetic predictor baseline #7

Closed
opened 2026-10-14 11:03:48 +00:00 by xrisk · 1 comment
Owner

Goal

Add a fast, deterministic LAION aesthetic predictor as a lightweight scoring baseline in the clock-photo curation pipeline: a CLIP ViT-L/14 image encoder + a linear head trained on human aesthetic ratings, ~0.6 GB, runs on CPU/MPS in milliseconds per image, outputs a 1–10 score you threshold. This is stage 3 of 3. Companion issues: #5 (stage 1, cheap local pre-filters) and #6 (stage 2, Clef decision-model judge). Work on this issue independently; do not implement the other stages.

What it is / is not (important — read before planning)

  • References: https://github.com/LAION-AI/aesthetic-predictor ("a linear estimator on top of CLIP to predict the aesthetic quality of pictures") and https://laion.ai/blog/laion-aesthetics/
  • Image in, one number out. There is NO text / natural-language input. It predicts a generic "how much do people like this image" human rating. It cannot be told what "good TV wallpaper" means.
  • Consequences: it cannot judge text/watermarks, aspect ratio, exposure-for-a-bright-room, or calm composition. Its role here is a fast first-pass ranker, a fallback when the Clef judge is unavailable (model not downloaded, different machine), and a baseline to compare the Clef judge's verdicts against on a sample set.
  • (Raw CLIP is text-promptable zero-shot, but that yields similarity scores, not calibrated judgments, and is weaker at exactly the wallpaper criteria — out of scope unless you find a concrete reason to include it.)

What to build

A maintainer-run script under scripts/ (style of discover-clock-photos.py) that:

  1. Scores a photo set (or the whole pool) with the LAION aesthetic predictor (CLIP ViT-L/14 + linear head; PyTorch with MPS on the M1, CPU fallback),
  2. Writes per-photo scores to a JSON sidecar atomically (temp file + mv — see the atomic-write rule in .wiki/wiki/references/task-routing.md),
  3. Documents the chosen threshold — calibrate on the existing pool and show the score distribution, not just a magic number,
  4. Includes a short comparison against the Clef judge's verdicts (#6) on a sample set — agreement rate + disagreements worth eyeballing — if that sidecar exists; otherwise document how to produce the comparison.

Placement in the flow: alongside/after the pre-filters (#5), before or in parallel with the Clef judge (#6) — it is cheap enough to always run.

Repo context (read first)

  • AGENTS.md — product constraints + source-control workflow: worktree under .worktrees/ on a feat/… branch; commit freely; make test before proposing a merge; never merge/push to main without explicit operator confirmation; push only when asked.
  • .wiki/_index.md + .wiki/wiki/references/task-routing.md — canonical routing; "Clock photos" section (manifest, probe, atomic-write rule, push path). (Wiki says manifest is at Resources/photos/manifest.json; actual path is Sources/TVDashboard/Resources/photos/manifest.json.)
  • Manifest: Sources/TVDashboard/Resources/photos/manifest.json (file/caption/credit/date/author/license/source/downloadUrl/clockY/depth); loader Sources/TVDashboard/Clock/ClockPhotoLibrary.swift.
  • Ingest flow: discover-clock-photos.py → fetch-clock-photos.sh → --clock-photo-probe → gen-photo-credits.py.
  • Kiosk constraints: TV view is read-only; curation is an operator-time maintainer tool (no TV-facing UI); the app must stay offline-resilient — scoring happens at ingest time, never at display time.
  • Update .wiki/ (committed on your feature branch) for durable decisions.

Decisions already made (do not re-litigate)

  • This is a baseline/fallback scorer, not the primary judge — the Clef judge (#6) makes the semantic "wallpaper-worthy" decision.
  • Local-only: no hosted APIs (no Cloudflare Workers AI, no OpenRouter), no Jev (closed source, text-only).

Acceptance criteria

  • Script scores the full existing pool in well under a minute on the M1 Pro (milliseconds per image), CPU/MPS, no GPU-server assumptions.
  • Threshold documented with the score distribution over the existing pool.
  • Sidecar is atomic and schema-documented.
  • Model weights are downloaded at run time, never committed (check .gitignore).
  • make test passes.

Open questions for the planning agent

  • Exact checkpoint + license handling (LAION aesthetic predictor weights; CLIP ViT-L/14) — verify terms before relying on them.
  • Runtime choice: PyTorch-MPS vs an ONNX/other runtime — pick the simplest that runs on the M1 Pro 16 GB without conflicting with the MLX env used by #6 (separate venvs? shared?).
  • Sidecar location/schema; whether scores become a manifest field or stay a sidecar (mind the tolerant-decode gotcha).
# Goal Add a fast, deterministic **LAION aesthetic predictor** as a lightweight scoring baseline in the clock-photo curation pipeline: a CLIP ViT-L/14 image encoder + a linear head trained on human aesthetic ratings, ~0.6 GB, runs on CPU/MPS in milliseconds per image, outputs a 1–10 score you threshold. This is **stage 3 of 3**. Companion issues: **#5** (stage 1, cheap local pre-filters) and **#6** (stage 2, Clef decision-model judge). Work on this issue independently; do not implement the other stages. # What it is / is not (important — read before planning) - References: https://github.com/LAION-AI/aesthetic-predictor ("a linear estimator on top of CLIP to predict the aesthetic quality of pictures") and https://laion.ai/blog/laion-aesthetics/ - **Image in, one number out. There is NO text / natural-language input.** It predicts a generic "how much do people like this image" human rating. It cannot be told what "good TV wallpaper" means. - Consequences: it cannot judge text/watermarks, aspect ratio, exposure-for-a-bright-room, or calm composition. Its role here is a **fast first-pass ranker**, a **fallback when the Clef judge is unavailable** (model not downloaded, different machine), and a **baseline to compare the Clef judge's verdicts against** on a sample set. - (Raw CLIP *is* text-promptable zero-shot, but that yields similarity scores, not calibrated judgments, and is weaker at exactly the wallpaper criteria — out of scope unless you find a concrete reason to include it.) # What to build A maintainer-run script under `scripts/` (style of `discover-clock-photos.py`) that: 1. Scores a photo set (or the whole pool) with the LAION aesthetic predictor (CLIP ViT-L/14 + linear head; PyTorch with MPS on the M1, CPU fallback), 2. Writes per-photo scores to a JSON sidecar **atomically** (temp file + `mv` — see the atomic-write rule in `.wiki/wiki/references/task-routing.md`), 3. Documents the chosen threshold — calibrate on the existing pool and show the score distribution, not just a magic number, 4. Includes a short comparison against the Clef judge's verdicts (#6) on a sample set — agreement rate + disagreements worth eyeballing — if that sidecar exists; otherwise document how to produce the comparison. Placement in the flow: alongside/after the pre-filters (#5), before or in parallel with the Clef judge (#6) — it is cheap enough to always run. # Repo context (read first) - `AGENTS.md` — product constraints + source-control workflow: worktree under `.worktrees/` on a `feat/…` branch; commit freely; `make test` before proposing a merge; **never merge/push to `main` without explicit operator confirmation**; push only when asked. - `.wiki/_index.md` + `.wiki/wiki/references/task-routing.md` — canonical routing; "Clock photos" section (manifest, probe, atomic-write rule, push path). (Wiki says manifest is at `Resources/photos/manifest.json`; actual path is `Sources/TVDashboard/Resources/photos/manifest.json`.) - Manifest: `Sources/TVDashboard/Resources/photos/manifest.json` (`file`/`caption`/`credit`/`date`/`author`/`license`/`source`/`downloadUrl`/`clockY`/`depth`); loader `Sources/TVDashboard/Clock/ClockPhotoLibrary.swift`. - Ingest flow: `discover-clock-photos.py` → `fetch-clock-photos.sh` → `--clock-photo-probe` → `gen-photo-credits.py`. - Kiosk constraints: TV view is read-only; curation is an operator-time maintainer tool (no TV-facing UI); the app must stay offline-resilient — scoring happens at ingest time, never at display time. - Update `.wiki/` (committed on your feature branch) for durable decisions. # Decisions already made (do not re-litigate) - This is a **baseline/fallback scorer, not the primary judge** — the Clef judge (#6) makes the semantic "wallpaper-worthy" decision. - **Local-only**: no hosted APIs (no Cloudflare Workers AI, no OpenRouter), no Jev (closed source, text-only). # Acceptance criteria - Script scores the full existing pool in well under a minute on the M1 Pro (milliseconds per image), CPU/MPS, no GPU-server assumptions. - Threshold documented with the score distribution over the existing pool. - Sidecar is atomic and schema-documented. - Model weights are **downloaded at run time, never committed** (check `.gitignore`). - `make test` passes. # Open questions for the planning agent - Exact checkpoint + license handling (LAION aesthetic predictor weights; CLIP ViT-L/14) — verify terms before relying on them. - Runtime choice: PyTorch-MPS vs an ONNX/other runtime — pick the simplest that runs on the M1 Pro 16 GB **without conflicting with the MLX env used by #6** (separate venvs? shared?). - Sidecar location/schema; whether scores become a manifest field or stay a sidecar (mind the tolerant-decode gotcha).
Author
Owner

Planning update — awaiting operator approval

Planning inspection is complete. No implementation, tests, inference, or calibration have begun. All recommendations below remain unapproved.

Proposed scope and findings

Add an independent maintainer-only aesthetic scorer, distribution/threshold report, and optional comparison against a supplied Clef sidecar (#6). Include model-free fixture tests, pinned dependency specifications, and concise schema/provenance documentation. No display-time scoring, app changes, source-photo edits, manifest edits, quarantine, or deletion.

Recommend the referenced LAION V1 linear head (sa_0_4_vit_l_14_linear.pth) plus OpenAI CLIP ViT-L/14, using a separate pinned PyTorch/OpenCLIP environment, not the MLX environment for #6. The upstream notebook uses normalized 768-dimensional image embeddings and a linear head, with no text input. Repository licenses for LAION and OpenAI CLIP are MIT; document that LAION provides no separate weight-specific model card in its root listing. Do not silently substitute V2.

The linear output targets human 1–10 ratings but is not mathematically bounded to that range. V1 was trained on synthetic-image ratings, making historical/monochrome photo bias a material calibration risk. CLIP encoding—not the tiny head—dominates computation; footprint, MPS compatibility, and full-pool throughput remain unmeasured.

The manifest currently has 649 entries; this worktree has 13 seeds, leaving 636 photos missing. ClockPhotoLibrary.swift filters absent files only. Existing fetch/probe/bake paths do not consume curation verdicts: a sidecar alone cannot prevent segmentation or change rotation.

Questions for the operator

  1. Shared interface: Approve separate stage-owned, gitignored .photo-curation/ sidecars outside bundled resources, keyed by set/file/SHA256 with schema/config/model provenance and pass/reject/review/error semantics? Recommended default: yes; only fresh passes advance in an explicitly enabled downstream pipeline. Commit schemas/tests/docs, not generated pool results. This gates caching and compatibility with #5/#6; a baseline pass is not a semantic wallpaper endorsement.

  2. Integration ownership: Should #5 own an opt-in probe/bake allowlist while #6/#7 remain independent sidecar producers, with source photos/manifest unchanged and no runtime filtering? Recommended default: yes. Alternatively defer integration, explicitly leaving “rejects never segmented” incomplete. This gates cross-stage scope, not a runtime behavior change in #7.

  3. Model/runtime: Approve the V1/OpenAI ViT-L/14 pairing, isolated pinned PyTorch/OpenCLIP environment, and documented MIT provenance caveat? Recommended default: yes. This gates dependency/artifact selection; no hosted judging or ONNX conversion is proposed.

  4. Calibration/performance: Choose the threshold only after pooled/per-set distributions and sample review, treating under-one-minute as a measured MPS target, not a CPU guarantee? Recommended default: yes; no active threshold initially. This gates honest acceptance criteria. Validate repeatability/device differences, near-threshold examples, and bias; compare Clef only on current hash-matched records, reporting exclusions and disagreements. Agreement is not accuracy.

  5. Execution scheduling: Proceed only after approval with implementation and model-free validation first, then separately request permission/scheduling for isolated-env installs, photo/model provisioning, serialized model pilots/full-pool calibration, and GUI-capable make test? Recommended default: yes. Validate atomic publication, invalidation, errors, and comparison fixtures before model runs. No relaunch or replacement of the running dashboard.

Status: awaiting operator answers and explicit implementation approval.

## Planning update — awaiting operator approval Planning inspection is complete. **No implementation, tests, inference, or calibration have begun. All recommendations below remain unapproved.** ### Proposed scope and findings Add an independent maintainer-only aesthetic scorer, distribution/threshold report, and optional comparison against a supplied Clef sidecar (#6). Include model-free fixture tests, pinned dependency specifications, and concise schema/provenance documentation. No display-time scoring, app changes, source-photo edits, manifest edits, quarantine, or deletion. Recommend the referenced **LAION V1 linear head (`sa_0_4_vit_l_14_linear.pth`) plus OpenAI CLIP ViT-L/14**, using a separate pinned PyTorch/OpenCLIP environment, not the MLX environment for #6. The [upstream notebook](https://github.com/LAION-AI/aesthetic-predictor/blob/main/asthetics_predictor.ipynb) uses normalized 768-dimensional image embeddings and a linear head, with no text input. Repository licenses for LAION and OpenAI CLIP are MIT; document that LAION provides no separate weight-specific model card in its root listing. Do not silently substitute V2. The linear output targets human 1–10 ratings but is not mathematically bounded to that range. V1 was trained on synthetic-image ratings, making historical/monochrome photo bias a material calibration risk. CLIP encoding—not the tiny head—dominates computation; footprint, MPS compatibility, and full-pool throughput remain unmeasured. The manifest currently has **649 entries; this worktree has 13 seeds, leaving 636 photos missing**. `ClockPhotoLibrary.swift` filters absent files only. Existing fetch/probe/bake paths do not consume curation verdicts: a sidecar alone cannot prevent segmentation or change rotation. ### Questions for the operator 1. **Shared interface:** Approve separate stage-owned, gitignored `.photo-curation/` sidecars outside bundled resources, keyed by set/file/SHA256 with schema/config/model provenance and pass/reject/review/error semantics? **Recommended default: yes; only fresh passes advance in an explicitly enabled downstream pipeline.** Commit schemas/tests/docs, not generated pool results. This gates caching and compatibility with #5/#6; a baseline pass is not a semantic wallpaper endorsement. 2. **Integration ownership:** Should #5 own an **opt-in probe/bake allowlist** while #6/#7 remain independent sidecar producers, with source photos/manifest unchanged and no runtime filtering? **Recommended default: yes.** Alternatively defer integration, explicitly leaving “rejects never segmented” incomplete. This gates cross-stage scope, not a runtime behavior change in #7. 3. **Model/runtime:** Approve the V1/OpenAI ViT-L/14 pairing, isolated pinned PyTorch/OpenCLIP environment, and documented MIT provenance caveat? **Recommended default: yes.** This gates dependency/artifact selection; no hosted judging or ONNX conversion is proposed. 4. **Calibration/performance:** Choose the threshold only after pooled/per-set distributions and sample review, treating under-one-minute as a **measured MPS target, not a CPU guarantee**? **Recommended default: yes; no active threshold initially.** This gates honest acceptance criteria. Validate repeatability/device differences, near-threshold examples, and bias; compare Clef only on current hash-matched records, reporting exclusions and disagreements. Agreement is not accuracy. 5. **Execution scheduling:** Proceed only after approval with implementation and model-free validation first, then separately request permission/scheduling for isolated-env installs, photo/model provisioning, **serialized** model pilots/full-pool calibration, and GUI-capable `make test`? **Recommended default: yes.** Validate atomic publication, invalidation, errors, and comparison fixtures before model runs. No relaunch or replacement of the running dashboard. **Status: awaiting operator answers and explicit implementation approval.**
xrisk closed this issue 2026-10-16 13:23:18 +00:00
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
xrisk/tvd#7
No description provided.