Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -3,15 +3,17 @@ 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 |
def predict(inp):
|
11 |
-
inp = transforms.ToTensor()(inp).unsqueeze(0)
|
12 |
-
with torch.no_grad():
|
13 |
-
|
14 |
-
|
|
|
|
|
15 |
return confidences
|
16 |
|
17 |
demo = gr.Interface(fn=predict,
|
|
|
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 |
def predict(inp):
|
11 |
+
# inp = transforms.ToTensor()(inp).unsqueeze(0)
|
12 |
+
# with torch.no_grad():
|
13 |
+
# prediction = torch.nn.functional.softmax(model(inp)[0], dim=0)
|
14 |
+
# confidences = {labels[i]: float(prediction[i]) for i in range(1000)}
|
15 |
+
|
16 |
+
confidences = {labels[i]: i for i in range(1000)}
|
17 |
return confidences
|
18 |
|
19 |
demo = gr.Interface(fn=predict,
|