ruslanmv commited on
Commit
5ce139d
1 Parent(s): ba97753

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +26 -23
main.py CHANGED
@@ -1,30 +1,33 @@
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()
 
1
  import gradio as gr
2
+ import os
3
+ import subprocess
4
+
5
+ def install_server():
6
+ output = ""
7
+ try:
8
+ os.mkdir("milvus_compose")
9
+ output += "Created directory 'milvus_compose'\n"
10
+ subprocess.run(["wget", "https://github.com/milvus-io/milvus/releases/download/v2.3.0-beta/milvus-standalone-docker-compose.yml", "-O", "milvus_compose/docker-compose.yml"], check=True)
11
+ output += "Downloaded 'docker-compose.yml'\n"
12
+ #subprocess.run(["docker-compose", "up", "-d"], check=True)
13
+ #output += "Started Milvus server\n"
14
+ except Exception as e:
15
+ output += str(e)
16
+ return output
17
+
18
+ def list_files():
19
+ files = os.listdir('.')
20
+ return files
21
 
22
  def run():
23
+ iface = gr.Interface(
24
+ fn=[install_server, list_files],
25
+ inputs=None,
26
+ outputs=["text", "text"],
27
+ layout="horizontal",
28
+ title="Milvus Server Installation"
29
  )
30
+ iface.launch(server_name="0.0.0.0", server_port=7860)
 
 
31
 
32
  if __name__ == "__main__":
33
  run()