Spaces:
Running
Running
Commit ·
9beb748
1
Parent(s): 0fd3a61
Default OCR off for deploy — TrOCR OOM-kills the 512MB Render worker
Browse filesAn OS OOM SIGKILL is uncatchable in Python, so the try/except fallback can't
save it — the worker dies and the request hangs (HTTP 000 / timeout). The only
reliable fix on a 512MB host is to never load TrOCR. Default ocr_enabled=False;
enable locally via OCR_ENABLED=true where RAM is available.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- .env.example +5 -0
- backend/app/config.py +6 -3
.env.example
CHANGED
|
@@ -10,6 +10,11 @@ STOP_LINE_FRAC=0.6
|
|
| 10 |
WRONG_SIDE_ENFORCEMENT=true
|
| 11 |
WRONG_SIDE_DIRECTION=down
|
| 12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
# ── Illegal parking zones ─────────────────────────────────────────────────
|
| 14 |
# JSON array of no-parking polygons. Each polygon is a list of [x, y] fractions
|
| 15 |
# of the frame (0.0–1.0, top-left origin). Example marks both road shoulders:
|
|
|
|
| 10 |
WRONG_SIDE_ENFORCEMENT=true
|
| 11 |
WRONG_SIDE_DIRECTION=down
|
| 12 |
|
| 13 |
+
# ── Plate OCR (TrOCR) ─────────────────────────────────────────────────────
|
| 14 |
+
# OFF by default. Loading TrOCR can exceed a 512MB host's RAM and the OS kills
|
| 15 |
+
# the worker (hangs the request). Only set true on a host with ≥2GB RAM.
|
| 16 |
+
# OCR_ENABLED=true
|
| 17 |
+
|
| 18 |
# ── Illegal parking zones ─────────────────────────────────────────────────
|
| 19 |
# JSON array of no-parking polygons. Each polygon is a list of [x, y] fractions
|
| 20 |
# of the frame (0.0–1.0, top-left origin). Example marks both road shoulders:
|
backend/app/config.py
CHANGED
|
@@ -32,9 +32,12 @@ class Settings(BaseSettings):
|
|
| 32 |
# ~1.4GB for "base" — base OOMs a 512MB host, so small is the deploy default.
|
| 33 |
# Use "microsoft/trocr-base-printed" only on a host with ≥2GB RAM.
|
| 34 |
trocr_model: str = "microsoft/trocr-small-printed"
|
| 35 |
-
# Plate OCR is the heaviest stage
|
| 36 |
-
#
|
| 37 |
-
|
|
|
|
|
|
|
|
|
|
| 38 |
|
| 39 |
# Violation rules
|
| 40 |
# Helmet/no-helmet detector. The bundled YOLO11 weight emits rider classes
|
|
|
|
| 32 |
# ~1.4GB for "base" — base OOMs a 512MB host, so small is the deploy default.
|
| 33 |
# Use "microsoft/trocr-base-printed" only on a host with ≥2GB RAM.
|
| 34 |
trocr_model: str = "microsoft/trocr-small-printed"
|
| 35 |
+
# Plate OCR is the heaviest stage — loading TrOCR can exceed a 512MB host's
|
| 36 |
+
# RAM and the OS SIGKILLs the worker (uncatchable in Python), hanging the
|
| 37 |
+
# request. So it's OFF by default for safe cloud deploys; violations are
|
| 38 |
+
# still detected, just without plate text. Set OCR_ENABLED=true on a host
|
| 39 |
+
# with enough RAM (e.g. your local machine) to read plates.
|
| 40 |
+
ocr_enabled: bool = False
|
| 41 |
|
| 42 |
# Violation rules
|
| 43 |
# Helmet/no-helmet detector. The bundled YOLO11 weight emits rider classes
|