Skip to main content

Pick an Engine

First, choose and configure a Layer 1 engine. Each engine has its own parameters — see the Layer 1 Engines section for details on each one.
from upsonic.ocr.layer_1.engines import EasyOCREngine

engine = EasyOCREngine(languages=['en'], gpu=True)
All available engines:
EngineBest for
EasyOCREngineMulti-language support, 80+ languages
RapidOCREngineSpeed and lightweight deployment
TesseractOCREngineTraditional OCR, 100+ languages
DeepSeekOCREngineBatch processing with vLLM
DeepSeekOllamaOCREngineLocal processing via Ollama
PaddleOCREngineGeneral OCR (PP-OCRv5)
PPStructureV3EngineDocument structure recognition
PPChatOCRv4EngineChat-based document understanding
PaddleOCRVLEngineVision-Language document understanding

Create the Orchestrator

Pass the engine instance to the OCR orchestrator:
from upsonic.ocr import OCR
from upsonic.ocr.layer_1.engines import EasyOCREngine

engine = EasyOCREngine(languages=['en'], gpu=True)
ocr = OCR(layer_1_ocr_engine=engine)

With Timeout

You can set a per-page timeout to prevent long-running operations:
from upsonic.ocr import OCR
from upsonic.ocr.layer_1.engines import EasyOCREngine

engine = EasyOCREngine(languages=['en'])
ocr = OCR(layer_1_ocr_engine=engine, layer_1_timeout=30.0)
See Timeout for details on timeout handling.

Full Example

from upsonic.ocr import OCR
from upsonic.ocr.layer_1.engines import EasyOCREngine

# 1. Configure engine
engine = EasyOCREngine(
    languages=['en'],
    rotation_fix=True,
    enhance_contrast=True,
    pdf_dpi=300
)

# 2. Create orchestrator
ocr = OCR(layer_1_ocr_engine=engine, layer_1_timeout=60.0)

# Ready to use
text = ocr.get_text('document.pdf')
print(text)