Remove synthetic training path and add fine-text OCR option

This commit is contained in:
OCR Team
2026-10-07 22:07:30 +02:00
parent e28f50bb88
commit e4adf70db0
10 changed files with 82 additions and 526 deletions
+9 -4
View File
@@ -2,10 +2,10 @@
from __future__ import annotations
import argparse
import json
import os
from pathlib import Path
import sys
ROOT = Path(os.environ.get("OCR_MODEL_HOME", Path(__file__).resolve().parents[1] / ".cache")).expanduser().resolve()
@@ -13,9 +13,12 @@ MODELS = ROOT / "official_models"
def main() -> None:
if len(sys.argv) != 3:
raise SystemExit(2)
image, output = map(Path, sys.argv[1:])
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("image", type=Path)
parser.add_argument("output", type=Path)
parser.add_argument("--fine-text", action="store_true")
args = parser.parse_args()
image, output = args.image, args.output
detector = MODELS / "PP-OCRv5_mobile_det"
recognizer = MODELS / "latin_PP-OCRv5_mobile_rec"
if not (detector / "inference.pdiparams").is_file() or not (recognizer / "inference.pdiparams").is_file():
@@ -30,6 +33,8 @@ def main() -> None:
use_doc_orientation_classify=False,
use_doc_unwarping=False,
use_textline_orientation=False,
text_det_limit_side_len=2048 if args.fine_text else 960,
text_det_limit_type="max",
device="cpu",
)
results = list(engine.predict(str(image)))