From 79891063ddb721a350c4f6d26be9e0131058a891 Mon Sep 17 00:00:00 2001 From: Benjamin Admin Date: Thu, 12 Mar 2026 13:32:54 +0100 Subject: [PATCH] fix: pin PaddlePaddle 2.6.2 + PaddleOCR 2.8.1 (stable, no PIR bug) 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 --- paddleocr-service/main.py | 53 +++++++++++++----------------- paddleocr-service/requirements.txt | 4 +-- 2 files changed, 25 insertions(+), 32 deletions(-) diff --git a/paddleocr-service/main.py b/paddleocr-service/main.py index 086d762..f66aef7 100644 --- a/paddleocr-service/main.py +++ b/paddleocr-service/main.py @@ -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, diff --git a/paddleocr-service/requirements.txt b/paddleocr-service/requirements.txt index 47f8951..0d3e063 100644 --- a/paddleocr-service/requirements.txt +++ b/paddleocr-service/requirements.txt @@ -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