paranox commited on
Commit
92f3c5b
Β·
verified Β·
1 Parent(s): 5c11c2c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +60 -37
app.py CHANGED
@@ -99,7 +99,7 @@ st.markdown("""
99
  }
100
 
101
  .emergency-alert {
102
- background: var(--emergency-gradient);
103
  color: white;
104
  padding: 0.5rem 1.5rem;
105
  border-radius: 24px;
@@ -108,7 +108,7 @@ st.markdown("""
108
  text-transform: uppercase;
109
  letter-spacing: 1.5px;
110
  animation: emergencyPulse 1s ease-in-out infinite;
111
- box-shadow: 0 0 30px rgba(255, 8, 68, 0.6);
112
  }
113
 
114
  @keyframes emergencyPulse {
@@ -157,12 +157,12 @@ st.markdown("""
157
  }
158
 
159
  .hero-subtitle {
160
- text-align: center !important;
161
- margin-left: auto !important;
162
- margin-right: auto !important;
163
- display: block !important;
164
- width: fit-content !important;
165
- max-width: 700px;
166
  }
167
 
168
  .tech-pill {
@@ -298,19 +298,19 @@ st.markdown("""
298
  }
299
 
300
  .signal-card.emergency-active {
301
- border-color: #ff0844;
302
- background: linear-gradient(135deg, rgba(255, 8, 68, 0.2) 0%, rgba(255, 107, 0, 0.2) 100%);
303
- box-shadow: 0 0 50px rgba(255, 8, 68, 0.8);
304
  animation: emergencySignal 0.5s ease-in-out infinite;
305
  }
306
 
307
  @keyframes emergencySignal {
308
  0%, 100% {
309
- box-shadow: 0 0 50px rgba(255, 8, 68, 0.8);
310
  transform: scale(1);
311
  }
312
  50% {
313
- box-shadow: 0 0 80px rgba(255, 8, 68, 1);
314
  transform: scale(1.02);
315
  }
316
  }
@@ -358,19 +358,19 @@ st.markdown("""
358
  }
359
 
360
  .light-emergency {
361
- background: radial-gradient(circle, rgba(255, 8, 68, 0.7) 0%, transparent 70%);
362
- border-color: #ff0844;
363
- box-shadow: 0 0 60px rgba(255, 8, 68, 0.8);
364
  animation: emergencyGlow 0.3s ease-in-out infinite;
365
  }
366
 
367
  @keyframes emergencyGlow {
368
  0%, 100% {
369
- box-shadow: 0 0 60px rgba(255, 8, 68, 0.8);
370
  transform: scale(1);
371
  }
372
  50% {
373
- box-shadow: 0 0 90px rgba(255, 8, 68, 1);
374
  transform: scale(1.05);
375
  }
376
  }
@@ -386,9 +386,9 @@ st.markdown("""
386
  }
387
 
388
  .timer-container.emergency {
389
- background: linear-gradient(135deg, rgba(255, 8, 68, 0.2) 0%, rgba(255, 107, 0, 0.2) 100%);
390
- border: 2px solid #ff0844;
391
- box-shadow: 0 0 60px rgba(255, 8, 68, 0.6);
392
  animation: emergencyPulse 1s ease-in-out infinite;
393
  }
394
 
@@ -426,13 +426,13 @@ st.markdown("""
426
  }
427
 
428
  .emergency-banner {
429
- background: linear-gradient(135deg, rgba(255, 8, 68, 0.3) 0%, rgba(255, 107, 0, 0.2) 100%);
430
- border: 3px solid #ff0844;
431
  border-radius: 28px;
432
  padding: 3rem;
433
  text-align: center;
434
  margin: 3rem 2rem;
435
- box-shadow: 0 0 60px rgba(255, 8, 68, 0.6);
436
  animation: emergencyPulse 1s ease-in-out infinite;
437
  }
438
 
@@ -503,6 +503,21 @@ st.markdown("""
503
  font-weight: 700;
504
  }
505
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
506
  .stButton > button {
507
  background: var(--primary-gradient);
508
  color: white;
@@ -831,7 +846,7 @@ st.markdown("""
831
  </h1>
832
  <p class="hero-subtitle">
833
  Revolutionizing urban mobility with cutting-edge AI. Real-time vehicle detection,
834
- adaptive signal optimization, and <strong style="color: #ff0844;">intelligent emergency vehicle prioritization</strong> powered by YOLOv8 & CNN.
835
  </p>
836
  <div>
837
  <span class="tech-pill">πŸ€– YOLOv8 Detection</span>
@@ -1098,11 +1113,11 @@ if all(uploaded_images.values()):
1098
  <div style="font-size: 1.5rem; color: #fff; font-weight: 700; margin: 1rem 0;">
1099
  {current_direction.upper()} Direction β€’ Confidence: {emergency_conf:.1f}%
1100
  </div>
1101
- <div style="font-size: 1rem; color: #fbbf24; font-weight: 600; margin: 0.5rem 0;">
1102
  Detection Method: {detection_method_used}
1103
  </div>
1104
- <div style="font-size: 1.1rem; color: #fbbf24; font-weight: 600;">
1105
- ⚠️ All other directions RED β€’ Emergency vehicle has priority clearance for {green_time} seconds
1106
  </div>
1107
  </div>
1108
  """, unsafe_allow_html=True)
@@ -1125,12 +1140,12 @@ if all(uploaded_images.values()):
1125
  direction, "None")
1126
 
1127
  if is_current and is_emergency:
1128
- # Emergency vehicle active
1129
  if st.session_state.phase == "green":
1130
  card_class = "signal-card emergency-active"
1131
  light_class = "light-emergency"
1132
- status = "🚨 EMERGENCY"
1133
- status_color = "#ff0844"
1134
  else:
1135
  card_class = "signal-card yellow-active"
1136
  light_class = "light-yellow"
@@ -1157,7 +1172,7 @@ if all(uploaded_images.values()):
1157
  # Add emergency badge if detected
1158
  emergency_badge = ""
1159
  if has_emergency:
1160
- emergency_badge = f'''<div style="background: #ff0844; color: white; padding: 0.375rem 0.75rem;
1161
  border-radius: 12px; font-size: 0.7rem; font-weight: 900;
1162
  margin-top: 0.5rem; letter-spacing: 1px;">
1163
  🚨 AMBULANCE<br><span style="font-size: 0.65rem;">{method}</span>
@@ -1176,7 +1191,7 @@ if all(uploaded_images.values()):
1176
  # Timer display
1177
  timer_placeholder = st.empty()
1178
 
1179
- # Display detected images
1180
  st.markdown("""
1181
  <div class="section-container">
1182
  <h2 class="section-title">🎯 Vehicle Detection Results</h2>
@@ -1192,17 +1207,25 @@ if all(uploaded_images.values()):
1192
  method = st.session_state.detection_method[direction]
1193
  caption += f"\n🚨 AMBULANCE ({st.session_state.emergency_confidence[direction]:.1f}% - {method})"
1194
 
 
 
 
 
 
1195
  st.image(
1196
  st.session_state.annotated_images[direction],
1197
  caption=caption,
1198
  use_container_width=True
1199
  )
1200
 
 
 
 
1201
  # Countdown timer
1202
  duration = green_time if st.session_state.phase == "green" else yellow_time
1203
  for remaining in range(duration, 0, -1):
1204
  if is_emergency and st.session_state.phase == "green":
1205
- phase_emoji = "🚨"
1206
  phase_text = "EMERGENCY CLEARANCE ACTIVE"
1207
  timer_class = "timer-container emergency"
1208
  value_class = "timer-value emergency"
@@ -1265,7 +1288,7 @@ if all(uploaded_images.values()):
1265
  <div style="font-size: 1.3rem; color: #fff; font-weight: 700; margin-top: 1rem;">
1266
  Detected in: {emergency_list}
1267
  </div>
1268
- <div style="font-size: 1rem; color: #fbbf24; margin-top: 1rem; font-weight: 600;">
1269
  βœ“ Emergency vehicles were given priority clearance with extended green time (35s)
1270
  </div>
1271
  </div>
@@ -1325,7 +1348,7 @@ if all(uploaded_images.values()):
1325
  colors = []
1326
  for d in st.session_state.counts.keys():
1327
  if d in st.session_state.emergency_directions:
1328
- colors.append('#ff0844') # Red for emergency
1329
  else:
1330
  colors.append('#667eea') # Blue for regular
1331
 
@@ -1435,7 +1458,7 @@ if all(uploaded_images.values()):
1435
  pie_colors = []
1436
  for d in st.session_state.counts.keys():
1437
  if d in st.session_state.emergency_directions:
1438
- pie_colors.append('#ff0844')
1439
  else:
1440
  pie_colors.append('#667eea')
1441
 
 
99
  }
100
 
101
  .emergency-alert {
102
+ background: linear-gradient(45deg, #00c400, #11ff11);
103
  color: white;
104
  padding: 0.5rem 1.5rem;
105
  border-radius: 24px;
 
108
  text-transform: uppercase;
109
  letter-spacing: 1.5px;
110
  animation: emergencyPulse 1s ease-in-out infinite;
111
+ box-shadow: 0 0 30px rgba(0, 196, 0, 0.6);
112
  }
113
 
114
  @keyframes emergencyPulse {
 
157
  }
158
 
159
  .hero-subtitle {
160
+ text-align: center !important;
161
+ margin-left: auto !important;
162
+ margin-right: auto !important;
163
+ display: block !important;
164
+ width: fit-content !important;
165
+ max-width: 700px;
166
  }
167
 
168
  .tech-pill {
 
298
  }
299
 
300
  .signal-card.emergency-active {
301
+ border-color: #00c400;
302
+ background: linear-gradient(135deg, rgba(0, 196, 0, 0.2) 0%, rgba(17, 255, 17, 0.2) 100%);
303
+ box-shadow: 0 0 50px rgba(0, 196, 0, 0.8);
304
  animation: emergencySignal 0.5s ease-in-out infinite;
305
  }
306
 
307
  @keyframes emergencySignal {
308
  0%, 100% {
309
+ box-shadow: 0 0 50px rgba(0, 196, 0, 0.8);
310
  transform: scale(1);
311
  }
312
  50% {
313
+ box-shadow: 0 0 80px rgba(0, 196, 0, 1);
314
  transform: scale(1.02);
315
  }
316
  }
 
358
  }
359
 
360
  .light-emergency {
361
+ background: radial-gradient(circle, rgba(0, 196, 0, 0.7) 0%, transparent 70%);
362
+ border-color: #00c400;
363
+ box-shadow: 0 0 60px rgba(0, 196, 0, 0.8);
364
  animation: emergencyGlow 0.3s ease-in-out infinite;
365
  }
366
 
367
  @keyframes emergencyGlow {
368
  0%, 100% {
369
+ box-shadow: 0 0 60px rgba(0, 196, 0, 0.8);
370
  transform: scale(1);
371
  }
372
  50% {
373
+ box-shadow: 0 0 90px rgba(0, 196, 0, 1);
374
  transform: scale(1.05);
375
  }
376
  }
 
386
  }
387
 
388
  .timer-container.emergency {
389
+ background: linear-gradient(135deg, rgba(0, 196, 0, 0.2) 0%, rgba(17, 255, 17, 0.2) 100%);
390
+ border: 2px solid #00c400;
391
+ box-shadow: 0 0 60px rgba(0, 196, 0, 0.6);
392
  animation: emergencyPulse 1s ease-in-out infinite;
393
  }
394
 
 
426
  }
427
 
428
  .emergency-banner {
429
+ background: linear-gradient(135deg, rgba(0, 196, 0, 0.3) 0%, rgba(17, 255, 17, 0.2) 100%);
430
+ border: 3px solid #00c400;
431
  border-radius: 28px;
432
  padding: 3rem;
433
  text-align: center;
434
  margin: 3rem 2rem;
435
+ box-shadow: 0 0 60px rgba(0, 196, 0, 0.6);
436
  animation: emergencyPulse 1s ease-in-out infinite;
437
  }
438
 
 
503
  font-weight: 700;
504
  }
505
 
506
+ .image-highlight {
507
+ border: 5px solid #00c400 !important;
508
+ box-shadow: 0 0 40px rgba(0, 196, 0, 0.8) !important;
509
+ animation: imageHighlight 1s ease-in-out infinite;
510
+ }
511
+
512
+ @keyframes imageHighlight {
513
+ 0%, 100% {
514
+ box-shadow: 0 0 40px rgba(0, 196, 0, 0.8);
515
+ }
516
+ 50% {
517
+ box-shadow: 0 0 60px rgba(0, 196, 0, 1);
518
+ }
519
+ }
520
+
521
  .stButton > button {
522
  background: var(--primary-gradient);
523
  color: white;
 
846
  </h1>
847
  <p class="hero-subtitle">
848
  Revolutionizing urban mobility with cutting-edge AI. Real-time vehicle detection,
849
+ adaptive signal optimization, and <strong style="color: #00c400;">intelligent emergency vehicle prioritization</strong> powered by YOLOv8 & CNN.
850
  </p>
851
  <div>
852
  <span class="tech-pill">πŸ€– YOLOv8 Detection</span>
 
1113
  <div style="font-size: 1.5rem; color: #fff; font-weight: 700; margin: 1rem 0;">
1114
  {current_direction.upper()} Direction β€’ Confidence: {emergency_conf:.1f}%
1115
  </div>
1116
+ <div style="font-size: 1rem; color: #11ff11; font-weight: 600; margin: 0.5rem 0;">
1117
  Detection Method: {detection_method_used}
1118
  </div>
1119
+ <div style="font-size: 1.1rem; color: #11ff11; font-weight: 600;">
1120
+ βœ… {current_direction.upper()} direction GREEN β€’ Emergency vehicle has priority clearance for {green_time} seconds
1121
  </div>
1122
  </div>
1123
  """, unsafe_allow_html=True)
 
1140
  direction, "None")
1141
 
1142
  if is_current and is_emergency:
1143
+ # Emergency vehicle active - SHOW GREEN
1144
  if st.session_state.phase == "green":
1145
  card_class = "signal-card emergency-active"
1146
  light_class = "light-emergency"
1147
+ status = "🟒 EMERGENCY GREEN"
1148
+ status_color = "#00c400"
1149
  else:
1150
  card_class = "signal-card yellow-active"
1151
  light_class = "light-yellow"
 
1172
  # Add emergency badge if detected
1173
  emergency_badge = ""
1174
  if has_emergency:
1175
+ emergency_badge = f'''<div style="background: #00c400; color: white; padding: 0.375rem 0.75rem;
1176
  border-radius: 12px; font-size: 0.7rem; font-weight: 900;
1177
  margin-top: 0.5rem; letter-spacing: 1px;">
1178
  🚨 AMBULANCE<br><span style="font-size: 0.65rem;">{method}</span>
 
1191
  # Timer display
1192
  timer_placeholder = st.empty()
1193
 
1194
+ # Display detected images WITH HIGHLIGHTING
1195
  st.markdown("""
1196
  <div class="section-container">
1197
  <h2 class="section-title">🎯 Vehicle Detection Results</h2>
 
1207
  method = st.session_state.detection_method[direction]
1208
  caption += f"\n🚨 AMBULANCE ({st.session_state.emergency_confidence[direction]:.1f}% - {method})"
1209
 
1210
+ # Apply highlighting CSS class for emergency images
1211
+ if direction in st.session_state.emergency_directions:
1212
+ st.markdown('<div class="image-highlight">',
1213
+ unsafe_allow_html=True)
1214
+
1215
  st.image(
1216
  st.session_state.annotated_images[direction],
1217
  caption=caption,
1218
  use_container_width=True
1219
  )
1220
 
1221
+ if direction in st.session_state.emergency_directions:
1222
+ st.markdown('</div>', unsafe_allow_html=True)
1223
+
1224
  # Countdown timer
1225
  duration = green_time if st.session_state.phase == "green" else yellow_time
1226
  for remaining in range(duration, 0, -1):
1227
  if is_emergency and st.session_state.phase == "green":
1228
+ phase_emoji = "🟒"
1229
  phase_text = "EMERGENCY CLEARANCE ACTIVE"
1230
  timer_class = "timer-container emergency"
1231
  value_class = "timer-value emergency"
 
1288
  <div style="font-size: 1.3rem; color: #fff; font-weight: 700; margin-top: 1rem;">
1289
  Detected in: {emergency_list}
1290
  </div>
1291
+ <div style="font-size: 1rem; color: #11ff11; margin-top: 1rem; font-weight: 600;">
1292
  βœ“ Emergency vehicles were given priority clearance with extended green time (35s)
1293
  </div>
1294
  </div>
 
1348
  colors = []
1349
  for d in st.session_state.counts.keys():
1350
  if d in st.session_state.emergency_directions:
1351
+ colors.append('#00c400') # Green for emergency
1352
  else:
1353
  colors.append('#667eea') # Blue for regular
1354
 
 
1458
  pie_colors = []
1459
  for d in st.session_state.counts.keys():
1460
  if d in st.session_state.emergency_directions:
1461
+ pie_colors.append('#00c400')
1462
  else:
1463
  pie_colors.append('#667eea')
1464