fix: PaddleOCR 3.4.0 compatibility — use lang=en with PP-OCRv5
Some checks failed
Deploy to Coolify / deploy (push) Has been cancelled
Some checks failed
Deploy to Coolify / deploy (push) Has been cancelled
PaddleOCR 3.4.0 removed 'latin' language support, causing ValueError at startup. Now uses lang='en' with ocr_version='PP-OCRv5' and falls back to lang='latin' for older PaddleOCR versions. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
"""PaddleOCR Remote Service — PP-OCRv4 Latin auf x86_64."""
|
||||
"""PaddleOCR Remote Service — PP-OCRv5 Latin auf x86_64."""
|
||||
|
||||
import io
|
||||
import logging
|
||||
@@ -24,11 +24,20 @@ def get_engine():
|
||||
from paddleocr import PaddleOCR
|
||||
|
||||
logger.info("Loading PaddleOCR model...")
|
||||
_engine = PaddleOCR(
|
||||
lang="latin",
|
||||
use_angle_cls=True,
|
||||
show_log=False,
|
||||
)
|
||||
# PaddleOCR >= 3.x: use ocr_version param; fallback for older API
|
||||
try:
|
||||
_engine = PaddleOCR(
|
||||
lang="en",
|
||||
ocr_version="PP-OCRv5",
|
||||
use_angle_cls=True,
|
||||
show_log=False,
|
||||
)
|
||||
except (ValueError, TypeError):
|
||||
_engine = PaddleOCR(
|
||||
lang="latin",
|
||||
use_angle_cls=True,
|
||||
show_log=False,
|
||||
)
|
||||
logger.info("PaddleOCR model loaded successfully")
|
||||
return _engine
|
||||
|
||||
@@ -48,7 +57,7 @@ def startup_load_model():
|
||||
@app.get("/health")
|
||||
def health():
|
||||
if _ready:
|
||||
return {"status": "ok", "model": "PP-OCRv4-latin"}
|
||||
return {"status": "ok", "model": "PP-OCRv5-latin"}
|
||||
return {"status": "loading"}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user