zainali9091 commited on
Commit
c4e745f
·
verified ·
1 Parent(s): ba70128

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +17 -17
src/streamlit_app.py CHANGED
@@ -23,7 +23,7 @@ def set_background_and_styles():
23
  }
24
 
25
  /* Changed all header colors to white, also targeting labels directly */
26
- h1, h2, h3, h4, h5, h6, .stMarkdown, label { /* Added label for white text */
27
  font-family: 'Merriweather', serif;
28
  color: white;
29
  }
@@ -64,10 +64,10 @@ def set_background_and_styles():
64
  color: #333; /* Selectbox text color should remain dark for readability */
65
  }
66
 
67
- /* Modified stSuccess and stInfo for white text on darker transparent background */
68
  .stSuccess {
69
  border-left: 5px solid #28a745;
70
- background-color: rgba(40, 167, 69, 0.7); /* Darker transparent green */
71
  color: white; /* Make text white */
72
  border-radius: 8px;
73
  padding: 10px;
@@ -75,7 +75,7 @@ def set_background_and_styles():
75
  }
76
  .stInfo {
77
  border-left: 5px solid #17a2b8;
78
- background-color: rgba(23, 162, 184, 0.7); /* Darker transparent blue */
79
  color: white; /* Make text white */
80
  border-radius: 8px;
81
  padding: 10px;
@@ -205,11 +205,11 @@ if st.button("Analyze"):
205
  emotion, polarity = detect_emotion(user_input)
206
  confidence = abs(polarity) * 100
207
 
208
- # Display Emotion - now white due to .stSuccess CSS
209
  st.subheader("Detected Emotion:")
210
  st.success(f"**{emotion.capitalize()}** with a confidence of **{confidence:.2f}%**")
211
 
212
- # Show a personal quote - now white due to .stInfo CSS
213
  st.markdown("### DilBot's Message:")
214
  quote = get_quote(emotion)[0]
215
  st.info(f"_{quote}_")
@@ -253,12 +253,12 @@ if st.button("Analyze"):
253
 
254
  # Bar Chart
255
  ax1.bar(labels, display_values, color=colors)
256
- ax1.set_title("Confidence by Emotion", color='black') # Title color changed to black for contrast
257
- ax1.set_ylabel("Percentage", color='black') # Label color changed to black for contrast
258
- ax1.tick_params(axis='x', colors='black') # X-axis tick labels color black
259
- ax1.tick_params(axis='y', colors='black') # Y-axis tick labels color black
260
- ax1.spines['bottom'].set_color('black') # X-axis line color black
261
- ax1.spines['left'].set_color('black') # Y-axis line color black
262
  ax1.spines['top'].set_visible(False)
263
  ax1.spines['right'].set_visible(False)
264
 
@@ -268,11 +268,11 @@ if st.button("Analyze"):
268
  display_values, labels=labels, autopct='%1.1f%%',
269
  colors=colors, startangle=90, wedgeprops=dict(width=0.4)
270
  )
271
- ax2.set_title("Emotion Distribution", color='black') # Title color changed to black for contrast
272
- for text_obj in texts: # Renamed 'text' to 'text_obj' to avoid conflict with the texts list
273
- text_obj.set_color('black') # Label color changed to black for contrast
274
- for autotext_obj in autotexts: # Renamed 'autotext' to 'autotext_obj'
275
- autotext_obj.set_color('black') # Percentage text color changed to black for contrast
276
 
277
  else:
278
  ax2.text(0.5, 0.5, 'No data', horizontalalignment='center', verticalalignment='center', transform=ax2.transAxes, color='black')
 
23
  }
24
 
25
  /* Changed all header colors to white, also targeting labels directly */
26
+ h1, h2, h3, h4, h5, h6, .stMarkdown, label { /* Added .stMarkdown and label for white text */
27
  font-family: 'Merriweather', serif;
28
  color: white;
29
  }
 
64
  color: #333; /* Selectbox text color should remain dark for readability */
65
  }
66
 
67
+ /* Modified stSuccess and stInfo for white text on darker transparent black background */
68
  .stSuccess {
69
  border-left: 5px solid #28a745;
70
+ background-color: rgba(0, 0, 0, 0.6); /* Transparent black */
71
  color: white; /* Make text white */
72
  border-radius: 8px;
73
  padding: 10px;
 
75
  }
76
  .stInfo {
77
  border-left: 5px solid #17a2b8;
78
+ background-color: rgba(0, 0, 0, 0.6); /* Transparent black */
79
  color: white; /* Make text white */
80
  border-radius: 8px;
81
  padding: 10px;
 
205
  emotion, polarity = detect_emotion(user_input)
206
  confidence = abs(polarity) * 100
207
 
208
+ # Display Emotion - now white text on transparent black background
209
  st.subheader("Detected Emotion:")
210
  st.success(f"**{emotion.capitalize()}** with a confidence of **{confidence:.2f}%**")
211
 
212
+ # Show a personal quote - now white text on transparent black background
213
  st.markdown("### DilBot's Message:")
214
  quote = get_quote(emotion)[0]
215
  st.info(f"_{quote}_")
 
253
 
254
  # Bar Chart
255
  ax1.bar(labels, display_values, color=colors)
256
+ ax1.set_title("Confidence by Emotion", color='black')
257
+ ax1.set_ylabel("Percentage", color='black')
258
+ ax1.tick_params(axis='x', colors='black')
259
+ ax1.tick_params(axis='y', colors='black')
260
+ ax1.spines['bottom'].set_color('black')
261
+ ax1.spines['left'].set_color('black')
262
  ax1.spines['top'].set_visible(False)
263
  ax1.spines['right'].set_visible(False)
264
 
 
268
  display_values, labels=labels, autopct='%1.1f%%',
269
  colors=colors, startangle=90, wedgeprops=dict(width=0.4)
270
  )
271
+ ax2.set_title("Emotion Distribution", color='black')
272
+ for text_obj in texts:
273
+ text_obj.set_color('black')
274
+ for autotext_obj in autotexts:
275
+ autotext_obj.set_color('black')
276
 
277
  else:
278
  ax2.text(0.5, 0.5, 'No data', horizontalalignment='center', verticalalignment='center', transform=ax2.transAxes, color='black')