kpkishankrishna commited on
Commit
a112a11
·
1 Parent(s): 27d706d
Files changed (3) hide show
  1. Dockerfile +3 -6
  2. app.py +3 -21
  3. requirements.txt +1 -4
Dockerfile CHANGED
@@ -6,19 +6,16 @@ COPY ./requirements.txt /code/requirements.txt
6
 
7
  RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
8
 
9
- # Set up a new user named "user" with user ID 1000
10
  RUN useradd -m -u 1000 user
11
- # Switch to the "user" user
12
  USER user
13
- # Set home to the user's home directory
14
  ENV HOME=/home/user \
15
  PATH=/home/user/.local/bin:$PATH
16
 
17
- # Set the working directory to the user's home directory
18
  WORKDIR $HOME/app
19
 
20
- # Copy the current directory contents into the container at $HOME/app setting the owner to the user
21
  COPY --chown=user . $HOME/app
22
 
23
-
24
  CMD ["python", "app.py"]
 
6
 
7
  RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
8
 
 
9
  RUN useradd -m -u 1000 user
10
+
11
  USER user
12
+
13
  ENV HOME=/home/user \
14
  PATH=/home/user/.local/bin:$PATH
15
 
16
+
17
  WORKDIR $HOME/app
18
 
 
19
  COPY --chown=user . $HOME/app
20
 
 
21
  CMD ["python", "app.py"]
app.py CHANGED
@@ -1,28 +1,10 @@
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
 
 
1
  import gradio as gr
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
+ def greet(name):
4
+ return "Hello " + name + "!!"
5
 
6
  def run():
7
+ demo = gr.Interface(fn=greet, inputs="text", outputs="text")
 
 
 
 
 
8
  demo.launch(server_name="0.0.0.0", server_port=7860)
9
 
10
 
requirements.txt CHANGED
@@ -1,4 +1 @@
1
- gradio
2
- torch
3
- torchvision
4
- requests
 
1
+ gradio