asquirous commited on
Commit
25751a2
1 Parent(s): f7f9f63

Fix probability threshold checking logic

Browse files
Files changed (1) hide show
  1. app.py +4 -1
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
- return {"Not Sure/Others": 0}
 
 
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))