ChatBotsTA commited on
Commit
daca736
Β·
verified Β·
1 Parent(s): 648d2ad

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -8
app.py CHANGED
@@ -35,6 +35,7 @@ st.markdown("""
35
  border-radius: 20px;
36
  font-weight: bold;
37
  margin: 0.2rem;
 
38
  }
39
  </style>
40
  """, unsafe_allow_html=True)
@@ -68,7 +69,7 @@ if classifier is None:
68
  st.error("Could not load the model. Please check if the model exists on Hugging Face.")
69
  st.stop()
70
 
71
- # Label colors
72
  label_colors = {
73
  "positive": "🟒",
74
  "negative": "πŸ”΄",
@@ -83,6 +84,13 @@ label_descriptions = {
83
  "uncertainty": "Uncertain/ambiguous content"
84
  }
85
 
 
 
 
 
 
 
 
86
  # Input section
87
  st.markdown("---")
88
  st.markdown("## πŸ“ Enter Tweet Text to Analyze")
@@ -123,18 +131,15 @@ if st.button("πŸ” Analyze Tweet", type="primary", use_container_width=True):
123
  st.markdown("## πŸ“Š Analysis Results")
124
 
125
  # Result box
126
- st.markdown(f'<div class="result-box">', unsafe_allow_html=True)
127
 
128
  # Label and confidence
129
  col1, col2 = st.columns([1, 2])
130
  with col1:
131
  st.markdown(f"### {label_colors.get(label, 'βšͺ')} **Prediction:**")
132
- st.markdown(f'<span class="label-badge" style="background-color: {{
133
- "positive": "#4CAF50",
134
- "negative": "#F44336",
135
- "litigious": "#2196F3",
136
- "uncertainty": "#FFC107"
137
- }.get(label, "#9E9E9E")}}; color: white;">{label.upper()}</span>', unsafe_allow_html=True)
138
 
139
  with col2:
140
  st.markdown(f"### πŸ“ˆ **Confidence:** {confidence:.1%}")
 
35
  border-radius: 20px;
36
  font-weight: bold;
37
  margin: 0.2rem;
38
+ display: inline-block;
39
  }
40
  </style>
41
  """, unsafe_allow_html=True)
 
69
  st.error("Could not load the model. Please check if the model exists on Hugging Face.")
70
  st.stop()
71
 
72
+ # Label colors and descriptions
73
  label_colors = {
74
  "positive": "🟒",
75
  "negative": "πŸ”΄",
 
84
  "uncertainty": "Uncertain/ambiguous content"
85
  }
86
 
87
+ badge_colors = {
88
+ "positive": "#4CAF50",
89
+ "negative": "#F44336",
90
+ "litigious": "#2196F3",
91
+ "uncertainty": "#FFC107"
92
+ }
93
+
94
  # Input section
95
  st.markdown("---")
96
  st.markdown("## πŸ“ Enter Tweet Text to Analyze")
 
131
  st.markdown("## πŸ“Š Analysis Results")
132
 
133
  # Result box
134
+ st.markdown('<div class="result-box">', unsafe_allow_html=True)
135
 
136
  # Label and confidence
137
  col1, col2 = st.columns([1, 2])
138
  with col1:
139
  st.markdown(f"### {label_colors.get(label, 'βšͺ')} **Prediction:**")
140
+ # FIXED: Simplified the badge color assignment
141
+ color = badge_colors.get(label, "#9E9E9E")
142
+ st.markdown(f'<span class="label-badge" style="background-color: {color}; color: white;">{label.upper()}</span>', unsafe_allow_html=True)
 
 
 
143
 
144
  with col2:
145
  st.markdown(f"### πŸ“ˆ **Confidence:** {confidence:.1%}")