AfshinMA commited on
Commit
8cefac5
·
verified ·
1 Parent(s): 9c98bdb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -1
app.py CHANGED
@@ -48,7 +48,11 @@ def classify_image(input_image):
48
 
49
  # Perform prediction
50
  prediction = inception_net.predict(input_image).flatten()
51
- confidences = {labels[i]: float(prediction[i]) for i in range(len(labels))}
 
 
 
 
52
  return confidences
53
 
54
  image = gr.Image(interactive=True, label="Upload Image")
 
48
 
49
  # Perform prediction
50
  prediction = inception_net.predict(input_image).flatten()
51
+
52
+ # Get the top indices and their respective confidence scores
53
+ top_indices = np.argsort(prediction)[-3:][::-1] # Get the top 3 indices
54
+ confidences = {labels[i]: float(prediction[i]) for i in top_indices}
55
+
56
  return confidences
57
 
58
  image = gr.Image(interactive=True, label="Upload Image")