Update app.py
Browse files
app.py
CHANGED
|
@@ -85,7 +85,7 @@ 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
|
| 89 |
|
| 90 |
# Calculate percentages for display
|
| 91 |
confidence_pct = avg_confidence * 100 if num_detections > 0 else 0
|
|
@@ -95,66 +95,88 @@ def create_detection_metrics_gauge(avg_confidence: float, iou: float, precision:
|
|
| 95 |
|
| 96 |
fig = go.Figure()
|
| 97 |
|
| 98 |
-
# Add
|
| 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 |
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
))
|
| 137 |
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
}
|
| 150 |
))
|
| 151 |
|
| 152 |
fig.update_layout(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 153 |
paper_bgcolor='rgba(0,0,0,0)',
|
| 154 |
plot_bgcolor='rgba(0,0,0,0)',
|
| 155 |
-
height=
|
| 156 |
-
margin=dict(l=
|
| 157 |
-
showlegend=False
|
| 158 |
)
|
| 159 |
|
| 160 |
return fig
|
|
@@ -494,6 +516,8 @@ with gr.Blocks(css=custom_css) as demo:
|
|
| 494 |
with gr.Column(scale=2):
|
| 495 |
gr.Markdown("### Detection Results")
|
| 496 |
output_image = gr.Image(label="Detected Forgeries", type="numpy")
|
|
|
|
|
|
|
| 497 |
|
| 498 |
with gr.Row():
|
| 499 |
with gr.Column(scale=1):
|
|
|
|
| 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 with concentric rings showing detection metrics"""
|
| 89 |
|
| 90 |
# Calculate percentages for display
|
| 91 |
confidence_pct = avg_confidence * 100 if num_detections > 0 else 0
|
|
|
|
| 95 |
|
| 96 |
fig = go.Figure()
|
| 97 |
|
| 98 |
+
# Add radial bars (concentric rings from outer to inner)
|
| 99 |
+
# Confidence - outermost ring (blue)
|
| 100 |
+
fig.add_trace(go.Barpolar(
|
| 101 |
+
r=[confidence_pct],
|
| 102 |
+
theta=[0],
|
| 103 |
+
width=[90],
|
| 104 |
+
name=f'Confidence: {confidence_pct:.1f}%',
|
| 105 |
+
marker_color='#4169E1',
|
| 106 |
+
marker_line_color='white',
|
| 107 |
+
marker_line_width=2,
|
| 108 |
+
opacity=0.8,
|
| 109 |
+
base=75,
|
| 110 |
))
|
| 111 |
|
| 112 |
+
# Precision - second ring (green)
|
| 113 |
+
fig.add_trace(go.Barpolar(
|
| 114 |
+
r=[precision_pct],
|
| 115 |
+
theta=[90],
|
| 116 |
+
width=[90],
|
| 117 |
+
name=f'Precision: {precision_pct:.1f}%',
|
| 118 |
+
marker_color='#5cb85c',
|
| 119 |
+
marker_line_color='white',
|
| 120 |
+
marker_line_width=2,
|
| 121 |
+
opacity=0.8,
|
| 122 |
+
base=50,
|
| 123 |
))
|
| 124 |
|
| 125 |
+
# Recall - third ring (orange)
|
| 126 |
+
fig.add_trace(go.Barpolar(
|
| 127 |
+
r=[recall_pct],
|
| 128 |
+
theta=[180],
|
| 129 |
+
width=[90],
|
| 130 |
+
name=f'Recall: {recall_pct:.1f}%',
|
| 131 |
+
marker_color='#f0ad4e',
|
| 132 |
+
marker_line_color='white',
|
| 133 |
+
marker_line_width=2,
|
| 134 |
+
opacity=0.8,
|
| 135 |
+
base=25,
|
| 136 |
))
|
| 137 |
|
| 138 |
+
# IoU - innermost ring (red)
|
| 139 |
+
fig.add_trace(go.Barpolar(
|
| 140 |
+
r=[iou_pct],
|
| 141 |
+
theta=[270],
|
| 142 |
+
width=[90],
|
| 143 |
+
name=f'IoU: {iou_pct:.1f}%',
|
| 144 |
+
marker_color='#d9534f',
|
| 145 |
+
marker_line_color='white',
|
| 146 |
+
marker_line_width=2,
|
| 147 |
+
opacity=0.8,
|
| 148 |
+
base=0,
|
|
|
|
| 149 |
))
|
| 150 |
|
| 151 |
fig.update_layout(
|
| 152 |
+
polar=dict(
|
| 153 |
+
radialaxis=dict(
|
| 154 |
+
visible=True,
|
| 155 |
+
range=[0, 100],
|
| 156 |
+
showticklabels=True,
|
| 157 |
+
tickfont=dict(size=10),
|
| 158 |
+
gridcolor='rgba(128,128,128,0.2)',
|
| 159 |
+
),
|
| 160 |
+
angularaxis=dict(
|
| 161 |
+
visible=True,
|
| 162 |
+
showticklabels=False,
|
| 163 |
+
gridcolor='rgba(128,128,128,0.2)',
|
| 164 |
+
),
|
| 165 |
+
bgcolor='rgba(0,0,0,0)'
|
| 166 |
+
),
|
| 167 |
+
showlegend=True,
|
| 168 |
+
legend=dict(
|
| 169 |
+
orientation="v",
|
| 170 |
+
yanchor="middle",
|
| 171 |
+
y=0.5,
|
| 172 |
+
xanchor="left",
|
| 173 |
+
x=1.05,
|
| 174 |
+
font=dict(size=11)
|
| 175 |
+
),
|
| 176 |
paper_bgcolor='rgba(0,0,0,0)',
|
| 177 |
plot_bgcolor='rgba(0,0,0,0)',
|
| 178 |
+
height=400,
|
| 179 |
+
margin=dict(l=40, r=120, t=40, b=40)
|
|
|
|
| 180 |
)
|
| 181 |
|
| 182 |
return fig
|
|
|
|
| 516 |
with gr.Column(scale=2):
|
| 517 |
gr.Markdown("### Detection Results")
|
| 518 |
output_image = gr.Image(label="Detected Forgeries", type="numpy")
|
| 519 |
+
|
| 520 |
+
gr.Markdown("---")
|
| 521 |
|
| 522 |
with gr.Row():
|
| 523 |
with gr.Column(scale=1):
|