fix: update paddle-ocr url

This commit is contained in:
liuyuanchuang
2026-02-09 22:26:31 +08:00
parent f64bf25f67
commit a568149164
2 changed files with 8 additions and 8 deletions

View File

@@ -50,12 +50,12 @@ def get_mineru_ocr_service() -> MineruOCRService:
"""Get a MinerOCR service instance.""" """Get a MinerOCR service instance."""
settings = get_settings() settings = get_settings()
api_url = getattr(settings, "miner_ocr_api_url", "http://127.0.0.1:8000/file_parse") api_url = getattr(settings, "miner_ocr_api_url", "http://127.0.0.1:8000/file_parse")
paddleocr_vl_url = getattr(settings, "paddleocr_vl_url", "http://localhost:8001/v1") glm_ocr_url = getattr(settings, "glm_ocr_url", "http://localhost:8002/v1")
return MineruOCRService( return MineruOCRService(
api_url=api_url, api_url=api_url,
converter=get_converter(), converter=get_converter(),
image_processor=get_image_processor(), image_processor=get_image_processor(),
paddleocr_vl_url=paddleocr_vl_url, glm_ocr_url=glm_ocr_url,
) )

View File

@@ -598,7 +598,7 @@ class MineruOCRService(OCRServiceBase):
api_url: str = "http://127.0.0.1:8000/file_parse", api_url: str = "http://127.0.0.1:8000/file_parse",
image_processor: Optional[ImageProcessor] = None, image_processor: Optional[ImageProcessor] = None,
converter: Optional[Converter] = None, converter: Optional[Converter] = None,
paddleocr_vl_url: str = "http://localhost:8001/v1", glm_ocr_url: str = "http://localhost:8002/v1",
layout_detector: Optional[LayoutDetector] = None, layout_detector: Optional[LayoutDetector] = None,
): ):
"""Initialize Local API service. """Initialize Local API service.
@@ -606,13 +606,13 @@ class MineruOCRService(OCRServiceBase):
Args: Args:
api_url: URL of the local file_parse API endpoint. api_url: URL of the local file_parse API endpoint.
converter: Optional converter instance for format conversion. converter: Optional converter instance for format conversion.
paddleocr_vl_url: URL of the PaddleOCR-VL vLLM server. glm_ocr_url: URL of the GLM-OCR vLLM server.
""" """
self.api_url = api_url self.api_url = api_url
self.image_processor = image_processor self.image_processor = image_processor
self.converter = converter self.converter = converter
self.paddleocr_vl_url = paddleocr_vl_url self.glm_ocr_url = glm_ocr_url
self.openai_client = OpenAI(api_key="EMPTY", base_url=paddleocr_vl_url, timeout=3600) self.openai_client = OpenAI(api_key="EMPTY", base_url=glm_ocr_url, timeout=3600)
def _recognize_formula_with_paddleocr_vl(self, image: np.ndarray, prompt: str = "Formula Recognition:") -> str: def _recognize_formula_with_paddleocr_vl(self, image: np.ndarray, prompt: str = "Formula Recognition:") -> str:
"""Recognize formula using PaddleOCR-VL API. """Recognize formula using PaddleOCR-VL API.
@@ -687,10 +687,10 @@ class MineruOCRService(OCRServiceBase):
image_bytes.seek(0) image_bytes.seek(0)
image_data = np.frombuffer(image_bytes.read(), dtype=np.uint8) image_data = np.frombuffer(image_bytes.read(), dtype=np.uint8)
original_image = cv2.imdecode(image_data, cv2.IMREAD_COLOR) original_image = cv2.imdecode(image_data, cv2.IMREAD_COLOR)
# Reset image_bytes for API request # Reset image_bytes for API request
image_bytes.seek(0) image_bytes.seek(0)
# Prepare multipart form data # Prepare multipart form data
files = {"files": ("image.png", image_bytes, "image/png")} files = {"files": ("image.png", image_bytes, "image/png")}