DocTROCRPrediction
Python template · sinapsis_doctr.templates.doc_tr_ocr_prediction
Overview
Template for Optical Character Recognition (OCR) prediction using docTR.
This class leverages docTR's OCR models to extract text, bounding boxes, and confidence scores from images. The extracted information is stored as annotations to each image packet in the input DataContainer.
docTR uses a two-stage approach for OCR: 1. Text detection: Localizing words in the document 2. Text recognition: Identifying characters in each detected word
The template allows configuration of both detection and recognition architectures, as well as various processing options.
Capabilities
Capabilities: not setInstallation
Install the published package using pip or uv.
pip install sinapsis-doctr==1.0.0uv pip install sinapsis-doctr==1.0.0uv add sinapsis-doctr==1.0.0Configuration
Effective fields from the inspector schema, including nested Pydantic model fields.
Detection architecture to use. Defaults to "fast_base". Options include db_resnet50, linknet_resnet18, fast_base, etc.
Optional
Default: "fast_base"
Optional
Default: null
Recognition architecture to use. Defaults to "crnn_vgg16_bn". Options include crnn_vgg16_bn, master, parseq, etc.
Optional
Default: "crnn_vgg16_bn"
Whether to use pretrained models. Defaults to True.
Optional
Default: true
Whether to use symmetric padding. Defaults to True.
Optional
Default: true
Whether to detect language of the text. Defaults to False.
Optional
Default: false
Whether to straighten pages before processing. Defaults to False.
Optional
Default: false
Whether to detect page orientation. Defaults to False.
Optional
Default: false
Whether to use pretrained backbones. Defaults to True.
Optional
Default: true
Whether to assume pages are straight (not rotated). Defaults to True.
Optional
Default: true
Whether to preserve aspect ratio during preprocessing. Defaults to True.
Optional
Default: true
Whether to use artefact types as label strings. Defaults to False.
Optional
Default: false
Whether to export rotated boxes as straight boxes. Defaults to False.
Optional
Default: false
Whether to use recognized text as label strings. Defaults to False.
Optional
Default: false
Configuration example
Generated from documented defaults. Replace any placeholders and complete required nested settings before running.
templates:
- template_name: "DocTROCRPrediction"
class_name: "DocTROCRPrediction"
attributes:
det_arch: "fast_base"
reco_arch: "crnn_vgg16_bn"
pretrained: true
symmetric_pad: true
detect_language: false
straighten_pages: false
detect_orientation: false
pretrained_backbone: true
assume_straight_pages: true
preserve_aspect_ratio: true
artefact_type_as_labels: false
export_as_straight_boxes: false
recognized_characters_as_labels: false
Inheritance
sinapsis_core.template_base.template.TemplateEnvironment variables
Environment definitions belong to their canonical Python modules.
No directly related environment variables listed.