Upload 2 files
Browse files- app,py.txt +82 -0
- 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
|