Skip to main content
Perceptron Mk1.5 can read text in images and extract the fields relevant to your application. Ask for a transcription, a product-and-price table, or a constrained JSON record. Request spatial annotations when you need to show where a text span came from.

Extract product names and prices

Install perceptron>=0.4.0 and jsonschema, and set PERCEPTRON_API_KEY. This example uses the public grocery-label image. It preserves printed prices as strings so currency symbols and decimal formatting are not lost, and allows null when a requested field is unreadable.
An illustrative response shape is:
These entries are invented to demonstrate the schema, not a transcription of the sample image. Validate extracted values against the image when accuracy matters. JSON Schema controls structure, not whether the reading or product-price association is correct. See structured outputs for other schema and validation patterns.

Extract a Markdown table

For a human-readable result, request Markdown instead of a JSON Schema response. Run this after the client and image setup above:
For a document page, change the instruction to “Transcribe the visible text in reading order as Markdown; preserve headings, lists, and tables.” If your application needs HTML, request semantic headings, paragraphs, and tables in the prompt. These formats express document structure rather than exact pixel layout. Use the JSON Schema workflow when downstream code requires a fixed set of fields.

Locate the text spans

Use a separate annotation request when you want boxes around the evidence. This example asks the model to put each transcribed span in its box’s mention attribute:
Boxes use normalized 0–1000 coordinates, with top-left followed by bottom-right. asset_idx="0" selects the supplied image. Follow rendering annotations to draw response.txt over it, and validate attributes and geometry using the annotation reference. OCR markup and constrained JSON are distinct output formats; the API does not automatically attach boxes to the JSON records from the earlier request.

Improve extraction quality

  • State the fields and reading order you need. Distinguish a shelf price, a unit price, and a promotional price when several numbers appear near one product.
  • Preserve identifiers, prices, dates, and other exact text as strings until your application applies its own normalization rules.
  • Use an image with enough detail for the smallest relevant text. If you supply a crop as well as the original, treat it as another asset and keep the crop-to-source mapping.
  • For several pages or labels, keep their order and request explicit asset_idx on grounded spans. See multiple assets.