Spaces:
Sleeping
Sleeping
Commit ·
05b8be6
1
Parent(s): 393dc75
Updating from matplotlib to plotly express for quality plots
Browse files
app.py
CHANGED
|
@@ -295,17 +295,25 @@ if st.session_state['prediction_made']:
|
|
| 295 |
classes = list(tumor_info.keys())
|
| 296 |
probs = st.session_state['prediction_probs'] * 100
|
| 297 |
|
| 298 |
-
|
| 299 |
-
|
| 300 |
-
|
| 301 |
-
|
| 302 |
-
|
| 303 |
-
|
| 304 |
-
|
| 305 |
-
|
| 306 |
-
|
| 307 |
-
|
| 308 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 309 |
|
| 310 |
with tab2:
|
| 311 |
if st.session_state['gradcam_img'] is not None:
|
|
|
|
| 295 |
classes = list(tumor_info.keys())
|
| 296 |
probs = st.session_state['prediction_probs'] * 100
|
| 297 |
|
| 298 |
+
# Use Plotly instead of matplotlib
|
| 299 |
+
fig = px.bar(
|
| 300 |
+
x=probs,
|
| 301 |
+
y=[c.replace('_', ' ').title() for c in classes],
|
| 302 |
+
orientation='h',
|
| 303 |
+
text=probs,
|
| 304 |
+
color=[c.replace('_', ' ').title() for c in classes],
|
| 305 |
+
color_discrete_sequence=['#1e88e5' if c != st.session_state['predicted_class'] else '#4CAF50' for c in classes]
|
| 306 |
+
)
|
| 307 |
+
fig.update_layout(
|
| 308 |
+
title='Prediction Confidence Distribution',
|
| 309 |
+
xaxis_title='Probability (%)',
|
| 310 |
+
yaxis_title='Class',
|
| 311 |
+
showlegend=False,
|
| 312 |
+
uniformtext_minsize=12,
|
| 313 |
+
uniformtext_mode='hide'
|
| 314 |
+
)
|
| 315 |
+
fig.update_traces(texttemplate='%{text:.1f}%', textposition='outside')
|
| 316 |
+
st.plotly_chart(fig, use_container_width=True)
|
| 317 |
|
| 318 |
with tab2:
|
| 319 |
if st.session_state['gradcam_img'] is not None:
|