asad231's picture
Create app.py
d239b7e verified
raw
history blame
1.36 kB
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()