fxsab commited on
Commit
263e245
·
1 Parent(s): f02acca

Fix PaddleOCR Deployment: Add libgomp1 and lock numpy<2

Browse files
Files changed (2) hide show
  1. Dockerfile +22 -2
  2. requirements.txt +1 -0
Dockerfile CHANGED
@@ -13,14 +13,24 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
13
  libsm6 \
14
  libxext6 \
15
  libxrender1 \
 
16
  && rm -rf /var/lib/apt/lists/*
17
 
18
  COPY requirements.txt .
19
  RUN pip install --no-cache-dir -r requirements.txt
20
 
21
  RUN mkdir -p /app/.paddleocr && python - <<'PY'
22
- from paddleocr import PaddleOCR
 
23
 
 
 
 
 
 
 
 
 
24
  for kwargs in (
25
  {'lang': 'en', 'device': 'cpu', 'use_textline_orientation': True, 'show_log': False},
26
  {'lang': 'en', 'device': 'cpu', 'use_textline_orientation': True},
@@ -28,10 +38,20 @@ for kwargs in (
28
  {'lang': 'en', 'use_angle_cls': True, 'use_gpu': False}
29
  ):
30
  try:
 
31
  PaddleOCR(**kwargs)
 
32
  break
33
- except (TypeError, ValueError):
 
34
  pass
 
 
 
 
 
 
 
35
 
36
  print("PaddleOCR models ready")
37
  PY
 
13
  libsm6 \
14
  libxext6 \
15
  libxrender1 \
16
+ libgomp1 \
17
  && rm -rf /var/lib/apt/lists/*
18
 
19
  COPY requirements.txt .
20
  RUN pip install --no-cache-dir -r requirements.txt
21
 
22
  RUN mkdir -p /app/.paddleocr && python - <<'PY'
23
+ import sys
24
+ import traceback
25
 
26
+ try:
27
+ from paddleocr import PaddleOCR
28
+ except Exception as e:
29
+ print(f"Failed to import PaddleOCR: {e}")
30
+ traceback.print_exc()
31
+ sys.exit(1)
32
+
33
+ success = False
34
  for kwargs in (
35
  {'lang': 'en', 'device': 'cpu', 'use_textline_orientation': True, 'show_log': False},
36
  {'lang': 'en', 'device': 'cpu', 'use_textline_orientation': True},
 
38
  {'lang': 'en', 'use_angle_cls': True, 'use_gpu': False}
39
  ):
40
  try:
41
+ print(f"Trying to initialize PaddleOCR with kwargs: {kwargs}")
42
  PaddleOCR(**kwargs)
43
+ success = True
44
  break
45
+ except (TypeError, ValueError) as e:
46
+ print(f"Skipping kwargs due to {type(e).__name__}: {e}")
47
  pass
48
+ except Exception as e:
49
+ print(f"Unexpected error with kwargs {kwargs}: {e}")
50
+ traceback.print_exc()
51
+
52
+ if not success:
53
+ print("Could not initialize PaddleOCR using any parameter combination.")
54
+ sys.exit(1)
55
 
56
  print("PaddleOCR models ready")
57
  PY
requirements.txt CHANGED
@@ -3,6 +3,7 @@ huggingface_hub
3
  httpx
4
  jinja2
5
  pandas
 
6
  paddleocr
7
  paddlepaddle
8
  Pillow
 
3
  httpx
4
  jinja2
5
  pandas
6
+ numpy<2
7
  paddleocr
8
  paddlepaddle
9
  Pillow