8000 feat(enhance): enhance low quality images before they're read by adeelahmad · Pull Request #479 · adeelahmad/lense · GitHub
[go: up one dir, main page]

Skip to content

feat(enhance): enhance low quality images before they're read - #479

Merged
adeelahmad merged 34 commits into
mainfrom
claude/project-thread-hnzflg
Oct 18, 2026
Merged

adeelahmad merged 34 commits into
mainfrom
claude/project-thread-hnzflg

Conversation

@adeelahmad
@adeelahmad adeelahmad commented Oct 17, 2026 •
Copy link
Copy Markdown
Owner

Description

Before: a small, blurry, noisy or dull image (a phone snap of a whiteboard, a thumbnail, a dark scan) was read as it was, so OCR, faces, objects and descriptions worked from a poor picture.

After: a new enhance step, first in the standard pipeline, measures each image (size, sharpness, noise, contrast, and the size of its faces where the namespace finds faces) and, when it looks low quality, keeps an enhanced copy that read and the steps after it work from. The original stays as it is. It's off by default: Settings → Enhance.

  • Two engines: classic (Pillow: median filter, Lanczos, autocontrast, unsharp mask; nothing to fetch, the default) and realesrgan (Real-ESRGAN general x4v3, BSD-3-Clause, 5 MB ONNX at a pinned revision with SHA-256, run in 128 px tiles on ONNX Runtime; fetched the first time it's chosen, and pictures over 1.5 MP fall back to classic).
  • Face size gate instead of insightface (whose models are non-commercial): Lens's own YuNet, only where the namespace's faces mode isn't off; enhance.only_faces limits it to pictures with a face.
  • The copy (renditions/<id>-enhanced.jpg) is encrypted like the namespace's files, re-keyed and deleted with the resource, and downloadable by members only (GET /resources/{rid}/enhanced, a signed link in enhanced.download).
  • On request, whatever the settings: Enhance in the Details tab, POST /resources/{rid}/enhance, the MCP tool enhance, and the enhance automation action. Each makes the copy and runs the rest of the pipeline again.
  • Web app: Settings → Enhance (Media and documents), the step in the pipeline editor and canvas, and an Enhance row in the Details tab with what was found and Save the copy.

Motivation and Context

Adeel asked for a pipeline step that detects low quality images and enhances them automatically (thread "detect and auto enhance for better quality as a step"). Audio cleanup before transcription follows in its own PR.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change; ! in the title)

Checklist:

  • The title is a Conventional Commit.
  • My code follows the code style of this project (make hooks checks it on commit).
  • I added or updated tests.
  • My change requires documentation updates, and I have updated docs/ accordingly.
  • Users need more than the title to understand it, so I wrote it under ## Unreleased in CHANGELOG.md.

Done questions (AGENTS.md)

  • Goal: detects low quality images and enhances them as a pipeline step; merged on green CI.
  • Agents: POST /resources/{rid}/enhance, the MCP tool enhance, the enhance automation action; get_recording says what was found.
  • Zero setup: classic needs nothing; Real-ESRGAN is fetched on first use when chosen.
  • Fewest clicks: one switch in Settings; one Enhance button on an image.
  • Configurable: seven enhance.* settings in the web app with defaults; nothing in the setup wizard.
  • Light: off by default; classic is Pillow alone; the 5 MB model only when picked.
  • Private and secure: runs on the server, copy encrypted, members-only download; threat model row for the model file.
  • Cost: no model provider calls; nothing for the ledger.
  • User decides: off by default, existing defaults unchanged.
  • Upgrades: n/a, a new optional field (recording.enhanced) and a new settings section with defaults; nothing to migrate.
  • Honest: docs/enhance.md says what's built, with "Refine later" items.
  • Tests (tests/api/test_enhance.py, __tests__/enhance.test.tsx), docs and the generated client (make openapi).
  • Open standards; Real-ESRGAN is BSD-3-Clause, Pillow and ONNX Runtime permissive.
  • Result reported with evidence; "refine later" items in docs/enhance.md.

Local CI (ci/local-ci.sh on c5b013a): FastAPI embedded and server, Next.js, pre-commit and PR title all pass.

🤖 Generated with Claude Code

https://claude.ai/code/session_012m72U9mPLCbuH8rSAZGSuZ

claude added 14 commits October 17, 2026 01:38
The new enhance step, first in the standard pipeline, measures each image
(size, sharpness, noise, contrast, and face size where the namespace finds
faces) and keeps an enhanced copy of a low quality one that read, faces,
objects and descriptions then work from. The original stays as it is.

