Spaces:
Runtime error
Runtime error
Commit
·
2b3e3f0
1
Parent(s):
3b1e528
capitalize to title
Browse files
app.py
CHANGED
|
@@ -109,6 +109,7 @@ if submit:
|
|
| 109 |
predicted_probabilities_HS = response_HS[0]
|
| 110 |
predicted_probabilities_SD = response_SD[0]
|
| 111 |
|
|
|
|
| 112 |
ED, _, HS, __, SD = st.columns([4,1,2,1,2])
|
| 113 |
|
| 114 |
with ED:
|
|
@@ -126,11 +127,16 @@ if submit:
|
|
| 126 |
vertical_spacing=0.4)
|
| 127 |
|
| 128 |
for i, emotion in enumerate(top_emotions):
|
|
|
|
| 129 |
category = emotion['label']
|
| 130 |
color = color_map[category]
|
| 131 |
value = normalized_scores[i]
|
|
|
|
|
|
|
| 132 |
row = i // 2 + 1
|
| 133 |
col = i % 2 + 1
|
|
|
|
|
|
|
| 134 |
fig.add_trace(go.Indicator(
|
| 135 |
domain={'x': [0, 1], 'y': [0, 1]},
|
| 136 |
value=value,
|
|
@@ -148,10 +154,10 @@ if submit:
|
|
| 148 |
'thickness': 0.5,
|
| 149 |
'value': 50}}), row=row, col=col)
|
| 150 |
|
| 151 |
-
|
| 152 |
-
# Update layout
|
| 153 |
fig.update_layout(height=400, margin=dict(t=50, b=5, l=0, r=0))
|
| 154 |
|
|
|
|
| 155 |
# Display gauge charts
|
| 156 |
st.text("")
|
| 157 |
st.text("")
|
|
@@ -186,7 +192,7 @@ if submit:
|
|
| 186 |
st.text("")
|
| 187 |
st.subheader("Sexism Detection")
|
| 188 |
st.text("")
|
| 189 |
-
label_SD = predicted_probabilities_SD[0]['label'].
|
| 190 |
st.image(f"assets/{label_SD}.jpg", width=200)
|
| 191 |
st.text("")
|
| 192 |
st.text("")
|
|
|
|
| 109 |
predicted_probabilities_HS = response_HS[0]
|
| 110 |
predicted_probabilities_SD = response_SD[0]
|
| 111 |
|
| 112 |
+
# Creating columns to visualize the results
|
| 113 |
ED, _, HS, __, SD = st.columns([4,1,2,1,2])
|
| 114 |
|
| 115 |
with ED:
|
|
|
|
| 127 |
vertical_spacing=0.4)
|
| 128 |
|
| 129 |
for i, emotion in enumerate(top_emotions):
|
| 130 |
+
# Get the emotion category, color, and normalized score for the current emotion
|
| 131 |
category = emotion['label']
|
| 132 |
color = color_map[category]
|
| 133 |
value = normalized_scores[i]
|
| 134 |
+
|
| 135 |
+
# Calculate the row and column position for adding the trace to the subplots
|
| 136 |
row = i // 2 + 1
|
| 137 |
col = i % 2 + 1
|
| 138 |
+
|
| 139 |
+
# Add a gauge chart trace for the current emotion category
|
| 140 |
fig.add_trace(go.Indicator(
|
| 141 |
domain={'x': [0, 1], 'y': [0, 1]},
|
| 142 |
value=value,
|
|
|
|
| 154 |
'thickness': 0.5,
|
| 155 |
'value': 50}}), row=row, col=col)
|
| 156 |
|
| 157 |
+
# Update the layout of the figure
|
|
|
|
| 158 |
fig.update_layout(height=400, margin=dict(t=50, b=5, l=0, r=0))
|
| 159 |
|
| 160 |
+
|
| 161 |
# Display gauge charts
|
| 162 |
st.text("")
|
| 163 |
st.text("")
|
|
|
|
| 192 |
st.text("")
|
| 193 |
st.subheader("Sexism Detection")
|
| 194 |
st.text("")
|
| 195 |
+
label_SD = predicted_probabilities_SD[0]['label'].title()
|
| 196 |
st.image(f"assets/{label_SD}.jpg", width=200)
|
| 197 |
st.text("")
|
| 198 |
st.text("")
|