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
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ============================================================
2
+ # LumiAI - LIVE AI STREET LIGHTING DASHBOARD
3
+ # ============================================================
4
+
5
+ import streamlit as st
6
+ import pandas as pd
7
+ import numpy as np
8
+ import plotly.graph_objects as go
9
+ from datetime import datetime
10
+ import time
11
+
12
+
13
+ # ============================================================
14
+ # PAGE CONFIGURATION
15
+ # ============================================================
16
+
17
+ st.set_page_config(
18
+ page_title="LumiAI Smart Street Lighting",
19
+ page_icon="💡",
20
+ layout="wide"
21
+ )
22
+
23
+
24
+ # ============================================================
25
+ # TITLE
26
+ # ============================================================
27
+
28
+ st.title("💡 LumiAI")
29
+ st.subheader(
30
+ "AI-Based Adaptive Smart Street Lighting "
31
+ "for Energy Optimization"
32
+ )
33
+
34
+ st.markdown(
35
+ "### YOLO + LSTM + Q-Learning"
36
+ )
37
+
38
+
39
+ # ============================================================
40
+ # SIDEBAR
41
+ # ============================================================
42
+
43
+ st.sidebar.header("System Control")
44
+
45
+ road = st.sidebar.selectbox(
46
+ "Select Road",
47
+ [
48
+ "Road A",
49
+ "Road B",
50
+ "Road C",
51
+ "Road D"
52
+ ]
53
+ )
54
+
55
+ auto_refresh = st.sidebar.checkbox(
56
+ "Live Refresh",
57
+ value=True
58
+ )
59
+
60
+
61
+ # ============================================================
62
+ # SIMULATED LIVE YOLO DATA
63
+ # ============================================================
64
+
65
+ # In final system these values will come from YOLO
66
+
67
+ vehicle_count = np.random.randint(
68
+ 5,
69
+ 100
70
+ )
71
+
72
+ pedestrian_count = np.random.randint(
73
+ 0,
74
+ 20
75
+ )
76
+
77
+
78
+ # ============================================================
79
+ # TRAFFIC CLASSIFICATION
80
+ # ============================================================
81
+
82
+ if vehicle_count < 20:
83
+
84
+ traffic_level = "LOW"
85
+
86
+ elif vehicle_count < 60:
87
+
88
+ traffic_level = "MEDIUM"
89
+
90
+ else:
91
+
92
+ traffic_level = "HIGH"
93
+
94
+
95
+ # ============================================================
96
+ # LSTM TRAFFIC PREDICTION
97
+ # ============================================================
98
+
99
+ # Demonstration prediction
100
+ # Replace this with actual LSTM prediction
101
+
102
+ predicted_traffic = int(
103
+ vehicle_count
104
+ + np.random.randint(-5, 15)
105
+ )
106
+
107
+ predicted_traffic = max(
108
+ 0,
109
+ predicted_traffic
110
+ )
111
+
112
+
113
+ # ============================================================
114
+ # Q-LEARNING OPTIMAL BRIGHTNESS
115
+ # ============================================================
116
+
117
+ if predicted_traffic >= 60:
118
+
119
+ brightness = 100
120
+
121
+ elif predicted_traffic >= 20:
122
+
123
+ brightness = 70
124
+
125
+ elif predicted_traffic > 0:
126
+
127
+ brightness = 50
128
+
129
+ else:
130
+
131
+ brightness = 30
132
+
133
+
134
+ # ============================================================
135
+ # ENERGY MODEL
136
+ # ============================================================
137
+
138
+ MAX_POWER = 100 # Watts
139
+
140
+ power = (
141
+ MAX_POWER
142
+ * brightness
143
+ / 100
144
+ )
145
+
146
+
147
+ # 15-minute energy consumption
148
+
149
+ energy = (
150
+ power
151
+ * 0.25
152
+ / 1000
153
+ )
154
+
155
+
156
+ # Conventional energy
157
+
158
+ conventional_energy = (
159
+ MAX_POWER
160
+ * 0.25
161
+ / 1000
162
+ )
163
+
164
+
165
+ energy_saved = (
166
+ conventional_energy
167
+ - energy
168
+ )
169
+
170
+
171
+ saving_percentage = (
172
+ energy_saved
173
+ / conventional_energy
174
+ ) * 100
175
+
176
+
177
+ # ============================================================
178
+ # CURRENT TIME
179
+ # ============================================================
180
+
181
+ current_time = datetime.now().strftime(
182
+ "%H:%M:%S"
183
+ )
184
+
185
+
186
+ # ============================================================
187
+ # TOP METRICS
188
+ # ============================================================
189
+
190
+ col1, col2, col3, col4, col5 = st.columns(5)
191
+
192
+
193
+ with col1:
194
+
195
+ st.metric(
196
+ "🚗 Vehicles",
197
+ vehicle_count
198
+ )
199
+
200
+
201
+ with col2:
202
+
203
+ st.metric(
204
+ "🚶 Pedestrians",
205
+ pedestrian_count
206
+ )
207
+
208
+
209
+ with col3:
210
+
211
+ st.metric(
212
+ "📊 Traffic",
213
+ traffic_level
214
+ )
215
+
216
+
217
+ with col4:
218
+
219
+ st.metric(
220
+ "💡 Brightness",
221
+ f"{brightness}%"
222
+ )
223
+
224
+
225
+ with col5:
226
+
227
+ st.metric(
228
+ "⚡ Energy Saving",
229
+ f"{saving_percentage:.1f}%"
230
+ )
231
+
232
+
233
+ st.divider()
234
+
235
+
236
+ # ============================================================
237
+ # SYSTEM STATUS
238
+ # ============================================================
239
+
240
+ col1, col2, col3 = st.columns(3)
241
+
242
+
243
+ with col1:
244
+
245
+ st.success(
246
+ "🟢 AI SYSTEM ACTIVE"
247
+ )
248
+
249
+
250
+ with col2:
251
+
252
+ st.info(
253
+ f"🕒 Last Update: {current_time}"
254
+ )
255
+
256
+
257
+ with col3:
258
+
259
+ st.success(
260
+ f"📍 {road}"
261
+ )
262
+
263
+
264
+ # ============================================================
265
+ # TRAFFIC + PREDICTION
266
+ # ============================================================
267
+
268
+ st.header("🚦 Traffic Intelligence")
269
+
270
+
271
+ col1, col2 = st.columns(2)
272
+
273
+
274
+ with col1:
275
+
276
+ st.subheader(
277
+ "Current vs Predicted Traffic"
278
+ )
279
+
280
+ traffic_data = pd.DataFrame({
281
+
282
+ "Time": [
283
+ "Now",
284
+ "+15 min"
285
+ ],
286
+
287
+ "Vehicles": [
288
+ vehicle_count,
289
+ predicted_traffic
290
+ ]
291
+
292
+ })
293
+
294
+ fig = go.Figure()
295
+
296
+ fig.add_trace(
297
+ go.Bar(
298
+ x=traffic_data["Time"],
299
+ y=traffic_data["Vehicles"],
300
+ name="Vehicles"
301
+ )
302
+ )
303
+
304
+ fig.update_layout(
305
+ yaxis_title="Vehicle Count",
306
+ xaxis_title="Time",
307
+ height=350
308
+ )
309
+
310
+ st.plotly_chart(
311
+ fig,
312
+ use_container_width=True
313
+ )
314
+
315
+
316
+ with col2:
317
+
318
+ st.subheader(
319
+ "AI Lighting Decision"
320
+ )
321
+
322
+ lighting_data = pd.DataFrame({
323
+
324
+ "Parameter": [
325
+ "Traffic",
326
+ "Predicted Traffic",
327
+ "Brightness",
328
+ "Power"
329
+ ],
330
+
331
+ "Value": [
332
+ vehicle_count,
333
+ predicted_traffic,
334
+ f"{brightness}%",
335
+ f"{power:.1f} W"
336
+ ]
337
+
338
+ })
339
+
340
+ st.table(
341
+ lighting_data
342
+ )
343
+
344
+
345
+ # ============================================================
346
+ # BRIGHTNESS GAUGE
347
+ # ============================================================
348
+
349
+ st.header("💡 Adaptive Lighting")
350
+
351
+
352
+ fig = go.Figure(
353
+ go.Indicator(
354
+
355
+ mode="gauge+number",
356
+
357
+ value=brightness,
358
+
359
+ title={
360
+ "text":
361
+ "Optimal Brightness (%)"
362
+ },
363
+
364
+ gauge={
365
+
366
+ "axis": {
367
+ "range": [0, 100]
368
+ }
369
+
370
+ }
371
+
372
+ )
373
+ )
374
+
375
+ fig.update_layout(
376
+ height=350
377
+ )
378
+
379
+ st.plotly_chart(
380
+ fig,
381
+ use_container_width=True
382
+ )
383
+
384
+
385
+ # ============================================================
386
+ # ENERGY ANALYTICS
387
+ # ============================================================
388
+
389
+ st.header("⚡ Energy Optimization")
390
+
391
+
392
+ col1, col2, col3 = st.columns(3)
393
+
394
+
395
+ with col1:
396
+
397
+ st.metric(
398
+ "Conventional",
399
+ f"{conventional_energy:.4f} kWh"
400
+ )
401
+
402
+
403
+ with col2:
404
+
405
+ st.metric(
406
+ "LumiAI",
407
+ f"{energy:.4f} kWh"
408
+ )
409
+
410
+
411
+ with col3:
412
+
413
+ st.metric(
414
+ "Saved",
415
+ f"{energy_saved:.4f} kWh"
416
+ )
417
+
418
+
419
+ # ============================================================
420
+ # ENERGY COMPARISON GRAPH
421
+ # ============================================================
422
+
423
+ energy_df = pd.DataFrame({
424
+
425
+ "System": [
426
+ "Conventional",
427
+ "LumiAI"
428
+ ],
429
+
430
+ "Energy": [
431
+ conventional_energy,
432
+ energy
433
+ ]
434
+
435
+ })
436
+
437
+
438
+ fig = go.Figure()
439
+
440
+ fig.add_trace(
441
+ go.Bar(
442
+ x=energy_df["System"],
443
+ y=energy_df["Energy"],
444
+ name="Energy"
445
+ )
446
+ )
447
+
448
+ fig.update_layout(
449
+ title="Energy Consumption Comparison",
450
+ yaxis_title="Energy (kWh)",
451
+ height=400
452
+ )
453
+
454
+ st.plotly_chart(
455
+ fig,
456
+ use_container_width=True
457
+ )
458
+
459
+
460
+ # ============================================================
461
+ # AI DECISION EXPLANATION
462
+ # ============================================================
463
+
464
+ st.header("🧠 AI Decision")
465
+
466
+
467
+ if brightness == 100:
468
+
469
+ st.error(
470
+ "HIGH TRAFFIC → Maximum brightness selected "
471
+ "for safety."
472
+ )
473
+
474
+ elif brightness == 70:
475
+
476
+ st.warning(
477
+ "MEDIUM TRAFFIC → 70% brightness selected."
478
+ )
479
+
480
+ elif brightness == 50:
481
+
482
+ st.info(
483
+ "LOW TRAFFIC → 50% brightness selected."
484
+ )
485
+
486
+ else:
487
+
488
+ st.success(
489
+ "VERY LOW TRAFFIC → Minimum safe brightness."
490
+ )
491
+
492
+
493
+ # ============================================================
494
+ # ROAD STATUS
495
+ # ============================================================
496
+
497
+ st.header("🗺️ Road Network Status")
498
+
499
+
500
+ road_data = pd.DataFrame({
501
+
502
+ "Road": [
503
+ "Road A",
504
+ "Road B",
505
+ "Road C",
506
+ "Road D"
507
+ ],
508
+
509
+ "Traffic": [
510
+ np.random.randint(10, 100),
511
+ np.random.randint(10, 100),
512
+ np.random.randint(10, 100),
513
+ np.random.randint(10, 100)
514
+ ]
515
+
516
+ })
517
+
518
+
519
+ road_data["Brightness"] = road_data[
520
+ "Traffic"
521
+ ].apply(
522
+
523
+ lambda x:
524
+ 100 if x >= 60
525
+ else 70 if x >= 20
526
+ else 50
527
+ )
528
+
529
+ st.dataframe(
530
+ road_data,
531
+ use_container_width=True
532
+ )
533
+
534
+
535
+ # ============================================================
536
+ # FOOTER
537
+ # ============================================================
538
+
539
+ st.divider()
540
+
541
+ st.caption(
542
+ "LumiAI | YOLO + LSTM + Q-Learning | "
543
+ "AI-Based Energy Optimization"
544
+ )
545
+
546
+
547
+ # ============================================================
548
+ # AUTO REFRESH
549
+ # ============================================================
550
+
551
+ if auto_refresh:
552
+
553
+ time.sleep(3)
554
+
555
+ st.rerun()