timothepearce commited on
Commit
953f8fe
1 Parent(s): ae5a619

Add softmax to output classes

Browse files
Files changed (2) hide show
  1. .gitignore +2 -0
  2. app.py +2 -3
.gitignore ADDED
@@ -0,0 +1,2 @@
 
 
1
+ .idea/
2
+ .DS_Store
app.py CHANGED
@@ -36,12 +36,11 @@ def image_classifier(img_input):
36
 
37
  with torch.no_grad():
38
  pred = model(img)[0]
39
- pred -= pred.min()
40
- pred /= pred.max()
41
  return {classes[i]: float(pred[i]) for i in range(10)}
42
 
43
 
44
  gr.Interface(fn=image_classifier,
45
  inputs=gr.Image(shape=(28, 28)),
46
- outputs="label",
47
  examples=["mnist_0.png", "mnist_2.png", "mnist_3.png"]).launch()
36
 
37
  with torch.no_grad():
38
  pred = model(img)[0]
39
+ pred = torch.nn.functional.softmax(pred)
 
40
  return {classes[i]: float(pred[i]) for i in range(10)}
41
 
42
 
43
  gr.Interface(fn=image_classifier,
44
  inputs=gr.Image(shape=(28, 28)),
45
+ outputs=gr.Label(num_top_classes=4),
46
  examples=["mnist_0.png", "mnist_2.png", "mnist_3.png"]).launch()