milewire commited on
Commit
e01b0f6
·
verified ·
1 Parent(s): 776eb13

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +147 -33
app.py CHANGED
@@ -1,44 +1,157 @@
1
  import gradio as gr
 
2
 
3
- def analyze_ul_interference(data):
 
 
 
 
 
4
 
5
- text = data.upper()
6
 
7
  findings = []
8
  causes = []
9
  actions = []
10
 
11
- if "UL SINR" in text or "SINR" in text:
12
- findings.append("Poor uplink SINR detected")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
 
14
- if "BLER" in text:
15
- findings.append("High uplink BLER condition detected")
16
 
17
- if "RTWP" in text:
18
- findings.append("Elevated RTWP/noise floor observed")
19
 
20
- if "UL PRB" in text:
21
- findings.append("High uplink resource utilization")
 
22
 
23
- causes = [
24
- "External uplink interference",
25
- "Passive Intermodulation (PIM)",
26
- "Overshooting sector",
27
- "Faulty radio or feeder path",
28
- "High uplink noise rise"
29
- ]
30
 
31
- actions = [
32
- "Review RTWP trend history",
33
- "Compare neighboring sector noise floor",
34
- "Validate feeder and jumper integrity",
35
- "Check uplink power control behavior",
36
- "Perform spectrum sweep if available",
37
- "Review recent site changes or maintenance"
38
- ]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
 
40
  result = f"""
41
- # UL Interference Analysis
 
 
 
 
 
 
42
 
43
  ## Findings
44
  {chr(10).join([f"- {x}" for x in findings])}
@@ -50,7 +163,7 @@ def analyze_ul_interference(data):
50
  {chr(10).join([f"- {x}" for x in actions])}
51
 
52
  ## Engineering Assessment
53
- Potential uplink interference condition identified based on submitted KPI and PM counter indicators.
54
  """
55
 
56
  return result
@@ -58,17 +171,18 @@ Potential uplink interference condition identified based on submitted KPI and PM
58
  demo = gr.Interface(
59
  fn=analyze_ul_interference,
60
  inputs=gr.Textbox(
61
- lines=12,
62
- label="Paste KPI / PM Counter Data",
63
  value="""UL SINR = -7
64
- PUSCH BLER = 32%
65
  RTWP = -95
66
- UL PRB = 88%
67
- CQI Avg = 4"""
 
68
  ),
69
  outputs=gr.Markdown(),
70
  title="UL Interference Analyzer",
71
- description="AI-assisted uplink interference analysis using LTE/5G KPI and PM counter indicators."
72
  )
73
 
74
  demo.launch()
 
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
+ def analyze_ul_interference(data):
12
 
13
  findings = []
14
  causes = []
15
  actions = []
16
 
17
+ severity = "LOW"
18
+ condition = "NORMAL"
19
+
20
+ ul_sinr = extract_value(data, "UL SINR")
21
+ rtwp = extract_value(data, "RTWP")
22
+ ul_prb = extract_value(data, "UL PRB")
23
+ dl_prb = extract_value(data, "DL PRB")
24
+ bler = extract_value(data, "PUSCH BLER")
25
+ cqi = extract_value(data, "CQI")
26
+
27
+ # =========================
28
+ # UL SINR ANALYSIS
29
+ # =========================
30
+
31
+ if ul_sinr is not None:
32
+
33
+ if ul_sinr < -5:
34
+ findings.append(f"Critical UL SINR degradation detected ({ul_sinr} dB)")
35
+ severity = "HIGH"
36
+
37
+ elif ul_sinr < 0:
38
+ findings.append(f"Poor UL SINR detected ({ul_sinr} dB)")
39
+ severity = "MEDIUM"
40
+
41
+ # =========================
42
+ # RTWP ANALYSIS
43
+ # =========================
44
+
45
+ if rtwp is not None:
46
+
47
+ if rtwp > -95:
48
+ findings.append(f"Severe RTWP elevation detected ({rtwp} dBm)")
49
+ severity = "HIGH"
50
+
51
+ elif rtwp > -100:
52
+ findings.append(f"Elevated RTWP/noise floor observed ({rtwp} dBm)")
53
+ severity = "MEDIUM"
54
+
55
+ # =========================
56
+ # BLER ANALYSIS
57
+ # =========================
58
+
59
+ if bler is not None:
60
+
61
+ if bler > 30:
62
+ findings.append(f"Critical PUSCH BLER condition ({bler}%)")
63
+ severity = "HIGH"
64
+
65
+ elif bler > 15:
66
+ findings.append(f"Elevated PUSCH BLER ({bler}%)")
67
+
68
+ # =========================
69
+ # CQI ANALYSIS
70
+ # =========================
71
 
72
+ if cqi is not None:
 
73
 
74
+ if cqi < 5:
75
+ findings.append(f"Low CQI detected ({cqi})")
76
 
77
+ # =========================
78
+ # PRB UTILIZATION
79
+ # =========================
80
 
81
+ congestion = False
82
+ interference = False
 
 
 
 
 
83
 
84
+ if ul_prb is not None:
85
+
86
+ if ul_prb > 85:
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
93
+ bler is not None and bler > 15
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
+
112
+ actions = [
113
+ "Review RTWP trend history",
114
+ "Compare neighboring sector RTWP",
115
+ "Inspect feeder and jumper path",
116
+ "Validate antenna alignment and RET",
117
+ "Perform spectrum sweep",
118
+ "Check recent maintenance activity"
119
+ ]
120
+
121
+ elif congestion:
122
+
123
+ condition = "LIKELY CAPACITY CONGESTION"
124
+
125
+ causes = [
126
+ "High uplink traffic demand",
127
+ "Sector loading imbalance",
128
+ "Subscriber concentration",
129
+ "Limited uplink scheduling capacity"
130
+ ]
131
+
132
+ actions = [
133
+ "Review busy-hour utilization trends",
134
+ "Evaluate load balancing",
135
+ "Assess carrier aggregation strategy",
136
+ "Review scheduler efficiency"
137
+ ]
138
+
139
+ else:
140
+
141
+ condition = "NO MAJOR UL IMPAIRMENT DETECTED"
142
+
143
+ actions = [
144
+ "Continue KPI monitoring"
145
+ ]
146
 
147
  result = f"""
148
+ # UL Interference Analyzer
149
+
150
+ ## Condition
151
+ **{condition}**
152
+
153
+ ## Severity
154
+ **{severity}**
155
 
156
  ## Findings
157
  {chr(10).join([f"- {x}" for x in findings])}
 
163
  {chr(10).join([f"- {x}" for x in actions])}
164
 
165
  ## Engineering Assessment
166
+ Analysis completed using uplink KPI and PM counter thresholds.
167
  """
168
 
169
  return result
 
171
  demo = gr.Interface(
172
  fn=analyze_ul_interference,
173
  inputs=gr.Textbox(
174
+ lines=14,
175
+ label="Paste LTE / 5G KPI and PM Counter Data",
176
  value="""UL SINR = -7
177
+ PUSCH BLER = 32
178
  RTWP = -95
179
+ UL PRB = 88
180
+ DL PRB = 42
181
+ CQI = 4"""
182
  ),
183
  outputs=gr.Markdown(),
184
  title="UL Interference Analyzer",
185
+ description="AI-assisted LTE and 5G uplink interference analysis using RF KPI and PM counter indicators."
186
  )
187
 
188
  demo.launch()