Spaces:
Runtime error
Runtime error
Commit ·
13fcf41
1
Parent(s): 72fbd6b
feat: returning both label probs
Browse files
app.py
CHANGED
|
@@ -35,9 +35,13 @@ def predict_fn(image):
|
|
| 35 |
output = model(image)
|
| 36 |
|
| 37 |
probabilities = torch.exp(output)
|
| 38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
|
| 40 |
# return dictionary whose keys are labels and values are confidences
|
| 41 |
-
return {
|
| 42 |
|
| 43 |
gr.Interface(predict_fn, gr.inputs.Image(type="pil", label="Input Image"), outputs="label").launch()
|
|
|
|
| 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}
|
| 46 |
|
| 47 |
gr.Interface(predict_fn, gr.inputs.Image(type="pil", label="Input Image"), outputs="label").launch()
|