From 36172ba4ff88a85240208a9fdae3b03d6441ffdf Mon Sep 17 00:00:00 2001 From: liuyuanchuang Date: Thu, 5 Feb 2026 22:07:39 +0800 Subject: [PATCH] fix: update port --- app/services/ocr_service.py | 2 +- test_paddleocr_vl_integration.py | 53 --------------------------- test_vllm_connection.py | 62 -------------------------------- 3 files changed, 1 insertion(+), 116 deletions(-) delete mode 100644 test_paddleocr_vl_integration.py delete mode 100644 test_vllm_connection.py diff --git a/app/services/ocr_service.py b/app/services/ocr_service.py index 47b65d9..05a6ac1 100644 --- a/app/services/ocr_service.py +++ b/app/services/ocr_service.py @@ -489,7 +489,7 @@ class MineruOCRService(OCRServiceBase): api_url: str = "http://127.0.0.1:8000/file_parse", image_processor: Optional[ImageProcessor] = None, converter: Optional[Converter] = None, - paddleocr_vl_url: str = "http://localhost:8001/v1", + paddleocr_vl_url: str = "http://localhost:8000/v1", ): """Initialize Local API service. diff --git a/test_paddleocr_vl_integration.py b/test_paddleocr_vl_integration.py deleted file mode 100644 index 7d5eadc..0000000 --- a/test_paddleocr_vl_integration.py +++ /dev/null @@ -1,53 +0,0 @@ -"""Test script for PaddleOCR-VL integration in MineruOCRService.""" - -import cv2 -import numpy as np -from app.services.ocr_service import MineruOCRService -from app.services.converter import Converter -from app.services.image_processor import ImageProcessor - -def test_paddleocr_vl_integration(): - """Test that PaddleOCR-VL is called when image references are found.""" - - # Create a simple test image (white background with black text) - test_image = np.ones((100, 300, 3), dtype=np.uint8) * 255 - cv2.putText(test_image, "x^2 + y^2 = 1", (50, 50), - cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 0, 0), 2) - - # Initialize service - service = MineruOCRService( - api_url="http://127.0.0.1:8000/file_parse", - converter=Converter(), - image_processor=ImageProcessor(), - paddleocr_vl_url="http://localhost:8000/v1" # Your PaddleOCR-VL server - ) - - # Simulate markdown with image reference (this is what Mineru returns) - test_markdown = "![](images/af7f211f671f16f57d346e8e17611e68e0f4671bd1ae52ed59013c10eecef589.jpg)" - - print("Testing formula extraction...") - result = service._extract_and_recognize_formulas(test_markdown, test_image) - - print(f"\nOriginal markdown: {test_markdown}") - print(f"Processed markdown: {result}") - - # Check if the image reference was replaced - if "![](images/" in result: - print("\n❌ FAILED: Image reference was not replaced") - else: - print("\n✅ SUCCESS: Image reference was replaced with formula") - -if __name__ == "__main__": - print("=" * 60) - print("PaddleOCR-VL Integration Test") - print("=" * 60) - print("\nMake sure your PaddleOCR-VL server is running at:") - print("http://localhost:8000/v1") - print("\n" + "=" * 60 + "\n") - - try: - test_paddleocr_vl_integration() - except Exception as e: - print(f"\n❌ Test failed with error: {e}") - import traceback - traceback.print_exc() diff --git a/test_vllm_connection.py b/test_vllm_connection.py deleted file mode 100644 index 8ac9035..0000000 --- a/test_vllm_connection.py +++ /dev/null @@ -1,62 +0,0 @@ -"""Quick test to verify PaddleOCR-VL connection.""" - -from openai import OpenAI -import base64 -import cv2 -import numpy as np - -# Create test image -test_image = np.ones((100, 300, 3), dtype=np.uint8) * 255 -cv2.putText(test_image, "x^2 = 4", (50, 50), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 0, 0), 2) - -# Encode to base64 -success, encoded_image = cv2.imencode(".png", test_image) -if not success: - print("Failed to encode image") - exit(1) - -image_base64 = base64.b64encode(encoded_image.tobytes()).decode("utf-8") -image_url = f"data:image/png;base64,{image_base64}" - -# Test connection -client = OpenAI( - api_key="EMPTY", - base_url="http://100.115.184.74:8001/v1", - timeout=3600 -) - -print("Testing PaddleOCR-VL connection...") -print(f"Server: http://100.115.184.74:8001/v1") -print(f"Model: PaddleOCR-VL-0.9B") -print("-" * 60) - -try: - messages = [ - { - "role": "user", - "content": [ - { - "type": "image_url", - "image_url": {"url": image_url} - }, - { - "type": "text", - "text": "Formula Recognition:" - } - ] - } - ] - - response = client.chat.completions.create( - model="PaddleOCR-VL-0.9B", - messages=messages, - temperature=0.0, - ) - - print("✅ SUCCESS!") - print(f"Response: {response.choices[0].message.content}") - -except Exception as e: - print(f"❌ FAILED: {e}") - import traceback - traceback.print_exc()