Upload 11 files
Browse files- .gitattributes +2 -0
- 2024-05-18_14-46-07_4910.png +3 -0
- 2024-05-18_14-57-09_5235.png +3 -0
- PS1/yolov8n.pt +3 -0
- PS2/DQN_MODELS/DQN_MODEL1.zip +3 -0
- PS2/single-intersection-gen.rou.xml +61 -0
- PS2/single-intersection.net.xml +186 -0
- PS3/best.pt +3 -0
- PS3/yolov8n.pt +3 -0
- app.py +419 -0
- pngtree-city-map-navigation-interface-picture-image_1833642.png +0 -0
- requirements.txt +12 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
2024-05-18_14-46-07_4910.png filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
2024-05-18_14-57-09_5235.png filter=lfs diff=lfs merge=lfs -text
|
2024-05-18_14-46-07_4910.png
ADDED
|
Git LFS Details
|
2024-05-18_14-57-09_5235.png
ADDED
|
Git LFS Details
|
PS1/yolov8n.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:31e20dde3def09e2cf938c7be6fe23d9150bbbe503982af13345706515f2ef95
|
| 3 |
+
size 6534387
|
PS2/DQN_MODELS/DQN_MODEL1.zip
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d9b7923d58703d779fdaee6b986dfbcad66332f42402536951864f97b82f067a
|
| 3 |
+
size 65427
|
PS2/single-intersection-gen.rou.xml
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<routes>
|
| 2 |
+
<route id="route_ns" edges="n_t t_s"/>
|
| 3 |
+
<route id="route_nw" edges="n_t t_w"/>
|
| 4 |
+
<route id="route_ne" edges="n_t t_e"/>
|
| 5 |
+
<route id="route_we" edges="w_t t_e"/>
|
| 6 |
+
<route id="route_wn" edges="w_t t_n"/>
|
| 7 |
+
<route id="route_ws" edges="w_t t_s"/>
|
| 8 |
+
<route id="route_ew" edges="e_t t_w"/>
|
| 9 |
+
<route id="route_en" edges="e_t t_n"/>
|
| 10 |
+
<route id="route_es" edges="e_t t_s"/>
|
| 11 |
+
<route id="route_sn" edges="s_t t_n"/>
|
| 12 |
+
<route id="route_se" edges="s_t t_e"/>
|
| 13 |
+
<route id="route_sw" edges="s_t t_w"/><flow id="flow_ns_0" route="route_ns" begin="0" end="100000" vehsPerHour="100" departSp100000d="max" departPos="base" departLane="best"/>
|
| 14 |
+
<flow id="flow_nw_0" route="route_nw" begin="0" end="100000" vehsPerHour="100" departSp100000d="max" departPos="base" departLane="best"/>
|
| 15 |
+
<flow id="flow_ne_0" route="route_ne" begin="0" end="100000" vehsPerHour="200" departSp100000d="max" departPos="base" departLane="best"/>
|
| 16 |
+
<flow id="flow_sw_0" route="route_sw" begin="0" end="100000" vehsPerHour="200" departSp100000d="max" departPos="base" departLane="best"/>
|
| 17 |
+
<flow id="flow_sn_0" route="route_sn" begin="0" end="100000" vehsPerHour="100" departSp100000d="max" departPos="base" departLane="best"/>
|
| 18 |
+
<flow id="flow_se_0" route="route_se" begin="0" end="100000" vehsPerHour="100" departSp100000d="max" departPos="base" departLane="best"/>
|
| 19 |
+
|
| 20 |
+
<flow id="flow_en_0" route="route_en" begin="0" end="100000" vehsPerHour="300" departSp100000d="max" departPos="base" departLane="best"/>
|
| 21 |
+
<flow id="flow_ew_0" route="route_ew" begin="0" end="100000" vehsPerHour="300" departSp100000d="max" departPos="base" departLane="best"/>
|
| 22 |
+
<flow id="flow_es_0" route="route_es" begin="0" end="100000" vehsPerHour="600" departSp100000d="max" departPos="base" departLane="best"/>
|
| 23 |
+
<flow id="flow_wn_0" route="route_wn" begin="0" end="100000" vehsPerHour="600" departSp100000d="max" departPos="base" departLane="best"/>
|
| 24 |
+
<flow id="flow_we_0" route="route_we" begin="0" end="100000" vehsPerHour="300" departSp100000d="max" departPos="base" departLane="best"/>
|
| 25 |
+
<flow id="flow_ws_0" route="route_ws" begin="0" end="100000" vehsPerHour="300" departSp100000d="max" departPos="base" departLane="best"/><flow id="flow_ns_1" route="route_ns" begin="100000" end="200000" vehsPerHour="200" departSp200000d="max" departPos="base" departLane="best"/>
|
| 26 |
+
<flow id="flow_nw_1" route="route_nw" begin="100000" end="200000" vehsPerHour="200" departSp200000d="max" departPos="base" departLane="best"/>
|
| 27 |
+
<flow id="flow_ne_1" route="route_ne" begin="100000" end="200000" vehsPerHour="400" departSp200000d="max" departPos="base" departLane="best"/>
|
| 28 |
+
<flow id="flow_sw_1" route="route_sw" begin="100000" end="200000" vehsPerHour="400" departSp200000d="max" departPos="base" departLane="best"/>
|
| 29 |
+
<flow id="flow_sn_1" route="route_sn" begin="100000" end="200000" vehsPerHour="200" departSp200000d="max" departPos="base" departLane="best"/>
|
| 30 |
+
<flow id="flow_se_1" route="route_se" begin="100000" end="200000" vehsPerHour="200" departSp200000d="max" departPos="base" departLane="best"/>
|
| 31 |
+
|
| 32 |
+
<flow id="flow_en_1" route="route_en" begin="100000" end="200000" vehsPerHour="200" departSp200000d="max" departPos="base" departLane="best"/>
|
| 33 |
+
<flow id="flow_ew_1" route="route_ew" begin="100000" end="200000" vehsPerHour="200" departSp200000d="max" departPos="base" departLane="best"/>
|
| 34 |
+
<flow id="flow_es_1" route="route_es" begin="100000" end="200000" vehsPerHour="400" departSp200000d="max" departPos="base" departLane="best"/>
|
| 35 |
+
<flow id="flow_wn_1" route="route_wn" begin="100000" end="200000" vehsPerHour="400" departSp200000d="max" departPos="base" departLane="best"/>
|
| 36 |
+
<flow id="flow_we_1" route="route_we" begin="100000" end="200000" vehsPerHour="200" departSp200000d="max" departPos="base" departLane="best"/>
|
| 37 |
+
<flow id="flow_ws_1" route="route_ws" begin="100000" end="200000" vehsPerHour="200" departSp200000d="max" departPos="base" departLane="best"/><flow id="flow_ns_2" route="route_ns" begin="200000" end="300000" vehsPerHour="100" departSp300000d="max" departPos="base" departLane="best"/>
|
| 38 |
+
<flow id="flow_nw_2" route="route_nw" begin="200000" end="300000" vehsPerHour="100" departSp300000d="max" departPos="base" departLane="best"/>
|
| 39 |
+
<flow id="flow_ne_2" route="route_ne" begin="200000" end="300000" vehsPerHour="200" departSp300000d="max" departPos="base" departLane="best"/>
|
| 40 |
+
<flow id="flow_sw_2" route="route_sw" begin="200000" end="300000" vehsPerHour="200" departSp300000d="max" departPos="base" departLane="best"/>
|
| 41 |
+
<flow id="flow_sn_2" route="route_sn" begin="200000" end="300000" vehsPerHour="100" departSp300000d="max" departPos="base" departLane="best"/>
|
| 42 |
+
<flow id="flow_se_2" route="route_se" begin="200000" end="300000" vehsPerHour="100" departSp300000d="max" departPos="base" departLane="best"/>
|
| 43 |
+
|
| 44 |
+
<flow id="flow_en_2" route="route_en" begin="200000" end="300000" vehsPerHour="300" departSp300000d="max" departPos="base" departLane="best"/>
|
| 45 |
+
<flow id="flow_ew_2" route="route_ew" begin="200000" end="300000" vehsPerHour="300" departSp300000d="max" departPos="base" departLane="best"/>
|
| 46 |
+
<flow id="flow_es_2" route="route_es" begin="200000" end="300000" vehsPerHour="600" departSp300000d="max" departPos="base" departLane="best"/>
|
| 47 |
+
<flow id="flow_wn_2" route="route_wn" begin="200000" end="300000" vehsPerHour="600" departSp300000d="max" departPos="base" departLane="best"/>
|
| 48 |
+
<flow id="flow_we_2" route="route_we" begin="200000" end="300000" vehsPerHour="300" departSp300000d="max" departPos="base" departLane="best"/>
|
| 49 |
+
<flow id="flow_ws_2" route="route_ws" begin="200000" end="300000" vehsPerHour="300" departSp300000d="max" departPos="base" departLane="best"/><flow id="flow_ns_3" route="route_ns" begin="300000" end="400000" vehsPerHour="200" departSp400000d="max" departPos="base" departLane="best"/>
|
| 50 |
+
<flow id="flow_nw_3" route="route_nw" begin="300000" end="400000" vehsPerHour="200" departSp400000d="max" departPos="base" departLane="best"/>
|
| 51 |
+
<flow id="flow_ne_3" route="route_ne" begin="300000" end="400000" vehsPerHour="400" departSp400000d="max" departPos="base" departLane="best"/>
|
| 52 |
+
<flow id="flow_sw_3" route="route_sw" begin="300000" end="400000" vehsPerHour="400" departSp400000d="max" departPos="base" departLane="best"/>
|
| 53 |
+
<flow id="flow_sn_3" route="route_sn" begin="300000" end="400000" vehsPerHour="200" departSp400000d="max" departPos="base" departLane="best"/>
|
| 54 |
+
<flow id="flow_se_3" route="route_se" begin="300000" end="400000" vehsPerHour="200" departSp400000d="max" departPos="base" departLane="best"/>
|
| 55 |
+
|
| 56 |
+
<flow id="flow_en_3" route="route_en" begin="300000" end="400000" vehsPerHour="200" departSp400000d="max" departPos="base" departLane="best"/>
|
| 57 |
+
<flow id="flow_ew_3" route="route_ew" begin="300000" end="400000" vehsPerHour="200" departSp400000d="max" departPos="base" departLane="best"/>
|
| 58 |
+
<flow id="flow_es_3" route="route_es" begin="300000" end="400000" vehsPerHour="400" departSp400000d="max" departPos="base" departLane="best"/>
|
| 59 |
+
<flow id="flow_wn_3" route="route_wn" begin="300000" end="400000" vehsPerHour="400" departSp400000d="max" departPos="base" departLane="best"/>
|
| 60 |
+
<flow id="flow_we_3" route="route_we" begin="300000" end="400000" vehsPerHour="200" departSp400000d="max" departPos="base" departLane="best"/>
|
| 61 |
+
<flow id="flow_ws_3" route="route_ws" begin="300000" end="400000" vehsPerHour="200" departSp400000d="max" departPos="base" departLane="best"/></routes>
|
PS2/single-intersection.net.xml
ADDED
|
@@ -0,0 +1,186 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
| 2 |
+
|
| 3 |
+
<!-- generated on sáb 26 jan 2019 20:40:10 -02 by Netedit Version 0.32.0
|
| 4 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
| 5 |
+
|
| 6 |
+
<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://sumo.dlr.de/xsd/netconvertConfiguration.xsd">
|
| 7 |
+
|
| 8 |
+
<input>
|
| 9 |
+
<sumo-net-file value="single-intersection.net.xml"/>
|
| 10 |
+
</input>
|
| 11 |
+
|
| 12 |
+
<output>
|
| 13 |
+
<output-file value="single-intersection.net.xml"/>
|
| 14 |
+
</output>
|
| 15 |
+
|
| 16 |
+
<processing>
|
| 17 |
+
<no-turnarounds value="true"/>
|
| 18 |
+
<offset.disable-normalization value="true"/>
|
| 19 |
+
<lefthand value="false"/>
|
| 20 |
+
<junctions.corner-detail value="0"/>
|
| 21 |
+
<rectangular-lane-cut value="false"/>
|
| 22 |
+
<walkingareas value="false"/>
|
| 23 |
+
</processing>
|
| 24 |
+
|
| 25 |
+
</configuration>
|
| 26 |
+
-->
|
| 27 |
+
|
| 28 |
+
<net version="0.27" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://sumo.dlr.de/xsd/net_file.xsd">
|
| 29 |
+
|
| 30 |
+
<location netOffset="150.00,150.00" convBoundary="-0.07,0.00,300.00,300.00" origBoundary="-150.00,-150.00,150.00,150.00" projParameter="!"/>
|
| 31 |
+
|
| 32 |
+
<edge id=":e_0" function="internal">
|
| 33 |
+
<lane id=":e_0_0" index="0" speed="13.90" length="4.82" shape="300.00,148.35 301.24,149.17 301.65,150.00 301.24,150.82 300.00,151.65"/>
|
| 34 |
+
</edge>
|
| 35 |
+
<edge id=":n_0" function="internal">
|
| 36 |
+
<lane id=":n_0_0" index="0" speed="13.90" length="4.82" shape="151.65,300.00 150.83,301.24 150.00,301.65 149.18,301.24 148.35,300.00"/>
|
| 37 |
+
</edge>
|
| 38 |
+
<edge id=":s_0" function="internal">
|
| 39 |
+
<lane id=":s_0_0" index="0" speed="13.90" length="4.82" shape="148.35,0.00 149.17,-1.24 150.00,-1.65 150.82,-1.24 151.65,0.00"/>
|
| 40 |
+
</edge>
|
| 41 |
+
<edge id=":t_0" function="internal">
|
| 42 |
+
<lane id=":t_0_0" index="0" speed="13.90" length="5.00" shape="145.05,158.05 144.86,156.69 144.28,155.73 143.31,155.14 141.95,154.95"/>
|
| 43 |
+
</edge>
|
| 44 |
+
<edge id=":t_1" function="internal">
|
| 45 |
+
<lane id=":t_1_0" index="0" speed="13.90" length="16.10" shape="145.05,158.05 145.05,141.95"/>
|
| 46 |
+
</edge>
|
| 47 |
+
<edge id=":t_2" function="internal">
|
| 48 |
+
<lane id=":t_2_0" index="0" speed="13.90" length="15.64" shape="148.35,158.05 148.96,153.81 150.77,150.77 153.81,148.96 158.05,148.35"/>
|
| 49 |
+
</edge>
|
| 50 |
+
<edge id=":t_3" function="internal">
|
| 51 |
+
<lane id=":t_3_0" index="0" speed="13.90" length="5.00" shape="158.05,154.95 156.69,155.14 155.72,155.72 155.14,156.69 154.95,158.05"/>
|
| 52 |
+
</edge>
|
| 53 |
+
<edge id=":t_4" function="internal">
|
| 54 |
+
<lane id=":t_4_0" index="0" speed="13.90" length="16.10" shape="158.05,154.95 141.95,154.95"/>
|
| 55 |
+
</edge>
|
| 56 |
+
<edge id=":t_5" function="internal">
|
| 57 |
+
<lane id=":t_5_0" index="0" speed="13.90" length="15.64" shape="158.05,151.65 153.81,151.04 150.77,149.23 148.96,146.19 148.35,141.95"/>
|
| 58 |
+
</edge>
|
| 59 |
+
<edge id=":t_6" function="internal">
|
| 60 |
+
<lane id=":t_6_0" index="0" speed="13.90" length="5.00" shape="154.95,141.95 155.14,143.31 155.72,144.28 156.69,144.86 158.05,145.05"/>
|
| 61 |
+
</edge>
|
| 62 |
+
<edge id=":t_7" function="internal">
|
| 63 |
+
<lane id=":t_7_0" index="0" speed="13.90" length="16.10" shape="154.95,141.95 154.95,158.05"/>
|
| 64 |
+
</edge>
|
| 65 |
+
<edge id=":t_8" function="internal">
|
| 66 |
+
<lane id=":t_8_0" index="0" speed="13.90" length="15.64" shape="151.65,141.95 151.04,146.19 149.23,149.22 146.19,151.04 141.95,151.65"/>
|
| 67 |
+
</edge>
|
| 68 |
+
<edge id=":t_9" function="internal">
|
| 69 |
+
<lane id=":t_9_0" index="0" speed="13.90" length="5.00" shape="141.95,145.05 143.31,144.86 144.28,144.28 144.86,143.31 145.05,141.95"/>
|
| 70 |
+
</edge>
|
| 71 |
+
<edge id=":t_10" function="internal">
|
| 72 |
+
<lane id=":t_10_0" index="0" speed="13.90" length="16.10" shape="141.95,145.05 158.05,145.05"/>
|
| 73 |
+
</edge>
|
| 74 |
+
<edge id=":t_11" function="internal">
|
| 75 |
+
<lane id=":t_11_0" index="0" speed="13.90" length="15.64" shape="141.95,148.35 146.19,148.96 149.23,150.77 151.04,153.81 151.65,158.05"/>
|
| 76 |
+
</edge>
|
| 77 |
+
<edge id=":w_0" function="internal">
|
| 78 |
+
<lane id=":w_0_0" index="0" speed="13.90" length="4.82" shape="-0.07,151.65 -1.29,150.80 -1.69,149.97 -1.26,149.15 0.00,148.35"/>
|
| 79 |
+
</edge>
|
| 80 |
+
|
| 81 |
+
<edge id="e_t" from="e" to="t" priority="-1">
|
| 82 |
+
<lane id="e_t_0" index="0" speed="13.90" length="141.95" shape="300.00,154.95 158.05,154.95"/>
|
| 83 |
+
<lane id="e_t_1" index="1" speed="13.90" length="141.95" shape="300.00,151.65 158.05,151.65"/>
|
| 84 |
+
</edge>
|
| 85 |
+
<edge id="n_t" from="n" to="t" priority="-1">
|
| 86 |
+
<lane id="n_t_0" index="0" speed="13.90" length="141.95" shape="145.05,300.00 145.05,158.05"/>
|
| 87 |
+
<lane id="n_t_1" index="1" speed="13.90" length="141.95" shape="148.35,300.00 148.35,158.05"/>
|
| 88 |
+
</edge>
|
| 89 |
+
<edge id="s_t" from="s" to="t" priority="-1">
|
| 90 |
+
<lane id="s_t_0" index="0" speed="13.90" length="141.95" shape="154.95,0.00 154.95,141.95"/>
|
| 91 |
+
<lane id="s_t_1" index="1" speed="13.90" length="141.95" shape="151.65,0.00 151.65,141.95"/>
|
| 92 |
+
</edge>
|
| 93 |
+
<edge id="t_e" from="t" to="e" priority="-1">
|
| 94 |
+
<lane id="t_e_0" index="0" speed="13.90" length="141.95" shape="158.05,145.05 300.00,145.05"/>
|
| 95 |
+
<lane id="t_e_1" index="1" speed="13.90" length="141.95" shape="158.05,148.35 300.00,148.35"/>
|
| 96 |
+
</edge>
|
| 97 |
+
<edge id="t_n" from="t" to="n" priority="-1">
|
| 98 |
+
<lane id="t_n_0" index="0" speed="13.90" length="141.95" shape="154.95,158.05 154.95,300.00"/>
|
| 99 |
+
<lane id="t_n_1" index="1" speed="13.90" length="141.95" shape="151.65,158.05 151.65,300.00"/>
|
| 100 |
+
</edge>
|
| 101 |
+
<edge id="t_s" from="t" to="s" priority="-1">
|
| 102 |
+
<lane id="t_s_0" index="0" speed="13.90" length="141.95" shape="145.05,141.95 145.05,0.00"/>
|
| 103 |
+
<lane id="t_s_1" index="1" speed="13.90" length="141.95" shape="148.35,141.95 148.35,0.00"/>
|
| 104 |
+
</edge>
|
| 105 |
+
<edge id="t_w" from="t" to="w" priority="-1" spreadType="center" shape="150.00,153.30 -0.07,153.30">
|
| 106 |
+
<lane id="t_w_0" index="0" speed="13.90" length="142.02" shape="141.95,154.95 -0.07,154.95"/>
|
| 107 |
+
<lane id="t_w_1" index="1" speed="13.90" length="142.02" shape="141.95,151.65 -0.07,151.65"/>
|
| 108 |
+
</edge>
|
| 109 |
+
<edge id="w_t" from="w" to="t" priority="-1">
|
| 110 |
+
<lane id="w_t_0" index="0" speed="13.90" length="141.95" shape="0.00,145.05 141.95,145.05"/>
|
| 111 |
+
<lane id="w_t_1" index="1" speed="13.90" length="141.95" shape="0.00,148.35 141.95,148.35"/>
|
| 112 |
+
</edge>
|
| 113 |
+
|
| 114 |
+
<tlLogic id="t" type="static" programID="0" offset="0">
|
| 115 |
+
<phase duration="33" state="GGrrrrGGrrrr"/>
|
| 116 |
+
<phase duration="2" state="yyrrrryyrrrr"/>
|
| 117 |
+
<phase duration="6" state="rrGrrrrrGrrr"/>
|
| 118 |
+
<phase duration="2" state="rryrrrrryrrr"/>
|
| 119 |
+
<phase duration="33" state="rrrGGrrrrGGr"/>
|
| 120 |
+
<phase duration="2" state="rrryyrrrryyr"/>
|
| 121 |
+
<phase duration="6" state="rrrrrGrrrrrG"/>
|
| 122 |
+
<phase duration="2" state="rrrrryrrrrry"/>
|
| 123 |
+
</tlLogic>
|
| 124 |
+
|
| 125 |
+
<junction id="e" type="priority" x="300.00" y="150.00" incLanes="t_e_0 t_e_1" intLanes=":e_0_0" shape="300.00,150.05 300.00,143.45 300.00,149.95">
|
| 126 |
+
<request index="0" response="0" foes="0" cont="0"/>
|
| 127 |
+
</junction>
|
| 128 |
+
<junction id="n" type="priority" x="150.00" y="300.00" incLanes="t_n_0 t_n_1" intLanes=":n_0_0" shape="149.95,300.00 156.55,300.00 150.05,300.00">
|
| 129 |
+
<request index="0" response="0" foes="0" cont="0"/>
|
| 130 |
+
</junction>
|
| 131 |
+
<junction id="s" type="priority" x="150.00" y="0.00" incLanes="t_s_0 t_s_1" intLanes=":s_0_0" shape="150.05,0.00 143.45,0.00 149.95,0.00">
|
| 132 |
+
<request index="0" response="0" foes="0" cont="0"/>
|
| 133 |
+
</junction>
|
| 134 |
+
<junction id="t" type="traffic_light" x="150.00" y="150.00" incLanes="n_t_0 n_t_1 e_t_0 e_t_1 s_t_0 s_t_1 w_t_0 w_t_1" intLanes=":t_0_0 :t_1_0 :t_2_0 :t_3_0 :t_4_0 :t_5_0 :t_6_0 :t_7_0 :t_8_0 :t_9_0 :t_10_0 :t_11_0" shape="143.45,158.05 156.55,158.05 158.05,156.55 158.05,143.45 156.55,141.95 143.45,141.95 141.95,143.45 141.95,156.55">
|
| 135 |
+
<request index="0" response="000000000000" foes="000100010000" cont="0"/>
|
| 136 |
+
<request index="1" response="000000000000" foes="111100110000" cont="0"/>
|
| 137 |
+
<request index="2" response="000011000000" foes="110011110000" cont="0"/>
|
| 138 |
+
<request index="3" response="000010000000" foes="100010000000" cont="0"/>
|
| 139 |
+
<request index="4" response="000110000111" foes="100110000111" cont="0"/>
|
| 140 |
+
<request index="5" response="011110000110" foes="011110000110" cont="0"/>
|
| 141 |
+
<request index="6" response="000000000000" foes="010000000100" cont="0"/>
|
| 142 |
+
<request index="7" response="000000000000" foes="110000111100" cont="0"/>
|
| 143 |
+
<request index="8" response="000000000011" foes="110000110011" cont="0"/>
|
| 144 |
+
<request index="9" response="000000000010" foes="000000100010" cont="0"/>
|
| 145 |
+
<request index="10" response="000111000110" foes="000111100110" cont="0"/>
|
| 146 |
+
<request index="11" response="000110011110" foes="000110011110" cont="0"/>
|
| 147 |
+
</junction>
|
| 148 |
+
<junction id="w" type="priority" x="0.00" y="150.00" incLanes="t_w_0 t_w_1" intLanes=":w_0_0" shape="0.00,149.95 0.00,156.55 0.00,150.05">
|
| 149 |
+
<request index="0" response="0" foes="0" cont="0"/>
|
| 150 |
+
</junction>
|
| 151 |
+
|
| 152 |
+
<connection from="e_t" to="t_n" fromLane="0" toLane="0" via=":t_3_0" tl="t" linkIndex="3" dir="r" state="o"/>
|
| 153 |
+
<connection from="e_t" to="t_w" fromLane="0" toLane="0" via=":t_4_0" tl="t" linkIndex="4" dir="s" state="o"/>
|
| 154 |
+
<connection from="e_t" to="t_s" fromLane="1" toLane="1" via=":t_5_0" tl="t" linkIndex="5" dir="l" state="o"/>
|
| 155 |
+
<connection from="n_t" to="t_w" fromLane="0" toLane="0" via=":t_0_0" tl="t" linkIndex="0" dir="r" state="o"/>
|
| 156 |
+
<connection from="n_t" to="t_s" fromLane="0" toLane="0" via=":t_1_0" tl="t" linkIndex="1" dir="s" state="o"/>
|
| 157 |
+
<connection from="n_t" to="t_e" fromLane="1" toLane="1" via=":t_2_0" tl="t" linkIndex="2" dir="l" state="o"/>
|
| 158 |
+
<connection from="s_t" to="t_e" fromLane="0" toLane="0" via=":t_6_0" tl="t" linkIndex="6" dir="r" state="o"/>
|
| 159 |
+
<connection from="s_t" to="t_n" fromLane="0" toLane="0" via=":t_7_0" tl="t" linkIndex="7" dir="s" state="o"/>
|
| 160 |
+
<connection from="s_t" to="t_w" fromLane="1" toLane="1" via=":t_8_0" tl="t" linkIndex="8" dir="l" state="o"/>
|
| 161 |
+
<connection from="t_e" to="e_t" fromLane="1" toLane="1" via=":e_0_0" dir="t" state="M"/>
|
| 162 |
+
<connection from="t_n" to="n_t" fromLane="1" toLane="1" via=":n_0_0" dir="t" state="M"/>
|
| 163 |
+
<connection from="t_s" to="s_t" fromLane="1" toLane="1" via=":s_0_0" dir="t" state="M"/>
|
| 164 |
+
<connection from="t_w" to="w_t" fromLane="1" toLane="1" via=":w_0_0" dir="t" state="M"/>
|
| 165 |
+
<connection from="w_t" to="t_s" fromLane="0" toLane="0" via=":t_9_0" tl="t" linkIndex="9" dir="r" state="o"/>
|
| 166 |
+
<connection from="w_t" to="t_e" fromLane="0" toLane="0" via=":t_10_0" tl="t" linkIndex="10" dir="s" state="o"/>
|
| 167 |
+
<connection from="w_t" to="t_n" fromLane="1" toLane="1" via=":t_11_0" tl="t" linkIndex="11" dir="l" state="o"/>
|
| 168 |
+
|
| 169 |
+
<connection from=":e_0" to="e_t" fromLane="0" toLane="1" dir="t" state="M"/>
|
| 170 |
+
<connection from=":n_0" to="n_t" fromLane="0" toLane="1" dir="t" state="M"/>
|
| 171 |
+
<connection from=":s_0" to="s_t" fromLane="0" toLane="1" dir="t" state="M"/>
|
| 172 |
+
<connection from=":t_0" to="t_w" fromLane="0" toLane="0" dir="r" state="M"/>
|
| 173 |
+
<connection from=":t_1" to="t_s" fromLane="0" toLane="0" dir="s" state="M"/>
|
| 174 |
+
<connection from=":t_2" to="t_e" fromLane="0" toLane="1" dir="l" state="M"/>
|
| 175 |
+
<connection from=":t_3" to="t_n" fromLane="0" toLane="0" dir="r" state="M"/>
|
| 176 |
+
<connection from=":t_4" to="t_w" fromLane="0" toLane="0" dir="s" state="M"/>
|
| 177 |
+
<connection from=":t_5" to="t_s" fromLane="0" toLane="1" dir="l" state="M"/>
|
| 178 |
+
<connection from=":t_6" to="t_e" fromLane="0" toLane="0" dir="r" state="M"/>
|
| 179 |
+
<connection from=":t_7" to="t_n" fromLane="0" toLane="0" dir="s" state="M"/>
|
| 180 |
+
<connection from=":t_8" to="t_w" fromLane="0" toLane="1" dir="l" state="M"/>
|
| 181 |
+
<connection from=":t_9" to="t_s" fromLane="0" toLane="0" dir="r" state="M"/>
|
| 182 |
+
<connection from=":t_10" to="t_e" fromLane="0" toLane="0" dir="s" state="M"/>
|
| 183 |
+
<connection from=":t_11" to="t_n" fromLane="0" toLane="1" dir="l" state="M"/>
|
| 184 |
+
<connection from=":w_0" to="w_t" fromLane="0" toLane="1" dir="t" state="M"/>
|
| 185 |
+
|
| 186 |
+
</net>
|
PS3/best.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b5b6ab79f1ff5b0e28a2715ac0bee9eb93c13aaa5214a2bfde2ab617c70a74e8
|
| 3 |
+
size 6780515
|
PS3/yolov8n.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:7eb70257593da06f682a3ddda54a9d260d4fc514f645237f5ca74b08f8da61a6
|
| 3 |
+
size 2
|
app.py
ADDED
|
@@ -0,0 +1,419 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from ultralytics import YOLO
|
| 2 |
+
import base64
|
| 3 |
+
import cv2
|
| 4 |
+
import io
|
| 5 |
+
import numpy as np
|
| 6 |
+
from ultralytics.utils.plotting import Annotator
|
| 7 |
+
import streamlit as st
|
| 8 |
+
from streamlit_image_coordinates import streamlit_image_coordinates
|
| 9 |
+
import pandas as pd
|
| 10 |
+
import ollama
|
| 11 |
+
import bs4
|
| 12 |
+
from langchain.text_splitter import RecursiveCharacterTextSplitter
|
| 13 |
+
from langchain_community.document_loaders import WebBaseLoader
|
| 14 |
+
from langchain_community.document_loaders import CSVLoader
|
| 15 |
+
from langchain_community.vectorstores import Chroma
|
| 16 |
+
from langchain_community.embeddings import OllamaEmbeddings
|
| 17 |
+
from langchain_core.output_parsers import StrOutputParser
|
| 18 |
+
from langchain_core.runnables import RunnablePassthrough
|
| 19 |
+
|
| 20 |
+
def set_background(image_file1,image_file2):
|
| 21 |
+
|
| 22 |
+
with open(image_file1, "rb") as f:
|
| 23 |
+
img_data1 = f.read()
|
| 24 |
+
b64_encoded1 = base64.b64encode(img_data1).decode()
|
| 25 |
+
with open(image_file2, "rb") as f:
|
| 26 |
+
img_data2 = f.read()
|
| 27 |
+
b64_encoded2 = base64.b64encode(img_data2).decode()
|
| 28 |
+
style = f"""
|
| 29 |
+
<style>
|
| 30 |
+
.stApp{{
|
| 31 |
+
background-image: url(data:image/png;base64,{b64_encoded1});
|
| 32 |
+
background-size: cover;
|
| 33 |
+
|
| 34 |
+
}}
|
| 35 |
+
.st-emotion-cache-6qob1r{{
|
| 36 |
+
background-image: url(data:image/png;base64,{b64_encoded2});
|
| 37 |
+
background-size: cover;
|
| 38 |
+
border: 5px solid rgb(14, 17, 23);
|
| 39 |
+
|
| 40 |
+
}}
|
| 41 |
+
</style>
|
| 42 |
+
"""
|
| 43 |
+
st.markdown(style, unsafe_allow_html=True)
|
| 44 |
+
|
| 45 |
+
set_background('pngtree-city-map-navigation-interface-picture-image_1833642.png','2024-05-18_14-57-09_5235.png')
|
| 46 |
+
|
| 47 |
+
st.title("Traffic Flow and Optimization Toolkit")
|
| 48 |
+
|
| 49 |
+
sb = st.sidebar # defining the sidebar
|
| 50 |
+
|
| 51 |
+
sb.markdown("🛰️ **Navigation**")
|
| 52 |
+
page_names = ["PS1", "PS2", "PS3","Chat with Results"]
|
| 53 |
+
page = sb.radio("", page_names, index=0)
|
| 54 |
+
st.session_state['n'] = sb.slider("Number of ROIs",1,5)
|
| 55 |
+
|
| 56 |
+
if page == 'PS1':
|
| 57 |
+
uploaded_file = st.file_uploader("Choose a video...", type=["mp4", "mpeg"])
|
| 58 |
+
if uploaded_file is not None:
|
| 59 |
+
g = io.BytesIO(uploaded_file.read())
|
| 60 |
+
temporary_location = "temp_PS1.mp4"
|
| 61 |
+
|
| 62 |
+
with open(temporary_location, 'wb') as out:
|
| 63 |
+
out.write(g.read())
|
| 64 |
+
out.close()
|
| 65 |
+
model = YOLO('PS1\yolov8n.pt')
|
| 66 |
+
if 'roi_list1' not in st.session_state:
|
| 67 |
+
st.session_state['roi_list1'] = []
|
| 68 |
+
if "all_rois1" not in st.session_state:
|
| 69 |
+
st.session_state['all_rois1'] = []
|
| 70 |
+
classes = model.names
|
| 71 |
+
|
| 72 |
+
done_1 = st.button('Selection Done')
|
| 73 |
+
|
| 74 |
+
while len(st.session_state["all_rois1"]) < st.session_state['n']:
|
| 75 |
+
cap = cv2.VideoCapture('temp_PS1.mp4')
|
| 76 |
+
while not done_1:
|
| 77 |
+
ret,frame=cap.read()
|
| 78 |
+
cv2.putText(frame,'SELECT ROI',(100,100),cv2.FONT_HERSHEY_SIMPLEX, 1,(0,0,255),4)
|
| 79 |
+
if not ret:
|
| 80 |
+
st.write('ROI selection has concluded')
|
| 81 |
+
break
|
| 82 |
+
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
|
| 83 |
+
value = streamlit_image_coordinates(frame,key='numpy',width=750)
|
| 84 |
+
st.session_state["roi_list1"].append([int(value['x']*2.55),int(value['y']*2.55)])
|
| 85 |
+
st.write(st.session_state["roi_list1"])
|
| 86 |
+
if cv2.waitKey(0)&0xFF==27:
|
| 87 |
+
break
|
| 88 |
+
cap.release()
|
| 89 |
+
st.session_state["all_rois1"].append(st.session_state["roi_list1"])
|
| 90 |
+
st.session_state["roi_list1"] = []
|
| 91 |
+
done_1 = False
|
| 92 |
+
|
| 93 |
+
st.write('ROI indices: ',st.session_state["all_rois1"][0])
|
| 94 |
+
|
| 95 |
+
|
| 96 |
+
|
| 97 |
+
cap = cv2.VideoCapture('temp_PS1.MP4')
|
| 98 |
+
st.write("Detection started")
|
| 99 |
+
st.session_state['fps'] = cap.get(cv2.CAP_PROP_FPS)
|
| 100 |
+
st.write(f"FPS OF VIDEO: {st.session_state['fps']}")
|
| 101 |
+
avg_list = []
|
| 102 |
+
count = 0
|
| 103 |
+
frame_placeholder = st.empty()
|
| 104 |
+
st.session_state["data1"] = {}
|
| 105 |
+
for i in range(len(st.session_state["all_rois1"])):
|
| 106 |
+
st.session_state["data1"][f"ROI{i}"] = []
|
| 107 |
+
while cap.isOpened():
|
| 108 |
+
ret,frame=cap.read()
|
| 109 |
+
if not ret:
|
| 110 |
+
break
|
| 111 |
+
count += 1
|
| 112 |
+
if count % 3 != 0:
|
| 113 |
+
continue
|
| 114 |
+
k = 0
|
| 115 |
+
for roi_list_here1 in st.session_state["all_rois1"]:
|
| 116 |
+
max = [0,0]
|
| 117 |
+
min = [10000,10000]
|
| 118 |
+
roi_list_here = roi_list_here1[1:]
|
| 119 |
+
for i in range(len(roi_list_here)):
|
| 120 |
+
if roi_list_here[i][0] > max[0]:
|
| 121 |
+
max[0] = roi_list_here[i][0]
|
| 122 |
+
if roi_list_here[i][1] > max[1]:
|
| 123 |
+
max[1] = roi_list_here[i][1]
|
| 124 |
+
if roi_list_here[i][0] < min[0]:
|
| 125 |
+
min[0] = roi_list_here[i][0]
|
| 126 |
+
if roi_list_here[i][1] < min[1]:
|
| 127 |
+
min[1] = roi_list_here[i][1]
|
| 128 |
+
frame_cropped = frame[min[1]:max[1],min[0]:max[0]]
|
| 129 |
+
roi_corners = np.array([roi_list_here],dtype=np.int32)
|
| 130 |
+
mask = np.zeros(frame.shape,dtype=np.uint8)
|
| 131 |
+
mask.fill(255)
|
| 132 |
+
channel_count = frame.shape[2]
|
| 133 |
+
ignore_mask_color = (255,)*channel_count
|
| 134 |
+
cv2.fillPoly(mask,roi_corners,0)
|
| 135 |
+
mask_cropped = mask[min[1]:max[1],min[0]:max[0]]
|
| 136 |
+
roi = cv2.bitwise_or(frame_cropped,mask_cropped)
|
| 137 |
+
|
| 138 |
+
#roi = frame[roi_list_here[0][1]:roi_list_here[1][1],roi_list_here[0][0]:roi_list_here[1][0]]
|
| 139 |
+
number = []
|
| 140 |
+
results = model.predict(roi)
|
| 141 |
+
for r in results:
|
| 142 |
+
boxes = r.boxes
|
| 143 |
+
counter = 0
|
| 144 |
+
for box in boxes:
|
| 145 |
+
counter += 1
|
| 146 |
+
name = classes[box.cls.numpy()[0]]
|
| 147 |
+
conf = str(round(box.conf.numpy()[0],2))
|
| 148 |
+
text = name+""+conf
|
| 149 |
+
bbox = box.xyxy[0].numpy()
|
| 150 |
+
cv2.rectangle(frame,(int(bbox[0])+min[0],int(bbox[1])+min[1]),(int(bbox[2])+min[0],int(bbox[3])+min[1]),(0,255,0),2)
|
| 151 |
+
cv2.putText(frame,text,(int(bbox[0])+min[0],int(bbox[1])+min[1]-5),cv2.FONT_HERSHEY_SIMPLEX, 1,(0,0,255),2)
|
| 152 |
+
number.append(counter)
|
| 153 |
+
avg = sum(number)/len(number)
|
| 154 |
+
stats = str(round(avg,2))
|
| 155 |
+
if count%10 == 0:
|
| 156 |
+
st.session_state["data1"][f"ROI{k}"].append(avg)
|
| 157 |
+
k+=1
|
| 158 |
+
cv2.putText(frame,stats,(min[0],min[1]),cv2.FONT_HERSHEY_SIMPLEX, 1,(0,0,0),4)
|
| 159 |
+
cv2.polylines(frame,roi_corners,True,(255,0,0),2)
|
| 160 |
+
cv2.putText(frame,'The average number of vehicles in the Regions of Interest',(100,100),cv2.FONT_HERSHEY_SIMPLEX, 1,(0,0,255),4)
|
| 161 |
+
frame_placeholder.image(frame,channels='BGR')
|
| 162 |
+
cap.release()
|
| 163 |
+
df = pd.DataFrame(st.session_state["data1"])
|
| 164 |
+
df.to_csv('PS1.csv', sep='\t', encoding='utf-8')
|
| 165 |
+
else:
|
| 166 |
+
st.error('PLEASE UPLOAD AN IMAGE OF THE FORMAT JPG,JPEG OR PNG', icon="🚨")
|
| 167 |
+
|
| 168 |
+
elif page == "PS3":
|
| 169 |
+
uploaded_file1 = st.file_uploader("Choose a video...", type=["mp4", "mpeg"])
|
| 170 |
+
if uploaded_file1 is not None:
|
| 171 |
+
g = io.BytesIO(uploaded_file1.read())
|
| 172 |
+
temporary_location = "temp_PS2.mp4"
|
| 173 |
+
|
| 174 |
+
with open(temporary_location, 'wb') as out:
|
| 175 |
+
out.write(g.read())
|
| 176 |
+
out.close()
|
| 177 |
+
model1 = YOLO("PS1\yolov8n.pt")
|
| 178 |
+
model2 = YOLO(r"PS3\best.pt")
|
| 179 |
+
if 'roi_list2' not in st.session_state:
|
| 180 |
+
st.session_state['roi_list2'] = []
|
| 181 |
+
if "all_rois2" not in st.session_state:
|
| 182 |
+
st.session_state['all_rois2'] = []
|
| 183 |
+
classes = model1.names
|
| 184 |
+
|
| 185 |
+
done_2 = st.button('Selection Done')
|
| 186 |
+
|
| 187 |
+
while len(st.session_state["all_rois2"]) < st.session_state['n']:
|
| 188 |
+
cap = cv2.VideoCapture('temp_PS2.mp4')
|
| 189 |
+
while not done_2:
|
| 190 |
+
ret,frame=cap.read()
|
| 191 |
+
cv2.putText(frame,'SELECT ROI',(100,100),cv2.FONT_HERSHEY_SIMPLEX, 1,(0,0,255),4)
|
| 192 |
+
if not ret:
|
| 193 |
+
st.write('ROI selection has concluded')
|
| 194 |
+
break
|
| 195 |
+
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
|
| 196 |
+
value = streamlit_image_coordinates(frame,key='numpy',width=750)
|
| 197 |
+
st.session_state["roi_list2"].append([int(value['x']*2.5),int(value['y']*2.5)])
|
| 198 |
+
st.write(st.session_state["roi_list2"])
|
| 199 |
+
if cv2.waitKey(0)&0xFF==27:
|
| 200 |
+
break
|
| 201 |
+
cap.release()
|
| 202 |
+
st.session_state["all_rois2"].append(st.session_state["roi_list2"])
|
| 203 |
+
st.session_state["roi_list2"] = []
|
| 204 |
+
done_2 = False
|
| 205 |
+
|
| 206 |
+
st.write('ROI indices: ',st.session_state["all_rois2"][0])
|
| 207 |
+
|
| 208 |
+
|
| 209 |
+
|
| 210 |
+
cap = cv2.VideoCapture('temp_PS2.MP4')
|
| 211 |
+
st.write("Detection started")
|
| 212 |
+
avg_list = []
|
| 213 |
+
count = 0
|
| 214 |
+
frame_placeholder = st.empty()
|
| 215 |
+
st.session_state.data = {}
|
| 216 |
+
for i in range(len(st.session_state["all_rois2"])):
|
| 217 |
+
st.session_state["data"][f"ROI{i}"] = []
|
| 218 |
+
for i in range(len(st.session_state['all_rois2'])):
|
| 219 |
+
st.session_state.data[f"ROI{i}"] = []
|
| 220 |
+
while cap.isOpened():
|
| 221 |
+
ret,frame=cap.read()
|
| 222 |
+
if not ret:
|
| 223 |
+
break
|
| 224 |
+
count += 1
|
| 225 |
+
if count % 3 != 0:
|
| 226 |
+
continue
|
| 227 |
+
# rois = []
|
| 228 |
+
k = 0
|
| 229 |
+
for roi_list_here1 in st.session_state["all_rois2"]:
|
| 230 |
+
max = [0,0]
|
| 231 |
+
min = [10000,10000]
|
| 232 |
+
roi_list_here = roi_list_here1[1:]
|
| 233 |
+
for i in range(len(roi_list_here)-1):
|
| 234 |
+
if roi_list_here[i][0] > max[0]:
|
| 235 |
+
max[0] = roi_list_here[i][0]
|
| 236 |
+
if roi_list_here[i][1] > max[1]:
|
| 237 |
+
max[1] = roi_list_here[i][1]
|
| 238 |
+
if roi_list_here[i][0] < min[0]:
|
| 239 |
+
min[0] = roi_list_here[i][0]
|
| 240 |
+
if roi_list_here[i][1] < min[1]:
|
| 241 |
+
min[1] = roi_list_here[i][1]
|
| 242 |
+
frame_cropped = frame[min[1]:max[1],min[0]:max[0]]
|
| 243 |
+
roi_corners = np.array([roi_list_here],dtype=np.int32)
|
| 244 |
+
mask = np.zeros(frame.shape,dtype=np.uint8)
|
| 245 |
+
mask.fill(255)
|
| 246 |
+
channel_count = frame.shape[2]
|
| 247 |
+
ignore_mask_color = (255,)*channel_count
|
| 248 |
+
cv2.fillPoly(mask,roi_corners,0)
|
| 249 |
+
mask_cropped = mask[min[1]:max[1],min[0]:max[0]]
|
| 250 |
+
roi = cv2.bitwise_or(frame_cropped,mask_cropped)
|
| 251 |
+
|
| 252 |
+
#roi = frame[roi_list_here[0][1]:roi_list_here[1][1],roi_list_here[0][0]:roi_list_here[1][0]]
|
| 253 |
+
number = []
|
| 254 |
+
results = model1.predict(roi)
|
| 255 |
+
results_pothole = model2.predict(source=frame)
|
| 256 |
+
for r in results:
|
| 257 |
+
boxes = r.boxes
|
| 258 |
+
counter = 0
|
| 259 |
+
for box in boxes:
|
| 260 |
+
counter += 1
|
| 261 |
+
name = classes[box.cls.numpy()[0]]
|
| 262 |
+
conf = str(round(box.conf.numpy()[0],2))
|
| 263 |
+
text = name+conf
|
| 264 |
+
bbox = box.xyxy[0].numpy()
|
| 265 |
+
cv2.rectangle(frame,(int(bbox[0])+min[0],int(bbox[1])+min[1]),(int(bbox[2])+min[0],int(bbox[3])+min[1]),(0,255,0),2)
|
| 266 |
+
cv2.putText(frame,text,(int(bbox[0])+min[0],int(bbox[1])+min[1]-5),cv2.FONT_HERSHEY_SIMPLEX, 0.4,(0,0,255),2)
|
| 267 |
+
number.append(counter)
|
| 268 |
+
for r in results_pothole:
|
| 269 |
+
masks = r.masks
|
| 270 |
+
boxes = r.boxes.cpu().numpy()
|
| 271 |
+
xyxys = boxes.xyxy
|
| 272 |
+
confs = boxes.conf
|
| 273 |
+
if masks is not None:
|
| 274 |
+
shapes = np.ones_like(frame)
|
| 275 |
+
for mask,conf,xyxy in zip(masks,confs,xyxys):
|
| 276 |
+
polygon = mask.xy[0]
|
| 277 |
+
if conf >= 0.49 and len(polygon)>=3:
|
| 278 |
+
cv2.fillPoly(shapes,pts=np.int32([polygon]),color=(0,0,255,0.5))
|
| 279 |
+
frame = cv2.addWeighted(frame,0.7,shapes,0.3,gamma=0)
|
| 280 |
+
cv2.rectangle(frame,(int(xyxy[0]),int(xyxy[1])),(int(xyxy[2]),int(xyxy[3])),(0,0,255),2)
|
| 281 |
+
cv2.putText(frame,'Pothole '+str(conf),(int(xyxy[0]),int(xyxy[1])-5),cv2.FONT_HERSHEY_SIMPLEX, 1,(0,0,255),2)
|
| 282 |
+
|
| 283 |
+
avg = sum(number)/len(number)
|
| 284 |
+
stats = str(round(avg,2))
|
| 285 |
+
if count % 10 == 0:
|
| 286 |
+
st.session_state.data[f"ROI{k}"].append(avg)
|
| 287 |
+
k+=1
|
| 288 |
+
cv2.putText(frame,stats,(min[0],min[1]),cv2.FONT_HERSHEY_SIMPLEX, 1,(0,0,0),4)
|
| 289 |
+
cv2.polylines(frame,roi_corners,True,(255,0,0),2)
|
| 290 |
+
if counter >= 5:
|
| 291 |
+
cv2.putText(frame,'!!CONGESTION MORE THAN '+str(counter)+' Objects',(min[0]+20,min[1]+20),cv2.FONT_HERSHEY_SIMPLEX, 1,(0,0,0),4)
|
| 292 |
+
cv2.polylines(frame,roi_corners,True,(255,0,0),2)
|
| 293 |
+
cv2.putText(frame,'Objects in the Regions of Interest',(100,100),cv2.FONT_HERSHEY_SIMPLEX, 1,(0,0,255),4)
|
| 294 |
+
frame_placeholder.image(frame,channels='BGR')
|
| 295 |
+
cap.release()
|
| 296 |
+
|
| 297 |
+
df = pd.DataFrame(st.session_state.data)
|
| 298 |
+
df.to_csv('PS2.csv', sep='\t', encoding='utf-8')
|
| 299 |
+
|
| 300 |
+
else:
|
| 301 |
+
st.error('PLEASE UPLOAD AN IMAGE OF THE FORMAT JPG,JPEG OR PNG', icon="🚨")
|
| 302 |
+
|
| 303 |
+
elif page == "PS2":
|
| 304 |
+
st.header("CLICK ON RUN SCRIPT TO START A TRAFFIC SIMULATION")
|
| 305 |
+
script = st.button("RUN SCRIPT")
|
| 306 |
+
st.session_state.con = -1
|
| 307 |
+
if script:
|
| 308 |
+
st.session_state.con += 1
|
| 309 |
+
import gymnasium as gym
|
| 310 |
+
import sumo_rl
|
| 311 |
+
import os
|
| 312 |
+
from stable_baselines3 import DQN
|
| 313 |
+
from stable_baselines3.common.vec_env import DummyVecEnv
|
| 314 |
+
from stable_baselines3.common.evaluation import evaluate_policy
|
| 315 |
+
from sumo_rl import SumoEnvironment
|
| 316 |
+
env = gym.make('sumo-rl-v0',
|
| 317 |
+
net_file='PS2\single-intersection.net.xml',
|
| 318 |
+
route_file='PS2\single-intersection-gen.rou.xml',
|
| 319 |
+
out_csv_name='output',
|
| 320 |
+
use_gui=True,
|
| 321 |
+
single_agent=True,
|
| 322 |
+
num_seconds=10000)
|
| 323 |
+
model1 = DQN.load('PS2\DQN_MODELS\DQN_MODEL3.zip',env=env)
|
| 324 |
+
one,two = evaluate_policy(model1,env = env,n_eval_episodes=5,render=True)
|
| 325 |
+
st.write("Evaluation Results: ",one,two)
|
| 326 |
+
import matplotlib.pyplot as plt
|
| 327 |
+
def eval_plot(path,metric,path_compare = None):
|
| 328 |
+
data = pd.read_csv(path)
|
| 329 |
+
if path_compare is not None:
|
| 330 |
+
data1 = pd.read_csv(path_compare)
|
| 331 |
+
x = []
|
| 332 |
+
for i in range(0,len(data)):
|
| 333 |
+
x.append(i)
|
| 334 |
+
|
| 335 |
+
y = data[metric]
|
| 336 |
+
y_1 = pd.to_numeric(y)
|
| 337 |
+
y_arr = np.array(y_1)
|
| 338 |
+
if path_compare is not None:
|
| 339 |
+
y2 = data1[metric]
|
| 340 |
+
y_2 = pd.to_numeric(y2)
|
| 341 |
+
y_arr2 = np.array(y_2)
|
| 342 |
+
|
| 343 |
+
x_arr = np.array(x)
|
| 344 |
+
|
| 345 |
+
fig = plt.figure()
|
| 346 |
+
ax1 = fig.add_subplot(2, 1, 1)
|
| 347 |
+
ax1.set_title(metric)
|
| 348 |
+
if path_compare is not None:
|
| 349 |
+
ax2 = fig.add_subplot(2, 1, 2,sharey=ax1)
|
| 350 |
+
ax2.set_title('compare '+metric)
|
| 351 |
+
|
| 352 |
+
ax1.plot(x_arr,y_arr)
|
| 353 |
+
|
| 354 |
+
if path_compare is not None:
|
| 355 |
+
ax2.plot(x_arr,y_arr2)
|
| 356 |
+
|
| 357 |
+
return fig
|
| 358 |
+
for i in range(1,2):
|
| 359 |
+
st.pyplot(eval_plot(f'output_conn{st.session_state.con}_ep{i}.csv','system_mean_waiting_time'))
|
| 360 |
+
st.pyplot(eval_plot(f'output_conn{st.session_state.con}_ep{i}.csv','agents_total_accumulated_waiting_time'))
|
| 361 |
+
|
| 362 |
+
elif page == "Chat with Results":
|
| 363 |
+
st.title('Chat with the Results')
|
| 364 |
+
st.write("Please upload the relevant CSV data to get started")
|
| 365 |
+
reload = st.button('Reload')
|
| 366 |
+
if 'isran' not in st.session_state or reload == True:
|
| 367 |
+
st.session_state['isran'] = False
|
| 368 |
+
|
| 369 |
+
|
| 370 |
+
uploaded_file = st.file_uploader('Choose your .csv file', type=["csv"])
|
| 371 |
+
if uploaded_file is not None and st.session_state['isran'] == False:
|
| 372 |
+
with open("temp.csv", "wb") as f:
|
| 373 |
+
f.write(uploaded_file.getvalue())
|
| 374 |
+
loader = CSVLoader('temp.csv')
|
| 375 |
+
docs = loader.load()
|
| 376 |
+
text_splitter = RecursiveCharacterTextSplitter(chunk_size = 1000, chunk_overlap = 200)
|
| 377 |
+
splits = text_splitter.split_documents(docs)
|
| 378 |
+
|
| 379 |
+
embeddings = OllamaEmbeddings(model='mistral')
|
| 380 |
+
st.session_state.vectorstore = Chroma.from_documents(documents=splits,embedding=embeddings)
|
| 381 |
+
st.session_state['isran'] = True
|
| 382 |
+
|
| 383 |
+
if st.session_state['isran'] == True:
|
| 384 |
+
st.write("Embedding created")
|
| 385 |
+
|
| 386 |
+
def fdocs(docs):
|
| 387 |
+
return "\n\n".join(doc.page_content for doc in docs)
|
| 388 |
+
|
| 389 |
+
def llm(question,context):
|
| 390 |
+
formatted_prompt = f"Question: {question}\n\nContext:{context}"
|
| 391 |
+
response = ollama.chat(model='mistral', messages=[
|
| 392 |
+
{
|
| 393 |
+
'role': 'user',
|
| 394 |
+
'content': formatted_prompt
|
| 395 |
+
},
|
| 396 |
+
])
|
| 397 |
+
return response['message']['content']
|
| 398 |
+
|
| 399 |
+
|
| 400 |
+
|
| 401 |
+
def rag_chain(question):
|
| 402 |
+
retriever = st.session_state.vectorstore.as_retriever()
|
| 403 |
+
retrieved_docs = retriever.invoke(question)
|
| 404 |
+
formatted_context = fdocs(retrieved_docs)
|
| 405 |
+
return llm(question,formatted_context)
|
| 406 |
+
|
| 407 |
+
if 'messages' not in st.session_state:
|
| 408 |
+
st.session_state.messages = []
|
| 409 |
+
|
| 410 |
+
for message in st.session_state.messages:
|
| 411 |
+
st.chat_message(message['role']).markdown(message['content'])
|
| 412 |
+
|
| 413 |
+
prompt = st.chat_input("Say something")
|
| 414 |
+
response = rag_chain(prompt)
|
| 415 |
+
if prompt:
|
| 416 |
+
st.chat_message('user').markdown(prompt)
|
| 417 |
+
st.session_state.messages.append({'role':'user','content':prompt})
|
| 418 |
+
st.session_state.messages.append({'role':'AI','content':response})
|
| 419 |
+
st.chat_message('AI').markdown(response)
|
pngtree-city-map-navigation-interface-picture-image_1833642.png
ADDED
|
requirements.txt
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
beautifulsoup4==4.12.3
|
| 2 |
+
langchain==0.2.0
|
| 3 |
+
langchain_community==0.2.0
|
| 4 |
+
langchain_core==0.2.0
|
| 5 |
+
numpy==1.26.4
|
| 6 |
+
ollama==0.2.0
|
| 7 |
+
opencv_python==4.9.0.80
|
| 8 |
+
pandas==2.2.2
|
| 9 |
+
streamlit==1.33.0
|
| 10 |
+
streamlit_image_coordinates==0.1.6
|
| 11 |
+
ultralytics==8.1.46
|
| 12 |
+
chromadb
|