paddleocr-lite 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- paddleocr_lite-0.1.0/PKG-INFO +9 -0
- paddleocr_lite-0.1.0/README.md +0 -0
- paddleocr_lite-0.1.0/pyproject.toml +17 -0
- paddleocr_lite-0.1.0/pyproject.toml.orig +17 -0
- paddleocr_lite-0.1.0/src/paddleocr_lite/__init__.py +3 -0
- paddleocr_lite-0.1.0/src/paddleocr_lite/cli.py +29 -0
- paddleocr_lite-0.1.0/src/paddleocr_lite/core.py +29 -0
|
File without changes
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "paddleocr-lite"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "Paddleocr wrapper package for simple usage."
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
requires-python = ">=3.12"
|
|
7
|
+
dependencies = [
|
|
8
|
+
"paddleocr>=3.7.0",
|
|
9
|
+
"paddlepaddle>=3.3.1",
|
|
10
|
+
]
|
|
11
|
+
|
|
12
|
+
[project.scripts]
|
|
13
|
+
paddleocr-lite = "paddleocr_lite.cli:main"
|
|
14
|
+
|
|
15
|
+
[build-system]
|
|
16
|
+
requires = ["uv_build>=0.12.6,<0.13.0"]
|
|
17
|
+
build-backend = "uv_build"
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "paddleocr-lite"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "Paddleocr wrapper package for simple usage."
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
requires-python = ">=3.12"
|
|
7
|
+
dependencies = [
|
|
8
|
+
"paddleocr>=3.7.0",
|
|
9
|
+
"paddlepaddle>=3.3.1",
|
|
10
|
+
]
|
|
11
|
+
|
|
12
|
+
[project.scripts]
|
|
13
|
+
paddleocr-lite = "paddleocr_lite.cli:main"
|
|
14
|
+
|
|
15
|
+
[build-system]
|
|
16
|
+
requires = ["uv_build>=0.12.6,<0.13.0"]
|
|
17
|
+
build-backend = "uv_build"
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import argparse
|
|
2
|
+
from .core import SimpleOCR
|
|
3
|
+
|
|
4
|
+
def main():
|
|
5
|
+
parser = argparse.ArgumentParser(
|
|
6
|
+
prog="paddleocr-lite",
|
|
7
|
+
description="Simple CLI wrapper around PaddleOCR"
|
|
8
|
+
)
|
|
9
|
+
parser.add_argument("image", help="Path to the image file to OCR")
|
|
10
|
+
parser.add_argument("--lang", default="en", help="Language for OCR (default: en)")
|
|
11
|
+
parser.add_argument("--detailed", action="store_true", help="Show confidence scores and bounding boxes")
|
|
12
|
+
|
|
13
|
+
args = parser.parse_args()
|
|
14
|
+
|
|
15
|
+
ocr = SimpleOCR(lang=args.lang)
|
|
16
|
+
|
|
17
|
+
if args.detailed:
|
|
18
|
+
results = ocr.read_with_confidence(args.image)
|
|
19
|
+
for item in results:
|
|
20
|
+
print(f"[{item['confidence']:.2f}] {item['text']}")
|
|
21
|
+
else:
|
|
22
|
+
text = ocr.read_text(args.image)
|
|
23
|
+
for line in text:
|
|
24
|
+
print(line)
|
|
25
|
+
|
|
26
|
+
if __name__ == '__main__':
|
|
27
|
+
main()
|
|
28
|
+
|
|
29
|
+
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
from paddleocr import PaddleOCR
|
|
2
|
+
|
|
3
|
+
class SimpleOCR:
|
|
4
|
+
def __init__(self, lang: str = "en"):
|
|
5
|
+
self._ocr = PaddleOCR(lang = lang, use_angle_cls = True)
|
|
6
|
+
|
|
7
|
+
def read_text(self, image_path: str) -> list[str]:
|
|
8
|
+
"""Returns the recognized text lines from an image"""
|
|
9
|
+
result = self._ocr.ocr(image_path)
|
|
10
|
+
lines = []
|
|
11
|
+
for block in result:
|
|
12
|
+
for _, (text, confidence) in block:
|
|
13
|
+
lines.append(text)
|
|
14
|
+
return lines
|
|
15
|
+
|
|
16
|
+
def read_with_confidence(self, image_path: str) -> list[dict]:
|
|
17
|
+
"""Returns text with bounding box + confidence for more detail."""
|
|
18
|
+
result = self._ocr.ocr(image_path)
|
|
19
|
+
output = []
|
|
20
|
+
for block in result:
|
|
21
|
+
for box, (text, confidence) in block:
|
|
22
|
+
output.append(
|
|
23
|
+
{
|
|
24
|
+
"text": text,
|
|
25
|
+
"confidence": confidence,
|
|
26
|
+
"box": box,
|
|
27
|
+
}
|
|
28
|
+
)
|
|
29
|
+
return output
|