Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
import gradio as gr
|
2 |
from ultralytics import YOLO
|
3 |
from PIL import Image
|
|
|
4 |
|
5 |
# Load YOLO model
|
6 |
model = YOLO("Suspicious_Activities_nano.pt")
|
@@ -8,42 +9,48 @@ model = YOLO("Suspicious_Activities_nano.pt")
|
|
8 |
# Define the prediction function
|
9 |
def predict_suspicious_activity(image):
|
10 |
results = model.predict(source=image, show=False, conf=0.6)
|
11 |
-
results_img = results[0].plot()
|
12 |
return Image.fromarray(results_img)
|
13 |
|
14 |
-
# Create
|
|
|
|
|
|
|
15 |
interface = gr.Interface(
|
16 |
fn=predict_suspicious_activity,
|
17 |
-
inputs=gr.Image(type="pil", label="
|
18 |
-
outputs=gr.Image(type="pil", label="
|
19 |
-
title="
|
20 |
description="""
|
21 |
-
**
|
22 |
-
Our system detects
|
23 |
-
-
|
24 |
-
-
|
25 |
-
-
|
26 |
-
- Vandalism and property damage
|
27 |
- Suspicious package handling
|
|
|
28 |
|
29 |
-
Upload your
|
30 |
""",
|
31 |
examples=[
|
32 |
-
["https://
|
33 |
-
["https://
|
34 |
-
["https://
|
35 |
],
|
36 |
cache_examples=False,
|
37 |
-
theme=gr.themes.Soft(
|
38 |
-
|
|
|
|
|
|
|
39 |
)
|
40 |
|
41 |
-
# Launch
|
42 |
interface.launch(
|
43 |
share=True,
|
44 |
-
debug=False,
|
45 |
server_port=7860,
|
46 |
show_api=False,
|
47 |
enable_queue=True,
|
48 |
-
favicon_path="https://raw.githubusercontent.com/ultralytics/assets/main/logo-Ultralytics.svg"
|
|
|
49 |
)
|
|
|
1 |
import gradio as gr
|
2 |
from ultralytics import YOLO
|
3 |
from PIL import Image
|
4 |
+
import os
|
5 |
|
6 |
# Load YOLO model
|
7 |
model = YOLO("Suspicious_Activities_nano.pt")
|
|
|
9 |
# Define the prediction function
|
10 |
def predict_suspicious_activity(image):
|
11 |
results = model.predict(source=image, show=False, conf=0.6)
|
12 |
+
results_img = results[0].plot()
|
13 |
return Image.fromarray(results_img)
|
14 |
|
15 |
+
# Create a temporary directory for examples if needed
|
16 |
+
os.makedirs("examples", exist_ok=True)
|
17 |
+
|
18 |
+
# Create Gradio interface with reliable example images
|
19 |
interface = gr.Interface(
|
20 |
fn=predict_suspicious_activity,
|
21 |
+
inputs=gr.Image(type="pil", label="Security Camera Feed", height=380),
|
22 |
+
outputs=gr.Image(type="pil", label="Threat Analysis", height=380),
|
23 |
+
title="🛡️ AI-Powered Suspicious Activity Detection System",
|
24 |
description="""
|
25 |
+
**Advanced security monitoring using YOLOv8 technology**
|
26 |
+
Our system detects critical security threats including:
|
27 |
+
- Unauthorized loitering in restricted zones
|
28 |
+
- Trespassing incidents captured in surveillance footage
|
29 |
+
- Vandalism and property damage activities
|
|
|
30 |
- Suspicious package handling
|
31 |
+
- Physical confrontations
|
32 |
|
33 |
+
Upload your security footage or test with the examples below:
|
34 |
""",
|
35 |
examples=[
|
36 |
+
["https://raw.githubusercontent.com/ultralytics/ultralytics/main/ultralytics/assets/bus.jpg"],
|
37 |
+
["https://raw.githubusercontent.com/ultralytics/ultralytics/main/ultralytics/assets/zidane.jpg"],
|
38 |
+
["https://ultralytics.com/images/bus.jpg"]
|
39 |
],
|
40 |
cache_examples=False,
|
41 |
+
theme=gr.themes.Soft(
|
42 |
+
primary_hue="amber",
|
43 |
+
font=[gr.themes.GoogleFont('IBM Plex Sans'), 'system-ui']
|
44 |
+
),
|
45 |
+
css=".footer {margin-top: 20px; padding: 15px; border-top: 1px solid #eee; text-align: center; color: #666;} footer {visibility: hidden}"
|
46 |
)
|
47 |
|
48 |
+
# Launch with professional configuration
|
49 |
interface.launch(
|
50 |
share=True,
|
|
|
51 |
server_port=7860,
|
52 |
show_api=False,
|
53 |
enable_queue=True,
|
54 |
+
favicon_path="https://raw.githubusercontent.com/ultralytics/assets/main/logo-Ultralytics.svg",
|
55 |
+
analytics_enabled=False
|
56 |
)
|