Update app.py
Browse files
app.py
CHANGED
@@ -1,8 +1,11 @@
|
|
|
|
1 |
import torch
|
2 |
from PIL import Image
|
3 |
from torchvision import transforms
|
4 |
import gradio as gr
|
5 |
|
|
|
|
|
6 |
model = torch.hub.load('huawei-noah/ghostnet', 'ghostnet_1x', pretrained=True)
|
7 |
model.eval()
|
8 |
# Download an example image from the pytorch website
|
@@ -27,8 +30,7 @@ def inference(input_image):
|
|
27 |
output = model(input_batch)
|
28 |
# The output has unnormalized scores. To get probabilities, you can run a softmax on it.
|
29 |
probabilities = torch.nn.functional.softmax(output[0], dim=0)
|
30 |
-
|
31 |
-
!wget https://raw.githubusercontent.com/pytorch/hub/master/imagenet_classes.txt
|
32 |
# Read the categories
|
33 |
with open("imagenet_classes.txt", "r") as f:
|
34 |
categories = [s.strip() for s in f.readlines()]
|
|
|
1 |
+
import os
|
2 |
import torch
|
3 |
from PIL import Image
|
4 |
from torchvision import transforms
|
5 |
import gradio as gr
|
6 |
|
7 |
+
os.system("wget https://raw.githubusercontent.com/pytorch/hub/master/imagenet_classes.txt")
|
8 |
+
|
9 |
model = torch.hub.load('huawei-noah/ghostnet', 'ghostnet_1x', pretrained=True)
|
10 |
model.eval()
|
11 |
# Download an example image from the pytorch website
|
|
|
30 |
output = model(input_batch)
|
31 |
# The output has unnormalized scores. To get probabilities, you can run a softmax on it.
|
32 |
probabilities = torch.nn.functional.softmax(output[0], dim=0)
|
33 |
+
|
|
|
34 |
# Read the categories
|
35 |
with open("imagenet_classes.txt", "r") as f:
|
36 |
categories = [s.strip() for s in f.readlines()]
|