SuriRaja commited on
Commit
676260b
·
1 Parent(s): 4861682

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -1
app.py CHANGED
@@ -150,7 +150,20 @@ with gr.Blocks(theme=gr.themes.Soft()) as app:
150
  def streaming_loop():
151
  while True:
152
  frame, metrics, logs, chart, pie, captured = monitor_feed()
153
- yield frame, str(metrics), logs, chart, pie, captured
 
 
 
 
 
 
 
 
 
 
 
 
 
154
  time.sleep(frame_rate)
155
 
156
  app.load(streaming_loop, outputs=[video_output, metrics_output, logs_output, chart_output, pie_output, captured_images])
 
150
  def streaming_loop():
151
  while True:
152
  frame, metrics, logs, chart, pie, captured = monitor_feed()
153
+ # Format metrics display
154
+ anomaly_text = ""
155
+ if 'anomalies' in metrics and isinstance(metrics['anomalies'], list):
156
+ anomaly_text = "\n".join(
157
+ f"- {a.get('label', 'Unknown')} at {a.get('position', 'N/A')}" if isinstance(a, dict) else str(a)
158
+ for a in metrics['anomalies']
159
+ )
160
+ else:
161
+ anomaly_text = "No anomalies detected"
162
+
163
+ metric_summary = f"📊 Total Anomalies: {len(metrics.get('anomalies', []))}\n{anomaly_text}"
164
+
165
+ yield frame, metric_summary, logs, chart, pie, captured
166
+
167
  time.sleep(frame_rate)
168
 
169
  app.load(streaming_loop, outputs=[video_output, metrics_output, logs_output, chart_output, pie_output, captured_images])