Spaces:
Runtime error
Runtime error
fix bug
Browse files
app.py
CHANGED
|
@@ -23,11 +23,8 @@ def predict_fn(img):
|
|
| 23 |
with torch.no_grad():
|
| 24 |
out = model(img)
|
| 25 |
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
values, indices = torch.topk(probalilities, k=5)
|
| 29 |
-
|
| 30 |
-
return [LABELS[i]: v.item() for i, v in zip(indices, values)]
|
| 31 |
-
gr.Interface(predict_fn, gr.inputs.Image(type='pil'), outputs='label').launch()
|
| 32 |
|
|
|
|
| 33 |
|
|
|
|
|
|
| 23 |
with torch.no_grad():
|
| 24 |
out = model(img)
|
| 25 |
|
| 26 |
+
probabilities = torch.nn.functional.softmax(out[0], dim=0)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
|
| 28 |
+
values, indices = torch.topk(probabilities, k=5)
|
| 29 |
|
| 30 |
+
return [{LABELS[i]: v.item()} for i, v in zip(indices, values)]
|