Update app.py
Browse files
app.py
CHANGED
|
@@ -85,90 +85,56 @@ def create_gauge_chart(value: float, title: str, max_value: float = 1.0) -> go.F
|
|
| 85 |
|
| 86 |
|
| 87 |
def create_detection_metrics_gauge(avg_confidence: float, iou: float, precision: float, recall: float, num_detections: int) -> go.Figure:
|
| 88 |
-
"""Create radial bar chart
|
| 89 |
|
| 90 |
-
# Calculate percentages
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
|
|
|
|
|
|
| 95 |
|
| 96 |
fig = go.Figure()
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
marker_line_color='#5cb85c',
|
| 125 |
-
marker_line_width=0,
|
| 126 |
-
opacity=0.9,
|
| 127 |
-
base=65,
|
| 128 |
-
))
|
| 129 |
-
|
| 130 |
-
# Recall - third ring (orange)
|
| 131 |
-
fig.add_trace(go.Barpolar(
|
| 132 |
-
r=[recall_pct] * 360,
|
| 133 |
-
theta=list(range(360)),
|
| 134 |
-
width=1,
|
| 135 |
-
name=f'Recall: {recall_pct:.1f}%',
|
| 136 |
-
marker_color='#f0ad4e',
|
| 137 |
-
marker_line_color='#f0ad4e',
|
| 138 |
-
marker_line_width=0,
|
| 139 |
-
opacity=0.9,
|
| 140 |
-
base=45,
|
| 141 |
-
))
|
| 142 |
-
|
| 143 |
-
# IoU - innermost ring (red)
|
| 144 |
-
fig.add_trace(go.Barpolar(
|
| 145 |
-
r=[iou_pct] * 360,
|
| 146 |
-
theta=list(range(360)),
|
| 147 |
-
width=1,
|
| 148 |
-
name=f'IoU: {iou_pct:.1f}%',
|
| 149 |
-
marker_color='#d9534f',
|
| 150 |
-
marker_line_color='#d9534f',
|
| 151 |
-
marker_line_width=0,
|
| 152 |
-
opacity=0.9,
|
| 153 |
-
base=25,
|
| 154 |
-
))
|
| 155 |
-
|
| 156 |
fig.update_layout(
|
| 157 |
polar=dict(
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
range=[0, 100],
|
| 161 |
-
showticklabels=True,
|
| 162 |
-
tickfont=dict(size=10),
|
| 163 |
-
gridcolor='rgba(128,128,128,0.3)',
|
| 164 |
-
tickmode='linear',
|
| 165 |
-
tick0=0,
|
| 166 |
-
dtick=20,
|
| 167 |
-
),
|
| 168 |
angularaxis=dict(
|
| 169 |
-
|
| 170 |
-
|
| 171 |
gridcolor='rgba(128,128,128,0.2)',
|
|
|
|
|
|
|
|
|
|
|
|
|
| 172 |
),
|
| 173 |
bgcolor='rgba(0,0,0,0)'
|
| 174 |
),
|
|
@@ -178,14 +144,13 @@ def create_detection_metrics_gauge(avg_confidence: float, iou: float, precision:
|
|
| 178 |
yanchor="middle",
|
| 179 |
y=0.5,
|
| 180 |
xanchor="left",
|
| 181 |
-
x=1.
|
| 182 |
-
font=dict(size=
|
| 183 |
-
bgcolor='rgba(0,0,0,0)'
|
| 184 |
),
|
| 185 |
paper_bgcolor='rgba(0,0,0,0)',
|
| 186 |
plot_bgcolor='rgba(0,0,0,0)',
|
| 187 |
height=400,
|
| 188 |
-
margin=dict(l=40, r=
|
| 189 |
)
|
| 190 |
|
| 191 |
return fig
|
|
|
|
| 85 |
|
| 86 |
|
| 87 |
def create_detection_metrics_gauge(avg_confidence: float, iou: float, precision: float, recall: float, num_detections: int) -> go.Figure:
|
| 88 |
+
"""Create a high-fidelity radial bar chart (concentric rings)"""
|
| 89 |
|
| 90 |
+
# Calculate percentages (0-100)
|
| 91 |
+
metrics = [
|
| 92 |
+
{'name': 'Confidence', 'val': avg_confidence * 100 if num_detections > 0 else 0, 'color': '#4169E1', 'base': 80},
|
| 93 |
+
{'name': 'Precision', 'val': precision * 100, 'color': '#5cb85c', 'base': 60},
|
| 94 |
+
{'name': 'Recall', 'val': recall * 100, 'color': '#f0ad4e', 'base': 40},
|
| 95 |
+
{'name': 'IoU', 'val': iou * 100, 'color': '#d9534f', 'base': 20}
|
| 96 |
+
]
|
| 97 |
|
| 98 |
fig = go.Figure()
|
| 99 |
+
|
| 100 |
+
for m in metrics:
|
| 101 |
+
# 1. Add background track (faint gray ring)
|
| 102 |
+
fig.add_trace(go.Barpolar(
|
| 103 |
+
r=[15],
|
| 104 |
+
theta=[180],
|
| 105 |
+
width=[360],
|
| 106 |
+
base=m['base'],
|
| 107 |
+
marker_color='rgba(128,128,128,0.1)',
|
| 108 |
+
hoverinfo='none',
|
| 109 |
+
showlegend=False
|
| 110 |
+
))
|
| 111 |
+
|
| 112 |
+
# 2. Add the actual metric bar (the colored arc)
|
| 113 |
+
# 100% = 360 degrees
|
| 114 |
+
angle_width = m['val'] * 3.6
|
| 115 |
+
fig.add_trace(go.Barpolar(
|
| 116 |
+
r=[15],
|
| 117 |
+
theta=[angle_width / 2],
|
| 118 |
+
width=[angle_width],
|
| 119 |
+
base=m['base'],
|
| 120 |
+
name=f"{m['name']}: {m['val']:.1f}%",
|
| 121 |
+
marker_color=m['color'],
|
| 122 |
+
marker_line_width=0,
|
| 123 |
+
hoverinfo='name'
|
| 124 |
+
))
|
| 125 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 126 |
fig.update_layout(
|
| 127 |
polar=dict(
|
| 128 |
+
hole=0.1,
|
| 129 |
+
radialaxis=dict(visible=False, range=[0, 100]),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 130 |
angularaxis=dict(
|
| 131 |
+
rotation=90, # Start at 12 o'clock
|
| 132 |
+
direction='clockwise', # Go clockwise
|
| 133 |
gridcolor='rgba(128,128,128,0.2)',
|
| 134 |
+
tickmode='linear',
|
| 135 |
+
tick0=0,
|
| 136 |
+
dtick=45, # Grid lines every 45 degrees
|
| 137 |
+
showticklabels=False
|
| 138 |
),
|
| 139 |
bgcolor='rgba(0,0,0,0)'
|
| 140 |
),
|
|
|
|
| 144 |
yanchor="middle",
|
| 145 |
y=0.5,
|
| 146 |
xanchor="left",
|
| 147 |
+
x=1.1,
|
| 148 |
+
font=dict(size=12)
|
|
|
|
| 149 |
),
|
| 150 |
paper_bgcolor='rgba(0,0,0,0)',
|
| 151 |
plot_bgcolor='rgba(0,0,0,0)',
|
| 152 |
height=400,
|
| 153 |
+
margin=dict(l=40, r=150, t=40, b=40)
|
| 154 |
)
|
| 155 |
|
| 156 |
return fig
|