Update app.py
Browse files
app.py
CHANGED
|
@@ -95,57 +95,62 @@ def create_detection_metrics_gauge(avg_confidence: float, iou: float, precision:
|
|
| 95 |
|
| 96 |
fig = go.Figure()
|
| 97 |
|
| 98 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 99 |
# Confidence - outermost ring (blue)
|
| 100 |
fig.add_trace(go.Barpolar(
|
| 101 |
-
r=[confidence_pct],
|
| 102 |
-
theta=
|
| 103 |
-
width=
|
| 104 |
name=f'Confidence: {confidence_pct:.1f}%',
|
| 105 |
marker_color='#4169E1',
|
| 106 |
-
marker_line_color='
|
| 107 |
-
marker_line_width=
|
| 108 |
-
opacity=0.
|
| 109 |
-
base=
|
| 110 |
))
|
| 111 |
|
| 112 |
# Precision - second ring (green)
|
| 113 |
fig.add_trace(go.Barpolar(
|
| 114 |
-
r=[precision_pct],
|
| 115 |
-
theta=
|
| 116 |
-
width=
|
| 117 |
name=f'Precision: {precision_pct:.1f}%',
|
| 118 |
marker_color='#5cb85c',
|
| 119 |
-
marker_line_color='
|
| 120 |
-
marker_line_width=
|
| 121 |
-
opacity=0.
|
| 122 |
-
base=
|
| 123 |
))
|
| 124 |
|
| 125 |
# Recall - third ring (orange)
|
| 126 |
fig.add_trace(go.Barpolar(
|
| 127 |
-
r=[recall_pct],
|
| 128 |
-
theta=
|
| 129 |
-
width=
|
| 130 |
name=f'Recall: {recall_pct:.1f}%',
|
| 131 |
marker_color='#f0ad4e',
|
| 132 |
-
marker_line_color='
|
| 133 |
-
marker_line_width=
|
| 134 |
-
opacity=0.
|
| 135 |
-
base=
|
| 136 |
))
|
| 137 |
|
| 138 |
# IoU - innermost ring (red)
|
| 139 |
fig.add_trace(go.Barpolar(
|
| 140 |
-
r=[iou_pct],
|
| 141 |
-
theta=
|
| 142 |
-
width=
|
| 143 |
name=f'IoU: {iou_pct:.1f}%',
|
| 144 |
marker_color='#d9534f',
|
| 145 |
-
marker_line_color='
|
| 146 |
-
marker_line_width=
|
| 147 |
-
opacity=0.
|
| 148 |
-
base=
|
| 149 |
))
|
| 150 |
|
| 151 |
fig.update_layout(
|
|
@@ -155,7 +160,10 @@ def create_detection_metrics_gauge(avg_confidence: float, iou: float, precision:
|
|
| 155 |
range=[0, 100],
|
| 156 |
showticklabels=True,
|
| 157 |
tickfont=dict(size=10),
|
| 158 |
-
gridcolor='rgba(128,128,128,0.
|
|
|
|
|
|
|
|
|
|
| 159 |
),
|
| 160 |
angularaxis=dict(
|
| 161 |
visible=True,
|
|
@@ -171,12 +179,13 @@ def create_detection_metrics_gauge(avg_confidence: float, iou: float, precision:
|
|
| 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=
|
| 180 |
)
|
| 181 |
|
| 182 |
return fig
|
|
@@ -516,9 +525,9 @@ with gr.Blocks(css=custom_css) as demo:
|
|
| 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):
|
| 524 |
gr.Markdown("### Analysis Report")
|
|
|
|
| 95 |
|
| 96 |
fig = go.Figure()
|
| 97 |
|
| 98 |
+
# Define ring thickness and spacing
|
| 99 |
+
ring_thickness = 15
|
| 100 |
+
|
| 101 |
+
# Add radial bars as thin concentric rings (from outer to inner)
|
| 102 |
+
# Each ring shows the full 360° but at different radii
|
| 103 |
+
|
| 104 |
# Confidence - outermost ring (blue)
|
| 105 |
fig.add_trace(go.Barpolar(
|
| 106 |
+
r=[confidence_pct] * 360,
|
| 107 |
+
theta=list(range(360)),
|
| 108 |
+
width=1,
|
| 109 |
name=f'Confidence: {confidence_pct:.1f}%',
|
| 110 |
marker_color='#4169E1',
|
| 111 |
+
marker_line_color='#4169E1',
|
| 112 |
+
marker_line_width=0,
|
| 113 |
+
opacity=0.9,
|
| 114 |
+
base=85,
|
| 115 |
))
|
| 116 |
|
| 117 |
# Precision - second ring (green)
|
| 118 |
fig.add_trace(go.Barpolar(
|
| 119 |
+
r=[precision_pct] * 360,
|
| 120 |
+
theta=list(range(360)),
|
| 121 |
+
width=1,
|
| 122 |
name=f'Precision: {precision_pct:.1f}%',
|
| 123 |
marker_color='#5cb85c',
|
| 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(
|
|
|
|
| 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 |
visible=True,
|
|
|
|
| 179 |
y=0.5,
|
| 180 |
xanchor="left",
|
| 181 |
x=1.05,
|
| 182 |
+
font=dict(size=11),
|
| 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=140, t=40, b=40)
|
| 189 |
)
|
| 190 |
|
| 191 |
return fig
|
|
|
|
| 525 |
with gr.Column(scale=2):
|
| 526 |
gr.Markdown("### Detection Results")
|
| 527 |
output_image = gr.Image(label="Detected Forgeries", type="numpy")
|
|
|
|
|
|
|
| 528 |
|
| 529 |
+
gr.Markdown("---")
|
| 530 |
+
|
| 531 |
with gr.Row():
|
| 532 |
with gr.Column(scale=1):
|
| 533 |
gr.Markdown("### Analysis Report")
|