Commit
·
e127159
1
Parent(s):
71b6b7a
simplify
Browse files- main.py +3 -13
- requirements.txt +0 -3
main.py
CHANGED
@@ -1,28 +1,18 @@
|
|
1 |
import gradio as gr
|
2 |
-
import torch
|
3 |
-
import requests
|
4 |
import frontmatter
|
5 |
-
from torchvision import transforms
|
6 |
|
7 |
description = frontmatter.load("README.md").content
|
8 |
-
model = torch.hub.load("pytorch/vision:v0.6.0", "resnet18", pretrained=True).eval()
|
9 |
-
response = requests.get("https://git.io/JJkYN")
|
10 |
-
labels = response.text.split("\n")
|
11 |
|
12 |
|
13 |
def predict(inp):
|
14 |
-
|
15 |
-
with torch.no_grad():
|
16 |
-
prediction = torch.nn.functional.softmax(model(inp)[0], dim=0)
|
17 |
-
confidences = {labels[i]: float(prediction[i]) for i in range(1000)}
|
18 |
-
return confidences
|
19 |
|
20 |
|
21 |
def run():
|
22 |
demo = gr.Interface(
|
23 |
fn=predict,
|
24 |
-
inputs=gr.
|
25 |
-
outputs=gr.
|
26 |
description=description
|
27 |
)
|
28 |
|
|
|
1 |
import gradio as gr
|
|
|
|
|
2 |
import frontmatter
|
|
|
3 |
|
4 |
description = frontmatter.load("README.md").content
|
|
|
|
|
|
|
5 |
|
6 |
|
7 |
def predict(inp):
|
8 |
+
return "hi"
|
|
|
|
|
|
|
|
|
9 |
|
10 |
|
11 |
def run():
|
12 |
demo = gr.Interface(
|
13 |
fn=predict,
|
14 |
+
inputs=gr.Textbox(),
|
15 |
+
outputs=gr.Textbox(),
|
16 |
description=description
|
17 |
)
|
18 |
|
requirements.txt
CHANGED
@@ -1,5 +1,2 @@
|
|
1 |
gradio
|
2 |
-
torch
|
3 |
-
torchvision
|
4 |
-
requests
|
5 |
python-frontmatter
|
|
|
1 |
gradio
|
|
|
|
|
|
|
2 |
python-frontmatter
|