MCPcopy Create free account
hub / github.com/BIT-DataLab/Edit-Banana / layout_ocr

Method layout_ocr

modules/text/restorer.py:63–80  ·  view source on GitHub ↗

Lazy-init layout OCR (tesseract or paddleocr); fallback to Tesseract if PaddleOCR fails.

(self)

Source from the content-addressed store, hash-verified

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):

Callers

nothing calls this directly

Calls 2

PaddleOCRAdapterClass · 0.85
LocalOCRClass · 0.85

Tested by

no test coverage detected