Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,11 +1,26 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import cv2
|
| 3 |
+
import torch
|
| 4 |
+
|
| 5 |
+
# Load your YOLO model
|
| 6 |
+
model = torch.hub.load('ultralytics/yolov5', 'custom', path='path/to/yolov8_motorbike_detect_v2_Check.pt')
|
| 7 |
+
|
| 8 |
+
# Function for YOLO detection
|
| 9 |
+
def detect_objects(image):
|
| 10 |
+
results = model(image)
|
| 11 |
+
return results
|
| 12 |
+
|
| 13 |
+
# Streamlit UI
|
| 14 |
+
st.title("Motorbike Violation Detection")
|
| 15 |
+
uploaded_file = st.file_uploader("Upload an image or video", type=["jpg", "jpeg", "png", "mp4"])
|
| 16 |
+
|
| 17 |
+
if uploaded_file is not None:
|
| 18 |
+
if uploaded_file.type == "video/mp4":
|
| 19 |
+
# Process video here
|
| 20 |
+
st.video(uploaded_file)
|
| 21 |
+
# Add video processing code
|
| 22 |
+
else:
|
| 23 |
+
# Process image
|
| 24 |
+
image = cv2.imdecode(np.frombuffer(uploaded_file.read(), np.uint8), 1)
|
| 25 |
+
results = detect_objects(image)
|
| 26 |
+
st.image(results.render()[0]) # Display results
|