Spaces:
Build error
Build error
matsunori39
commited on
Commit
•
ecddcd1
1
Parent(s):
8503b05
fix bug
Browse files
app.py
CHANGED
@@ -23,10 +23,10 @@ def predict_fn(img):
|
|
23 |
with torch.no_grad():
|
24 |
out = model(img)
|
25 |
|
26 |
-
|
27 |
|
28 |
-
values, indices = torch.topk(
|
29 |
|
30 |
return {LABELS[i]: v.item() for i, v in zip(indices, values)}
|
31 |
|
32 |
-
gr.Interface(predict_fn, gr.inputs.Image(type='
|
|
|
23 |
with torch.no_grad():
|
24 |
out = model(img)
|
25 |
|
26 |
+
probabilites = torch.nn.functional.softmax(out[0], dim=0)
|
27 |
|
28 |
+
values, indices = torch.topk(probabilites, k=5)
|
29 |
|
30 |
return {LABELS[i]: v.item() for i, v in zip(indices, values)}
|
31 |
|
32 |
+
gr.Interface(predict_fn, gr.inputs.Image(type='pil'), outputs='label').launch()
|