Update app.py
Browse files
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(
|
| 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 |
-
|
| 133 |
-
|
| 134 |
-
|
| 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%}")
|