Metadata-Version: 2.4
Name: tesela
Version: 0.0.1
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Rust
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: POSIX :: Linux
Classifier: Topic :: Scientific/Engineering :: Image Recognition
Requires-Dist: numpy
License-File: LICENSE
License-File: NOTICE
License-File: THIRD-PARTY-LICENSES.txt
Summary: Fast document OCR and ONNX inference on ordinary CPUs, written in Rust (Python extension)
Keywords: ocr,onnx,inference,cpu,rust,document-ocr,paddleocr
Author-email: Cristian Camilo Robledo Cuellar <cristiancamilorobledo@gmail.com>
License-Expression: Apache-2.0
Requires-Python: >=3.12
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
Project-URL: Changelog, https://github.com/tesela-engine/tesela/blob/main/CHANGELOG.md
Project-URL: Homepage, https://github.com/tesela-engine/tesela
Project-URL: Issues, https://github.com/tesela-engine/tesela/issues
Project-URL: Repository, https://github.com/tesela-engine/tesela

# Tesela

**Fast document OCR and ONNX inference on ordinary CPUs, written in Rust.**

Tesela is a CPU inference engine written in Rust that runs ONNX models and a complete OCR pipeline (page decoding, text
detection, recognition, line orientation and page unwarping) with no ONNX Runtime or PaddlePaddle at run time. This package
is its Python extension: the module `tesela`. It is also the optional fastest engine of
[LegereOCR](https://github.com/legere-ocr-full/legereocr).

On a full OCR page it takes 0.294 s against 0.739 s for LegereOCR on ONNX Runtime, measured on a Ryzen 9 9900X; the
[Results](https://github.com/tesela-engine/tesela#results) section of the repository gives every measurement, its memory and
what it measures.

**Status: first public version (0.0.1).** Error messages and identifiers are in Spanish.

## Install

```bash
pip install tesela
```

Wheels for Python 3.12 or later on Windows x64 and Linux x64 (glibc). On other platforms pip tries to build it from the
source distribution, which needs a recent stable Rust toolchain; only Windows x64 and Linux x64 are tested. The instruction set is chosen when it runs (AVX-512, AVX2+FMA or scalar); force
a lower one with `TESELA_ISA=avx2` or `TESELA_ISA=escalar`.

## With LegereOCR

```bash
pip install legereocr tesela
```

```powershell
$env:LEGERE_MOTOR = "pagina"      # then run LegereOCR as usual
legere ocr page.png --json out.json
```

`LEGERE_MOTOR=auto` (the default) never loads Tesela: it is opt-in.

## On its own

It reads the OCR models from a folder (see [Models](https://github.com/tesela-engine/tesela#models); the downloader of
LegereOCR fetches them and checks every hash: `python -m legereocr.motores.descarga det_v6_tiny rec_latin ori_linea uvdoc`).

```python
import cv2, tesela

page = tesela.Pagina("modelos", hilos=8)   # folder with the OCR models
result = page.ocr(cv2.imread("page.png"))  # BGR uint8 array, H x W x 3
for text, confidence in zip(result["textos"], result["confianzas"]):
    print(f"{confidence:.2f}  {text}")
```

`opencv-python` is only for reading the image in this example; any BGR `uint8` array works.

## More

The repository has the full README, the command-line tool, the build from source and the measurements:
[github.com/tesela-engine/tesela](https://github.com/tesela-engine/tesela). Licensed under the
[Apache License 2.0](https://github.com/tesela-engine/tesela/blob/main/LICENSE); each OCR model keeps its own licence. The
package carries `NOTICE` and `THIRD-PARTY-LICENSES.txt` with the code and crates it includes.

