Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,33 +2,32 @@ import gradio as gr
|
|
| 2 |
import datetime
|
| 3 |
import random
|
| 4 |
|
| 5 |
-
|
| 6 |
-
|
| 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 |
-
|
| 14 |
-
return alert,
|
| 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(
|
| 23 |
with gr.Column():
|
| 24 |
-
lat = gr.Number(value=24.8607
|
| 25 |
-
lon = gr.Number(value=67.0011
|
| 26 |
detect_btn = gr.Button("Detect Theft")
|
| 27 |
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
|
| 32 |
-
detect_btn.click(detect_theft, inputs=[cam, lat, lon], outputs=[
|
| 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()
|