File size: 1,361 Bytes
d239b7e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import gradio as gr
import datetime
import random

# Simulate theft detection (AI model logic will go here)
def detect_theft(live_frame, lat, lon):
    # Placeholder: randomly simulate detection
    is_theft = random.choice([True, False])
    time_detected = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")

    if is_theft:
        alert = f"🚨 Theft detected at {time_detected}!"
        location_map = f"""<iframe width="100%" height="300" src="https://maps.google.com/maps?q={lat},{lon}&z=15&output=embed"></iframe>"""
        return alert, live_frame, location_map
    else:
        return "✅ No theft detected", None, None

with gr.Blocks() as demo:
    gr.Markdown("## 🚨 Theft Detection & Live Location Surveillance AI")
    
    with gr.Row():
        cam = gr.Image(source="webcam", streaming=True, label="Live CCTV Feed")
        with gr.Column():
            lat = gr.Number(value=24.8607, label="Latitude")  # default: Karachi
            lon = gr.Number(value=67.0011, label="Longitude")
            detect_btn = gr.Button("Detect Theft")

    alert_output = gr.Textbox(label="System Alert")
    thief_img = gr.Image(label="Captured Frame (If Theft Detected)")
    map_output = gr.HTML(label="Live Location Map")

    detect_btn.click(detect_theft, inputs=[cam, lat, lon], outputs=[alert_output, thief_img, map_output])

demo.launch()