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
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:
@@ -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 io
|
||||||
import logging
|
import logging
|
||||||
@@ -23,12 +23,11 @@ def get_engine():
|
|||||||
if _engine is None:
|
if _engine is None:
|
||||||
from paddleocr import PaddleOCR
|
from paddleocr import PaddleOCR
|
||||||
|
|
||||||
logger.info("Loading PaddleOCR model (first time may download)...")
|
logger.info("Loading PaddleOCR model...")
|
||||||
_engine = PaddleOCR(
|
_engine = PaddleOCR(
|
||||||
text_recognition_model_name="latin_PP-OCRv5_mobile_rec",
|
lang="latin",
|
||||||
use_doc_orientation_classify=False,
|
use_angle_cls=True,
|
||||||
use_doc_unwarping=False,
|
show_log=False,
|
||||||
use_textline_orientation=False,
|
|
||||||
)
|
)
|
||||||
logger.info("PaddleOCR model loaded successfully")
|
logger.info("PaddleOCR model loaded successfully")
|
||||||
return _engine
|
return _engine
|
||||||
@@ -49,7 +48,7 @@ def startup_load_model():
|
|||||||
@app.get("/health")
|
@app.get("/health")
|
||||||
def health():
|
def health():
|
||||||
if _ready:
|
if _ready:
|
||||||
return {"status": "ok", "model": "PP-OCRv5-latin"}
|
return {"status": "ok", "model": "PP-OCRv4-latin"}
|
||||||
return {"status": "loading"}
|
return {"status": "loading"}
|
||||||
|
|
||||||
|
|
||||||
@@ -69,31 +68,25 @@ async def ocr(
|
|||||||
img_np = np.array(img)
|
img_np = np.array(img)
|
||||||
|
|
||||||
engine = get_engine()
|
engine = get_engine()
|
||||||
result = engine.predict(img_np)
|
result = engine.ocr(img_np)
|
||||||
|
|
||||||
words = []
|
words = []
|
||||||
for item in result:
|
for line in result[0] or []:
|
||||||
rec_texts = item.get("rec_texts", [])
|
box, (text, conf) = line[0], line[1]
|
||||||
rec_scores = item.get("rec_scores", [])
|
x_min = min(p[0] for p in box)
|
||||||
dt_polys = item.get("dt_polys", [])
|
y_min = min(p[1] for p in box)
|
||||||
|
x_max = max(p[0] for p in box)
|
||||||
for text, score, poly in zip(rec_texts, rec_scores, dt_polys):
|
y_max = max(p[1] for p in box)
|
||||||
if not text or not text.strip():
|
words.append(
|
||||||
continue
|
{
|
||||||
xs = [p[0] for p in poly]
|
"text": text.strip(),
|
||||||
ys = [p[1] for p in poly]
|
"left": int(x_min),
|
||||||
x_min, x_max = min(xs), max(xs)
|
"top": int(y_min),
|
||||||
y_min, y_max = min(ys), max(ys)
|
"width": int(x_max - x_min),
|
||||||
words.append(
|
"height": int(y_max - y_min),
|
||||||
{
|
"conf": round(conf * 100, 1),
|
||||||
"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),
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"words": words,
|
"words": words,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
paddlepaddle>=3.0.0
|
paddlepaddle==2.6.2
|
||||||
paddleocr>=2.9.0
|
paddleocr==2.8.1
|
||||||
fastapi>=0.110.0
|
fastapi>=0.110.0
|
||||||
uvicorn>=0.25.0
|
uvicorn>=0.25.0
|
||||||
python-multipart>=0.0.6
|
python-multipart>=0.0.6
|
||||||
|
|||||||
Reference in New Issue
Block a user