Off by default (Settings → Enhance). The classic engine (Pillow) needs
nothing; Real-ESRGAN general x4v3 (BSD-3-Clause, 5 MB ONNX) is fetched the
first time it's chosen. The copy is encrypted like the namespace's files,
re-keyed and deleted with them, and downloadable by members only.

Agents: POST /resources/{rid}/enhance, the MCP tool enhance and the enhance
automation action enhance an image on request. The web app has the settings
section, the pipeline step and an Enhance row in the Details tab.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012m72U9mPLCbuH8rSAZGSuZ
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012m72U9mPLCbuH8rSAZGSuZ
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012m72U9mPLCbuH8rSAZGSuZ
Copy link
Copy Markdown
Owner Author

Upgrade from the last release failed on 643e1d7: the check read Monday and Friday as gone after the upgrade. That isn't this PR's doing: since #395 the entity-types step types them as Dates, which the entities list leaves out, and main fixed the check in #512. I merged main (with #512) into this branch in d90df50; ci/upgrade/upgrade.sh passes on it locally ("Upgraded from v0.13.0 with nothing lost").


Generated by Claude Code

claude added 11 commits October 17, 2026 06:24
…-hnzflg

# Conflicts:
#	README.md
#	threat-model.yaml
…-hnzflg

# Conflicts:
#	CHANGELOG.md
#	threat-model.yaml
…-hnzflg

# Conflicts:
#	CHANGELOG.md
#	docs/mcp.md
#	fastapi_backend/app/domain/pipelines.py
#	threat-model.yaml
…-hnzflg

# Conflicts:
#	CHANGELOG.md
#	README.md
#	docs/components.md
#	docs/mcp.md
#	nextjs-frontend/components/pipelines/pipeline-canvas.tsx
#	threat-model.md
#	threat-model.yaml
The threat model's YAML now changes with the prose, as the validator asks
since main's same-commit scheme.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012m72U9mPLCbuH8rSAZGSuZ
…-hnzflg

# Conflicts:
#	CHANGELOG.md
#	README.md
#	docs/mcp.md
adeelahmad pushed a commit that referenced this pull request Oct 18, 2026
…enhance step in #479

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014WcBxU5ARBoLWMYZU46St6
#400 is released, so the requirements check on main was red; its In
progress line goes, and its checks join the built list.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012m72U9mPLCbuH8rSAZGSuZ
…-hnzflg

# Conflicts:
#	fastapi_backend/app/domain/deletion.py
#	fastapi_backend/app/domain/pipelines.py
#	nextjs-frontend/components/pipelines/pipeline-canvas.tsx
…-hnzflg

# Conflicts:
#	docs/configuration.md
#	docs/mcp.md
Copy link
Copy Markdown
Owner Author

Clicks and keystrokes per feature failed on 9bb0ba9: the phone survey's chat-ask journey timed out waiting for the answer (locator.waitFor: Timeout 60000ms); the computer survey passed, and every other phone journey passed. This PR doesn't touch chat: it adds the enhance pipeline step. The same phone-survey failure hit #570 (timeline reactions) in the same window, so it's the shared runners under load, not this change. No fix to port. The next head (7ef1d3d, main merged in again) re-runs it once.


Generated by Claude Code

@adeelahmad
adeelahmad merged commit 8d3a4af into main Oct 18, 2026
12 checks passed
@adeelahmad
adeelahmad deleted the claude/project-thread-hnzflg branch October 18, 2026 12:24
adeelahmad added a commit that referenced this pull request Oct 18, 2026
…#569)

* feat(pipelines): clean up a recording's sound before it's transcribed

A new pipeline step, enhance (Clean up audio), runs a recording through
WebRTC's audio processing with pywebrtc-audio (Apache-2.0, ~0.5 MB, fetched
the first time the step runs): noise suppression, automatic gain, a
high-pass filter, echo cancellation for two-channel call recordings, and
voice detection that leaves pauses out of what's transcribed. The
transcript's times are mapped back onto the recording's own timeline.

The step keeps its options and what it measured on the recording
(audio_cleanup); transcribing then hears the cleaned audio. The file is
never changed and no copy is stored. No pipeline has the step until one
adds it, so defaults are unchanged. Settings > Transcription > Audio
cleanup holds the options (transcribe.cleanup).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014WcBxU5ARBoLWMYZU46St6

* refactor(pipelines): name the step clean_audio, apart from the image enhance step in #479

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014WcBxU5ARBoLWMYZU46St6

* style(pipelines): format the canvas's asset steps

---------

Co-authored-by: Adeel Ahmad <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0