Pravalika56 commited on
Commit
cec7ea2
·
verified ·
1 Parent(s): a8486a7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -4,14 +4,15 @@ import gradio as gr
4
  from PIL import Image
5
  from torchvision import transforms
6
 
7
- model = torch.hub.load('pytorch/vision:v0.10.0', 'resnet18', pretrained = True).eval()
8
  response = requests.get("https://git.io/JJkYN")
9
  labels = response.text.split("\n")
10
 
11
  def get_predictions(inp):
12
  inp = transforms.ToTensor()(inp).unsqueeze(0)
13
- predictions = torch.nn.functional.softmax(model(inp)[0], dim = 0)
14
- conf = {labels[i]: predictions[i] for i in range(len(labels))}
 
15
  return conf
16
 
17
 
 
4
  from PIL import Image
5
  from torchvision import transforms
6
 
7
+ model = torch.hub.load('pytorch/vision:v0.6.0', 'resnet18', pretrained = True).eval()
8
  response = requests.get("https://git.io/JJkYN")
9
  labels = response.text.split("\n")
10
 
11
  def get_predictions(inp):
12
  inp = transforms.ToTensor()(inp).unsqueeze(0)
13
+ with torch.no_grad():
14
+ predictions = torch.nn.functional.softmax(model(inp)[0], dim = 0)
15
+ conf = {labels[i]: float(predictions[i]) for i in range(len(labels))}
16
  return conf
17
 
18