fix: add warmup OCR call to avoid timeout on first request
All checks were successful
CI / go-lint (push) Has been skipped
CI / python-lint (push) Has been skipped
CI / nodejs-lint (push) Has been skipped
CI / test-go-consent (push) Successful in 43s
CI / test-python-voice (push) Successful in 35s
CI / test-bqas (push) Successful in 34s
CI / Deploy (push) Successful in 3s

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Benjamin Admin
2026-03-13 16:56:08 +01:00
parent c433bc021e
commit 8979aa8e43

View File

@@ -48,6 +48,13 @@ def _load_model():
logger.info(f"PaddleOCR init strategy {i} failed: {e}") logger.info(f"PaddleOCR init strategy {i} failed: {e}")
else: else:
raise RuntimeError("All PaddleOCR init strategies failed") 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 _ready = True
logger.info("PaddleOCR model loaded successfully — ready to serve") logger.info("PaddleOCR model loaded successfully — ready to serve")
except Exception as e: except Exception as e: