robocan commited on
Commit
c48e224
·
verified ·
1 Parent(s): 2355c91

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -15
app.py CHANGED
@@ -79,21 +79,16 @@ def predict(input_img):
79
  def create_bar_plot(predictions):
80
  data = pd.DataFrame(list(predictions.items()), columns=["Location", "Probability"])
81
  max_prob = data["Probability"].max()
82
-
83
- fig, ax = plt.subplots(figsize=(10, 6))
84
- ax.barh(data["Location"], data["Probability"], color='skyblue')
85
- ax.set_xlabel('Probability', fontsize=14)
86
- ax.set_title('Top 10 Predictions with Probabilities', fontsize=16)
87
- ax.set_xlim(0, max_prob)
88
- ax.tick_params(axis='y', labelsize=12) # Increase font size for y-axis labels
89
- ax.invert_yaxis()
90
-
91
- # Save the plot to a BytesIO object
92
- buf = io.BytesIO()
93
- plt.savefig(buf, format='png')
94
- buf.seek(0)
95
-
96
- return buf
97
 
98
  def predict_and_plot(input_img):
99
  predictions = predict(input_img)
 
79
  def create_bar_plot(predictions):
80
  data = pd.DataFrame(list(predictions.items()), columns=["Location", "Probability"])
81
  max_prob = data["Probability"].max()
82
+ return gr.BarPlot(
83
+ data,
84
+ x="Location",
85
+ y="Probability",
86
+ title="Top 10 Predictions with Probabilities",
87
+ tooltip=["Location", "Probability"],
88
+ y_lim=[0, max_prob],
89
+ width=350, # Set the width of the plot
90
+ height=600 # Set the height of the plot
91
+ )
 
 
 
 
 
92
 
93
  def predict_and_plot(input_img):
94
  predictions = predict(input_img)