tonyliu404 commited on
Commit
7dc70e8
·
verified ·
1 Parent(s): 2d0046e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -281,6 +281,7 @@ def display_dishes_in_grid(dishes, cols=3):
281
  st.sidebar.write(dish.replace("_", " ").capitalize())
282
 
283
  def display_prediction_graph(class_names, confidences):
 
284
  #reversing them so graph displays highest predictions at the top
285
  confidences.reverse()
286
  class_names.reverse()
@@ -303,7 +304,7 @@ def display_prediction_graph(class_names, confidences):
303
  if width < min_width:
304
  width = min_width
305
  ax.text(width - 0.02, bar.get_y() + bar.get_height()/2, f'{original_width:.1f}%',
306
- va='center', ha='right', color='white', fontweight='bold', fontsize=16)
307
 
308
  ax.set_xticklabels([]) #remove x label
309
 
@@ -311,13 +312,13 @@ def display_prediction_graph(class_names, confidences):
311
  max_label_width = 10
312
  labels = ax.get_yticklabels()
313
  wrapped_labels = [textwrap.fill(label.get_text(), width=max_label_width) for label in labels] # Wrap the labels if they exceed the max width
314
- ax.set_yticklabels(wrapped_labels, fontsize=16, color='white')
315
 
316
  #no borders
317
  for spine in ax.spines.values():
318
  spine.set_visible(False)
319
 
320
- ax.set_title(class_names[-1], color='white', fontsize=24, fontweight='bold', ha='left', x=0.5)
321
 
322
  st.pyplot(fig) # Display the plot
323
 
 
281
  st.sidebar.write(dish.replace("_", " ").capitalize())
282
 
283
  def display_prediction_graph(class_names, confidences):
284
+ theme_mode = st.get_option("theme.base")
285
  #reversing them so graph displays highest predictions at the top
286
  confidences.reverse()
287
  class_names.reverse()
 
304
  if width < min_width:
305
  width = min_width
306
  ax.text(width - 0.02, bar.get_y() + bar.get_height()/2, f'{original_width:.1f}%',
307
+ va='center', ha='right', color='white' if theme_mode == "dark" else "black", fontweight='bold', fontsize=16)
308
 
309
  ax.set_xticklabels([]) #remove x label
310
 
 
312
  max_label_width = 10
313
  labels = ax.get_yticklabels()
314
  wrapped_labels = [textwrap.fill(label.get_text(), width=max_label_width) for label in labels] # Wrap the labels if they exceed the max width
315
+ ax.set_yticklabels(wrapped_labels, fontsize=16, color='white' if theme_mode == "dark" else "black")
316
 
317
  #no borders
318
  for spine in ax.spines.values():
319
  spine.set_visible(False)
320
 
321
+ ax.set_title(class_names[-1], color='white' if theme_mode == "dark" else "black", fontsize=24, fontweight='bold', ha='left', x=0.5)
322
 
323
  st.pyplot(fig) # Display the plot
324