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
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:
@@ -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:
|
||||||
|
|||||||
Reference in New Issue
Block a user