logasja commited on
Commit
d2ebc6b
·
unverified ·
2 Parent(s): de3e460 181c2cc

Merge pull request #1 from logasja/newdockerfile

Browse files
Files changed (5) hide show
  1. .dockerignore +1 -0
  2. Dockerfile +29 -14
  3. Dockerfile.bkup +18 -0
  4. app.py +4 -3
  5. requirements_personal.txt +1 -1
.dockerignore CHANGED
@@ -1,2 +1,3 @@
1
  /venv
2
  /flagged
 
 
1
  /venv
2
  /flagged
3
+ /.env
Dockerfile CHANGED
@@ -1,18 +1,33 @@
1
- FROM continuumio/miniconda3
2
- EXPOSE 7860
 
 
 
 
 
 
 
3
 
4
- RUN apt-get update && \
5
- apt-get install -y --no-install-recommends libgl1-mesa-glx && \
6
- apt-get install -y --no-install-recommends libglib2.0-0 && \
7
- apt-get clean && \
8
- rm -rf /var/lib/apt/lists/*
9
 
10
- ENV GRADIO_SERVER_NAME=0.0.0.0
11
- WORKDIR /workspace
12
 
13
- ADD environment.yaml /workspace/environment.yaml
14
- RUN conda env update -n base --file environment.yaml && \
15
- pip install typing-extensions -U
16
 
17
- ADD app.py /workspace/
18
- CMD [ "python" , "/workspace/app.py" ]
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.7-slim as builder
2
+
3
+ RUN apt update && \
4
+ apt install --no-install-recommends -y build-essential gcc
5
+ COPY requirements_personal.txt /req.txt
6
+
7
+ RUN python -m pip install --upgrade pip && \
8
+ pip install --no-cache-dir --no-warn-script-location --user -r req.txt && \
9
+ pip install --no-cache-dir --no-warn-script-location --user typing-extensions -U
10
 
11
+ # Stage 2: Runtime
12
+ FROM nvidia/cuda:11.0.3-cudnn8-runtime
 
 
 
13
 
14
+ RUN rm /etc/apt/sources.list.d/cuda.list
15
+ RUN rm /etc/apt/sources.list.d/nvidia-ml.list
16
 
17
+ ENV TZ=America/New_York
18
+ RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
 
19
 
20
+ RUN apt update && \
21
+ apt install --no-install-recommends -y build-essential software-properties-common libgl1-mesa-glx && \
22
+ add-apt-repository -y ppa:deadsnakes/ppa && \
23
+ apt install --no-install-recommends -y python3.7 python3.7-distutils && \
24
+ # update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 1 && \
25
+ update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.7 2 && \
26
+ apt clean && rm -rf /var/lib/apt/lists/*
27
+ COPY --from=builder /root/.local/lib/python3.7/site-packages /usr/local/lib/python3.7/dist-packages
28
+ COPY app.py app.py
29
+
30
+ # RUN ln -s /usr/local/cuda/lib64/libcusolver.so.11 /usr/local/cuda/lib64/libcusolver.so.10
31
+
32
+ CMD ["python3", "app.py"]
33
+ EXPOSE 7860
Dockerfile.bkup ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM continuumio/miniconda3
2
+ EXPOSE 7860
3
+
4
+ RUN apt-get update && \
5
+ apt-get install -y --no-install-recommends libgl1-mesa-glx && \
6
+ apt-get install -y --no-install-recommends libglib2.0-0 && \
7
+ apt-get clean && \
8
+ rm -rf /var/lib/apt/lists/*
9
+
10
+ ENV GRADIO_SERVER_NAME=0.0.0.0
11
+ WORKDIR /workspace
12
+
13
+ ADD environment.yaml /workspace/environment.yaml
14
+ RUN conda env update -n base --file environment.yaml && \
15
+ pip install typing-extensions -U
16
+
17
+ ADD app.py /workspace/
18
+ CMD [ "python" , "/workspace/app.py" ]
app.py CHANGED
@@ -1,14 +1,15 @@
1
  from fawkes.protection import Fawkes
2
  import gradio as gr
 
3
 
4
  def predict(level, img):
5
  # print(img)
6
  fwks = Fawkes("extractor_2", '0', 1, mode=level)
7
  fwks.run_protection([img], format='jpeg')
8
  splt = img.split(".")
9
- # print(os.listdir('/tmp'))
10
- return splt[0] + "_cloaked." + splt[1]
11
 
12
  gr.Interface(fn=predict, inputs=[gr.components.Dropdown(["low", "mid", "high"], label="Protection Level"),
13
  gr.components.Image(type='filepath')],
14
- outputs=gr.components.Image(type="pil")).launch(show_error=True)
 
1
  from fawkes.protection import Fawkes
2
  import gradio as gr
3
+ import os
4
 
5
  def predict(level, img):
6
  # print(img)
7
  fwks = Fawkes("extractor_2", '0', 1, mode=level)
8
  fwks.run_protection([img], format='jpeg')
9
  splt = img.split(".")
10
+ print(os.listdir('/tmp'))
11
+ return splt[0] + "_cloaked.jpeg"
12
 
13
  gr.Interface(fn=predict, inputs=[gr.components.Dropdown(["low", "mid", "high"], label="Protection Level"),
14
  gr.components.Image(type='filepath')],
15
+ outputs=gr.components.Image(type="pil")).launch(show_error=True, server_name="0.0.0.0")
requirements_personal.txt CHANGED
@@ -1,2 +1,2 @@
1
- gradio==3.0.20
2
  fawkes==1.0.4
 
1
+ gradio==3.14.0
2
  fawkes==1.0.4