cisemh commited on
Commit
b11eeae
·
verified ·
1 Parent(s): 6e54a07

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -48,10 +48,11 @@ def predict(img):
48
 
49
  preds = model.predict(img)[0]
50
 
51
- # Print the predictions
52
- print("Predictions:", preds)
 
53
 
54
- return {label: float(pred) for label, pred in zip(labels, preds)}
55
  except Exception as e:
56
  # Print the exception to the console
57
  print(f"Error during prediction: {e}")
 
48
 
49
  preds = model.predict(img)[0]
50
 
51
+ # Tahmin sonuçlarını formatla
52
+ sorted_preds = sorted(zip(labels, preds), key=lambda x: x[1], reverse=True)[:3]
53
+ formatted_preds = "\n".join([f"{label}: {prob:.2f}" for label, prob in sorted_preds])
54
 
55
+ return formatted_preds
56
  except Exception as e:
57
  # Print the exception to the console
58
  print(f"Error during prediction: {e}")