lucent
On-device AI image upscaler on hand-written WebGPU kernels
- Role
- Personal project
- Year
- 2026
- Built with
- TypeScript · WebGPU · WGSL
Overview
lucent is an AI image upscaler and enhancer that runs entirely in the browser, on your own GPU. It upscales up to 16×, removes noise and recovers detail, and shows the before and after live. Nothing is uploaded. The whole app is 15 KB of gzipped JS plus 6 MB of fp16 weights.
What it does
It runs Real-ESRGAN's compact models: one for photos and one for illustration and line art. Scales from 1× to 16× are supported; above 4× it chains two passes. The denoise slider does real network interpolation between checkpoints. Sharpen, film grain and 'preserve original' controls fight the plastic look, and you can batch-export to PNG, JPEG or WebP.
How it runs
Images are split into 512px tiles with a 24px context apron. Each tile goes through 34 conv3x3+PReLU dispatches, then pixel-shuffle, Lanczos resampling and finishing. Tiles nearest your view render first, so the image never goes blank while settings change.
Accuracy and speed
The GPU path is tested in headless Chromium on a real GPU against a deliberately naive CPU implementation. fp32 output matches it exactly, and fp16 stays within 2/255. Register blocking, weights staged in workgroup memory and fp16 brought the conv kernel to 3.1 TFLOP/s on a laptop GPU, 5.3× faster than the first version.
Tech Stack
- TypeScript
- WebGPU
- WGSL
- Real-ESRGAN
- Playwright