fix: refact logic
This commit is contained in:
@@ -3,20 +3,20 @@
|
||||
from app.services.image_processor import ImageProcessor
|
||||
from app.services.layout_detector import LayoutDetector
|
||||
from app.services.ocr_service import OCRService
|
||||
from app.services.docx_converter import DocxConverter
|
||||
from app.services.converter import Converter
|
||||
from app.core.config import get_settings
|
||||
|
||||
# Global instances (initialized on startup)
|
||||
_layout_detector: LayoutDetector | None = None
|
||||
|
||||
|
||||
def init_layout_detector(model_path: str) -> None:
|
||||
def init_layout_detector() -> None:
|
||||
"""Initialize the global layout detector.
|
||||
|
||||
Called during application startup.
|
||||
"""
|
||||
global _layout_detector
|
||||
_layout_detector = LayoutDetector(model_path=model_path)
|
||||
_layout_detector.load_model()
|
||||
_layout_detector = LayoutDetector()
|
||||
|
||||
|
||||
def get_layout_detector() -> LayoutDetector:
|
||||
@@ -33,10 +33,15 @@ def get_image_processor() -> ImageProcessor:
|
||||
|
||||
def get_ocr_service() -> OCRService:
|
||||
"""Get an OCR service instance."""
|
||||
return OCRService()
|
||||
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_docx_converter() -> DocxConverter:
|
||||
def get_converter() -> Converter:
|
||||
"""Get a DOCX converter instance."""
|
||||
return DocxConverter()
|
||||
return Converter()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user