AI Grounds

Open AI Grounds on a desktop

These interactive lessons need a larger screen. Please continue on a desktop or laptop computer.

Guided discovery

OCR Line Detection

Turn page pixels into line boxes. Inspect what the network predicts.

Authored two-page raster PDF · no personal information

Actual Indra 1.1.2 detector · 90,568 stored weights · 390 kB · ONNX Runtime Web / browser CPU. Starting the detector means you agree to the model license and use restrictions. Model and outputs follow that license; application code remains MIT.

The decoder averages predicted top and bottom edges within each retained component and extends its horizontal bounds. Box numbers match the line list.

Start browser detector to run the real model on the example PDF.

Selected output cell

Inspect a detected line, click the page or focus it and use arrow keys. The inspector shows actual output values.

Play steps replays views of a completed pass. It does not show hidden-layer activations or slow down inference. Colors show values; the inspector and line table provide numeric equivalents. Distance colors mask inactive cells and cap the active 98th percentile; exported values remain unchanged.

Input and decoding controls

Strict probability cutoff, applied after inference. Kept pixels cannot increase as the cutoff rises; component and box counts can increase through splitting. Use arrow keys on the slider. Press Enter or leave the number field to apply an exact edit.

Discard regions smaller than this number of active output cells. This reuses the model tensor. Use arrow keys on the slider. Press Enter or leave the number field to apply an exact edit.

Input tensor

One batch, one ink channel, padded height and width.

—

x: float32 [1,1,H,W]

Output tensor

One score and two distances on a stride-two grid.

—

out: float32 [1,3,H/2,W/2]

Line boxes

Retained connected regions after decoding.

—

No inference yet

The detector has not run yet.

Construction, model and limits

PDF.js renders one page at a time at up to 200 dpi, capped at 2400 pixels on its long edge. The browser converts to grayscale, resizes with area reduction or bilinear enlargement, normalizes ink and pads with white. Browser rasterization and rounding can differ from PDFium/OpenCV. No PDF text layer or external OCR service supplies the detections.

ONNX Runtime Web 1.23.2 executes the real Indra det.onnx with WebAssembly in a single-thread worker. There is no server inference fallback. The worker verifies SHA256 f2bd4cba23e9c328cf7ec824634e423e191a2c6aacbbf35c62bd79dd70f62f59 before loading. Resolution changes rerun the network; threshold and area reuse the most recent matching input. Timings are device-dependent model execution only, excluding initialization, PDF rendering and visualization.

For each four-neighbor connected component, keep area ≥ minimum, average (2y+1 − top distance) and (2y+1 + bottom distance), and extend horizontal bounds by 0.15 × max(1, predicted height). Divide by preprocessing scale and clip for source-page boxes. Padding uses a zero ink map; stride does not change distance units.

This is line detection only. It does not run text recognition, orientation correction, reading order, adaptive retries or model training. The authored two-page classroom PDF is a real raster PDF, not personal data or an accuracy benchmark. Uploaded PDFs/images are held only by this browser and released when leaving the lesson. Limit: 25 MB, 500 PDF pages, 24-megapixel images; unsupported/encrypted files report an error.

NPZ exports contain x, out and UTF-8 JSON metadata as a uint8 NumPy array; use numpy.load(..., allow_pickle=False), then json.loads(run['metadata'].tobytes().decode()). JSON includes source coordinates, scores, shapes, settings, model identity and timings.

Indra by Datalab · Model revision bd02167fdf2005a19962cc15188f8496a2c87d3b · Modified OpenRAIL-M model/output license · ONNX Runtime license · PDF.js license