Update app.py
Browse files
app.py
CHANGED
|
@@ -1,33 +1,30 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
import cv2
|
| 4 |
-
import numpy as np
|
| 5 |
|
| 6 |
-
#
|
| 7 |
-
|
| 8 |
-
ocr = PaddleOCR(use_angle_cls=True, lang='en', use_gpu=False)
|
| 9 |
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
-
|
| 15 |
-
|
|
|
|
|
|
|
| 16 |
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
|
| 22 |
-
|
|
|
|
| 23 |
|
| 24 |
-
#
|
| 25 |
-
|
| 26 |
-
demo = gr.Interface(
|
| 27 |
-
fn=run_ocr,
|
| 28 |
-
inputs=gr.Image(type="numpy"),
|
| 29 |
-
outputs="text",
|
| 30 |
-
)
|
| 31 |
-
|
| 32 |
-
if __name__ == "__main__":
|
| 33 |
-
demo.launch()
|
|
|
|
| 1 |
+
# 1. Use Python 3.10 (Most stable for Paddle)
|
| 2 |
+
FROM python:3.10
|
|
|
|
|
|
|
| 3 |
|
| 4 |
+
# 2. Set working directory
|
| 5 |
+
WORKDIR /app
|
|
|
|
| 6 |
|
| 7 |
+
# 3. INSTALL MISSING GRAPHICS LIBRARIES (This fixes the "Starting" crash)
|
| 8 |
+
RUN apt-get update && apt-get install -y \
|
| 9 |
+
libgl1 \
|
| 10 |
+
libglib2.0-0 \
|
| 11 |
+
libsm6 \
|
| 12 |
+
libxext6 \
|
| 13 |
+
libxrender-dev \
|
| 14 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 15 |
|
| 16 |
+
# 4. Copy requirements and install
|
| 17 |
+
COPY requirements.txt requirements.txt
|
| 18 |
+
RUN pip install --no-cache-dir --upgrade pip && \
|
| 19 |
+
pip install --no-cache-dir -r requirements.txt
|
| 20 |
|
| 21 |
+
# 5. Pre-download the models so they don't timeout your browser
|
| 22 |
+
# (This runs a dummy scan during build to cache the files)
|
| 23 |
+
RUN pip install paddlepaddle==2.6.2 paddleocr==2.7.3 numpy<2.0.0
|
| 24 |
+
RUN python -c "from paddleocr import PaddleOCR; PaddleOCR(use_angle_cls=False, lang='en', use_gpu=False)"
|
| 25 |
|
| 26 |
+
# 6. Copy App Code
|
| 27 |
+
COPY . .
|
| 28 |
|
| 29 |
+
# 7. Start the Server
|
| 30 |
+
CMD ["python", "app.py"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|