Spaces:
Runtime error
Runtime error
Fix probability threshold checking logic
Browse files
app.py
CHANGED
@@ -10,10 +10,13 @@ def classify_image(img):
|
|
10 |
pred, idx, probs = learn.predict(img)
|
11 |
output = dict(zip(labels, map(float, probs)))
|
12 |
print(probs[0].item()*100)
|
|
|
13 |
for out in output:
|
14 |
val = output[out]
|
15 |
if val*100 < 60:
|
16 |
-
|
|
|
|
|
17 |
return output
|
18 |
|
19 |
image = gr.inputs.Image(shape=(224, 224))
|
|
|
10 |
pred, idx, probs = learn.predict(img)
|
11 |
output = dict(zip(labels, map(float, probs)))
|
12 |
print(probs[0].item()*100)
|
13 |
+
count = 0
|
14 |
for out in output:
|
15 |
val = output[out]
|
16 |
if val*100 < 60:
|
17 |
+
count += 1
|
18 |
+
if count == 2:
|
19 |
+
return {"Not sure/Others": 100}
|
20 |
return output
|
21 |
|
22 |
image = gr.inputs.Image(shape=(224, 224))
|