Files
ocr-server/scripts/download_models.py
T
zimoyin a7d4ff6454 feat: add enable_detection switch to skip text detection
enable_detection: false 跳过检测模型,直接把整图当一行文本送识别。
实测:单行图可正确识别;多行整图因识别模型固定缩放到高 48px 会返回空结果,已加告警。

Co-Authored-By: Claude Code <noreply@anthropic.com>
2026-10-13 15:59:25 +08:00

28 lines
1.1 KiB
Python

"""Download PP-OCRv5 models into the project's configured model directory."""
from ocr_server.config import Settings
from ocr_server.ocr import OCRService
if __name__ == "__main__":
settings = Settings()
OCRService(
lang=settings.lang,
device=settings.device,
model_dir=settings.model_dir,
det_model_name=settings.det_model_name,
rec_model_name=settings.rec_model_name,
text_det_limit_side_len=settings.text_det_limit_side_len,
text_det_limit_type=settings.text_det_limit_type,
text_det_thresh=settings.text_det_thresh,
text_det_box_thresh=settings.text_det_box_thresh,
text_det_unclip_ratio=settings.text_det_unclip_ratio,
text_rec_score_thresh=settings.text_rec_score_thresh,
text_recognition_batch_size=settings.text_recognition_batch_size,
cpu_threads=settings.cpu_threads_resolved,
enable_mkldnn=settings.enable_mkldnn,
enable_detection=settings.enable_detection,
return_word_box=settings.return_word_box,
).prepare()
print(f"Models are ready in: {settings.model_dir.resolve()}")