From 8979aa8e43ddbb93b027ac73255bea863d039dc9 Mon Sep 17 00:00:00 2001 From: Benjamin Admin Date: Fri, 13 Mar 2026 16:56:08 +0100 Subject: [PATCH] fix: add warmup OCR call to avoid timeout on first request Co-Authored-By: Claude Opus 4.6 --- paddleocr-service/main.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/paddleocr-service/main.py b/paddleocr-service/main.py index 04b7e77..455136d 100644 --- a/paddleocr-service/main.py +++ b/paddleocr-service/main.py @@ -48,6 +48,13 @@ def _load_model(): logger.info(f"PaddleOCR init strategy {i} failed: {e}") else: raise RuntimeError("All PaddleOCR init strategies failed") + # Warmup: run a dummy OCR to trigger JIT compilation + # Without this, the first real request takes minutes on CPU + logger.info("Running warmup OCR (JIT compilation)...") + dummy = np.ones((50, 200, 3), dtype=np.uint8) * 255 + _engine.ocr(dummy) + logger.info("Warmup complete") + _ready = True logger.info("PaddleOCR model loaded successfully — ready to serve") except Exception as e: