fix: pin PaddlePaddle 2.6.2 + PaddleOCR 2.8.1 (stable, no PIR bug)
Some checks failed
Deploy to Coolify / deploy (push) Has been cancelled

PaddlePaddle 3.x hat oneDNN/PIR Executor Bug. Zurueck auf 2.6.2
mit bewaeherter ocr() API statt predict().

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Benjamin Admin
2026-03-12 13:32:54 +01:00
parent 2c9b0dc448
commit 79891063dd
2 changed files with 25 additions and 32 deletions

View File

@@ -1,4 +1,4 @@
"""PaddleOCR Remote Service — PP-OCRv5 Latin auf x86_64."""
"""PaddleOCR Remote Service — PP-OCRv4 Latin auf x86_64."""
import io
import logging
@@ -23,12 +23,11 @@ def get_engine():
if _engine is None:
from paddleocr import PaddleOCR
logger.info("Loading PaddleOCR model (first time may download)...")
logger.info("Loading PaddleOCR model...")
_engine = PaddleOCR(
text_recognition_model_name="latin_PP-OCRv5_mobile_rec",
use_doc_orientation_classify=False,
use_doc_unwarping=False,
use_textline_orientation=False,
lang="latin",
use_angle_cls=True,
show_log=False,
)
logger.info("PaddleOCR model loaded successfully")
return _engine
@@ -49,7 +48,7 @@ def startup_load_model():
@app.get("/health")
def health():
if _ready:
return {"status": "ok", "model": "PP-OCRv5-latin"}
return {"status": "ok", "model": "PP-OCRv4-latin"}
return {"status": "loading"}
@@ -69,31 +68,25 @@ async def ocr(
img_np = np.array(img)
engine = get_engine()
result = engine.predict(img_np)
result = engine.ocr(img_np)
words = []
for item in result:
rec_texts = item.get("rec_texts", [])
rec_scores = item.get("rec_scores", [])
dt_polys = item.get("dt_polys", [])
for text, score, poly in zip(rec_texts, rec_scores, dt_polys):
if not text or not text.strip():
continue
xs = [p[0] for p in poly]
ys = [p[1] for p in poly]
x_min, x_max = min(xs), max(xs)
y_min, y_max = min(ys), max(ys)
words.append(
{
"text": text.strip(),
"left": int(x_min),
"top": int(y_min),
"width": int(x_max - x_min),
"height": int(y_max - y_min),
"conf": round(float(score) * 100, 1),
}
)
for line in result[0] or []:
box, (text, conf) = line[0], line[1]
x_min = min(p[0] for p in box)
y_min = min(p[1] for p in box)
x_max = max(p[0] for p in box)
y_max = max(p[1] for p in box)
words.append(
{
"text": text.strip(),
"left": int(x_min),
"top": int(y_min),
"width": int(x_max - x_min),
"height": int(y_max - y_min),
"conf": round(conf * 100, 1),
}
)
return {
"words": words,

View File

@@ -1,5 +1,5 @@
paddlepaddle>=3.0.0
paddleocr>=2.9.0
paddlepaddle==2.6.2
paddleocr==2.8.1
fastapi>=0.110.0
uvicorn>=0.25.0
python-multipart>=0.0.6