Add 195 files (runs/hf-recognizer-mixed-v2-full/finalized/package/artifacts/model/model.safetensors ...)
1ef1de7 verified Download tests/test_engines.py from prosperious/ocr-tech-k2: direct link, hf CLI and curl.
- Browser
- Download file 1.67 kB
-
https://huggingface.co/prosperious/ocr-tech-k2/resolve/main/tests/test_engines.py
- Command line
-
hf download hf://prosperious/ocr-tech-k2/tests/test_engines.py
-
curl -L -o test_engines.py https://huggingface.co/prosperious/ocr-tech-k2/resolve/main/tests/test_engines.py
1.67 kB
| from __future__ import annotations | |
| from ocrtech.engines import PaddleOcrEngine | |
| def test_paddleocr_engine_parses_v3_page_results() -> None: | |
| engine = object.__new__(PaddleOcrEngine) | |
| raw_result = [ | |
| { | |
| "input_path": "page.png", | |
| "rec_texts": ["नेपाल सरकार", "Mixed English 123"], | |
| "rec_scores": [0.98, 0.87], | |
| "rec_polys": [ | |
| [[10, 10], [210, 10], [210, 40], [10, 40]], | |
| [[10, 50], [250, 50], [250, 80], [10, 80]], | |
| ], | |
| } | |
| ] | |
| lines = engine._parse_result(raw_result, page_index=0) | |
| assert [line.text for line in lines] == ["नेपाल सरकार", "Mixed English 123"] | |
| assert [line.confidence for line in lines] == [0.98, 0.87] | |
| assert [line.line_id for line in lines] == ["p0-l0", "p0-l1"] | |
| def test_paddleocr_engine_parses_v3_json_wrapper_results() -> None: | |
| engine = object.__new__(PaddleOcrEngine) | |
| class FakeOcrResult: | |
| def __init__(self) -> None: | |
| self.json = { | |
| "res": { | |
| "rec_texts": ["तालिका", "Table"], | |
| "rec_scores": [0.75, 0.66], | |
| "rec_polys": [ | |
| [[0, 0], [80, 0], [80, 20], [0, 20]], | |
| [[0, 30], [80, 30], [80, 50], [0, 50]], | |
| ], | |
| } | |
| } | |
| lines = engine._parse_result([FakeOcrResult()], page_index=2) | |
| assert [line.text for line in lines] == ["तालिका", "Table"] | |
| assert [line.page_index for line in lines] == [2, 2] | |
| assert [line.line_id for line in lines] == ["p2-l0", "p2-l1"] | |