akhaliq HF staff commited on
Commit
985bade
1 Parent(s): 9297431

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -2
app.py CHANGED
@@ -2,6 +2,9 @@ import torch
2
  from PIL import Image
3
  from torchvision import transforms
4
  import gradio as gr
 
 
 
5
 
6
  torch.hub.download_url_to_file("https://github.com/pytorch/hub/raw/master/images/dog.jpg", "dog.jpg")
7
 
@@ -29,8 +32,6 @@ def inference(input_image):
29
  output = model(input_batch)
30
  # The output has unnormalized scores. To get probabilities, you can run a softmax on it.
31
  probabilities = torch.nn.functional.softmax(output[0], dim=0)
32
- # Download ImageNet labels
33
- !wget https://raw.githubusercontent.com/pytorch/hub/master/imagenet_classes.txt
34
  # Read the categories
35
  with open("imagenet_classes.txt", "r") as f:
36
  categories = [s.strip() for s in f.readlines()]
 
2
  from PIL import Image
3
  from torchvision import transforms
4
  import gradio as gr
5
+ import os
6
+
7
+ os.system("wget https://raw.githubusercontent.com/pytorch/hub/master/imagenet_classes.txt")
8
 
9
  torch.hub.download_url_to_file("https://github.com/pytorch/hub/raw/master/images/dog.jpg", "dog.jpg")
10
 
 
32
  output = model(input_batch)
33
  # The output has unnormalized scores. To get probabilities, you can run a softmax on it.
34
  probabilities = torch.nn.functional.softmax(output[0], dim=0)
 
 
35
  # Read the categories
36
  with open("imagenet_classes.txt", "r") as f:
37
  categories = [s.strip() for s in f.readlines()]