OARDoc is a Python toolkit for training, evaluating, exporting, and running document image rectification models through one API and command-line interface.
The figures and OARDoc rows show actual evaluation results and rectification outputs from models trained with OARDoc. Paper-reported rows reproduce the rounded values published for each model. Model weights are not included.
UVDoc validation examples: input image, predicted backward grid, ground-truth rectification, and predicted rectification.
| Result | Epochs | Images | MS-SSIM ↑ | AD ↓ |
|---|---|---|---|---|
| OARDoc trained model | 21 | 50 | 0.783579 | 0.119782 |
| Paper-reported | 21 | 50 | 0.784 | 0.122 |
DocTr++ validation examples for complete, partial, and out-of-frame document boundaries, including ground-truth and predicted grids and rectifications.
DocUNet
| Result | Epochs | Images | OCR images | MSSIM ↑ | LD ↓ | ED ↓ | CER ↓ |
|---|---|---|---|---|---|---|---|
| OARDoc trained model | 65 | 130 | 60 | 0.505877 | 7.609163 | 507.433333 | 0.191467 |
| Paper-reported | 65 | 130 | 60 | 0.51 | 7.52 | 447.47 | 0.1695 |
UDIR
| Result | Epochs | Images | OCR images | MSSIM-M ↑ | LD-M ↓ | ED ↓ | CER ↓ |
|---|---|---|---|---|---|---|---|
| OARDoc trained model | 65 | 195 | 70 | 0.488510 | 10.225263 | 1029.714286 | 0.346802 |
| Paper-reported | 65 | 195 | 70 | 0.45 | 12.47 | 666.49 | 0.2288 |
The arrows indicate metric direction. UDIR OCR values are raw diagnostics and are sensitive to unfilled output regions.
Install the package and its core inference dependencies from a source checkout:
python -m pip install .Add the training dependencies when preparing datasets, training models, or running metrics that need optional backends:
python -m pip install ".[train]"Install export support when producing ONNX artifacts:
python -m pip install ".[export]"Create the project environment:
uv syncInclude training, export, and development tools when working on the repository:
uv sync --extra train --extra export --group devRun commands inside the managed environment with uv run, for example uv run pytest or uv run oardoc info model=uvdoc.yaml.
Load a checkpoint and rectify one image:
from oardoc import OARDoc
model = OARDoc("weights.pt")
results = list(model.predict(source="document.jpg", save=True))
print(results[0].save_dir)Start a training run from a bundled model and dataset configuration:
from oardoc import OARDoc
model = OARDoc("uvdoc.yaml")
run = model.train(data="uvdoc.yaml", data_root="datasets")
print(run["last"])Configuration names resolve from the bundled oardoc/configs/models/ and oardoc/configs/datasets/ directories. Explicit paths and configuration mappings are also accepted. Dataset paths in a bundled YAML are resolved relative to the data_root supplied by the caller.
The CLI uses key=value arguments and parses values as YAML:
oardoc predict model=weights.pt source=document.jpg save=true
oardoc train model=uvdoc.yaml data=uvdoc.yaml data_root=datasets
oardoc val model=weights.pt data=uvdoc.yaml data_root=datasets
oardoc export model=weights.pt format=onnxRun oardoc help for the workflow overview or oardoc help COMMAND for command-specific arguments.
Run the test and static checks from the repository root:
uv run pytest
uv run ruff check .
uv run ruff format --check .OARDoc is licensed under the Apache License 2.0. See LICENSE and THIRD_PARTY_NOTICES.md for details.

