Lazy-init layout OCR (tesseract or paddleocr); fallback to Tesseract if PaddleOCR fails.
(self)
| 61 | |
| 62 | @property |
| 63 | def layout_ocr(self): |
| 64 | """Lazy-init layout OCR (tesseract or paddleocr); fallback to Tesseract if PaddleOCR fails.""" |
| 65 | if self._layout_ocr is None: |
| 66 | if self._ocr_engine == "paddleocr": |
| 67 | try: |
| 68 | from .ocr.paddle_ocr import PaddleOCRAdapter |
| 69 | self._layout_ocr = PaddleOCRAdapter() |
| 70 | except Exception as e: |
| 71 | import warnings |
| 72 | warnings.warn( |
| 73 | f"PaddleOCR unavailable ({e}), falling back to Tesseract. See README for compatible install.", |
| 74 | UserWarning, |
| 75 | stacklevel=2, |
| 76 | ) |
| 77 | self._layout_ocr = LocalOCR() |
| 78 | else: |
| 79 | self._layout_ocr = LocalOCR() |
| 80 | return self._layout_ocr |
| 81 | |
| 82 | @property |
| 83 | def pix2text_ocr(self): |
nothing calls this directly
no test coverage detected