Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,3 +1,4 @@
|
|
|
|
1 |
import torch
|
2 |
from PIL import Image
|
3 |
from torchvision import transforms
|
@@ -36,7 +37,7 @@ def inference(input_image):
|
|
36 |
# The output has unnormalized scores. To get probabilities, you can run a softmax on it.
|
37 |
probabilities = torch.nn.functional.softmax(output[0], dim=0)
|
38 |
# Download ImageNet labels
|
39 |
-
|
40 |
# Read the categories
|
41 |
with open("imagenet_classes.txt", "r") as f:
|
42 |
categories = [s.strip() for s in f.readlines()]
|
|
|
1 |
+
import os
|
2 |
import torch
|
3 |
from PIL import Image
|
4 |
from torchvision import transforms
|
|
|
37 |
# The output has unnormalized scores. To get probabilities, you can run a softmax on it.
|
38 |
probabilities = torch.nn.functional.softmax(output[0], dim=0)
|
39 |
# Download ImageNet labels
|
40 |
+
os.system("wget https://raw.githubusercontent.com/pytorch/hub/master/imagenet_classes.txt")
|
41 |
# Read the categories
|
42 |
with open("imagenet_classes.txt", "r") as f:
|
43 |
categories = [s.strip() for s in f.readlines()]
|