The problem
Every image on a shop or a news site needs alt text, most product photos need a description, and someone has to read the weight, the price and the dates off the label. Done by hand it is slow, so it gets skipped, and the site is worse for screen-reader users and for search.
A model that drafts all of it in a few seconds turns the job into checking and editing. It fits best where photos are clear and each one matters a little: catalogues, listings, archives and social posts.
The data
Five sample images. Three are openly licensed (CC0) photos from Wikimedia Commons: a white cup of tea on a square saucer, on a white background; a couple buying vegetables at a busy market stall in Mumbai; stacks of clay lamps for sale on a street stall. Two I rendered from HTML for the demo: a coffee label for a made-up brand and a sale poster for a made-up shop, so I know exactly what text is on them.
Your own photos stay on your device: the page draws the photo onto a canvas, shrinks it to at most 1,024 pixels on the long side, and hands the pixels to the model in a background worker.
Nothing is trained here. The model learnt from a large set of images with captions, text regions and boxes; I use it as it comes and do the clean-up around it.
The model
Florence-2 base (about 230 million parameters, MIT licence) is a vision-language model: an image encoder turns the photo into features, and a text encoder and decoder write the answer. One model does many jobs, picked by a short task prompt: <CAPTION> for alt text, <MORE_DETAILED_CAPTION> for a description, <OCR_WITH_REGION> for lines of text with their boxes, and <OD> for objects.
Boxes come back as location tokens: the model writes each corner as one of 1,000 steps across the photo's width or height. The processor turns those into pixels of the copy the model saw, and the page scales them to the photo as drawn on your screen, at whatever size that is.
I chose it because it does all four jobs in one download, runs in a browser, and its licence allows commercial use. Bigger vision-language models write richer descriptions, but they are gigabytes, not hundreds of megabytes.
On a graphics chip with 16-bit support, the image encoder and the word embeddings run at half precision and the text encoder and decoder at 4 bits: about 360 MB. On a processor every part uses 8-bit weights: about 280 MB. A graphics chip without 16-bit support needs the full-precision image encoder, about 620 MB.
The pipeline
- 01Load
The model's files download once and stay in the browser's cache. On a graphics chip a tiny first run compiles the model, so your first job is quick. If the graphics chip fails, it starts again on the processor.
- 02Prepare
The photo is drawn at no more than 1,024 pixels on its long side; the processor resizes it to 768 × 768 and normalises the colours. The prepared photo is kept for the next job on it.
- 03Prompt
Each button sends one task prompt. When the line-by-line reading finds nothing, it asks for a plain
<OCR>reading instead. - 04Generate
Greedy decoding, one token at a time, with the model's own rule against repeating any run of three tokens. Captions appear as they are written, and Stop ends a long answer early.
- 05Clean up
Location tokens become boxes in pixels. Lines are put in reading order, top to bottom and left to right; repeated boxes are dropped; captions lose openings such as “An image of”.
- 06Show
A canvas over the photo draws the boxes and redraws them when the photo changes size or the theme changes. Every box is also listed as text with the same number, and each answer shows how long it took.
Results
Recorded with this page's own code in Edge on 23 Nov 2026: each job three times on a laptop's built-in graphics chip (WebGPU) and twice on its processor, and each gave the same answers every time. Times are medians on a busy machine, so a quiet one is quicker; yours will differ, and the demo shows the time of every job it runs. Every line it got wrong differs only by a raised dot (·) read as a full stop. The two versions of the model do not always agree: for the cup and saucer the graphics chip wrote “A cup of coffee is on a saucer.” and the processor “A cup of tea sits on a saucer.”
For a client
For a client I would run it over the catalogue in batches, on a server with a graphics card or in the editor's own browser, and put the drafts in front of a person: alt text and descriptions are drafts, not facts.
I would feed it the client's own data: product names, materials and sizes from the catalogue go into the description template, and a check flags any caption that names a colour or a size the product data disagrees with.
For dense or small print I would crop the label first or pair the model with a dedicated text reader; for counting stock or spotting defects I would train a detector on the client's own photos.
Where the download size does not matter, the larger Florence-2 or a bigger vision-language model gives richer descriptions with the same pipeline.
Stack
| Part | What it does here | Licence |
|---|---|---|
| Florence-2 base | Captions, descriptions, text reading and object boxes, from one vision-language model in ONNX form | MIT |
| transformers.js | Runs the model in a web worker: processor, tokenizer and generation | Apache 2.0 |
| ONNX Runtime Web | The inference engine underneath, on WebGPU or WebAssembly | MIT |
| My post-processing | Reading order, repeats, alt-text clean-up, box scaling and drawing, written in TypeScript and unit-tested | Mine |
| Sample photos | Petr Kratochvil, Nicolas Vigier, Apurv013, via Wikimedia Commons | CC0 |
| Preact | The interactive demo | MIT |
| Astro | The page, built as static HTML | MIT |
Privacy
Everything happens in your browser. Your photo is read from your device into the page, shrunk and passed to the model in a worker; it is never uploaded, and there is no server behind this page.
The only download is the model itself, once, from its public host. After that it works from the browser's cache, even offline.
Limits
- Florence-2 base is small. Its captions are short and plain, it can name the wrong object or miss small ones, and it knows nothing about brands, places or people.
- It reads clear printed English well and handwriting, small print, curved labels and other scripts such as Tamil or Hindi poorly.
- A description can state things that are not in the photo, such as a material, a shade or what something is for. Treat every answer as a draft for a person to check.
- Object boxes use everyday categories; it has no idea of a particular product or a defect.
- On a processor, without WebGPU, it is slow: the first job on a photo took 26.5 s on the test laptop. A phone with little memory may not load the model at all.