fxsab commited on
Commit
8366b4f
·
1 Parent(s): c29fc90

Preload Paddle OCR models and stabilize runtime deps

Browse files
Files changed (3) hide show
  1. Dockerfile +3 -0
  2. requirements.txt +1 -0
  3. simpliscribe/web.py +5 -0
Dockerfile CHANGED
@@ -3,12 +3,15 @@ FROM python:3.10-slim
3
  ENV PYTHONDONTWRITEBYTECODE=1
4
  ENV PYTHONUNBUFFERED=1
5
  ENV PADDLE_PDX_DISABLE_MODEL_SOURCE_CHECK=True
 
6
 
7
  WORKDIR /app
8
 
9
  COPY requirements.txt .
10
  RUN pip install --no-cache-dir -r requirements.txt
11
 
 
 
12
  COPY . .
13
 
14
  EXPOSE 7860
 
3
  ENV PYTHONDONTWRITEBYTECODE=1
4
  ENV PYTHONUNBUFFERED=1
5
  ENV PADDLE_PDX_DISABLE_MODEL_SOURCE_CHECK=True
6
+ ENV PADDLEOCR_HOME=/app/.paddleocr
7
 
8
  WORKDIR /app
9
 
10
  COPY requirements.txt .
11
  RUN pip install --no-cache-dir -r requirements.txt
12
 
13
+ RUN mkdir -p /app/.paddleocr && python -c "from paddleocr import PaddleOCR; PaddleOCR(use_angle_cls=True, lang='en', use_gpu=False, show_log=False); print('PaddleOCR models ready')"
14
+
15
  COPY . .
16
 
17
  EXPOSE 7860
requirements.txt CHANGED
@@ -11,5 +11,6 @@ pyarrow
11
  pytest
12
  python-dotenv
13
  python-multipart
 
14
  reportlab
15
  uvicorn[standard]
 
11
  pytest
12
  python-dotenv
13
  python-multipart
14
+ requests>=2.32.3
15
  reportlab
16
  uvicorn[standard]
simpliscribe/web.py CHANGED
@@ -1,3 +1,4 @@
 
1
  import re
2
  import uuid
3
  from datetime import datetime, timezone
@@ -15,6 +16,9 @@ from .reporting import build_pdf_report
15
  from .storage import append_history, get_analysis_record, load_history
16
 
17
 
 
 
 
18
  def utc_now_iso() -> str:
19
  return datetime.now(timezone.utc).isoformat()
20
 
@@ -109,6 +113,7 @@ async def analyze(file: UploadFile = File(...)) -> JSONResponse:
109
  except HTTPException:
110
  raise
111
  except Exception as exc:
 
112
  message = str(exc)
113
  if "PDX has already been initialized" in message:
114
  message = "OCR engine is warming up. Please retry in a few seconds."
 
1
+ import logging
2
  import re
3
  import uuid
4
  from datetime import datetime, timezone
 
16
  from .storage import append_history, get_analysis_record, load_history
17
 
18
 
19
+ logger = logging.getLogger(__name__)
20
+
21
+
22
  def utc_now_iso() -> str:
23
  return datetime.now(timezone.utc).isoformat()
24
 
 
113
  except HTTPException:
114
  raise
115
  except Exception as exc:
116
+ logger.exception("Prescription analysis failed.")
117
  message = str(exc)
118
  if "PDX has already been initialized" in message:
119
  message = "OCR engine is warming up. Please retry in a few seconds."