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

Method __init__

modules/text/ocr/paddle_ocr.py:31–48  ·  view source on GitHub ↗
(self, use_angle_cls: bool = True, lang: str = "ch")

Source from the content-addressed store, hash-verified

29 """
30
31 def __init__(self, use_angle_cls: bool = True, lang: str = "ch"):
32 if PaddleOCR is None:
33 raise ImportError(
34 "Install PaddleOCR: pip install paddleocr paddlepaddle (or paddlepaddle-gpu)"
35 )
36 try:
37 self._engine = PaddleOCR(use_angle_cls=use_angle_cls, lang=lang)
38 except AttributeError as e:
39 if "set_optimization_level" in str(e):
40 raise RuntimeError(
41 "PaddleOCR incompatible with this PaddlePaddle (missing set_optimization_level).\n"
42 "Install PaddlePaddle 3.x and PaddleOCR 3.x:\n"
43 " pip uninstall paddleocr paddlepaddle paddlepaddle-gpu paddlex -y\n"
44 " pip install \"paddlepaddle>=3.0\" paddleocr # CPU\n"
45 " # GPU: pip install paddlepaddle-gpu paddleocr\n"
46 "See README Optional PaddleOCR section."
47 ) from e
48 raise
49
50 def _parse_result(self, result: Any) -> List[TextBlock]:
51 """Parse PaddleOCR 2.x or 3.x result into list of TextBlock."""

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected