45rtygu commited on
Commit
29e4c09
Β·
verified Β·
1 Parent(s): 1952ea1

Upload 2 files

Browse files
Files changed (2) hide show
  1. app,py.txt +82 -0
  2. requirements.txt +6 -0
app,py.txt ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import random
3
+ import time
4
+
5
+ # ----- PAGE CONFIG -----
6
+ st.set_page_config(page_title="🚦 AI Traffic Cloud Dashboard", layout="wide", initial_sidebar_state="expanded")
7
+
8
+ # ----- CUSTOM DARK THEME -----
9
+ st.markdown("""
10
+ <style>
11
+ body {
12
+ background-color: #0E1117;
13
+ color: white;
14
+ }
15
+ .metric-container {
16
+ background-color: #1E222A;
17
+ border-radius: 10px;
18
+ padding: 15px;
19
+ text-align: center;
20
+ box-shadow: 0 0 10px rgba(0, 255, 100, 0.1);
21
+ }
22
+ .stMetric {
23
+ font-size: 22px;
24
+ }
25
+ </style>
26
+ """, unsafe_allow_html=True)
27
+
28
+ # ----- TITLE -----
29
+ st.title("🌐 AI Traffic Cloud System Dashboard")
30
+ st.markdown("#### Real-time Urban Traffic Monitoring and Control")
31
+
32
+ # ----- VIDEO UPLOAD -----
33
+ st.sidebar.header("πŸŽ₯ Upload Traffic Video")
34
+ video_file = st.sidebar.file_uploader("Upload traffic footage", type=["mp4", "avi", "mov"])
35
+
36
+ if video_file:
37
+ st.video(video_file)
38
+ with st.spinner("Analyzing video using YOLO + DeepSORT..."):
39
+ time.sleep(5) # simulate analysis delay
40
+
41
+ # ----- SIMULATED RESULTS -----
42
+ total_vehicles = random.randint(80, 200)
43
+ car_count = int(total_vehicles * 0.65)
44
+ truck_count = int(total_vehicles * 0.25)
45
+ bike_count = total_vehicles - (car_count + truck_count)
46
+ congestion_level = random.randint(30, 90)
47
+ emergency_vehicle_detected = random.choice([True, False])
48
+
49
+ st.markdown("---")
50
+ st.subheader("πŸ“Š Detection Summary")
51
+
52
+ col1, col2, col3, col4 = st.columns(4)
53
+ col1.metric("πŸš— Cars", car_count)
54
+ col2.metric("🚚 Trucks", truck_count)
55
+ col3.metric("🏍️ Bikes", bike_count)
56
+ col4.metric("🚦 Total Vehicles", total_vehicles)
57
+
58
+ st.markdown("---")
59
+ st.subheader("πŸ“ˆ Traffic Density & Lane Control")
60
+ st.progress(congestion_level / 100)
61
+ st.write(f"Current congestion: **{congestion_level}%**")
62
+
63
+ # ----- GREEN CORRIDOR LOGIC -----
64
+ st.markdown("---")
65
+ st.subheader("🟒 Emergency Green Corridor System")
66
+
67
+ if emergency_vehicle_detected:
68
+ st.success("πŸš‘ Emergency Vehicle Detected β€” Activating Green Corridor!")
69
+ st.markdown("""
70
+ - πŸ”„ Synchronizing signals across intersections
71
+ - 🟩 Clearing lanes for emergency route
72
+ - πŸ“‘ Notifying nearby traffic units
73
+ """)
74
+ st.balloons()
75
+ else:
76
+ st.info("βœ… No emergency vehicles detected. Traffic flow normal.")
77
+
78
+ st.markdown("---")
79
+ st.caption("πŸ’‘ Powered by simulated YOLO + DeepSORT AI | Cloud Intelligence for Smart Cities")
80
+
81
+ else:
82
+ st.info("⬆️ Upload a traffic video to start AI analysis and visualization.")
requirements.txt ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ streamlit
2
+ ultralytics
3
+ deep-sort-realtime
4
+ opencv-python
5
+ pandas
6
+ numpy