Update app.py
Browse files
app.py
CHANGED
|
@@ -20,78 +20,231 @@ client = OpenAI(
|
|
| 20 |
) if XAI_API_KEY else None
|
| 21 |
|
| 22 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
PATHOLOGY_CATALOG = {
|
| 24 |
-
"
|
| 25 |
-
"name": "Longitudinal
|
| 26 |
"severity": "Medium",
|
| 27 |
"priority": "P2",
|
| 28 |
"deadline": "Medium term: 1–3 months",
|
| 29 |
"risk": "Water infiltration and progressive structural degradation.",
|
| 30 |
-
"recommendation": "Seal cracks with modified bituminous mastic. If opening exceeds 5 mm, mill and replace the wearing course."
|
| 31 |
},
|
| 32 |
-
"
|
| 33 |
-
"name": "Transverse
|
| 34 |
"severity": "Medium",
|
| 35 |
"priority": "P2",
|
| 36 |
"deadline": "Medium term: 1–3 months",
|
| 37 |
"risk": "Water infiltration, frost damage, vibration, and risk to motorcycles.",
|
| 38 |
-
"recommendation": "Seal with SBS-modified mastic. For recurring cracks, investigate
|
| 39 |
},
|
| 40 |
-
"
|
| 41 |
-
"name": "
|
| 42 |
"severity": "High",
|
| 43 |
"priority": "P1/P2",
|
| 44 |
"deadline": "Immediate or short term",
|
| 45 |
-
"risk": "
|
| 46 |
-
"recommendation": "Mill affected layers and reconstruct pavement structure.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
},
|
| 48 |
-
"
|
| 49 |
"name": "Potholes",
|
| 50 |
"severity": "High",
|
| 51 |
"priority": "P1",
|
| 52 |
"deadline": "Immediate: within 24–48 hours",
|
| 53 |
"risk": "Direct accident risk, especially for motorcycles and bicycles; vehicle tire and suspension damage.",
|
| 54 |
-
"recommendation": "Immediate patching with hot
|
| 55 |
},
|
| 56 |
-
"
|
| 57 |
-
"name": "Permanent
|
| 58 |
"severity": "Medium–High",
|
| 59 |
"priority": "P1/P2",
|
| 60 |
"deadline": "Short term if rut depth exceeds 15–20 mm",
|
| 61 |
-
"risk": "Aquaplaning, vehicle instability, and lower-layer degradation.",
|
| 62 |
"recommendation": "Mill affected area and replace with high-stability asphalt mix such as SMA or BBTM."
|
| 63 |
},
|
| 64 |
-
"
|
| 65 |
-
"name": "
|
| 66 |
"severity": "Medium",
|
| 67 |
"priority": "P2/P3",
|
| 68 |
"deadline": "Medium term: 1–3 months",
|
| 69 |
-
"risk": "
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 70 |
"recommendation": "Apply slurry seal, microsurfacing, or mill and resurface if advanced."
|
| 71 |
},
|
| 72 |
-
"
|
| 73 |
-
"name": "
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
"severity": "Medium; High on curves/intersections",
|
| 75 |
"priority": "P1/P3",
|
| 76 |
"deadline": "Short term; immediate on sharp curves",
|
| 77 |
-
"risk": "Loss of skid resistance and
|
| 78 |
"recommendation": "Apply cover aggregate and compact lightly. In severe cases, micro-mill and replace surface layer."
|
| 79 |
},
|
| 80 |
-
"
|
| 81 |
-
"name": "
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 82 |
"severity": "Medium; High if shoulder level difference exists",
|
| 83 |
"priority": "P1/P3",
|
| 84 |
-
"deadline": "Medium term; immediate if dangerous level difference
|
| 85 |
-
"risk": "Loss of control when
|
| 86 |
"recommendation": "Cut deteriorated edge, replace with compacted hot mix, and restore shoulder continuity."
|
| 87 |
},
|
| 88 |
-
"
|
| 89 |
-
"name": "Patches in
|
| 90 |
"severity": "Medium; High if level difference exceeds 2 cm",
|
| 91 |
"priority": "P1/P2",
|
| 92 |
"deadline": "Short term; immediate if level difference exceeds 2 cm",
|
| 93 |
"risk": "Uneven surface, fall risk, aggregate projection, and unresolved underlying defect.",
|
| 94 |
"recommendation": "Mill and repatch correctly using straight cut, priming, hot mix, and layer compaction."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 95 |
}
|
| 96 |
}
|
| 97 |
|
|
|
|
| 20 |
) if XAI_API_KEY else None
|
| 21 |
|
| 22 |
|
| 23 |
+
def normalize_class_name(name):
|
| 24 |
+
name = name.upper().strip()
|
| 25 |
+
name = name.replace(".", "")
|
| 26 |
+
name = name.replace("-", " ")
|
| 27 |
+
name = name.replace("_", " ")
|
| 28 |
+
name = " ".join(name.split())
|
| 29 |
+
return name
|
| 30 |
+
|
| 31 |
+
|
| 32 |
PATHOLOGY_CATALOG = {
|
| 33 |
+
"01LONGITUDINAL CRACKS": {
|
| 34 |
+
"name": "Longitudinal Cracks",
|
| 35 |
"severity": "Medium",
|
| 36 |
"priority": "P2",
|
| 37 |
"deadline": "Medium term: 1–3 months",
|
| 38 |
"risk": "Water infiltration and progressive structural degradation.",
|
| 39 |
+
"recommendation": "Seal cracks with modified bituminous mastic. If crack opening exceeds 5 mm, mill and replace the wearing course."
|
| 40 |
},
|
| 41 |
+
"02TRANSVERSE CRACKS": {
|
| 42 |
+
"name": "Transverse Cracks",
|
| 43 |
"severity": "Medium",
|
| 44 |
"priority": "P2",
|
| 45 |
"deadline": "Medium term: 1–3 months",
|
| 46 |
"risk": "Water infiltration, frost damage, vibration, and risk to motorcycles.",
|
| 47 |
+
"recommendation": "Seal with SBS-modified mastic. For recurring cracks, investigate base and consider anti-crack geogrid."
|
| 48 |
},
|
| 49 |
+
"03ALLIGATOR CRACKING": {
|
| 50 |
+
"name": "Alligator / Crocodile Skin Cracking",
|
| 51 |
"severity": "High",
|
| 52 |
"priority": "P1/P2",
|
| 53 |
"deadline": "Immediate or short term",
|
| 54 |
+
"risk": "Advanced structural fatigue, pothole formation, and possible pavement collapse.",
|
| 55 |
+
"recommendation": "Mill affected layers and reconstruct pavement structure. Perform geotechnical investigation if widespread."
|
| 56 |
+
},
|
| 57 |
+
"04REFLECTION CRACKS": {
|
| 58 |
+
"name": "Reflection Cracks",
|
| 59 |
+
"severity": "Medium–High",
|
| 60 |
+
"priority": "P2",
|
| 61 |
+
"deadline": "Medium term: 1–3 months",
|
| 62 |
+
"risk": "Water ingress, internal erosion, and pothole formation.",
|
| 63 |
+
"recommendation": "Seal with elastomeric mastic. For resurfacing, use anti-crack geogrid or SAMI membrane."
|
| 64 |
},
|
| 65 |
+
"05POTHOLES": {
|
| 66 |
"name": "Potholes",
|
| 67 |
"severity": "High",
|
| 68 |
"priority": "P1",
|
| 69 |
"deadline": "Immediate: within 24–48 hours",
|
| 70 |
"risk": "Direct accident risk, especially for motorcycles and bicycles; vehicle tire and suspension damage.",
|
| 71 |
+
"recommendation": "Immediate patching with hot/cold bituminous mix. Cut edges, clean, prime, fill, and compact."
|
| 72 |
},
|
| 73 |
+
"06RUTTING": {
|
| 74 |
+
"name": "Permanent Deformation / Rutting",
|
| 75 |
"severity": "Medium–High",
|
| 76 |
"priority": "P1/P2",
|
| 77 |
"deadline": "Short term if rut depth exceeds 15–20 mm",
|
| 78 |
+
"risk": "Aquaplaning, vehicle instability, and progressive lower-layer degradation.",
|
| 79 |
"recommendation": "Mill affected area and replace with high-stability asphalt mix such as SMA or BBTM."
|
| 80 |
},
|
| 81 |
+
"07UNDULATIONS AND CORRUGATION": {
|
| 82 |
+
"name": "Undulations and Corrugation",
|
| 83 |
"severity": "Medium",
|
| 84 |
"priority": "P2/P3",
|
| 85 |
"deadline": "Medium term: 1–3 months",
|
| 86 |
+
"risk": "Loss of driving comfort, braking instability, and possible vehicle control issues.",
|
| 87 |
+
"recommendation": "Mill wearing course and replace with deformation-resistant asphalt mixture."
|
| 88 |
+
},
|
| 89 |
+
"08DEPRESSIONS AND SETTLEMENTS": {
|
| 90 |
+
"name": "Depressions and Settlements",
|
| 91 |
+
"severity": "High",
|
| 92 |
+
"priority": "P1",
|
| 93 |
+
"deadline": "Immediate if depression exceeds 3 cm",
|
| 94 |
+
"risk": "Water accumulation, aquaplaning, and potential sudden pavement collapse.",
|
| 95 |
+
"recommendation": "Investigate cause using GPR/load tests. Repair underlying cause before structural reconstruction."
|
| 96 |
+
},
|
| 97 |
+
"09SWELLING": {
|
| 98 |
+
"name": "Swelling / Bulges",
|
| 99 |
+
"severity": "Medium–High",
|
| 100 |
+
"priority": "P1/P2",
|
| 101 |
+
"deadline": "Short term; immediate if height exceeds 5 cm",
|
| 102 |
+
"risk": "Vehicle instability and fall risk for cyclists/pedestrians.",
|
| 103 |
+
"recommendation": "Investigate cause such as roots, frost, leakage, or expansive soil. Remove cause, mill, and level area."
|
| 104 |
+
},
|
| 105 |
+
"10SURFACE RAVELING": {
|
| 106 |
+
"name": "Surface Raveling",
|
| 107 |
+
"severity": "Medium",
|
| 108 |
+
"priority": "P2/P3",
|
| 109 |
+
"deadline": "Medium term: 1–3 months",
|
| 110 |
+
"risk": "Loose aggregate, reduced traction, water penetration, and future pothole formation.",
|
| 111 |
"recommendation": "Apply slurry seal, microsurfacing, or mill and resurface if advanced."
|
| 112 |
},
|
| 113 |
+
"11PEELING AND LAYER DETACHMENT": {
|
| 114 |
+
"name": "Peeling and Layer Detachment",
|
| 115 |
+
"severity": "High",
|
| 116 |
+
"priority": "P1",
|
| 117 |
+
"deadline": "Immediate; remove loose material within 24 hours",
|
| 118 |
+
"risk": "Loose material causing motorcyclist/cyclist falls and rapid base exposure.",
|
| 119 |
+
"recommendation": "Remove loose material, mill affected area, clean, apply proper tack coat, and resurface."
|
| 120 |
+
},
|
| 121 |
+
"12BINDER BLEEDING": {
|
| 122 |
+
"name": "Binder Bleeding / Exudation",
|
| 123 |
"severity": "Medium; High on curves/intersections",
|
| 124 |
"priority": "P1/P3",
|
| 125 |
"deadline": "Short term; immediate on sharp curves",
|
| 126 |
+
"risk": "Loss of skid resistance and accident risk in wet/hot conditions.",
|
| 127 |
"recommendation": "Apply cover aggregate and compact lightly. In severe cases, micro-mill and replace surface layer."
|
| 128 |
},
|
| 129 |
+
"13AGGREGATE POLISHING": {
|
| 130 |
+
"name": "Aggregate Polishing",
|
| 131 |
+
"severity": "Medium; High in wet/slope areas",
|
| 132 |
+
"priority": "P1",
|
| 133 |
+
"deadline": "Short term: less than 1 month",
|
| 134 |
+
"risk": "Loss of wet skid resistance and increased braking distance.",
|
| 135 |
+
"recommendation": "Apply anti-skid surface treatment or overlay with high-CPA aggregate mix."
|
| 136 |
+
},
|
| 137 |
+
"14PAVEMENT SHOULDER LEVEL DIFFERENCE": {
|
| 138 |
+
"name": "Pavement–Shoulder Level Difference",
|
| 139 |
+
"severity": "High",
|
| 140 |
+
"priority": "P1",
|
| 141 |
+
"deadline": "Short term; immediate if level difference exceeds 8 cm",
|
| 142 |
+
"risk": "Vehicle rollover risk and abrupt re-entry collision risk.",
|
| 143 |
+
"recommendation": "Level shoulder to roadway or construct transition ramp with maximum slope 1:6."
|
| 144 |
+
},
|
| 145 |
+
"15CONSTRUCTION JOINT DETERIORATION": {
|
| 146 |
+
"name": "Construction Joint Deterioration",
|
| 147 |
+
"severity": "Medium",
|
| 148 |
+
"priority": "P2/P3",
|
| 149 |
+
"deadline": "Medium term: 1–3 months",
|
| 150 |
+
"risk": "Water infiltration and progressive deterioration along joint line.",
|
| 151 |
+
"recommendation": "Seal joint with elastomeric bituminous mastic. Mill and rebuild severely deteriorated joints."
|
| 152 |
+
},
|
| 153 |
+
"16CRESCENT CRACKS": {
|
| 154 |
+
"name": "Crescent-Shaped / Slippage Cracks",
|
| 155 |
+
"severity": "High",
|
| 156 |
+
"priority": "P1",
|
| 157 |
+
"deadline": "Short term or immediate if active detachment exists",
|
| 158 |
+
"risk": "Layer sliding, material detachment, and direct danger to motorcycles.",
|
| 159 |
+
"recommendation": "Mill affected area and replace with proper tack coat and compacted asphalt layer."
|
| 160 |
+
},
|
| 161 |
+
"17CHANNELS AND DEEP GROOVES": {
|
| 162 |
+
"name": "Channels and Deep Grooves",
|
| 163 |
+
"severity": "Medium; High if depth exceeds 2 cm",
|
| 164 |
+
"priority": "P2",
|
| 165 |
+
"deadline": "Medium term: 1–3 months",
|
| 166 |
+
"risk": "Aquaplaning and fall risk for motorcycles/cyclists.",
|
| 167 |
+
"recommendation": "Mill and resurface with abrasion-resistant mix. Correct surface drainage."
|
| 168 |
+
},
|
| 169 |
+
"18LATERAL DISPLACEMENT": {
|
| 170 |
+
"name": "Lateral Displacement / Shoving",
|
| 171 |
+
"severity": "Medium; High in turning areas",
|
| 172 |
+
"priority": "P2/P3",
|
| 173 |
+
"deadline": "Medium term: 1–3 months",
|
| 174 |
+
"risk": "Vehicle instability on curves and cyclist risk near displaced material.",
|
| 175 |
+
"recommendation": "Mill affected area and replace with high-stability polymer-modified mix."
|
| 176 |
+
},
|
| 177 |
+
"20WATER SEEPAGE": {
|
| 178 |
+
"name": "Water Seepage / Wet Areas",
|
| 179 |
+
"severity": "High",
|
| 180 |
+
"priority": "P1/P2",
|
| 181 |
+
"deadline": "Immediate investigation within 24–48 hours",
|
| 182 |
+
"risk": "Internal erosion, loss of bearing capacity, and possible pavement collapse.",
|
| 183 |
+
"recommendation": "Investigate drainage/leakage source, repair water source, drain retained water, and reconstruct affected pavement."
|
| 184 |
+
},
|
| 185 |
+
"21PERIMETER DETERIORATION OF MANHOLES": {
|
| 186 |
+
"name": "Perimeter Deterioration of Manholes",
|
| 187 |
+
"severity": "High",
|
| 188 |
+
"priority": "P1",
|
| 189 |
+
"deadline": "Short term; immediate if level difference exceeds 2 cm or loose material exists",
|
| 190 |
+
"risk": "Cyclist/motorcyclist falls, vehicle impact damage, and water ingress.",
|
| 191 |
+
"recommendation": "Demolish perimeter, adjust frame level, and replace pavement with compacted hot mix."
|
| 192 |
+
},
|
| 193 |
+
"22EDGE DETERIORATION": {
|
| 194 |
+
"name": "Road Edge Deterioration",
|
| 195 |
"severity": "Medium; High if shoulder level difference exists",
|
| 196 |
"priority": "P1/P3",
|
| 197 |
+
"deadline": "Medium term; immediate if associated with dangerous level difference",
|
| 198 |
+
"risk": "Loss of vehicle control when moving to shoulder and progressive edge failure.",
|
| 199 |
"recommendation": "Cut deteriorated edge, replace with compacted hot mix, and restore shoulder continuity."
|
| 200 |
},
|
| 201 |
+
"23PATCHES IN POOR CONDITION": {
|
| 202 |
+
"name": "Patches in Poor Condition",
|
| 203 |
"severity": "Medium; High if level difference exceeds 2 cm",
|
| 204 |
"priority": "P1/P2",
|
| 205 |
"deadline": "Short term; immediate if level difference exceeds 2 cm",
|
| 206 |
"risk": "Uneven surface, fall risk, aggregate projection, and unresolved underlying defect.",
|
| 207 |
"recommendation": "Mill and repatch correctly using straight cut, priming, hot mix, and layer compaction."
|
| 208 |
+
},
|
| 209 |
+
"24MARKING DAMAGE": {
|
| 210 |
+
"name": "Horizontal Marking Damage",
|
| 211 |
+
"severity": "Medium; High at pedestrian crossings/intersections",
|
| 212 |
+
"priority": "P1/P3",
|
| 213 |
+
"deadline": "Short term at intersections; long term for secondary markings",
|
| 214 |
+
"risk": "Driver disorientation, lane invasion, and pedestrian crossing visibility loss.",
|
| 215 |
+
"recommendation": "Clean surface and repaint/apply thermoplastic marking with glass microspheres."
|
| 216 |
+
},
|
| 217 |
+
"25STEP BETWEEN LANES": {
|
| 218 |
+
"name": "Step Between Lanes",
|
| 219 |
+
"severity": "Medium; High if step exceeds 3 cm",
|
| 220 |
+
"priority": "P1/P2",
|
| 221 |
+
"deadline": "Short term: less than 1 month",
|
| 222 |
+
"risk": "Motorcycle instability during lane changes and water retention.",
|
| 223 |
+
"recommendation": "Mill transition zone and level the step using a ramp with maximum slope 1:10."
|
| 224 |
+
},
|
| 225 |
+
"26THERMAL FATIGUE CRACKING": {
|
| 226 |
+
"name": "Thermal Fatigue Cracking",
|
| 227 |
+
"severity": "Medium",
|
| 228 |
+
"priority": "P2",
|
| 229 |
+
"deadline": "Medium term: 1–3 months",
|
| 230 |
+
"risk": "Water infiltration, freeze-thaw damage, and evolution to structural cracking.",
|
| 231 |
+
"recommendation": "Seal cracks and use polymer-modified bitumen with suitable low-temperature performance in resurfacing."
|
| 232 |
+
},
|
| 233 |
+
"27CHEMICAL AGENTS": {
|
| 234 |
+
"name": "Deterioration due to Hydrocarbons / Chemical Agents",
|
| 235 |
+
"severity": "Medium–High",
|
| 236 |
+
"priority": "P1/P2",
|
| 237 |
+
"deadline": "Short term: less than 1 month",
|
| 238 |
+
"risk": "Softened asphalt, soil/groundwater contamination, and slippery surface.",
|
| 239 |
+
"recommendation": "Apply absorbents, mill contaminated area, manage waste properly, and replace with resistant asphalt mix."
|
| 240 |
+
},
|
| 241 |
+
"28OXIDATION AND AGING OF BINDER": {
|
| 242 |
+
"name": "Oxidation and Aging of Binder",
|
| 243 |
+
"severity": "Medium",
|
| 244 |
+
"priority": "P3",
|
| 245 |
+
"deadline": "Long term: 3–6 months",
|
| 246 |
+
"risk": "Reduced pavement life, brittleness, cracking, and surface disintegration.",
|
| 247 |
+
"recommendation": "Apply rejuvenating treatment or slurry seal. Plan resurfacing before structural cracking occurs."
|
| 248 |
}
|
| 249 |
}
|
| 250 |
|