xpark.dataset.ImageExtractTextLayout#
- class xpark.dataset.ImageExtractTextLayout(mode: Literal['accurate', 'fast'] = 'accurate', text_confidence: float = 0.5, box_confidence: float = 0.6, concurrency: int = 10, use_cls: bool = False, text_detection_only: bool = False, engine: Literal['paddleocr', 'rapidocr'] = 'paddleocr', **ocr_kwargs)#
Extract the OCR text layout of an image via PP-OCRv6 (ONNXRuntime).
Each input row is one image; the output is a list of detected text regions
TextLayoutBox. Input accepts a local path, a remote URI (cos:///s3:///http(s)://), raw image bytes, or a decodeduint8HWC ndarray.- Parameters:
mode –
"accurate"(default, best accuracy) or"fast"(faster, lower resource usage).text_confidence – Recognition confidence threshold in [0, 1]; regions below it are dropped. Default
0.5.box_confidence – Detection box confidence threshold in [0, 1]; boxes below it are dropped. Default
0.6mirrors PaddleOCR’stext_det_box_threshdefault.concurrency – CPU inference threads (CPU only). Default
10.use_cls – If True, run the text-line orientation classifier (rotates 180°-flipped lines upright) before recognition; keep False for upright text. Ignored when
text_detection_only=Trueandengine="paddleocr", since the standalone detector has no orientation step. DefaultFalse.text_detection_only – If True, only detect boxes and skip recognition entirely — for
"paddleocr"a standalone detector is used (no recognition model is even loaded); for"rapidocr"the recognition step is disabled.textis""andconfidenceis 0.0. DefaultFalse.engine – OCR backend,
"paddleocr"or"rapidocr". Default"paddleocr".**ocr_kwargs – Extra params forwarded to the engine.
"paddleocr"→PaddleOCR.__init__(e.g.use_doc_orientation_classify/use_doc_unwarping);"rapidocr"→ merged into the RapidOCRparamsdict (dotted keys, e.g.{"Det.box_thresh": 0.5}).
Examples
from xpark.dataset import ImageExtractTextLayout, from_items from xpark.dataset.expressions import col ds = from_items([{"image": "example.jpg"}]) ds = ds.with_column( "layout", ImageExtractTextLayout(text_confidence=0.75, box_confidence=0.6) .options(num_workers={"CPU": 1}, batch_size=8) .with_column(col("image")), )
Methods
__call__(images)Call self as a function.
options(**kwargs)with_column(images)- __call__(images: pa.ChunkedArray) pa.Array#
Call self as a function.
- options(**kwargs: Unpack[ExprUDFOptions]) Self#
- with_column(images: pa.ChunkedArray) pa.Array#