Update app.py
Browse files
app.py
CHANGED
|
@@ -1,9 +1,9 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import re
|
| 3 |
|
| 4 |
-
# =========================
|
| 5 |
# KPI Extraction
|
| 6 |
-
# =========================
|
| 7 |
|
| 8 |
def extract_value(text, key):
|
| 9 |
pattern = rf"{key}\s*=\s*(-?\d+\.?\d*)"
|
|
@@ -14,9 +14,9 @@ def extract_value(text, key):
|
|
| 14 |
|
| 15 |
return None
|
| 16 |
|
| 17 |
-
# =========================
|
| 18 |
-
# Main Analysis
|
| 19 |
-
# =========================
|
| 20 |
|
| 21 |
def analyze_ul_interference(vendor, data):
|
| 22 |
|
|
@@ -34,9 +34,9 @@ def analyze_ul_interference(vendor, data):
|
|
| 34 |
bler = extract_value(data, "PUSCH BLER")
|
| 35 |
cqi = extract_value(data, "CQI")
|
| 36 |
|
| 37 |
-
# =========================
|
| 38 |
# UL SINR
|
| 39 |
-
# =========================
|
| 40 |
|
| 41 |
if ul_sinr is not None:
|
| 42 |
|
|
@@ -48,9 +48,9 @@ def analyze_ul_interference(vendor, data):
|
|
| 48 |
findings.append(f"Poor UL SINR detected ({ul_sinr} dB)")
|
| 49 |
severity = "MEDIUM"
|
| 50 |
|
| 51 |
-
# =========================
|
| 52 |
# RTWP
|
| 53 |
-
# =========================
|
| 54 |
|
| 55 |
if rtwp is not None:
|
| 56 |
|
|
@@ -62,9 +62,9 @@ def analyze_ul_interference(vendor, data):
|
|
| 62 |
findings.append(f"Elevated RTWP/noise floor ({rtwp} dBm)")
|
| 63 |
severity = "MEDIUM"
|
| 64 |
|
| 65 |
-
# =========================
|
| 66 |
# BLER
|
| 67 |
-
# =========================
|
| 68 |
|
| 69 |
if bler is not None:
|
| 70 |
|
|
@@ -75,18 +75,18 @@ def analyze_ul_interference(vendor, data):
|
|
| 75 |
elif bler > 15:
|
| 76 |
findings.append(f"Elevated PUSCH BLER ({bler}%)")
|
| 77 |
|
| 78 |
-
# =========================
|
| 79 |
# CQI
|
| 80 |
-
# =========================
|
| 81 |
|
| 82 |
if cqi is not None:
|
| 83 |
|
| 84 |
if cqi < 5:
|
| 85 |
findings.append(f"Low CQI detected ({cqi})")
|
| 86 |
|
| 87 |
-
# =========================
|
| 88 |
# PRB
|
| 89 |
-
# =========================
|
| 90 |
|
| 91 |
congestion = False
|
| 92 |
interference = False
|
|
@@ -97,9 +97,9 @@ def analyze_ul_interference(vendor, data):
|
|
| 97 |
findings.append(f"High UL PRB utilization ({ul_prb}%)")
|
| 98 |
congestion = True
|
| 99 |
|
| 100 |
-
# =========================
|
| 101 |
# Classification Logic
|
| 102 |
-
# =========================
|
| 103 |
|
| 104 |
if (
|
| 105 |
ul_sinr is not None and ul_sinr < 0 and
|
|
@@ -108,6 +108,10 @@ def analyze_ul_interference(vendor, data):
|
|
| 108 |
):
|
| 109 |
interference = True
|
| 110 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 111 |
if interference:
|
| 112 |
|
| 113 |
condition = "LIKELY UL INTERFERENCE"
|
|
@@ -129,6 +133,10 @@ def analyze_ul_interference(vendor, data):
|
|
| 129 |
"Review recent maintenance activity"
|
| 130 |
]
|
| 131 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 132 |
elif congestion:
|
| 133 |
|
| 134 |
condition = "LIKELY CAPACITY CONGESTION"
|
|
@@ -147,6 +155,10 @@ def analyze_ul_interference(vendor, data):
|
|
| 147 |
"Review carrier utilization"
|
| 148 |
]
|
| 149 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 150 |
else:
|
| 151 |
|
| 152 |
condition = "NO MAJOR UL IMPAIRMENT DETECTED"
|
|
@@ -155,48 +167,41 @@ def analyze_ul_interference(vendor, data):
|
|
| 155 |
"Continue KPI monitoring"
|
| 156 |
]
|
| 157 |
|
| 158 |
-
|
| 159 |
-
#
|
| 160 |
-
|
| 161 |
-
## Vendor
|
| 162 |
-
**{vendor}**
|
| 163 |
-
|
| 164 |
-
## Condition
|
| 165 |
-
**{condition}**
|
| 166 |
-
|
| 167 |
-
## Severity
|
| 168 |
-
**{severity}**
|
| 169 |
-
|
| 170 |
-
---
|
| 171 |
-
|
| 172 |
-
## Findings
|
| 173 |
-
|
| 174 |
-
{chr(10).join([f"- {x}" for x in findings])}
|
| 175 |
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
{chr(10).join([f"- {x}" for x in causes])}
|
| 181 |
-
|
| 182 |
-
---
|
| 183 |
-
|
| 184 |
-
## Recommended Actions
|
| 185 |
|
| 186 |
-
|
|
|
|
|
|
|
| 187 |
|
| 188 |
-
|
|
|
|
|
|
|
| 189 |
|
| 190 |
-
|
|
|
|
| 191 |
|
| 192 |
Analysis completed using LTE/5G uplink KPI and PM counter thresholds.
|
| 193 |
"""
|
| 194 |
|
| 195 |
-
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 196 |
|
| 197 |
-
# =========================
|
| 198 |
-
#
|
| 199 |
-
# =========================
|
| 200 |
|
| 201 |
examples = [
|
| 202 |
[
|
|
@@ -216,12 +221,21 @@ RTWP = -108
|
|
| 216 |
UL PRB = 96
|
| 217 |
DL PRB = 92
|
| 218 |
CQI = 11"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 219 |
]
|
| 220 |
]
|
| 221 |
|
| 222 |
-
# =========================
|
| 223 |
# UI
|
| 224 |
-
# =========================
|
| 225 |
|
| 226 |
with gr.Blocks(theme=gr.themes.Default()) as demo:
|
| 227 |
|
|
@@ -232,30 +246,82 @@ AI-assisted LTE and 5G uplink interference analysis using KPI and PM counter ind
|
|
| 232 |
""")
|
| 233 |
|
| 234 |
vendor = gr.Dropdown(
|
| 235 |
-
|
| 236 |
-
|
| 237 |
-
|
| 238 |
-
|
| 239 |
)
|
| 240 |
|
| 241 |
data_input = gr.Textbox(
|
| 242 |
-
lines=
|
| 243 |
label="Paste KPI / PM Counter Data"
|
| 244 |
)
|
| 245 |
|
| 246 |
-
analyze_btn = gr.Button(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 247 |
|
| 248 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 249 |
|
| 250 |
gr.Examples(
|
| 251 |
examples=examples,
|
| 252 |
inputs=[vendor, data_input]
|
| 253 |
)
|
| 254 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 255 |
analyze_btn.click(
|
| 256 |
fn=analyze_ul_interference,
|
| 257 |
inputs=[vendor, data_input],
|
| 258 |
-
outputs=
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 259 |
)
|
| 260 |
|
| 261 |
demo.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import re
|
| 3 |
|
| 4 |
+
# ============================================
|
| 5 |
# KPI Extraction
|
| 6 |
+
# ============================================
|
| 7 |
|
| 8 |
def extract_value(text, key):
|
| 9 |
pattern = rf"{key}\s*=\s*(-?\d+\.?\d*)"
|
|
|
|
| 14 |
|
| 15 |
return None
|
| 16 |
|
| 17 |
+
# ============================================
|
| 18 |
+
# Main Analysis Logic
|
| 19 |
+
# ============================================
|
| 20 |
|
| 21 |
def analyze_ul_interference(vendor, data):
|
| 22 |
|
|
|
|
| 34 |
bler = extract_value(data, "PUSCH BLER")
|
| 35 |
cqi = extract_value(data, "CQI")
|
| 36 |
|
| 37 |
+
# ============================================
|
| 38 |
# UL SINR
|
| 39 |
+
# ============================================
|
| 40 |
|
| 41 |
if ul_sinr is not None:
|
| 42 |
|
|
|
|
| 48 |
findings.append(f"Poor UL SINR detected ({ul_sinr} dB)")
|
| 49 |
severity = "MEDIUM"
|
| 50 |
|
| 51 |
+
# ============================================
|
| 52 |
# RTWP
|
| 53 |
+
# ============================================
|
| 54 |
|
| 55 |
if rtwp is not None:
|
| 56 |
|
|
|
|
| 62 |
findings.append(f"Elevated RTWP/noise floor ({rtwp} dBm)")
|
| 63 |
severity = "MEDIUM"
|
| 64 |
|
| 65 |
+
# ============================================
|
| 66 |
# BLER
|
| 67 |
+
# ============================================
|
| 68 |
|
| 69 |
if bler is not None:
|
| 70 |
|
|
|
|
| 75 |
elif bler > 15:
|
| 76 |
findings.append(f"Elevated PUSCH BLER ({bler}%)")
|
| 77 |
|
| 78 |
+
# ============================================
|
| 79 |
# CQI
|
| 80 |
+
# ============================================
|
| 81 |
|
| 82 |
if cqi is not None:
|
| 83 |
|
| 84 |
if cqi < 5:
|
| 85 |
findings.append(f"Low CQI detected ({cqi})")
|
| 86 |
|
| 87 |
+
# ============================================
|
| 88 |
# PRB
|
| 89 |
+
# ============================================
|
| 90 |
|
| 91 |
congestion = False
|
| 92 |
interference = False
|
|
|
|
| 97 |
findings.append(f"High UL PRB utilization ({ul_prb}%)")
|
| 98 |
congestion = True
|
| 99 |
|
| 100 |
+
# ============================================
|
| 101 |
# Classification Logic
|
| 102 |
+
# ============================================
|
| 103 |
|
| 104 |
if (
|
| 105 |
ul_sinr is not None and ul_sinr < 0 and
|
|
|
|
| 108 |
):
|
| 109 |
interference = True
|
| 110 |
|
| 111 |
+
# ============================================
|
| 112 |
+
# Interference Condition
|
| 113 |
+
# ============================================
|
| 114 |
+
|
| 115 |
if interference:
|
| 116 |
|
| 117 |
condition = "LIKELY UL INTERFERENCE"
|
|
|
|
| 133 |
"Review recent maintenance activity"
|
| 134 |
]
|
| 135 |
|
| 136 |
+
# ============================================
|
| 137 |
+
# Congestion Condition
|
| 138 |
+
# ============================================
|
| 139 |
+
|
| 140 |
elif congestion:
|
| 141 |
|
| 142 |
condition = "LIKELY CAPACITY CONGESTION"
|
|
|
|
| 155 |
"Review carrier utilization"
|
| 156 |
]
|
| 157 |
|
| 158 |
+
# ============================================
|
| 159 |
+
# Normal Condition
|
| 160 |
+
# ============================================
|
| 161 |
+
|
| 162 |
else:
|
| 163 |
|
| 164 |
condition = "NO MAJOR UL IMPAIRMENT DETECTED"
|
|
|
|
| 167 |
"Continue KPI monitoring"
|
| 168 |
]
|
| 169 |
|
| 170 |
+
# ============================================
|
| 171 |
+
# Markdown Formatting
|
| 172 |
+
# ============================================
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 173 |
|
| 174 |
+
findings_md = "### Findings\n\n" + "\n".join(
|
| 175 |
+
[f"- {x}" for x in findings]
|
| 176 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 177 |
|
| 178 |
+
causes_md = "### Likely Causes\n\n" + "\n".join(
|
| 179 |
+
[f"- {x}" for x in causes]
|
| 180 |
+
)
|
| 181 |
|
| 182 |
+
actions_md = "### Recommended Actions\n\n" + "\n".join(
|
| 183 |
+
[f"- {x}" for x in actions]
|
| 184 |
+
)
|
| 185 |
|
| 186 |
+
assessment_md = """
|
| 187 |
+
### Engineering Assessment
|
| 188 |
|
| 189 |
Analysis completed using LTE/5G uplink KPI and PM counter thresholds.
|
| 190 |
"""
|
| 191 |
|
| 192 |
+
return (
|
| 193 |
+
condition,
|
| 194 |
+
severity,
|
| 195 |
+
vendor,
|
| 196 |
+
findings_md,
|
| 197 |
+
causes_md,
|
| 198 |
+
actions_md,
|
| 199 |
+
assessment_md
|
| 200 |
+
)
|
| 201 |
|
| 202 |
+
# ============================================
|
| 203 |
+
# Example Inputs
|
| 204 |
+
# ============================================
|
| 205 |
|
| 206 |
examples = [
|
| 207 |
[
|
|
|
|
| 221 |
UL PRB = 96
|
| 222 |
DL PRB = 92
|
| 223 |
CQI = 11"""
|
| 224 |
+
],
|
| 225 |
+
[
|
| 226 |
+
"Samsung",
|
| 227 |
+
"""UL SINR = -2
|
| 228 |
+
PUSCH BLER = 18
|
| 229 |
+
RTWP = -99
|
| 230 |
+
UL PRB = 88
|
| 231 |
+
DL PRB = 81
|
| 232 |
+
CQI = 6"""
|
| 233 |
]
|
| 234 |
]
|
| 235 |
|
| 236 |
+
# ============================================
|
| 237 |
# UI
|
| 238 |
+
# ============================================
|
| 239 |
|
| 240 |
with gr.Blocks(theme=gr.themes.Default()) as demo:
|
| 241 |
|
|
|
|
| 246 |
""")
|
| 247 |
|
| 248 |
vendor = gr.Dropdown(
|
| 249 |
+
choices=["Ericsson", "Nokia", "Samsung"],
|
| 250 |
+
value="Ericsson",
|
| 251 |
+
label="RAN Vendor",
|
| 252 |
+
container=False
|
| 253 |
)
|
| 254 |
|
| 255 |
data_input = gr.Textbox(
|
| 256 |
+
lines=10,
|
| 257 |
label="Paste KPI / PM Counter Data"
|
| 258 |
)
|
| 259 |
|
| 260 |
+
analyze_btn = gr.Button(
|
| 261 |
+
"Analyze",
|
| 262 |
+
variant="primary"
|
| 263 |
+
)
|
| 264 |
+
|
| 265 |
+
# ============================================
|
| 266 |
+
# Top Status Row
|
| 267 |
+
# ============================================
|
| 268 |
+
|
| 269 |
+
with gr.Row():
|
| 270 |
+
|
| 271 |
+
condition_box = gr.Textbox(
|
| 272 |
+
label="Condition",
|
| 273 |
+
interactive=False
|
| 274 |
+
)
|
| 275 |
+
|
| 276 |
+
severity_box = gr.Textbox(
|
| 277 |
+
label="Severity",
|
| 278 |
+
interactive=False
|
| 279 |
+
)
|
| 280 |
+
|
| 281 |
+
vendor_box = gr.Textbox(
|
| 282 |
+
label="Vendor",
|
| 283 |
+
interactive=False
|
| 284 |
+
)
|
| 285 |
|
| 286 |
+
# ============================================
|
| 287 |
+
# Main Analysis Panels
|
| 288 |
+
# ============================================
|
| 289 |
+
|
| 290 |
+
with gr.Row():
|
| 291 |
+
|
| 292 |
+
findings_box = gr.Markdown()
|
| 293 |
+
|
| 294 |
+
causes_box = gr.Markdown()
|
| 295 |
+
|
| 296 |
+
actions_box = gr.Markdown()
|
| 297 |
+
|
| 298 |
+
assessment_box = gr.Markdown()
|
| 299 |
+
|
| 300 |
+
# ============================================
|
| 301 |
+
# Examples
|
| 302 |
+
# ============================================
|
| 303 |
|
| 304 |
gr.Examples(
|
| 305 |
examples=examples,
|
| 306 |
inputs=[vendor, data_input]
|
| 307 |
)
|
| 308 |
|
| 309 |
+
# ============================================
|
| 310 |
+
# Button Action
|
| 311 |
+
# ============================================
|
| 312 |
+
|
| 313 |
analyze_btn.click(
|
| 314 |
fn=analyze_ul_interference,
|
| 315 |
inputs=[vendor, data_input],
|
| 316 |
+
outputs=[
|
| 317 |
+
condition_box,
|
| 318 |
+
severity_box,
|
| 319 |
+
vendor_box,
|
| 320 |
+
findings_box,
|
| 321 |
+
causes_box,
|
| 322 |
+
actions_box,
|
| 323 |
+
assessment_box
|
| 324 |
+
]
|
| 325 |
)
|
| 326 |
|
| 327 |
demo.launch()
|