Spaces:
Runtime error
Runtime error
Commit ·
88ac1ec
1
Parent(s): 858b8f1
go back to previous probability computation
Browse files
app.py
CHANGED
|
@@ -34,11 +34,12 @@ def predict_fn(image):
|
|
| 34 |
with torch.no_grad():
|
| 35 |
output = model(image)
|
| 36 |
|
| 37 |
-
|
|
|
|
| 38 |
# focused (0) round probability
|
| 39 |
-
focused_prob = round(
|
| 40 |
# distracted (1) round probability
|
| 41 |
-
distracted_prob = round(
|
| 42 |
|
| 43 |
# return dictionary whose keys are labels and values are confidences
|
| 44 |
return {'focused': focused_prob, 'distracted': distracted_prob}
|
|
|
|
| 34 |
with torch.no_grad():
|
| 35 |
output = model(image)
|
| 36 |
|
| 37 |
+
probabilities = torch.exp(output)
|
| 38 |
+
print(probabilities)
|
| 39 |
# focused (0) round probability
|
| 40 |
+
focused_prob = round(probabilities[0][0].item(), 2)
|
| 41 |
# distracted (1) round probability
|
| 42 |
+
distracted_prob = round(probabilities[0][1].item(), 2)
|
| 43 |
|
| 44 |
# return dictionary whose keys are labels and values are confidences
|
| 45 |
return {'focused': focused_prob, 'distracted': distracted_prob}
|