Update app.py
Browse files
app.py
CHANGED
|
@@ -1,652 +1,510 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
#
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
#
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
#
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
from
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
)
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
#
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
padding:
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
}
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
box-shadow: 0
|
| 225 |
-
|
| 226 |
-
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
|
| 234 |
-
|
| 235 |
-
|
| 236 |
-
|
| 237 |
-
|
| 238 |
-
|
| 239 |
-
|
| 240 |
-
|
| 241 |
-
|
| 242 |
-
|
| 243 |
-
|
| 244 |
-
|
| 245 |
-
|
| 246 |
-
|
| 247 |
-
|
| 248 |
-
|
| 249 |
-
|
| 250 |
-
|
| 251 |
-
|
| 252 |
-
|
| 253 |
-
|
| 254 |
-
|
| 255 |
-
|
| 256 |
-
|
| 257 |
-
|
| 258 |
-
|
| 259 |
-
|
| 260 |
-
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
|
| 264 |
-
|
| 265 |
-
|
| 266 |
-
|
| 267 |
-
|
| 268 |
-
|
| 269 |
-
|
| 270 |
-
|
| 271 |
-
|
| 272 |
-
|
| 273 |
-
|
| 274 |
-
|
| 275 |
-
|
| 276 |
-
|
| 277 |
-
|
| 278 |
-
|
| 279 |
-
|
| 280 |
-
|
| 281 |
-
|
| 282 |
-
|
| 283 |
-
|
| 284 |
-
|
| 285 |
-
|
| 286 |
-
|
| 287 |
-
}
|
| 288 |
-
|
| 289 |
-
|
| 290 |
-
|
| 291 |
-
|
| 292 |
-
|
| 293 |
-
|
| 294 |
-
|
| 295 |
-
|
| 296 |
-
|
| 297 |
-
}
|
| 298 |
-
|
| 299 |
-
|
| 300 |
-
|
| 301 |
-
|
| 302 |
-
|
| 303 |
-
|
| 304 |
-
|
| 305 |
-
|
| 306 |
-
|
| 307 |
-
|
| 308 |
-
|
| 309 |
-
|
| 310 |
-
}
|
| 311 |
-
|
| 312 |
-
|
| 313 |
-
color:
|
| 314 |
-
|
| 315 |
-
|
| 316 |
-
|
| 317 |
-
|
| 318 |
-
|
| 319 |
-
|
| 320 |
-
|
| 321 |
-
|
| 322 |
-
|
| 323 |
-
|
| 324 |
-
|
| 325 |
-
|
| 326 |
-
|
| 327 |
-
|
| 328 |
-
|
| 329 |
-
}
|
| 330 |
-
}
|
| 331 |
-
|
| 332 |
-
/*
|
| 333 |
-
.
|
| 334 |
-
|
| 335 |
-
|
| 336 |
-
|
| 337 |
-
|
| 338 |
-
|
| 339 |
-
|
| 340 |
-
|
| 341 |
-
|
| 342 |
-
|
| 343 |
-
|
| 344 |
-
|
| 345 |
-
|
| 346 |
-
|
| 347 |
-
|
| 348 |
-
|
| 349 |
-
|
| 350 |
-
|
| 351 |
-
|
| 352 |
-
|
| 353 |
-
|
| 354 |
-
|
| 355 |
-
|
| 356 |
-
|
| 357 |
-
|
| 358 |
-
|
| 359 |
-
100% {
|
| 360 |
-
transform: scale(1)
|
| 361 |
-
|
| 362 |
-
}
|
| 363 |
-
|
| 364 |
-
|
| 365 |
-
|
| 366 |
-
|
| 367 |
-
|
| 368 |
-
|
| 369 |
-
|
| 370 |
-
|
| 371 |
-
|
| 372 |
-
|
| 373 |
-
|
| 374 |
-
|
| 375 |
-
|
| 376 |
-
|
| 377 |
-
|
| 378 |
-
|
| 379 |
-
|
| 380 |
-
|
| 381 |
-
|
| 382 |
-
|
| 383 |
-
|
| 384 |
-
|
| 385 |
-
|
| 386 |
-
|
| 387 |
-
|
| 388 |
-
|
| 389 |
-
|
| 390 |
-
|
| 391 |
-
|
| 392 |
-
|
| 393 |
-
|
| 394 |
-
|
| 395 |
-
|
| 396 |
-
|
| 397 |
-
|
| 398 |
-
|
| 399 |
-
|
| 400 |
-
|
| 401 |
-
|
| 402 |
-
|
| 403 |
-
|
| 404 |
-
|
| 405 |
-
|
| 406 |
-
|
| 407 |
-
|
| 408 |
-
|
| 409 |
-
|
| 410 |
-
|
| 411 |
-
}
|
| 412 |
-
|
| 413 |
-
|
| 414 |
-
|
| 415 |
-
|
| 416 |
-
|
| 417 |
-
|
| 418 |
-
|
| 419 |
-
|
| 420 |
-
|
| 421 |
-
|
| 422 |
-
|
| 423 |
-
|
| 424 |
-
|
| 425 |
-
|
| 426 |
-
|
| 427 |
-
|
| 428 |
-
|
| 429 |
-
|
| 430 |
-
|
| 431 |
-
|
| 432 |
-
|
| 433 |
-
|
| 434 |
-
|
| 435 |
-
|
| 436 |
-
|
| 437 |
-
|
| 438 |
-
|
| 439 |
-
|
| 440 |
-
|
| 441 |
-
|
| 442 |
-
|
| 443 |
-
|
| 444 |
-
|
| 445 |
-
|
| 446 |
-
|
| 447 |
-
|
| 448 |
-
|
| 449 |
-
|
| 450 |
-
|
| 451 |
-
|
| 452 |
-
|
| 453 |
-
|
| 454 |
-
|
| 455 |
-
|
| 456 |
-
|
| 457 |
-
|
| 458 |
-
|
| 459 |
-
|
| 460 |
-
|
| 461 |
-
|
| 462 |
-
|
| 463 |
-
|
| 464 |
-
|
| 465 |
-
|
| 466 |
-
|
| 467 |
-
|
| 468 |
-
|
| 469 |
-
|
| 470 |
-
|
| 471 |
-
|
| 472 |
-
}
|
| 473 |
-
|
| 474 |
-
|
| 475 |
-
|
| 476 |
-
|
| 477 |
-
|
| 478 |
-
|
| 479 |
-
|
| 480 |
-
|
| 481 |
-
|
| 482 |
-
|
| 483 |
-
|
| 484 |
-
|
| 485 |
-
|
| 486 |
-
|
| 487 |
-
|
| 488 |
-
|
| 489 |
-
|
| 490 |
-
|
| 491 |
-
|
| 492 |
-
|
| 493 |
-
|
| 494 |
-
|
| 495 |
-
|
| 496 |
-
|
| 497 |
-
|
| 498 |
-
|
| 499 |
-
|
| 500 |
-
|
| 501 |
-
|
| 502 |
-
|
| 503 |
-
|
| 504 |
-
|
| 505 |
-
|
| 506 |
-
|
| 507 |
-
|
| 508 |
-
|
| 509 |
-
|
| 510 |
-
|
| 511 |
-
/* Text */
|
| 512 |
-
.safe-text, .bully-text {
|
| 513 |
-
font-size: 28px;
|
| 514 |
-
font-weight: 800;
|
| 515 |
-
margin-bottom: 15px;
|
| 516 |
-
animation: fadeInDown 0.8s ease-out 0.2s both;
|
| 517 |
-
letter-spacing: 0.5px;
|
| 518 |
-
}
|
| 519 |
-
|
| 520 |
-
@keyframes fadeInDown {
|
| 521 |
-
from {
|
| 522 |
-
opacity: 0;
|
| 523 |
-
transform: translateY(-20px);
|
| 524 |
-
}
|
| 525 |
-
to {
|
| 526 |
-
opacity: 1;
|
| 527 |
-
transform: translateY(0);
|
| 528 |
-
}
|
| 529 |
-
}
|
| 530 |
-
|
| 531 |
-
.label-badge {
|
| 532 |
-
display: inline-block;
|
| 533 |
-
background: rgba(255, 107, 107, 0.2);
|
| 534 |
-
border: 2px solid rgba(255, 107, 107, 0.5);
|
| 535 |
-
padding: 10px 20px;
|
| 536 |
-
border-radius: 25px;
|
| 537 |
-
margin-bottom: 18px;
|
| 538 |
-
font-size: 14px;
|
| 539 |
-
font-weight: 700;
|
| 540 |
-
animation: zoomIn 0.7s ease-out 0.3s both;
|
| 541 |
-
box-shadow: 0 5px 20px rgba(255, 107, 107, 0.2);
|
| 542 |
-
}
|
| 543 |
-
|
| 544 |
-
@keyframes zoomIn {
|
| 545 |
-
from {
|
| 546 |
-
opacity: 0;
|
| 547 |
-
transform: scale(0.3);
|
| 548 |
-
}
|
| 549 |
-
to {
|
| 550 |
-
opacity: 1;
|
| 551 |
-
transform: scale(1);
|
| 552 |
-
}
|
| 553 |
-
}
|
| 554 |
-
|
| 555 |
-
/* Confidence Bar */
|
| 556 |
-
.confidence-bar {
|
| 557 |
-
width: 100%;
|
| 558 |
-
height: 10px;
|
| 559 |
-
background: rgba(255, 255, 255, 0.1);
|
| 560 |
-
border-radius: 12px;
|
| 561 |
-
margin-bottom: 15px;
|
| 562 |
-
overflow: hidden;
|
| 563 |
-
animation: fadeIn 0.8s ease-out 0.1s both;
|
| 564 |
-
border: 1px solid rgba(255, 255, 255, 0.2);
|
| 565 |
-
box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.3);
|
| 566 |
-
}
|
| 567 |
-
|
| 568 |
-
.confidence-fill {
|
| 569 |
-
height: 100%;
|
| 570 |
-
border-radius: 12px;
|
| 571 |
-
transition: width 1.2s cubic-bezier(0.34, 1.56, 0.64, 1);
|
| 572 |
-
animation: fillWidth 1.2s ease-out;
|
| 573 |
-
}
|
| 574 |
-
|
| 575 |
-
@keyframes fillWidth {
|
| 576 |
-
from {
|
| 577 |
-
width: 0 !important;
|
| 578 |
-
}
|
| 579 |
-
}
|
| 580 |
-
|
| 581 |
-
.safe-fill {
|
| 582 |
-
background: linear-gradient(90deg, #00ff64, #00d452, #00ff64);
|
| 583 |
-
background-size: 200% 200%;
|
| 584 |
-
box-shadow: 0 0 25px rgba(0, 255, 100, 0.8), inset 0 0 10px rgba(255, 255, 255, 0.3);
|
| 585 |
-
animation: fillWidth 1.2s ease-out, shimmer 2s ease-in-out infinite;
|
| 586 |
-
}
|
| 587 |
-
|
| 588 |
-
.bully-fill {
|
| 589 |
-
background: linear-gradient(90deg, #ff6b6b, #ff4444, #ff6b6b);
|
| 590 |
-
background-size: 200% 200%;
|
| 591 |
-
box-shadow: 0 0 25px rgba(255, 107, 107, 0.8), inset 0 0 10px rgba(255, 255, 255, 0.3);
|
| 592 |
-
animation: fillWidth 1.2s ease-out, shimmer 2s ease-in-out infinite;
|
| 593 |
-
}
|
| 594 |
-
|
| 595 |
-
@keyframes shimmer {
|
| 596 |
-
0%, 100% {background-position: 0% 50%;}
|
| 597 |
-
50% {background-position: 100% 50%;}
|
| 598 |
-
}
|
| 599 |
-
|
| 600 |
-
.confidence-score {
|
| 601 |
-
font-size: 15px;
|
| 602 |
-
opacity: 0.9;
|
| 603 |
-
animation: fadeIn 0.8s ease-out 0.4s both;
|
| 604 |
-
font-weight: 600;
|
| 605 |
-
letter-spacing: 0.5px;
|
| 606 |
-
}
|
| 607 |
-
|
| 608 |
-
@keyframes fadeIn {
|
| 609 |
-
from {
|
| 610 |
-
opacity: 0;
|
| 611 |
-
}
|
| 612 |
-
to {
|
| 613 |
-
opacity: 1;
|
| 614 |
-
}
|
| 615 |
-
}
|
| 616 |
-
|
| 617 |
-
/* Responsive */
|
| 618 |
-
@media (max-width: 768px) {
|
| 619 |
-
.title {
|
| 620 |
-
font-size: 36px;
|
| 621 |
-
}
|
| 622 |
-
|
| 623 |
-
.safe, .bully {
|
| 624 |
-
padding: 25px;
|
| 625 |
-
}
|
| 626 |
-
|
| 627 |
-
html, body {
|
| 628 |
-
background-size: 600% 600%;
|
| 629 |
-
}
|
| 630 |
-
}
|
| 631 |
-
""") as demo:
|
| 632 |
-
gr.Markdown("<div class='title'>🛡️ Cyberbullying Detection System</div>")
|
| 633 |
-
gr.Markdown("<div class='subtitle'>End-to-end NLP system for detecting cyberbullying, including religion-based abuse</div>")
|
| 634 |
-
|
| 635 |
-
with gr.Group():
|
| 636 |
-
text_input = gr.Textbox(
|
| 637 |
-
lines=4,
|
| 638 |
-
placeholder="Enter a message to analyze...",
|
| 639 |
-
label="Input Text",
|
| 640 |
-
elem_classes="textbox-container"
|
| 641 |
-
)
|
| 642 |
-
detect_btn = gr.Button("🔍 Detect", variant="primary")
|
| 643 |
-
|
| 644 |
-
output = gr.HTML()
|
| 645 |
-
|
| 646 |
-
detect_btn.click(
|
| 647 |
-
fn=predict,
|
| 648 |
-
inputs=text_input,
|
| 649 |
-
outputs=output
|
| 650 |
-
)
|
| 651 |
-
|
| 652 |
demo.launch()
|
|
|
|
| 1 |
+
|
| 2 |
+
|
| 3 |
+
# gradio_app.py
|
| 4 |
+
|
| 5 |
+
import gradio as gr
|
| 6 |
+
from transformers import AutoTokenizer, AutoModelForSequenceClassification, pipeline
|
| 7 |
+
# ---------------- Load Model ----------------
|
| 8 |
+
def load_model():
|
| 9 |
+
model_path = "."
|
| 10 |
+
tokenizer = AutoTokenizer.from_pretrained(model_path)
|
| 11 |
+
model = AutoModelForSequenceClassification.from_pretrained(model_path)
|
| 12 |
+
return pipeline(
|
| 13 |
+
"text-classification",
|
| 14 |
+
model=model,
|
| 15 |
+
tokenizer=tokenizer,
|
| 16 |
+
return_all_scores=True
|
| 17 |
+
)
|
| 18 |
+
classifier = load_model()
|
| 19 |
+
# ---------------- Prediction Logic ----------------
|
| 20 |
+
def predict(text):
|
| 21 |
+
if not text.strip():
|
| 22 |
+
return "<div class='warn'>⚠️ Please enter some text.</div>"
|
| 23 |
+
results = classifier(text)[0]
|
| 24 |
+
best = max(results, key=lambda x: x["score"])
|
| 25 |
+
label = best["label"]
|
| 26 |
+
score = best["score"]
|
| 27 |
+
if label.lower() == "not_cyberbullying":
|
| 28 |
+
return f"""
|
| 29 |
+
<div class='safe'>
|
| 30 |
+
<div class='checkmark'>✅</div>
|
| 31 |
+
<div class='safe-text'>Safe Message</div>
|
| 32 |
+
<div class='confidence-bar'>
|
| 33 |
+
<div class='confidence-fill safe-fill' style='width: {score*100}%'></div>
|
| 34 |
+
</div>
|
| 35 |
+
<span class='confidence-score'>Confidence: {score:.2%}</span>
|
| 36 |
+
</div>
|
| 37 |
+
"""
|
| 38 |
+
else:
|
| 39 |
+
return f"""
|
| 40 |
+
<div class='bully'>
|
| 41 |
+
<div class='warning-icon'>⚠️</div>
|
| 42 |
+
<div class='bully-text'>Cyberbullying Detected</div>
|
| 43 |
+
<div class='label-badge'>{label}</div>
|
| 44 |
+
<div class='confidence-bar'>
|
| 45 |
+
<div class='confidence-fill bully-fill' style='width: {score*100}%'></div>
|
| 46 |
+
</div>
|
| 47 |
+
<span class='confidence-score'>Confidence: {score:.2%}</span>
|
| 48 |
+
</div>
|
| 49 |
+
"""
|
| 50 |
+
# ---------------- UI ----------------
|
| 51 |
+
with gr.Blocks(theme=gr.themes.Soft(), css="""
|
| 52 |
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css"/>
|
| 53 |
+
|
| 54 |
+
* {
|
| 55 |
+
margin: 0;
|
| 56 |
+
padding: 0;
|
| 57 |
+
box-sizing: border-box;
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
html, body {
|
| 61 |
+
background: linear-gradient(-45deg, #ff4b4b, #ff8c00, #4b7fff, #7d00ff);
|
| 62 |
+
background-size: 400% 400%;
|
| 63 |
+
animation: gradientBG 15s ease infinite;
|
| 64 |
+
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
| 65 |
+
min-height: 100vh;
|
| 66 |
+
position: fixed;
|
| 67 |
+
width: 100%;
|
| 68 |
+
height: 100%;
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
@keyframes gradientBG {
|
| 72 |
+
0% {background-position: 0% 50%;}
|
| 73 |
+
25% {background-position: 100% 50%;}
|
| 74 |
+
50% {background-position: 100% 100%;}
|
| 75 |
+
75% {background-position: 0% 100%;}
|
| 76 |
+
100% {background-position: 0% 50%;}
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
.gradio-container {
|
| 80 |
+
background: rgba(20, 20, 40, 0.85) !important;
|
| 81 |
+
border-radius: 25px !important;
|
| 82 |
+
box-shadow: 0 25px 80px rgba(0, 0, 0, 0.4), inset 0 0 30px rgba(255, 255, 255, 0.1) !important;
|
| 83 |
+
backdrop-filter: blur(15px) !important;
|
| 84 |
+
border: 1px solid rgba(255, 255, 255, 0.15) !important;
|
| 85 |
+
padding: 40px !important;
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
+
.title {
|
| 89 |
+
font-size: 52px;
|
| 90 |
+
font-weight: 900;
|
| 91 |
+
text-align: center;
|
| 92 |
+
background: linear-gradient(135deg, #ff4b4b, #ff8c00, #4b7fff, #7d00ff);
|
| 93 |
+
-webkit-background-clip: text;
|
| 94 |
+
-webkit-text-fill-color: transparent;
|
| 95 |
+
background-clip: text;
|
| 96 |
+
animation: slideInDown 1s ease-out, glow 3s ease-in-out infinite;
|
| 97 |
+
margin-bottom: 10px;
|
| 98 |
+
text-shadow: 0 0 30px rgba(255, 75, 75, 0.5);
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
@keyframes slideInDown {
|
| 102 |
+
from {
|
| 103 |
+
opacity: 0;
|
| 104 |
+
transform: translateY(-50px);
|
| 105 |
+
}
|
| 106 |
+
to {
|
| 107 |
+
opacity: 1;
|
| 108 |
+
transform: translateY(0);
|
| 109 |
+
}
|
| 110 |
+
}
|
| 111 |
+
|
| 112 |
+
@keyframes glow {
|
| 113 |
+
0%, 100% {
|
| 114 |
+
text-shadow: 0 0 20px rgba(255, 75, 75, 0.5), 0 0 40px rgba(255, 140, 0, 0.3);
|
| 115 |
+
}
|
| 116 |
+
50% {
|
| 117 |
+
text-shadow: 0 0 30px rgba(75, 127, 255, 0.6), 0 0 60px rgba(125, 0, 255, 0.4);
|
| 118 |
+
}
|
| 119 |
+
}
|
| 120 |
+
|
| 121 |
+
.subtitle {
|
| 122 |
+
text-align: center;
|
| 123 |
+
color: #e0e0ff;
|
| 124 |
+
margin-bottom: 30px;
|
| 125 |
+
font-style: italic;
|
| 126 |
+
font-size: 16px;
|
| 127 |
+
animation: fadeInUp 1s ease-out 0.2s both;
|
| 128 |
+
letter-spacing: 1px;
|
| 129 |
+
}
|
| 130 |
+
|
| 131 |
+
@keyframes fadeInUp {
|
| 132 |
+
from {
|
| 133 |
+
opacity: 0;
|
| 134 |
+
transform: translateY(30px);
|
| 135 |
+
}
|
| 136 |
+
to {
|
| 137 |
+
opacity: 1;
|
| 138 |
+
transform: translateY(0);
|
| 139 |
+
}
|
| 140 |
+
}
|
| 141 |
+
|
| 142 |
+
/* Input Container */
|
| 143 |
+
.textbox-container {
|
| 144 |
+
animation: scaleIn 0.7s ease-out 0.3s both;
|
| 145 |
+
}
|
| 146 |
+
|
| 147 |
+
@keyframes scaleIn {
|
| 148 |
+
from {
|
| 149 |
+
opacity: 0;
|
| 150 |
+
transform: scale(0.9) rotateX(10deg);
|
| 151 |
+
}
|
| 152 |
+
to {
|
| 153 |
+
opacity: 1;
|
| 154 |
+
transform: scale(1) rotateX(0deg);
|
| 155 |
+
}
|
| 156 |
+
}
|
| 157 |
+
|
| 158 |
+
textarea {
|
| 159 |
+
background: rgba(255, 255, 255, 0.08) !important;
|
| 160 |
+
border: 2px solid rgba(75, 127, 255, 0.3) !important;
|
| 161 |
+
border-radius: 15px !important;
|
| 162 |
+
padding: 18px !important;
|
| 163 |
+
font-size: 16px !important;
|
| 164 |
+
color: #e0e0ff !important;
|
| 165 |
+
transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
|
| 166 |
+
box-shadow: 0 8px 32px rgba(75, 127, 255, 0.1), inset 0 0 20px rgba(255, 255, 255, 0.05) !important;
|
| 167 |
+
backdrop-filter: blur(10px) !important;
|
| 168 |
+
}
|
| 169 |
+
|
| 170 |
+
textarea::placeholder {
|
| 171 |
+
color: rgba(224, 224, 255, 0.5) !important;
|
| 172 |
+
}
|
| 173 |
+
|
| 174 |
+
textarea:focus {
|
| 175 |
+
border-color: #4b7fff !important;
|
| 176 |
+
box-shadow: 0 15px 50px rgba(75, 127, 255, 0.4), inset 0 0 30px rgba(75, 127, 255, 0.1) !important;
|
| 177 |
+
transform: translateY(-5px) scale(1.02);
|
| 178 |
+
animation: inputGlow 2s ease-in-out infinite;
|
| 179 |
+
}
|
| 180 |
+
|
| 181 |
+
@keyframes inputGlow {
|
| 182 |
+
0%, 100% {
|
| 183 |
+
box-shadow: 0 15px 50px rgba(75, 127, 255, 0.4), inset 0 0 30px rgba(75, 127, 255, 0.1);
|
| 184 |
+
}
|
| 185 |
+
50% {
|
| 186 |
+
box-shadow: 0 20px 60px rgba(125, 0, 255, 0.5), inset 0 0 40px rgba(125, 0, 255, 0.2);
|
| 187 |
+
}
|
| 188 |
+
}
|
| 189 |
+
|
| 190 |
+
/* Button Styling with Ripple Effect */
|
| 191 |
+
.btn-primary {
|
| 192 |
+
background: linear-gradient(135deg, #4b7fff, #7d00ff, #ff4b4b) !important;
|
| 193 |
+
background-size: 300% 300% !important;
|
| 194 |
+
border: 2px solid rgba(75, 127, 255, 0.5) !important;
|
| 195 |
+
color: white !important;
|
| 196 |
+
font-weight: 700 !important;
|
| 197 |
+
font-size: 16px !important;
|
| 198 |
+
padding: 14px 40px !important;
|
| 199 |
+
border-radius: 50px !important;
|
| 200 |
+
cursor: pointer !important;
|
| 201 |
+
transition: all 0.4s ease !important;
|
| 202 |
+
box-shadow: 0 10px 40px rgba(75, 127, 255, 0.4), inset 0 0 20px rgba(255, 255, 255, 0.1) !important;
|
| 203 |
+
animation: bounceIn 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55) 0.4s both;
|
| 204 |
+
position: relative;
|
| 205 |
+
overflow: hidden;
|
| 206 |
+
}
|
| 207 |
+
|
| 208 |
+
@keyframes bounceIn {
|
| 209 |
+
0% {
|
| 210 |
+
opacity: 0;
|
| 211 |
+
transform: scale(0.1) rotateZ(-45deg);
|
| 212 |
+
}
|
| 213 |
+
50% {
|
| 214 |
+
opacity: 1;
|
| 215 |
+
transform: scale(1.1) rotateZ(10deg);
|
| 216 |
+
}
|
| 217 |
+
100% {
|
| 218 |
+
transform: scale(1) rotateZ(0deg);
|
| 219 |
+
}
|
| 220 |
+
}
|
| 221 |
+
|
| 222 |
+
.btn-primary:hover {
|
| 223 |
+
transform: translateY(-5px) scale(1.05);
|
| 224 |
+
box-shadow: 0 20px 60px rgba(125, 0, 255, 0.6), inset 0 0 30px rgba(255, 255, 255, 0.15) !important;
|
| 225 |
+
background-position: 100% 0 !important;
|
| 226 |
+
animation: gradientShift 3s ease infinite;
|
| 227 |
+
}
|
| 228 |
+
|
| 229 |
+
@keyframes gradientShift {
|
| 230 |
+
0% {background-position: 0% 50%;}
|
| 231 |
+
50% {background-position: 100% 50%;}
|
| 232 |
+
100% {background-position: 0% 50%;}
|
| 233 |
+
}
|
| 234 |
+
|
| 235 |
+
.btn-primary:active {
|
| 236 |
+
transform: translateY(-2px) scale(0.98);
|
| 237 |
+
}
|
| 238 |
+
|
| 239 |
+
/* Ripple Effect */
|
| 240 |
+
.btn-primary::before {
|
| 241 |
+
content: '';
|
| 242 |
+
position: absolute;
|
| 243 |
+
top: 50%;
|
| 244 |
+
left: 50%;
|
| 245 |
+
width: 0;
|
| 246 |
+
height: 0;
|
| 247 |
+
border-radius: 50%;
|
| 248 |
+
background: rgba(255, 255, 255, 0.6);
|
| 249 |
+
transform: translate(-50%, -50%);
|
| 250 |
+
transition: width 0.6s, height 0.6s;
|
| 251 |
+
}
|
| 252 |
+
|
| 253 |
+
.btn-primary:active::before {
|
| 254 |
+
width: 400px;
|
| 255 |
+
height: 400px;
|
| 256 |
+
}
|
| 257 |
+
|
| 258 |
+
/* Result Cards */
|
| 259 |
+
.safe {
|
| 260 |
+
background: linear-gradient(135deg, rgba(0, 255, 100, 0.15), rgba(100, 255, 150, 0.08));
|
| 261 |
+
border: 2px solid rgba(0, 255, 100, 0.4);
|
| 262 |
+
padding: 35px;
|
| 263 |
+
border-radius: 20px;
|
| 264 |
+
color: #00ff64;
|
| 265 |
+
text-align: center;
|
| 266 |
+
animation: slideInRight 0.8s cubic-bezier(0.34, 1.56, 0.64, 1), cardGlowGreen 3s ease-in-out infinite;
|
| 267 |
+
box-shadow: 0 20px 60px rgba(0, 255, 100, 0.25), inset 0 0 30px rgba(0, 255, 100, 0.1);
|
| 268 |
+
backdrop-filter: blur(15px);
|
| 269 |
+
}
|
| 270 |
+
|
| 271 |
+
.bully {
|
| 272 |
+
background: linear-gradient(135deg, rgba(255, 0, 0, 0.15), rgba(255, 100, 100, 0.08));
|
| 273 |
+
border: 2px solid rgba(255, 107, 107, 0.4);
|
| 274 |
+
padding: 35px;
|
| 275 |
+
border-radius: 20px;
|
| 276 |
+
color: #ff6b6b;
|
| 277 |
+
text-align: center;
|
| 278 |
+
animation: slideInRight 0.8s cubic-bezier(0.34, 1.56, 0.64, 1), cardGlowRed 2s ease-in-out infinite;
|
| 279 |
+
box-shadow: 0 20px 60px rgba(255, 107, 107, 0.25), inset 0 0 30px rgba(255, 107, 107, 0.1);
|
| 280 |
+
backdrop-filter: blur(15px);
|
| 281 |
+
}
|
| 282 |
+
|
| 283 |
+
@keyframes slideInRight {
|
| 284 |
+
from {
|
| 285 |
+
opacity: 0;
|
| 286 |
+
transform: translateX(100px) rotateY(20deg);
|
| 287 |
+
}
|
| 288 |
+
to {
|
| 289 |
+
opacity: 1;
|
| 290 |
+
transform: translateX(0) rotateY(0deg);
|
| 291 |
+
}
|
| 292 |
+
}
|
| 293 |
+
|
| 294 |
+
@keyframes cardGlowGreen {
|
| 295 |
+
0%, 100% {
|
| 296 |
+
box-shadow: 0 20px 60px rgba(0, 255, 100, 0.25), inset 0 0 30px rgba(0, 255, 100, 0.1);
|
| 297 |
+
}
|
| 298 |
+
50% {
|
| 299 |
+
box-shadow: 0 30px 80px rgba(0, 255, 100, 0.4), inset 0 0 40px rgba(0, 255, 100, 0.2);
|
| 300 |
+
}
|
| 301 |
+
}
|
| 302 |
+
|
| 303 |
+
@keyframes cardGlowRed {
|
| 304 |
+
0%, 100% {
|
| 305 |
+
box-shadow: 0 20px 60px rgba(255, 107, 107, 0.25), inset 0 0 30px rgba(255, 107, 107, 0.1);
|
| 306 |
+
}
|
| 307 |
+
50% {
|
| 308 |
+
box-shadow: 0 30px 80px rgba(255, 107, 107, 0.4), inset 0 0 40px rgba(255, 107, 107, 0.2);
|
| 309 |
+
}
|
| 310 |
+
}
|
| 311 |
+
|
| 312 |
+
.warn {
|
| 313 |
+
color: #ffb700;
|
| 314 |
+
text-align: center;
|
| 315 |
+
font-weight: 700;
|
| 316 |
+
font-size: 18px;
|
| 317 |
+
animation: shake 0.5s ease-in-out, pulse 1.5s ease-in-out infinite 0.5s;
|
| 318 |
+
padding: 20px;
|
| 319 |
+
}
|
| 320 |
+
|
| 321 |
+
@keyframes shake {
|
| 322 |
+
0%, 100% {transform: translateX(0);}
|
| 323 |
+
10%, 30%, 50%, 70%, 90% {transform: translateX(-8px);}
|
| 324 |
+
20%, 40%, 60%, 80% {transform: translateX(8px);}
|
| 325 |
+
}
|
| 326 |
+
|
| 327 |
+
@keyframes pulse {
|
| 328 |
+
0%, 100% {opacity: 1;}
|
| 329 |
+
50% {opacity: 0.6;}
|
| 330 |
+
}
|
| 331 |
+
|
| 332 |
+
/* Icons */
|
| 333 |
+
.checkmark, .warning-icon {
|
| 334 |
+
font-size: 56px;
|
| 335 |
+
margin-bottom: 15px;
|
| 336 |
+
animation: bounce 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55);
|
| 337 |
+
display: inline-block;
|
| 338 |
+
}
|
| 339 |
+
|
| 340 |
+
@keyframes bounce {
|
| 341 |
+
0% {
|
| 342 |
+
opacity: 0;
|
| 343 |
+
transform: scale(0) rotateZ(-45deg);
|
| 344 |
+
}
|
| 345 |
+
50% {
|
| 346 |
+
transform: scale(1.2) rotateZ(15deg);
|
| 347 |
+
}
|
| 348 |
+
100% {
|
| 349 |
+
opacity: 1;
|
| 350 |
+
transform: scale(1) rotateZ(0deg);
|
| 351 |
+
}
|
| 352 |
+
}
|
| 353 |
+
|
| 354 |
+
.warning-icon {
|
| 355 |
+
animation: bounce 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55), pulse-warning 1.5s ease-in-out 0.8s infinite;
|
| 356 |
+
}
|
| 357 |
+
|
| 358 |
+
@keyframes pulse-warning {
|
| 359 |
+
0%, 100% {
|
| 360 |
+
transform: scale(1);
|
| 361 |
+
filter: drop-shadow(0 0 5px rgba(255, 107, 107, 0.5));
|
| 362 |
+
}
|
| 363 |
+
50% {
|
| 364 |
+
transform: scale(1.2);
|
| 365 |
+
filter: drop-shadow(0 0 20px rgba(255, 107, 107, 1));
|
| 366 |
+
}
|
| 367 |
+
}
|
| 368 |
+
|
| 369 |
+
/* Text */
|
| 370 |
+
.safe-text, .bully-text {
|
| 371 |
+
font-size: 28px;
|
| 372 |
+
font-weight: 800;
|
| 373 |
+
margin-bottom: 15px;
|
| 374 |
+
animation: fadeInDown 0.8s ease-out 0.2s both;
|
| 375 |
+
letter-spacing: 0.5px;
|
| 376 |
+
}
|
| 377 |
+
|
| 378 |
+
@keyframes fadeInDown {
|
| 379 |
+
from {
|
| 380 |
+
opacity: 0;
|
| 381 |
+
transform: translateY(-20px);
|
| 382 |
+
}
|
| 383 |
+
to {
|
| 384 |
+
opacity: 1;
|
| 385 |
+
transform: translateY(0);
|
| 386 |
+
}
|
| 387 |
+
}
|
| 388 |
+
|
| 389 |
+
.label-badge {
|
| 390 |
+
display: inline-block;
|
| 391 |
+
background: rgba(255, 107, 107, 0.2);
|
| 392 |
+
border: 2px solid rgba(255, 107, 107, 0.5);
|
| 393 |
+
padding: 10px 20px;
|
| 394 |
+
border-radius: 25px;
|
| 395 |
+
margin-bottom: 18px;
|
| 396 |
+
font-size: 14px;
|
| 397 |
+
font-weight: 700;
|
| 398 |
+
animation: zoomIn 0.7s ease-out 0.3s both;
|
| 399 |
+
box-shadow: 0 5px 20px rgba(255, 107, 107, 0.2);
|
| 400 |
+
}
|
| 401 |
+
|
| 402 |
+
@keyframes zoomIn {
|
| 403 |
+
from {
|
| 404 |
+
opacity: 0;
|
| 405 |
+
transform: scale(0.3);
|
| 406 |
+
}
|
| 407 |
+
to {
|
| 408 |
+
opacity: 1;
|
| 409 |
+
transform: scale(1);
|
| 410 |
+
}
|
| 411 |
+
}
|
| 412 |
+
|
| 413 |
+
/* Confidence Bar */
|
| 414 |
+
.confidence-bar {
|
| 415 |
+
width: 100%;
|
| 416 |
+
height: 10px;
|
| 417 |
+
background: rgba(255, 255, 255, 0.1);
|
| 418 |
+
border-radius: 12px;
|
| 419 |
+
margin-bottom: 15px;
|
| 420 |
+
overflow: hidden;
|
| 421 |
+
animation: fadeIn 0.8s ease-out 0.1s both;
|
| 422 |
+
border: 1px solid rgba(255, 255, 255, 0.2);
|
| 423 |
+
box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.3);
|
| 424 |
+
}
|
| 425 |
+
|
| 426 |
+
.confidence-fill {
|
| 427 |
+
height: 100%;
|
| 428 |
+
border-radius: 12px;
|
| 429 |
+
transition: width 1.2s cubic-bezier(0.34, 1.56, 0.64, 1);
|
| 430 |
+
animation: fillWidth 1.2s ease-out;
|
| 431 |
+
}
|
| 432 |
+
|
| 433 |
+
@keyframes fillWidth {
|
| 434 |
+
from {
|
| 435 |
+
width: 0 !important;
|
| 436 |
+
}
|
| 437 |
+
}
|
| 438 |
+
|
| 439 |
+
.safe-fill {
|
| 440 |
+
background: linear-gradient(90deg, #00ff64, #00d452, #00ff64);
|
| 441 |
+
background-size: 200% 200%;
|
| 442 |
+
box-shadow: 0 0 25px rgba(0, 255, 100, 0.8), inset 0 0 10px rgba(255, 255, 255, 0.3);
|
| 443 |
+
animation: fillWidth 1.2s ease-out, shimmer 2s ease-in-out infinite;
|
| 444 |
+
}
|
| 445 |
+
|
| 446 |
+
.bully-fill {
|
| 447 |
+
background: linear-gradient(90deg, #ff6b6b, #ff4444, #ff6b6b);
|
| 448 |
+
background-size: 200% 200%;
|
| 449 |
+
box-shadow: 0 0 25px rgba(255, 107, 107, 0.8), inset 0 0 10px rgba(255, 255, 255, 0.3);
|
| 450 |
+
animation: fillWidth 1.2s ease-out, shimmer 2s ease-in-out infinite;
|
| 451 |
+
}
|
| 452 |
+
|
| 453 |
+
@keyframes shimmer {
|
| 454 |
+
0%, 100% {background-position: 0% 50%;}
|
| 455 |
+
50% {background-position: 100% 50%;}
|
| 456 |
+
}
|
| 457 |
+
|
| 458 |
+
.confidence-score {
|
| 459 |
+
font-size: 15px;
|
| 460 |
+
opacity: 0.9;
|
| 461 |
+
animation: fadeIn 0.8s ease-out 0.4s both;
|
| 462 |
+
font-weight: 600;
|
| 463 |
+
letter-spacing: 0.5px;
|
| 464 |
+
}
|
| 465 |
+
|
| 466 |
+
@keyframes fadeIn {
|
| 467 |
+
from {
|
| 468 |
+
opacity: 0;
|
| 469 |
+
}
|
| 470 |
+
to {
|
| 471 |
+
opacity: 1;
|
| 472 |
+
}
|
| 473 |
+
}
|
| 474 |
+
|
| 475 |
+
/* Responsive */
|
| 476 |
+
@media (max-width: 768px) {
|
| 477 |
+
.title {
|
| 478 |
+
font-size: 36px;
|
| 479 |
+
}
|
| 480 |
+
|
| 481 |
+
.safe, .bully {
|
| 482 |
+
padding: 25px;
|
| 483 |
+
}
|
| 484 |
+
|
| 485 |
+
html, body {
|
| 486 |
+
background-size: 600% 600%;
|
| 487 |
+
}
|
| 488 |
+
}
|
| 489 |
+
""") as demo:
|
| 490 |
+
gr.Markdown("<div class='title'>🛡️ Cyberbullying Detection System</div>")
|
| 491 |
+
gr.Markdown("<div class='subtitle'>End-to-end NLP system for detecting cyberbullying, including religion-based abuse</div>")
|
| 492 |
+
|
| 493 |
+
with gr.Group():
|
| 494 |
+
text_input = gr.Textbox(
|
| 495 |
+
lines=4,
|
| 496 |
+
placeholder="Enter a message to analyze...",
|
| 497 |
+
label="Input Text",
|
| 498 |
+
elem_classes="textbox-container"
|
| 499 |
+
)
|
| 500 |
+
detect_btn = gr.Button("🔍 Detect", variant="primary")
|
| 501 |
+
|
| 502 |
+
output = gr.HTML()
|
| 503 |
+
|
| 504 |
+
detect_btn.click(
|
| 505 |
+
fn=predict,
|
| 506 |
+
inputs=text_input,
|
| 507 |
+
outputs=output
|
| 508 |
+
)
|
| 509 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 510 |
demo.launch()
|