asad231 commited on
Commit
d239b7e
·
verified ·
1 Parent(s): fa60613

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +34 -0
app.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 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()