Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,14 +1,24 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import re
|
| 3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
def extract_value(text, key):
|
| 5 |
pattern = rf"{key}\s*=\s*(-?\d+\.?\d*)"
|
| 6 |
match = re.search(pattern, text, re.IGNORECASE)
|
|
|
|
| 7 |
if match:
|
| 8 |
return float(match.group(1))
|
|
|
|
| 9 |
return None
|
| 10 |
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
findings = []
|
| 14 |
causes = []
|
|
@@ -25,13 +35,13 @@ def analyze_ul_interference(data):
|
|
| 25 |
cqi = extract_value(data, "CQI")
|
| 26 |
|
| 27 |
# =========================
|
| 28 |
-
# UL SINR
|
| 29 |
# =========================
|
| 30 |
|
| 31 |
if ul_sinr is not None:
|
| 32 |
|
| 33 |
if ul_sinr < -5:
|
| 34 |
-
findings.append(f"Critical UL SINR degradation
|
| 35 |
severity = "HIGH"
|
| 36 |
|
| 37 |
elif ul_sinr < 0:
|
|
@@ -39,34 +49,34 @@ def analyze_ul_interference(data):
|
|
| 39 |
severity = "MEDIUM"
|
| 40 |
|
| 41 |
# =========================
|
| 42 |
-
# RTWP
|
| 43 |
# =========================
|
| 44 |
|
| 45 |
if rtwp is not None:
|
| 46 |
|
| 47 |
if rtwp > -95:
|
| 48 |
-
findings.append(f"Severe RTWP elevation
|
| 49 |
severity = "HIGH"
|
| 50 |
|
| 51 |
elif rtwp > -100:
|
| 52 |
-
findings.append(f"Elevated RTWP/noise floor
|
| 53 |
severity = "MEDIUM"
|
| 54 |
|
| 55 |
# =========================
|
| 56 |
-
# BLER
|
| 57 |
# =========================
|
| 58 |
|
| 59 |
if bler is not None:
|
| 60 |
|
| 61 |
if bler > 30:
|
| 62 |
-
findings.append(f"Critical PUSCH BLER
|
| 63 |
severity = "HIGH"
|
| 64 |
|
| 65 |
elif bler > 15:
|
| 66 |
findings.append(f"Elevated PUSCH BLER ({bler}%)")
|
| 67 |
|
| 68 |
# =========================
|
| 69 |
-
# CQI
|
| 70 |
# =========================
|
| 71 |
|
| 72 |
if cqi is not None:
|
|
@@ -75,7 +85,7 @@ def analyze_ul_interference(data):
|
|
| 75 |
findings.append(f"Low CQI detected ({cqi})")
|
| 76 |
|
| 77 |
# =========================
|
| 78 |
-
# PRB
|
| 79 |
# =========================
|
| 80 |
|
| 81 |
congestion = False
|
|
@@ -87,6 +97,10 @@ def analyze_ul_interference(data):
|
|
| 87 |
findings.append(f"High UL PRB utilization ({ul_prb}%)")
|
| 88 |
congestion = True
|
| 89 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 90 |
if (
|
| 91 |
ul_sinr is not None and ul_sinr < 0 and
|
| 92 |
rtwp is not None and rtwp > -100 and
|
|
@@ -94,18 +108,15 @@ def analyze_ul_interference(data):
|
|
| 94 |
):
|
| 95 |
interference = True
|
| 96 |
|
| 97 |
-
# =========================
|
| 98 |
-
# CONDITION CLASSIFICATION
|
| 99 |
-
# =========================
|
| 100 |
-
|
| 101 |
if interference:
|
|
|
|
| 102 |
condition = "LIKELY UL INTERFERENCE"
|
| 103 |
|
| 104 |
causes = [
|
| 105 |
"External uplink interference",
|
| 106 |
"Passive Intermodulation (PIM)",
|
| 107 |
-
"Feeder or jumper degradation",
|
| 108 |
"Overshooting sector",
|
|
|
|
| 109 |
"Radio hardware impairment"
|
| 110 |
]
|
| 111 |
|
|
@@ -113,9 +124,9 @@ def analyze_ul_interference(data):
|
|
| 113 |
"Review RTWP trend history",
|
| 114 |
"Compare neighboring sector RTWP",
|
| 115 |
"Inspect feeder and jumper path",
|
| 116 |
-
"Validate antenna alignment
|
| 117 |
"Perform spectrum sweep",
|
| 118 |
-
"
|
| 119 |
]
|
| 120 |
|
| 121 |
elif congestion:
|
|
@@ -130,10 +141,10 @@ def analyze_ul_interference(data):
|
|
| 130 |
]
|
| 131 |
|
| 132 |
actions = [
|
| 133 |
-
"Review busy-hour utilization
|
| 134 |
"Evaluate load balancing",
|
| 135 |
-
"Assess
|
| 136 |
-
"Review
|
| 137 |
]
|
| 138 |
|
| 139 |
else:
|
|
@@ -145,7 +156,10 @@ def analyze_ul_interference(data):
|
|
| 145 |
]
|
| 146 |
|
| 147 |
result = f"""
|
| 148 |
-
# UL Interference
|
|
|
|
|
|
|
|
|
|
| 149 |
|
| 150 |
## Condition
|
| 151 |
**{condition}**
|
|
@@ -153,36 +167,96 @@ def analyze_ul_interference(data):
|
|
| 153 |
## Severity
|
| 154 |
**{severity}**
|
| 155 |
|
|
|
|
|
|
|
| 156 |
## Findings
|
|
|
|
| 157 |
{chr(10).join([f"- {x}" for x in findings])}
|
| 158 |
|
|
|
|
|
|
|
| 159 |
## Likely Causes
|
|
|
|
| 160 |
{chr(10).join([f"- {x}" for x in causes])}
|
| 161 |
|
|
|
|
|
|
|
| 162 |
## Recommended Actions
|
|
|
|
| 163 |
{chr(10).join([f"- {x}" for x in actions])}
|
| 164 |
|
|
|
|
|
|
|
| 165 |
## Engineering Assessment
|
| 166 |
-
|
|
|
|
| 167 |
"""
|
| 168 |
|
| 169 |
return result
|
| 170 |
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 174 |
lines=14,
|
| 175 |
-
label="Paste
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 187 |
|
| 188 |
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*)"
|
| 10 |
match = re.search(pattern, text, re.IGNORECASE)
|
| 11 |
+
|
| 12 |
if match:
|
| 13 |
return float(match.group(1))
|
| 14 |
+
|
| 15 |
return None
|
| 16 |
|
| 17 |
+
# =========================
|
| 18 |
+
# Main Analysis
|
| 19 |
+
# =========================
|
| 20 |
+
|
| 21 |
+
def analyze_ul_interference(vendor, data):
|
| 22 |
|
| 23 |
findings = []
|
| 24 |
causes = []
|
|
|
|
| 35 |
cqi = extract_value(data, "CQI")
|
| 36 |
|
| 37 |
# =========================
|
| 38 |
+
# UL SINR
|
| 39 |
# =========================
|
| 40 |
|
| 41 |
if ul_sinr is not None:
|
| 42 |
|
| 43 |
if ul_sinr < -5:
|
| 44 |
+
findings.append(f"Critical UL SINR degradation ({ul_sinr} dB)")
|
| 45 |
severity = "HIGH"
|
| 46 |
|
| 47 |
elif ul_sinr < 0:
|
|
|
|
| 49 |
severity = "MEDIUM"
|
| 50 |
|
| 51 |
# =========================
|
| 52 |
+
# RTWP
|
| 53 |
# =========================
|
| 54 |
|
| 55 |
if rtwp is not None:
|
| 56 |
|
| 57 |
if rtwp > -95:
|
| 58 |
+
findings.append(f"Severe RTWP elevation ({rtwp} dBm)")
|
| 59 |
severity = "HIGH"
|
| 60 |
|
| 61 |
elif rtwp > -100:
|
| 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 |
|
| 71 |
if bler > 30:
|
| 72 |
+
findings.append(f"Critical PUSCH BLER ({bler}%)")
|
| 73 |
severity = "HIGH"
|
| 74 |
|
| 75 |
elif bler > 15:
|
| 76 |
findings.append(f"Elevated PUSCH BLER ({bler}%)")
|
| 77 |
|
| 78 |
# =========================
|
| 79 |
+
# CQI
|
| 80 |
# =========================
|
| 81 |
|
| 82 |
if cqi is not None:
|
|
|
|
| 85 |
findings.append(f"Low CQI detected ({cqi})")
|
| 86 |
|
| 87 |
# =========================
|
| 88 |
+
# PRB
|
| 89 |
# =========================
|
| 90 |
|
| 91 |
congestion = 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
|
| 106 |
rtwp is not None and rtwp > -100 and
|
|
|
|
| 108 |
):
|
| 109 |
interference = True
|
| 110 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 111 |
if interference:
|
| 112 |
+
|
| 113 |
condition = "LIKELY UL INTERFERENCE"
|
| 114 |
|
| 115 |
causes = [
|
| 116 |
"External uplink interference",
|
| 117 |
"Passive Intermodulation (PIM)",
|
|
|
|
| 118 |
"Overshooting sector",
|
| 119 |
+
"Feeder or jumper degradation",
|
| 120 |
"Radio hardware impairment"
|
| 121 |
]
|
| 122 |
|
|
|
|
| 124 |
"Review RTWP trend history",
|
| 125 |
"Compare neighboring sector RTWP",
|
| 126 |
"Inspect feeder and jumper path",
|
| 127 |
+
"Validate antenna alignment",
|
| 128 |
"Perform spectrum sweep",
|
| 129 |
+
"Review recent maintenance activity"
|
| 130 |
]
|
| 131 |
|
| 132 |
elif congestion:
|
|
|
|
| 141 |
]
|
| 142 |
|
| 143 |
actions = [
|
| 144 |
+
"Review busy-hour utilization",
|
| 145 |
"Evaluate load balancing",
|
| 146 |
+
"Assess scheduler efficiency",
|
| 147 |
+
"Review carrier utilization"
|
| 148 |
]
|
| 149 |
|
| 150 |
else:
|
|
|
|
| 156 |
]
|
| 157 |
|
| 158 |
result = f"""
|
| 159 |
+
# UL Interference Analysis
|
| 160 |
+
|
| 161 |
+
## Vendor
|
| 162 |
+
**{vendor}**
|
| 163 |
|
| 164 |
## Condition
|
| 165 |
**{condition}**
|
|
|
|
| 167 |
## Severity
|
| 168 |
**{severity}**
|
| 169 |
|
| 170 |
+
---
|
| 171 |
+
|
| 172 |
## Findings
|
| 173 |
+
|
| 174 |
{chr(10).join([f"- {x}" for x in findings])}
|
| 175 |
|
| 176 |
+
---
|
| 177 |
+
|
| 178 |
## Likely Causes
|
| 179 |
+
|
| 180 |
{chr(10).join([f"- {x}" for x in causes])}
|
| 181 |
|
| 182 |
+
---
|
| 183 |
+
|
| 184 |
## Recommended Actions
|
| 185 |
+
|
| 186 |
{chr(10).join([f"- {x}" for x in actions])}
|
| 187 |
|
| 188 |
+
---
|
| 189 |
+
|
| 190 |
## Engineering Assessment
|
| 191 |
+
|
| 192 |
+
Analysis completed using LTE/5G uplink KPI and PM counter thresholds.
|
| 193 |
"""
|
| 194 |
|
| 195 |
return result
|
| 196 |
|
| 197 |
+
# =========================
|
| 198 |
+
# Examples
|
| 199 |
+
# =========================
|
| 200 |
+
|
| 201 |
+
examples = [
|
| 202 |
+
[
|
| 203 |
+
"Ericsson",
|
| 204 |
+
"""UL SINR = -8
|
| 205 |
+
PUSCH BLER = 41
|
| 206 |
+
RTWP = -94
|
| 207 |
+
UL PRB = 72
|
| 208 |
+
DL PRB = 35
|
| 209 |
+
CQI = 3"""
|
| 210 |
+
],
|
| 211 |
+
[
|
| 212 |
+
"Nokia",
|
| 213 |
+
"""UL SINR = 4
|
| 214 |
+
PUSCH BLER = 5
|
| 215 |
+
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.Soft()) as demo:
|
| 227 |
+
|
| 228 |
+
gr.Markdown("""
|
| 229 |
+
# UL Interference Analyzer
|
| 230 |
+
|
| 231 |
+
AI-assisted LTE and 5G uplink interference analysis using KPI and PM counter indicators.
|
| 232 |
+
""")
|
| 233 |
+
|
| 234 |
+
with gr.Row():
|
| 235 |
+
|
| 236 |
+
vendor = gr.Dropdown(
|
| 237 |
+
choices=["Ericsson", "Nokia", "Samsung"],
|
| 238 |
+
value="Ericsson",
|
| 239 |
+
label="RAN Vendor"
|
| 240 |
+
)
|
| 241 |
+
|
| 242 |
+
data_input = gr.Textbox(
|
| 243 |
lines=14,
|
| 244 |
+
label="Paste KPI / PM Counter Data"
|
| 245 |
+
)
|
| 246 |
+
|
| 247 |
+
analyze_btn = gr.Button("Analyze")
|
| 248 |
+
|
| 249 |
+
output = gr.Markdown()
|
| 250 |
+
|
| 251 |
+
gr.Examples(
|
| 252 |
+
examples=examples,
|
| 253 |
+
inputs=[vendor, data_input]
|
| 254 |
+
)
|
| 255 |
+
|
| 256 |
+
analyze_btn.click(
|
| 257 |
+
fn=analyze_ul_interference,
|
| 258 |
+
inputs=[vendor, data_input],
|
| 259 |
+
outputs=output
|
| 260 |
+
)
|
| 261 |
|
| 262 |
demo.launch()
|