Model zoo#

docTR implements a range of published architectures for each task of the pipeline, all with pretrained weights. This section lists them with their benchmarks, so you can pick the right trade-off between speed and accuracy.

At a glance#

Task

Architectures

Default

Use it with

Text detection

DBNet, LinkNet, FAST

fast_base

ocr_predictor(det_arch=...)

Text recognition

CRNN, SAR, MASTER, ViTSTR, PARSeq, VIPTR

crnn_vgg16_bn

ocr_predictor(reco_arch=...)

Layout analysis

LW-DETR

lw_detr_s

ocr_predictor(detect_layout=True, layout_arch=...)

Table structure

TableCenterNet

tablecenternet

ocr_predictor(detect_tables=True)

Orientation

MobileNetV3

mobilenet_v3_small_*_orientation

ocr_predictor(assume_straight_pages=False)

End-to-end benchmarks compare detection + recognition pairs, including commercial OCR services.

How to choose#

Balanced

The defaults, fast_base + crnn_vgg16_bn, are accurate on most documents and run fine on a CPU.

Fast

fast_tiny or db_mobilenet_v3_large with crnn_mobilenet_v3_small or viptr_tiny for CPUs, edge devices and high-volume pipelines.

Accurate

db_resnet50 or fast_base with parseq, vitstr_base or master, ideally on a GPU.

Benchmarks on public datasets are a starting point: the best way to choose is to compare a few combinations on a sample of your documents. If none is good enough, fine-tune a model on your data.

Orientation classifiers#

Two lightweight MobileNetV3 classifiers handle rotated documents. They are loaded automatically when needed.

Architecture

Predicts

Factory

mobilenet_v3_small_page_orientation

The orientation of a page: 0°, 90°, 180°, 270°

page_orientation_predictor()

mobilenet_v3_small_crop_orientation

The orientation of a word crop: 0°, 90°, 180°, 270°

crop_orientation_predictor()

About the benchmarks#

  • Datasets: unless stated otherwise, models are evaluated on both the training and test sets of FUNSD and CORD (see Datasets). FUNSD has 199 pages (30,595 word crops), which might not be representative of every use case.

  • Metrics are described in Task evaluation.

  • Speed (sec/it) is measured on an 11th Gen Intel(R) Core(TM) i7-11800H @ 2.30GHz CPU, after a warm-up of 100 tensors, as the average over 1,000 samples. The batch size is given in each table.

  • Reproduce or extend them with the evaluate.py and latency.py scripts of the references.