asad231 commited on
Commit
46032a9
·
verified ·
1 Parent(s): 892b700

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -13
app.py CHANGED
@@ -2,33 +2,32 @@ import gradio as gr
2
  import datetime
3
  import random
4
 
5
- # Simulate theft detection (AI model logic will go here)
6
- def detect_theft(live_frame, lat, lon):
7
- # Placeholder: randomly simulate detection
8
  is_theft = random.choice([True, False])
9
  time_detected = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
10
 
11
  if is_theft:
12
  alert = f"🚨 Theft detected at {time_detected}!"
13
- location_map = f"""<iframe width="100%" height="300" src="https://maps.google.com/maps?q={lat},{lon}&z=15&output=embed"></iframe>"""
14
- return alert, live_frame, location_map
15
  else:
16
  return "✅ No theft detected", None, None
17
 
18
  with gr.Blocks() as demo:
19
  gr.Markdown("## 🚨 Theft Detection & Live Location Surveillance AI")
20
-
21
  with gr.Row():
22
- cam = gr.Image(source="webcam", streaming=True, label="Live CCTV Feed")
23
  with gr.Column():
24
- lat = gr.Number(value=24.8607, label="Latitude") # default: Karachi
25
- lon = gr.Number(value=67.0011, label="Longitude")
26
  detect_btn = gr.Button("Detect Theft")
27
 
28
- alert_output = gr.Textbox(label="System Alert")
29
- thief_img = gr.Image(label="Captured Frame (If Theft Detected)")
30
- map_output = gr.HTML(label="Live Location Map")
31
 
32
- detect_btn.click(detect_theft, inputs=[cam, lat, lon], outputs=[alert_output, thief_img, map_output])
33
 
34
  demo.launch()
 
2
  import datetime
3
  import random
4
 
5
+ def detect_theft(frame, lat, lon):
6
+ # Simulate detection
 
7
  is_theft = random.choice([True, False])
8
  time_detected = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
9
 
10
  if is_theft:
11
  alert = f"🚨 Theft detected at {time_detected}!"
12
+ map_embed = f"""<iframe width="100%" height="300" src="https://maps.google.com/maps?q={lat},{lon}&z=15&output=embed"></iframe>"""
13
+ return alert, frame, map_embed
14
  else:
15
  return "✅ No theft detected", None, None
16
 
17
  with gr.Blocks() as demo:
18
  gr.Markdown("## 🚨 Theft Detection & Live Location Surveillance AI")
19
+
20
  with gr.Row():
21
+ cam = gr.Image(label="Upload CCTV Frame / Snapshot", type="pil")
22
  with gr.Column():
23
+ lat = gr.Number(label="Latitude", value=24.8607)
24
+ lon = gr.Number(label="Longitude", value=67.0011)
25
  detect_btn = gr.Button("Detect Theft")
26
 
27
+ alert = gr.Textbox(label="Alert")
28
+ captured = gr.Image(label="Thief Frame")
29
+ map_html = gr.HTML(label="Live Location Map")
30
 
31
+ detect_btn.click(fn=detect_theft, inputs=[cam, lat, lon], outputs=[alert, captured, map_html])
32
 
33
  demo.launch()