JKrishnanandhaa commited on
Commit
299edf4
·
verified ·
1 Parent(s): e89409d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +74 -50
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 concentric radial gauge showing actual detection metrics"""
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 concentric gauge rings (from outer to inner)
99
- fig.add_trace(go.Indicator(
100
- mode="gauge",
101
- value=confidence_pct,
102
- domain={'x': [0, 1], 'y': [0, 1]},
103
- title={'text': f"Confidence: {confidence_pct:.1f}%", 'font': {'size': 11}},
104
- gauge={
105
- 'axis': {'range': [0, 100], 'visible': False},
106
- 'bar': {'color': '#4169E1', 'thickness': 0.15},
107
- 'bgcolor': 'rgba(0,0,0,0.05)',
108
- 'borderwidth': 0,
109
- }
110
  ))
111
 
112
- fig.add_trace(go.Indicator(
113
- mode="gauge",
114
- value=precision_pct,
115
- domain={'x': [0.1, 0.9], 'y': [0.1, 0.9]},
116
- title={'text': f"Precision: {precision_pct:.1f}%", 'font': {'size': 10}},
117
- gauge={
118
- 'axis': {'range': [0, 100], 'visible': False},
119
- 'bar': {'color': '#5cb85c', 'thickness': 0.15},
120
- 'bgcolor': 'rgba(0,0,0,0.05)',
121
- 'borderwidth': 0,
122
- }
123
  ))
124
 
125
- fig.add_trace(go.Indicator(
126
- mode="gauge",
127
- value=recall_pct,
128
- domain={'x': [0.2, 0.8], 'y': [0.2, 0.8]},
129
- title={'text': f"Recall: {recall_pct:.1f}%", 'font': {'size': 9}},
130
- gauge={
131
- 'axis': {'range': [0, 100], 'visible': False},
132
- 'bar': {'color': '#f0ad4e', 'thickness': 0.15},
133
- 'bgcolor': 'rgba(0,0,0,0.05)',
134
- 'borderwidth': 0,
135
- }
136
  ))
137
 
138
- fig.add_trace(go.Indicator(
139
- mode="gauge+number",
140
- value=iou_pct,
141
- domain={'x': [0.3, 0.7], 'y': [0.3, 0.7]},
142
- title={'text': "IoU", 'font': {'size': 10}},
143
- number={'suffix': '%', 'font': {'size': 16}},
144
- gauge={
145
- 'axis': {'range': [0, 100], 'visible': False},
146
- 'bar': {'color': '#d9534f', 'thickness': 0.2},
147
- 'bgcolor': 'rgba(0,0,0,0.05)',
148
- 'borderwidth': 0,
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=300,
156
- margin=dict(l=20, r=20, t=60, b=20),
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):