Erinc commited on
Commit
b879795
1 Parent(s): 603eb08

initial commit

Browse files
Files changed (3) hide show
  1. Dockerfile +46 -0
  2. main.py +30 -0
  3. requirements.txt +3 -0
Dockerfile ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM anibali/pytorch:2.0.0-cuda11.8-ubuntu22.04
2
+ USER root
3
+ # Set up time zone.
4
+ ENV TZ=UTC
5
+ RUN sudo ln -snf /usr/share/zoneinfo/$TZ /etc/localtime
6
+
7
+
8
+
9
+ # Install torch geometric
10
+ RUN pip install pyg_lib torch_scatter torch_sparse torch_cluster torch_spline_conv -f https://data.pyg.org/whl/torch-2.0.0+cu118.html
11
+ RUN pip install torch_geometric
12
+ RUN pip install h5py ipykernel==5.5.5 ipywidgets==7.6.3 jupyter nglview==2.7.7 pandas
13
+ RUN pip install pytorch-lightning==1.8.3
14
+ RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
15
+
16
+ RUN apt-get update; \
17
+ DEBIAN_FRONTEND=noninteractive; \
18
+ apt-get install -y --no-install-recommends --allow-downgrades\
19
+ bzip2=1.0.8-5build1 cmake=3.22.1-1ubuntu1.22.04.1 csh=20110502-7 \
20
+ make=4.3-4.1build1 gcc=4:11.2.0-1ubuntu1 gfortran=4:11.2.0-1ubuntu1 \
21
+ g++=4:11.2.0-1ubuntu1 flex=2.6.4-8build2 bison=2:3.8.2+dfsg-1build1 \
22
+ patch=2.7.6-7build2 bc=1.07.1-3build1 libbz2-dev=1.0.8-5build1 \
23
+ wget=1.21.2-2ubuntu1 openmpi-bin=4.1.2-2ubuntu1 \
24
+ libopenmpi-dev=4.1.2-2ubuntu1 openssh-client=1:8.9p1-3 \
25
+ ca-certificates=20211016ubuntu0.22.04.1
26
+
27
+ WORKDIR /usr/bin
28
+ COPY AmberTools22.tar.bz2 .
29
+ RUN tar xjvf AmberTools22.tar.bz2 && rm AmberTools22.tar.bz2
30
+
31
+ WORKDIR amber22_src
32
+ WORKDIR build
33
+ RUN chmod +x run_cmake
34
+ RUN ./run_cmake
35
+ RUN make -j 4 install
36
+ RUN echo "source /usr/bin/amber22/amber.sh" >> /etc/bash.bashrc
37
+ SHELL ["/bin/bash", "-c"]
38
+
39
+ ENV AMBERHOME="/usr/bin/amber22/"
40
+ ENV PATH="$AMBERHOME/bin:$PATH"
41
+ ENV PYTHONPATH="$AMBERHOME/lib/python3.10/site-packages"
42
+
43
+ RUN adduser -u 5678 --disabled-password --gecos "" appuser && chown -R appuser .
44
+ USER appuser
45
+ CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]
46
+
main.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import torch
3
+ import requests
4
+ from torchvision import transforms
5
+
6
+ model = torch.hub.load("pytorch/vision:v0.6.0", "resnet18", pretrained=True).eval()
7
+ response = requests.get("https://git.io/JJkYN")
8
+ labels = response.text.split("\n")
9
+
10
+
11
+ def predict(inp):
12
+ inp = transforms.ToTensor()(inp).unsqueeze(0)
13
+ with torch.no_grad():
14
+ prediction = torch.nn.functional.softmax(model(inp)[0], dim=0)
15
+ confidences = {labels[i]: float(prediction[i]) for i in range(1000)}
16
+ return confidences
17
+
18
+
19
+ def run():
20
+ demo = gr.Interface(
21
+ fn=predict,
22
+ inputs=gr.inputs.Image(type="pil"),
23
+ outputs=gr.outputs.Label(num_top_classes=3),
24
+ )
25
+
26
+ demo.launch(server_name="0.0.0.0", server_port=7860)
27
+
28
+
29
+ if __name__ == "__main__":
30
+ run()
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ gradio
2
+ torchvision
3
+ requests