feat add glm-ocr core

This commit is contained in:
liuyuanchuang
2026-03-09 16:51:06 +08:00
parent d74130914c
commit 6dfaf9668b
17 changed files with 1687 additions and 140 deletions

View File

@@ -2,7 +2,7 @@
from app.services.image_processor import ImageProcessor
from app.services.layout_detector import LayoutDetector
from app.services.ocr_service import OCRService, MineruOCRService, GLMOCRService
from app.services.ocr_service import GLMOCREndToEndService
from app.services.converter import Converter
from app.core.config import get_settings
@@ -31,40 +31,17 @@ def get_image_processor() -> ImageProcessor:
return ImageProcessor()
def get_ocr_service() -> OCRService:
"""Get an OCR service instance."""
return OCRService(
vl_server_url=get_settings().paddleocr_vl_url,
layout_detector=get_layout_detector(),
image_processor=get_image_processor(),
converter=get_converter(),
)
def get_converter() -> Converter:
"""Get a DOCX converter instance."""
return Converter()
def get_mineru_ocr_service() -> MineruOCRService:
"""Get a MinerOCR service instance."""
def get_glmocr_endtoend_service() -> GLMOCREndToEndService:
"""Get end-to-end GLM-OCR service (layout detection + per-region OCR)."""
settings = get_settings()
api_url = getattr(settings, "miner_ocr_api_url", "http://127.0.0.1:8000/file_parse")
glm_ocr_url = getattr(settings, "glm_ocr_url", "http://localhost:8002/v1")
return MineruOCRService(
api_url=api_url,
converter=get_converter(),
image_processor=get_image_processor(),
glm_ocr_url=glm_ocr_url,
)
def get_glmocr_service() -> GLMOCRService:
"""Get a GLM OCR service instance."""
settings = get_settings()
glm_ocr_url = getattr(settings, "glm_ocr_url", "http://127.0.0.1:8002/v1")
return GLMOCRService(
vl_server_url=glm_ocr_url,
return GLMOCREndToEndService(
vl_server_url=settings.glm_ocr_url,
image_processor=get_image_processor(),
converter=get_converter(),
layout_detector=get_layout_detector(),
)