Jacob Logas
commited on
Update packages and minimize docker size
Browse files- Dockerfile +18 -17
- app.py +1 -2
- requirements.txt +13 -4
Dockerfile
CHANGED
@@ -1,23 +1,24 @@
|
|
1 |
-
|
2 |
-
|
|
|
|
|
|
|
|
|
|
|
3 |
|
|
|
|
|
|
|
|
|
|
|
4 |
ENV GRADIO_SERVER_NAME=0.0.0.0
|
5 |
-
WORKDIR /workspace
|
6 |
|
7 |
-
RUN
|
8 |
-
apt-get install -y \
|
9 |
-
build-essential \
|
10 |
-
make \
|
11 |
-
gcc
|
12 |
|
13 |
-
|
14 |
-
RUN pip install --upgrade pip
|
15 |
-
RUN pip install --quiet --no-cache-dir -r requirements.txt
|
16 |
|
17 |
-
|
18 |
-
|
19 |
-
&& rm -rf /var/lib/apt/lists/*
|
20 |
|
21 |
-
|
22 |
-
|
23 |
-
CMD [ "python" , "/workspace/app.py" ]
|
|
|
1 |
+
# Stage 1: Build Dependencies
|
2 |
+
FROM python:slim as builder
|
3 |
+
|
4 |
+
RUN apt update && \
|
5 |
+
apt install --no-install-recommends -y build-essential gcc
|
6 |
+
|
7 |
+
COPY requirements.txt /requirements.txt
|
8 |
|
9 |
+
RUN pip install --upgrade pip && \
|
10 |
+
pip install --quiet --no-cache-dir --no-warn-script-location --user -r requirements.txt
|
11 |
+
|
12 |
+
# Stage 2: Runtime
|
13 |
+
FROM python:slim
|
14 |
ENV GRADIO_SERVER_NAME=0.0.0.0
|
|
|
15 |
|
16 |
+
RUN rm -rf /var/lib/apt/lists/*
|
|
|
|
|
|
|
|
|
17 |
|
18 |
+
COPY --from=builder /root/.local/lib/python3.11/site-packages /root/.local/lib/python3.11/site-packages
|
|
|
|
|
19 |
|
20 |
+
COPY raccoon_emoji.png raccoon_emoji.png
|
21 |
+
COPY app.py app.py
|
|
|
22 |
|
23 |
+
CMD [ "python" , "-u", "app.py" ]
|
24 |
+
EXPOSE 7860
|
|
app.py
CHANGED
@@ -2,7 +2,6 @@ import cv2
|
|
2 |
import gradio as gr
|
3 |
import numpy as np
|
4 |
from mtcnn_cv2 import MTCNN
|
5 |
-
import os
|
6 |
|
7 |
detector = MTCNN()
|
8 |
|
@@ -113,4 +112,4 @@ def overlay_transparent(background_img, img_to_overlay_t, x, y, overlay_size=Non
|
|
113 |
|
114 |
gr.Interface(fn=predict,
|
115 |
inputs=[gr.components.Image(type='numpy'), gr.components.Radio(["Low", "Medium", "High", "Emoji"], value="Medium")],
|
116 |
-
outputs=gr.components.Image(type="pil")).launch(show_error=True)
|
|
|
2 |
import gradio as gr
|
3 |
import numpy as np
|
4 |
from mtcnn_cv2 import MTCNN
|
|
|
5 |
|
6 |
detector = MTCNN()
|
7 |
|
|
|
112 |
|
113 |
gr.Interface(fn=predict,
|
114 |
inputs=[gr.components.Image(type='numpy'), gr.components.Radio(["Low", "Medium", "High", "Emoji"], value="Medium")],
|
115 |
+
outputs=gr.components.Image(type="pil"), allow_flagging="never").launch(show_error=True, quiet=False)
|
requirements.txt
CHANGED
@@ -1,31 +1,37 @@
|
|
|
|
1 |
aiohttp==3.8.3
|
2 |
aiosignal==1.3.1
|
|
|
3 |
anyio==3.6.2
|
4 |
async-timeout==4.0.2
|
5 |
attrs==22.1.0
|
6 |
bcrypt==4.0.1
|
7 |
-
certifi==2022.
|
8 |
cffi==1.15.1
|
9 |
charset-normalizer==2.1.1
|
10 |
click==8.1.3
|
11 |
contourpy==1.0.6
|
12 |
-
cryptography==
|
13 |
cycler==0.11.0
|
14 |
emoji==2.2.0
|
|
|
15 |
fastapi==0.86.0
|
16 |
ffmpy==0.3.0
|
|
|
17 |
fonttools==4.38.0
|
18 |
frozenlist==1.3.3
|
19 |
fsspec==2022.10.0
|
20 |
-
gradio==3.
|
21 |
h11==0.12.0
|
22 |
httpcore==0.15.0
|
23 |
httpx==0.23.0
|
|
|
24 |
idna==3.4
|
25 |
Jinja2==3.1.2
|
|
|
26 |
kiwisolver==1.4.4
|
27 |
linkify-it-py==1.0.3
|
28 |
-
markdown-it-py==2.
|
29 |
MarkupSafe==2.1.1
|
30 |
matplotlib==3.6.2
|
31 |
mdit-py-plugins==0.3.1
|
@@ -45,6 +51,7 @@ pydantic==1.10.2
|
|
45 |
pydub==0.25.1
|
46 |
PyNaCl==1.5.0
|
47 |
pyparsing==3.0.9
|
|
|
48 |
python-dateutil==2.8.2
|
49 |
python-multipart==0.0.5
|
50 |
pytz==2022.6
|
@@ -54,6 +61,8 @@ rfc3986==1.5.0
|
|
54 |
six==1.16.0
|
55 |
sniffio==1.3.0
|
56 |
starlette==0.20.4
|
|
|
|
|
57 |
typing_extensions==4.4.0
|
58 |
uc-micro-py==1.0.1
|
59 |
urllib3==1.26.12
|
|
|
1 |
+
aiofiles==23.1.0
|
2 |
aiohttp==3.8.3
|
3 |
aiosignal==1.3.1
|
4 |
+
altair==4.2.2
|
5 |
anyio==3.6.2
|
6 |
async-timeout==4.0.2
|
7 |
attrs==22.1.0
|
8 |
bcrypt==4.0.1
|
9 |
+
certifi==2022.12.7
|
10 |
cffi==1.15.1
|
11 |
charset-normalizer==2.1.1
|
12 |
click==8.1.3
|
13 |
contourpy==1.0.6
|
14 |
+
cryptography==39.0.2
|
15 |
cycler==0.11.0
|
16 |
emoji==2.2.0
|
17 |
+
entrypoints==0.4
|
18 |
fastapi==0.86.0
|
19 |
ffmpy==0.3.0
|
20 |
+
filelock==3.9.1
|
21 |
fonttools==4.38.0
|
22 |
frozenlist==1.3.3
|
23 |
fsspec==2022.10.0
|
24 |
+
gradio==3.21.0
|
25 |
h11==0.12.0
|
26 |
httpcore==0.15.0
|
27 |
httpx==0.23.0
|
28 |
+
huggingface-hub==0.13.2
|
29 |
idna==3.4
|
30 |
Jinja2==3.1.2
|
31 |
+
jsonschema==4.17.3
|
32 |
kiwisolver==1.4.4
|
33 |
linkify-it-py==1.0.3
|
34 |
+
markdown-it-py==2.2.0
|
35 |
MarkupSafe==2.1.1
|
36 |
matplotlib==3.6.2
|
37 |
mdit-py-plugins==0.3.1
|
|
|
51 |
pydub==0.25.1
|
52 |
PyNaCl==1.5.0
|
53 |
pyparsing==3.0.9
|
54 |
+
pyrsistent==0.19.3
|
55 |
python-dateutil==2.8.2
|
56 |
python-multipart==0.0.5
|
57 |
pytz==2022.6
|
|
|
61 |
six==1.16.0
|
62 |
sniffio==1.3.0
|
63 |
starlette==0.20.4
|
64 |
+
toolz==0.12.0
|
65 |
+
tqdm==4.65.0
|
66 |
typing_extensions==4.4.0
|
67 |
uc-micro-py==1.0.1
|
68 |
urllib3==1.26.12
|