Spaces:
Runtime error
Runtime error
Rivalcoder
commited on
Commit
·
210935f
1
Parent(s):
0dbdcad
Add files
Browse files- Dockerfile +13 -2
Dockerfile
CHANGED
|
@@ -12,13 +12,24 @@ RUN apt-get update && apt-get install -y \
|
|
| 12 |
|
| 13 |
WORKDIR /app
|
| 14 |
|
| 15 |
-
# Create writable EasyOCR
|
| 16 |
RUN mkdir -p /app/.EasyOCR/user_network
|
| 17 |
|
| 18 |
-
# Copy requirements
|
| 19 |
COPY requirements.txt .
|
| 20 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
# Copy app
|
| 23 |
COPY app.py .
|
| 24 |
|
|
|
|
| 12 |
|
| 13 |
WORKDIR /app
|
| 14 |
|
| 15 |
+
# Create writable dirs for EasyOCR
|
| 16 |
RUN mkdir -p /app/.EasyOCR/user_network
|
| 17 |
|
| 18 |
+
# Copy requirements first (cache layer)
|
| 19 |
COPY requirements.txt .
|
| 20 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 21 |
|
| 22 |
+
# ⚡ Pre-download EasyOCR model files at build time
|
| 23 |
+
RUN python3 - <<'EOF'
|
| 24 |
+
import easyocr, os
|
| 25 |
+
MODEL_DIR = "/app/.EasyOCR"
|
| 26 |
+
USER_NET_DIR = os.path.join(MODEL_DIR, "user_network")
|
| 27 |
+
os.makedirs(MODEL_DIR, exist_ok=True)
|
| 28 |
+
os.makedirs(USER_NET_DIR, exist_ok=True)
|
| 29 |
+
# this will download weights into /app/.EasyOCR
|
| 30 |
+
reader = easyocr.Reader(['en'], model_storage_directory=MODEL_DIR, user_network_directory=USER_NET_DIR)
|
| 31 |
+
EOF
|
| 32 |
+
|
| 33 |
# Copy app
|
| 34 |
COPY app.py .
|
| 35 |
|