init
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
"""Benchmark the configured OCR pipeline without modifying model files."""
|
||||
|
||||
from pathlib import Path
|
||||
from time import perf_counter
|
||||
|
||||
from ocr_server.config import Settings
|
||||
from ocr_server.ocr import OCRService
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
image_path = Path("http/fixtures/general_ocr_002.png")
|
||||
settings = Settings()
|
||||
service = 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,
|
||||
)
|
||||
service.prepare()
|
||||
started = perf_counter()
|
||||
lines = service.recognize(image_path)
|
||||
elapsed_ms = (perf_counter() - started) * 1000
|
||||
print(f"image={image_path}")
|
||||
print(f"elapsed_ms={elapsed_ms:.2f}")
|
||||
print(f"segments={len(lines)}")
|
||||
@@ -0,0 +1,23 @@
|
||||
"""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,
|
||||
).prepare()
|
||||
print(f"Models are ready in: {settings.model_dir.resolve()}")
|
||||
Reference in New Issue
Block a user