Spaces:
Runtime error
Runtime error
Witold Wydmański
commited on
Commit
·
21e7816
1
Parent(s):
e74d416
fix: more docker fixes
Browse files- Dockerfile +13 -2
- app.py +10 -11
Dockerfile
CHANGED
@@ -8,8 +8,19 @@ RUN apt-get update && apt-get install -y tesseract-ocr
|
|
8 |
COPY requirements.txt .
|
9 |
RUN pip install -r requirements.txt
|
10 |
|
11 |
-
#
|
12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
|
14 |
RUN mkdir -p flagged
|
15 |
RUN chmod 777 flagged
|
|
|
8 |
COPY requirements.txt .
|
9 |
RUN pip install -r requirements.txt
|
10 |
|
11 |
+
# Set up a new user named "user" with user ID 1000
|
12 |
+
RUN useradd -m -u 1000 user
|
13 |
+
# Switch to the "user" user
|
14 |
+
USER user
|
15 |
+
# Set home to the user's home directory
|
16 |
+
ENV HOME=/home/user \
|
17 |
+
PATH=/home/user/.local/bin:$PATH
|
18 |
+
|
19 |
+
# Set the working directory to the user's home directory
|
20 |
+
WORKDIR $HOME/app
|
21 |
+
|
22 |
+
# Copy the current directory contents into the container at $HOME/app setting the owner to the user
|
23 |
+
COPY --chown=user . $HOME/app
|
24 |
|
25 |
RUN mkdir -p flagged
|
26 |
RUN chmod 777 flagged
|
app.py
CHANGED
@@ -36,15 +36,14 @@ def tesseract_ocr(image, progress=gr.Progress()):
|
|
36 |
return file.name
|
37 |
|
38 |
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
).queue(concurrency_count=10)
|
49 |
|
50 |
-
iface.launch()
|
|
|
36 |
return file.name
|
37 |
|
38 |
|
39 |
+
if __name__ == "__main__":
|
40 |
+
logging.info("Starting Tesseract OCR")
|
41 |
+
iface = gr.Interface(
|
42 |
+
fn=tesseract_ocr,
|
43 |
+
inputs=[gr.File(label="PDF file")],
|
44 |
+
outputs=gr.File(label="Text file", type="file"),
|
45 |
+
title="PDF to Text Converter",
|
46 |
+
description="Converts a PDF file to text using Tesseract OCR."
|
47 |
+
).queue(concurrency_count=10)
|
|
|
48 |
|
49 |
+
iface.launch(server_port=7860, server_name="0.0.0.0")
|