Update app.py
Browse files
app.py
CHANGED
|
@@ -75,37 +75,53 @@ def anomalies_detector(logs: str) -> str:
|
|
| 75 |
return output
|
| 76 |
|
| 77 |
|
| 78 |
-
# Custom CSS for dark
|
| 79 |
custom_css = """
|
| 80 |
:root {
|
| 81 |
-
--
|
| 82 |
-
--
|
| 83 |
-
--
|
| 84 |
-
--
|
|
|
|
| 85 |
--white: #FFFFFF;
|
| 86 |
-
--off-white: #
|
| 87 |
-
--light-gray: #
|
|
|
|
| 88 |
}
|
| 89 |
|
| 90 |
/* Main background */
|
| 91 |
.gradio-container {
|
| 92 |
-
background: linear-gradient(135deg, var(--deep-
|
| 93 |
font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 94 |
}
|
| 95 |
|
| 96 |
/* Header styling */
|
| 97 |
.contain {
|
| 98 |
background: rgba(255, 255, 255, 0.98) !important;
|
| 99 |
border-radius: 20px !important;
|
| 100 |
-
box-shadow: 0 20px 60px rgba(
|
| 101 |
padding: 2rem !important;
|
| 102 |
margin: 2rem auto !important;
|
| 103 |
max-width: 1400px !important;
|
|
|
|
| 104 |
}
|
| 105 |
|
| 106 |
/* Title styling */
|
| 107 |
h1 {
|
| 108 |
-
background: linear-gradient(135deg, var(--
|
| 109 |
-webkit-background-clip: text !important;
|
| 110 |
-webkit-text-fill-color: transparent !important;
|
| 111 |
background-clip: text !important;
|
|
@@ -113,11 +129,12 @@ h1 {
|
|
| 113 |
font-size: 2.5rem !important;
|
| 114 |
margin-bottom: 0.5rem !important;
|
| 115 |
text-align: center !important;
|
|
|
|
| 116 |
}
|
| 117 |
|
| 118 |
/* Description text */
|
| 119 |
.prose p {
|
| 120 |
-
color: var(--
|
| 121 |
font-size: 1.1rem !important;
|
| 122 |
text-align: center !important;
|
| 123 |
margin-bottom: 1.5rem !important;
|
|
@@ -125,23 +142,24 @@ h1 {
|
|
| 125 |
|
| 126 |
/* Input/Output boxes */
|
| 127 |
.input-text, .output-text, textarea {
|
| 128 |
-
border: 2px solid var(--
|
| 129 |
border-radius: 12px !important;
|
| 130 |
background: var(--white) !important;
|
| 131 |
font-family: 'Fira Code', 'Courier New', monospace !important;
|
| 132 |
font-size: 0.95rem !important;
|
| 133 |
transition: all 0.3s ease !important;
|
|
|
|
| 134 |
}
|
| 135 |
|
| 136 |
.input-text:focus, textarea:focus {
|
| 137 |
-
border-color: var(--
|
| 138 |
-
box-shadow: 0 0 0 3px rgba(
|
| 139 |
outline: none !important;
|
| 140 |
}
|
| 141 |
|
| 142 |
/* Labels */
|
| 143 |
label {
|
| 144 |
-
color: var(--
|
| 145 |
font-weight: 600 !important;
|
| 146 |
font-size: 1rem !important;
|
| 147 |
margin-bottom: 0.5rem !important;
|
|
@@ -149,7 +167,7 @@ label {
|
|
| 149 |
|
| 150 |
/* Submit button */
|
| 151 |
.submit-button, button[id$="-submit-button"] {
|
| 152 |
-
background: linear-gradient(135deg, var(--
|
| 153 |
color: var(--white) !important;
|
| 154 |
border: none !important;
|
| 155 |
border-radius: 12px !important;
|
|
@@ -158,19 +176,20 @@ label {
|
|
| 158 |
font-size: 1rem !important;
|
| 159 |
cursor: pointer !important;
|
| 160 |
transition: all 0.3s ease !important;
|
| 161 |
-
box-shadow: 0 4px 15px rgba(
|
| 162 |
}
|
| 163 |
|
| 164 |
.submit-button:hover, button[id$="-submit-button"]:hover {
|
| 165 |
transform: translateY(-2px) !important;
|
| 166 |
-
box-shadow: 0 6px 20px rgba(
|
|
|
|
| 167 |
}
|
| 168 |
|
| 169 |
/* Clear button */
|
| 170 |
.clear-button, button.secondary {
|
| 171 |
background: var(--white) !important;
|
| 172 |
-
color: var(--
|
| 173 |
-
border: 2px solid var(--
|
| 174 |
border-radius: 12px !important;
|
| 175 |
padding: 0.75rem 2rem !important;
|
| 176 |
font-weight: 600 !important;
|
|
@@ -178,9 +197,10 @@ label {
|
|
| 178 |
}
|
| 179 |
|
| 180 |
.clear-button:hover, button.secondary:hover {
|
| 181 |
-
background: var(--
|
| 182 |
color: var(--white) !important;
|
| 183 |
transform: translateY(-2px) !important;
|
|
|
|
| 184 |
}
|
| 185 |
|
| 186 |
/* Output markdown styling */
|
|
@@ -188,22 +208,24 @@ label {
|
|
| 188 |
background: var(--off-white) !important;
|
| 189 |
padding: 1.5rem !important;
|
| 190 |
border-radius: 12px !important;
|
| 191 |
-
border-left: 4px solid var(--
|
|
|
|
| 192 |
}
|
| 193 |
|
| 194 |
.markdown-text code {
|
| 195 |
background: var(--white) !important;
|
| 196 |
padding: 0.2rem 0.4rem !important;
|
| 197 |
border-radius: 4px !important;
|
| 198 |
-
color: var(--
|
| 199 |
-
border: 1px solid var(--
|
| 200 |
}
|
| 201 |
|
| 202 |
.markdown-text pre {
|
| 203 |
background: var(--white) !important;
|
| 204 |
-
border: 2px solid var(--
|
| 205 |
border-radius: 8px !important;
|
| 206 |
padding: 1rem !important;
|
|
|
|
| 207 |
}
|
| 208 |
|
| 209 |
/* Footer */
|
|
@@ -212,10 +234,11 @@ footer {
|
|
| 212 |
color: var(--white) !important;
|
| 213 |
text-align: center !important;
|
| 214 |
padding: 2rem !important;
|
|
|
|
| 215 |
}
|
| 216 |
|
| 217 |
footer a {
|
| 218 |
-
color: var(--
|
| 219 |
text-decoration: underline !important;
|
| 220 |
}
|
| 221 |
|
|
@@ -224,7 +247,8 @@ footer a {
|
|
| 224 |
background: var(--off-white) !important;
|
| 225 |
border-radius: 12px !important;
|
| 226 |
padding: 1rem !important;
|
| 227 |
-
border: 2px solid var(--
|
|
|
|
| 228 |
}
|
| 229 |
|
| 230 |
/* Scrollbar styling */
|
|
@@ -238,12 +262,34 @@ footer a {
|
|
| 238 |
}
|
| 239 |
|
| 240 |
::-webkit-scrollbar-thumb {
|
| 241 |
-
background: var(--
|
| 242 |
border-radius: 5px !important;
|
|
|
|
| 243 |
}
|
| 244 |
|
| 245 |
::-webkit-scrollbar-thumb:hover {
|
| 246 |
-
background: var(--
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 247 |
}
|
| 248 |
"""
|
| 249 |
|
|
@@ -285,8 +331,8 @@ demo = gr.Interface(
|
|
| 285 |
examples=example_logs,
|
| 286 |
css=custom_css,
|
| 287 |
theme=gr.themes.Soft(
|
| 288 |
-
primary_hue="
|
| 289 |
-
secondary_hue="
|
| 290 |
),
|
| 291 |
allow_flagging="never",
|
| 292 |
analytics_enabled=False
|
|
@@ -299,62 +345,4 @@ if __name__ == "__main__":
|
|
| 299 |
server_port=7860,
|
| 300 |
share=True,
|
| 301 |
show_error=True
|
| 302 |
-
)
|
| 303 |
-
|
| 304 |
-
|
| 305 |
-
|
| 306 |
-
# import gradio as gr
|
| 307 |
-
# from transformers import pipeline
|
| 308 |
-
# import re
|
| 309 |
-
|
| 310 |
-
# def anomalies_detector(logs: str) -> list[str]:
|
| 311 |
-
# """
|
| 312 |
-
# Detect anomalies in software logs using a Hugging Face transformer model.
|
| 313 |
-
# This function uses a specialized model trained to identify unusual patterns
|
| 314 |
-
# in system logs, such as:
|
| 315 |
-
# - Error messages
|
| 316 |
-
# - Unusual system states
|
| 317 |
-
# - Security-related events
|
| 318 |
-
# - Performance anomalies
|
| 319 |
-
# - Unexpected behavior patterns
|
| 320 |
-
|
| 321 |
-
# Args:
|
| 322 |
-
# logs (str): The input text containing log entries
|
| 323 |
-
|
| 324 |
-
# Returns:
|
| 325 |
-
# list[tuple[int, str]]: List of tuples containing (line_number, anomalous_text)
|
| 326 |
-
# """
|
| 327 |
-
# # Initialize the text classification pipeline with a proper classification model
|
| 328 |
-
# classifier = pipeline("text-classification",
|
| 329 |
-
# model="distilbert/distilbert-base-uncased-finetuned-sst-2-english")
|
| 330 |
-
|
| 331 |
-
|
| 332 |
-
# # Split logs into lines
|
| 333 |
-
# log_lines = logs.split('\n')
|
| 334 |
-
# anomalies = []
|
| 335 |
-
|
| 336 |
-
# # Process each line
|
| 337 |
-
# for line_num, line in enumerate(log_lines, 1):
|
| 338 |
-
# if not line.strip(): # Skip empty lines
|
| 339 |
-
# continue
|
| 340 |
-
|
| 341 |
-
# # Get classification result
|
| 342 |
-
# results = classifier(line)
|
| 343 |
-
|
| 344 |
-
|
| 345 |
-
# for log, res in zip(logs, results):
|
| 346 |
-
# anomalies.append(f"{log} => {res}")
|
| 347 |
-
# return anomalies
|
| 348 |
-
|
| 349 |
-
# # Create a standard Gradio interface
|
| 350 |
-
# demo = gr.Interface(
|
| 351 |
-
# fn=anomalies_detector,
|
| 352 |
-
# inputs="textbox",
|
| 353 |
-
# outputs="text",
|
| 354 |
-
# title="Log Anomaly Detector",
|
| 355 |
-
# description="Enter log entries to detect anomalous patterns using BERT Model. The system will identify unusual patterns, errors, and potential issues in your logs."
|
| 356 |
-
# )
|
| 357 |
-
|
| 358 |
-
# # Launch both the Gradio web interface and the MCP server
|
| 359 |
-
# if __name__ == "__main__":
|
| 360 |
-
# demo.launch(mcp_server=True, share=True)
|
|
|
|
| 75 |
return output
|
| 76 |
|
| 77 |
|
| 78 |
+
# Custom CSS for dark navy blue and electric blue theme
|
| 79 |
custom_css = """
|
| 80 |
:root {
|
| 81 |
+
--electric-blue: #00D4FF;
|
| 82 |
+
--bright-blue: #0099FF;
|
| 83 |
+
--navy-blue: #001F3F;
|
| 84 |
+
--dark-navy: #001129;
|
| 85 |
+
--deep-navy: #000814;
|
| 86 |
--white: #FFFFFF;
|
| 87 |
+
--off-white: #F8FCFF;
|
| 88 |
+
--light-gray: #E8F4F8;
|
| 89 |
+
--cyber-glow: rgba(0, 212, 255, 0.3);
|
| 90 |
}
|
| 91 |
|
| 92 |
/* Main background */
|
| 93 |
.gradio-container {
|
| 94 |
+
background: linear-gradient(135deg, var(--deep-navy) 0%, var(--dark-navy) 50%, var(--navy-blue) 100%) !important;
|
| 95 |
font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important;
|
| 96 |
+
position: relative !important;
|
| 97 |
+
}
|
| 98 |
+
|
| 99 |
+
.gradio-container::before {
|
| 100 |
+
content: '' !important;
|
| 101 |
+
position: absolute !important;
|
| 102 |
+
top: 0 !important;
|
| 103 |
+
left: 0 !important;
|
| 104 |
+
right: 0 !important;
|
| 105 |
+
bottom: 0 !important;
|
| 106 |
+
background: radial-gradient(circle at 20% 50%, rgba(0, 212, 255, 0.08) 0%, transparent 50%),
|
| 107 |
+
radial-gradient(circle at 80% 80%, rgba(0, 153, 255, 0.06) 0%, transparent 50%) !important;
|
| 108 |
+
pointer-events: none !important;
|
| 109 |
}
|
| 110 |
|
| 111 |
/* Header styling */
|
| 112 |
.contain {
|
| 113 |
background: rgba(255, 255, 255, 0.98) !important;
|
| 114 |
border-radius: 20px !important;
|
| 115 |
+
box-shadow: 0 20px 60px rgba(0, 212, 255, 0.2), 0 0 40px rgba(0, 153, 255, 0.1) !important;
|
| 116 |
padding: 2rem !important;
|
| 117 |
margin: 2rem auto !important;
|
| 118 |
max-width: 1400px !important;
|
| 119 |
+
border: 1px solid rgba(0, 212, 255, 0.1) !important;
|
| 120 |
}
|
| 121 |
|
| 122 |
/* Title styling */
|
| 123 |
h1 {
|
| 124 |
+
background: linear-gradient(135deg, var(--bright-blue), var(--electric-blue)) !important;
|
| 125 |
-webkit-background-clip: text !important;
|
| 126 |
-webkit-text-fill-color: transparent !important;
|
| 127 |
background-clip: text !important;
|
|
|
|
| 129 |
font-size: 2.5rem !important;
|
| 130 |
margin-bottom: 0.5rem !important;
|
| 131 |
text-align: center !important;
|
| 132 |
+
filter: drop-shadow(0 0 20px rgba(0, 212, 255, 0.3)) !important;
|
| 133 |
}
|
| 134 |
|
| 135 |
/* Description text */
|
| 136 |
.prose p {
|
| 137 |
+
color: var(--navy-blue) !important;
|
| 138 |
font-size: 1.1rem !important;
|
| 139 |
text-align: center !important;
|
| 140 |
margin-bottom: 1.5rem !important;
|
|
|
|
| 142 |
|
| 143 |
/* Input/Output boxes */
|
| 144 |
.input-text, .output-text, textarea {
|
| 145 |
+
border: 2px solid var(--bright-blue) !important;
|
| 146 |
border-radius: 12px !important;
|
| 147 |
background: var(--white) !important;
|
| 148 |
font-family: 'Fira Code', 'Courier New', monospace !important;
|
| 149 |
font-size: 0.95rem !important;
|
| 150 |
transition: all 0.3s ease !important;
|
| 151 |
+
box-shadow: 0 2px 10px rgba(0, 153, 255, 0.1) !important;
|
| 152 |
}
|
| 153 |
|
| 154 |
.input-text:focus, textarea:focus {
|
| 155 |
+
border-color: var(--electric-blue) !important;
|
| 156 |
+
box-shadow: 0 0 0 3px var(--cyber-glow), 0 0 20px rgba(0, 212, 255, 0.2) !important;
|
| 157 |
outline: none !important;
|
| 158 |
}
|
| 159 |
|
| 160 |
/* Labels */
|
| 161 |
label {
|
| 162 |
+
color: var(--navy-blue) !important;
|
| 163 |
font-weight: 600 !important;
|
| 164 |
font-size: 1rem !important;
|
| 165 |
margin-bottom: 0.5rem !important;
|
|
|
|
| 167 |
|
| 168 |
/* Submit button */
|
| 169 |
.submit-button, button[id$="-submit-button"] {
|
| 170 |
+
background: linear-gradient(135deg, var(--bright-blue), var(--electric-blue)) !important;
|
| 171 |
color: var(--white) !important;
|
| 172 |
border: none !important;
|
| 173 |
border-radius: 12px !important;
|
|
|
|
| 176 |
font-size: 1rem !important;
|
| 177 |
cursor: pointer !important;
|
| 178 |
transition: all 0.3s ease !important;
|
| 179 |
+
box-shadow: 0 4px 15px rgba(0, 212, 255, 0.3), 0 0 20px rgba(0, 153, 255, 0.2) !important;
|
| 180 |
}
|
| 181 |
|
| 182 |
.submit-button:hover, button[id$="-submit-button"]:hover {
|
| 183 |
transform: translateY(-2px) !important;
|
| 184 |
+
box-shadow: 0 6px 20px rgba(0, 212, 255, 0.4), 0 0 30px rgba(0, 153, 255, 0.3) !important;
|
| 185 |
+
filter: brightness(1.1) !important;
|
| 186 |
}
|
| 187 |
|
| 188 |
/* Clear button */
|
| 189 |
.clear-button, button.secondary {
|
| 190 |
background: var(--white) !important;
|
| 191 |
+
color: var(--navy-blue) !important;
|
| 192 |
+
border: 2px solid var(--bright-blue) !important;
|
| 193 |
border-radius: 12px !important;
|
| 194 |
padding: 0.75rem 2rem !important;
|
| 195 |
font-weight: 600 !important;
|
|
|
|
| 197 |
}
|
| 198 |
|
| 199 |
.clear-button:hover, button.secondary:hover {
|
| 200 |
+
background: var(--electric-blue) !important;
|
| 201 |
color: var(--white) !important;
|
| 202 |
transform: translateY(-2px) !important;
|
| 203 |
+
box-shadow: 0 4px 15px rgba(0, 212, 255, 0.3) !important;
|
| 204 |
}
|
| 205 |
|
| 206 |
/* Output markdown styling */
|
|
|
|
| 208 |
background: var(--off-white) !important;
|
| 209 |
padding: 1.5rem !important;
|
| 210 |
border-radius: 12px !important;
|
| 211 |
+
border-left: 4px solid var(--electric-blue) !important;
|
| 212 |
+
box-shadow: 0 2px 10px rgba(0, 153, 255, 0.1) !important;
|
| 213 |
}
|
| 214 |
|
| 215 |
.markdown-text code {
|
| 216 |
background: var(--white) !important;
|
| 217 |
padding: 0.2rem 0.4rem !important;
|
| 218 |
border-radius: 4px !important;
|
| 219 |
+
color: var(--navy-blue) !important;
|
| 220 |
+
border: 1px solid var(--bright-blue) !important;
|
| 221 |
}
|
| 222 |
|
| 223 |
.markdown-text pre {
|
| 224 |
background: var(--white) !important;
|
| 225 |
+
border: 2px solid var(--bright-blue) !important;
|
| 226 |
border-radius: 8px !important;
|
| 227 |
padding: 1rem !important;
|
| 228 |
+
box-shadow: inset 0 2px 8px rgba(0, 153, 255, 0.05) !important;
|
| 229 |
}
|
| 230 |
|
| 231 |
/* Footer */
|
|
|
|
| 234 |
color: var(--white) !important;
|
| 235 |
text-align: center !important;
|
| 236 |
padding: 2rem !important;
|
| 237 |
+
text-shadow: 0 0 10px rgba(0, 212, 255, 0.5) !important;
|
| 238 |
}
|
| 239 |
|
| 240 |
footer a {
|
| 241 |
+
color: var(--electric-blue) !important;
|
| 242 |
text-decoration: underline !important;
|
| 243 |
}
|
| 244 |
|
|
|
|
| 247 |
background: var(--off-white) !important;
|
| 248 |
border-radius: 12px !important;
|
| 249 |
padding: 1rem !important;
|
| 250 |
+
border: 2px solid var(--bright-blue) !important;
|
| 251 |
+
box-shadow: 0 2px 10px rgba(0, 153, 255, 0.1) !important;
|
| 252 |
}
|
| 253 |
|
| 254 |
/* Scrollbar styling */
|
|
|
|
| 262 |
}
|
| 263 |
|
| 264 |
::-webkit-scrollbar-thumb {
|
| 265 |
+
background: linear-gradient(180deg, var(--electric-blue), var(--bright-blue)) !important;
|
| 266 |
border-radius: 5px !important;
|
| 267 |
+
box-shadow: 0 0 10px rgba(0, 212, 255, 0.3) !important;
|
| 268 |
}
|
| 269 |
|
| 270 |
::-webkit-scrollbar-thumb:hover {
|
| 271 |
+
background: var(--electric-blue) !important;
|
| 272 |
+
box-shadow: 0 0 15px rgba(0, 212, 255, 0.5) !important;
|
| 273 |
+
}
|
| 274 |
+
|
| 275 |
+
/* Cyber glow effects */
|
| 276 |
+
.submit-button::before, button[id$="-submit-button"]::before {
|
| 277 |
+
content: '' !important;
|
| 278 |
+
position: absolute !important;
|
| 279 |
+
top: -2px !important;
|
| 280 |
+
left: -2px !important;
|
| 281 |
+
right: -2px !important;
|
| 282 |
+
bottom: -2px !important;
|
| 283 |
+
background: linear-gradient(45deg, var(--electric-blue), var(--bright-blue)) !important;
|
| 284 |
+
border-radius: 12px !important;
|
| 285 |
+
z-index: -1 !important;
|
| 286 |
+
opacity: 0 !important;
|
| 287 |
+
transition: opacity 0.3s ease !important;
|
| 288 |
+
filter: blur(10px) !important;
|
| 289 |
+
}
|
| 290 |
+
|
| 291 |
+
.submit-button:hover::before, button[id$="-submit-button"]:hover::before {
|
| 292 |
+
opacity: 0.7 !important;
|
| 293 |
}
|
| 294 |
"""
|
| 295 |
|
|
|
|
| 331 |
examples=example_logs,
|
| 332 |
css=custom_css,
|
| 333 |
theme=gr.themes.Soft(
|
| 334 |
+
primary_hue="blue",
|
| 335 |
+
secondary_hue="cyan",
|
| 336 |
),
|
| 337 |
allow_flagging="never",
|
| 338 |
analytics_enabled=False
|
|
|
|
| 345 |
server_port=7860,
|
| 346 |
share=True,
|
| 347 |
show_error=True
|
| 348 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|