Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,31 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
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 |
-
|
11 |
-
|
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
|
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("
|
26 |
|
27 |
alert = gr.Textbox(label="Alert")
|
28 |
-
captured = gr.Image(label="Thief
|
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])
|
|
|
1 |
+
# import gradio as gr
|
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()
|
34 |
+
|
35 |
import gradio as gr
|
36 |
import datetime
|
|
|
37 |
|
38 |
def detect_theft(frame, lat, lon):
|
|
|
|
|
39 |
time_detected = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
40 |
+
alert = f"π¨ Theft detected at {time_detected}!"
|
41 |
+
map_embed = f"""<iframe width="100%" height="300" src="https://maps.google.com/maps?q={lat},{lon}&z=15&output=embed"></iframe>"""
|
42 |
+
return alert, frame, map_embed
|
|
|
|
|
|
|
|
|
43 |
|
44 |
with gr.Blocks() as demo:
|
45 |
gr.Markdown("## π¨ Theft Detection & Live Location Surveillance AI")
|
46 |
|
47 |
with gr.Row():
|
48 |
+
cam = gr.Image(label="Upload Thief Image", type="pil")
|
49 |
with gr.Column():
|
50 |
lat = gr.Number(label="Latitude", value=24.8607)
|
51 |
lon = gr.Number(label="Longitude", value=67.0011)
|
52 |
+
detect_btn = gr.Button("π Show Location on Map")
|
53 |
|
54 |
alert = gr.Textbox(label="Alert")
|
55 |
+
captured = gr.Image(label="Thief Image")
|
56 |
map_html = gr.HTML(label="Live Location Map")
|
57 |
|
58 |
detect_btn.click(fn=detect_theft, inputs=[cam, lat, lon], outputs=[alert, captured, map_html])
|