Spaces:
Running
Running
Updates to theming.
Browse files
app.py
CHANGED
|
@@ -6,6 +6,9 @@ import gradio as gr
|
|
| 6 |
import re
|
| 7 |
import pandas as pd
|
| 8 |
import io
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
# Check if GPU is available and use it if possible
|
| 11 |
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|
|
@@ -425,7 +428,320 @@ def chatbot(task, text=None, context=None, question=None, file=None):
|
|
| 425 |
return "Please select a valid task."
|
| 426 |
|
| 427 |
|
| 428 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 429 |
with gr.Column():
|
| 430 |
with gr.Row(elem_id="header", elem_classes="header-container"):
|
| 431 |
gr.Markdown("<div class='header-title-center'><a href='https://eventdata.utdallas.edu/conflibert/' style='font-size: 4rem; font-weight: 900;'>ConfliBERT</a></div>")
|
|
@@ -559,4 +875,4 @@ with gr.Blocks(theme="allenai/gradio-theme") as demo:
|
|
| 559 |
outputs=[output, file_output]
|
| 560 |
)
|
| 561 |
|
| 562 |
-
demo.launch(share=True)
|
|
|
|
| 6 |
import re
|
| 7 |
import pandas as pd
|
| 8 |
import io
|
| 9 |
+
import os
|
| 10 |
+
os.environ['TF_ENABLE_ONEDNN_OPTS'] = '0'
|
| 11 |
+
import keras
|
| 12 |
|
| 13 |
# Check if GPU is available and use it if possible
|
| 14 |
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|
|
|
|
| 428 |
return "Please select a valid task."
|
| 429 |
|
| 430 |
|
| 431 |
+
# Custom CSS for modern orange theme
|
| 432 |
+
custom_css = """
|
| 433 |
+
/* CSS Variables for Light and Dark Theme */
|
| 434 |
+
:root {
|
| 435 |
+
--primary-orange: #ff6b35;
|
| 436 |
+
--primary-orange-light: #ff8c5a;
|
| 437 |
+
--primary-orange-dark: #e55a2b;
|
| 438 |
+
--secondary-orange: #ffa366;
|
| 439 |
+
--accent-orange: #ff9f40;
|
| 440 |
+
--background-light: #fefefe;
|
| 441 |
+
--background-dark: #1a1a1a;
|
| 442 |
+
--surface-light: #ffffff;
|
| 443 |
+
--surface-dark: #2d2d2d;
|
| 444 |
+
--text-primary-light: #2c2c2c;
|
| 445 |
+
--text-primary-dark: #ffffff;
|
| 446 |
+
--text-secondary-light: #666666;
|
| 447 |
+
--text-secondary-dark: #cccccc;
|
| 448 |
+
--border-light: #e0e0e0;
|
| 449 |
+
--border-dark: #404040;
|
| 450 |
+
--shadow-light: rgba(0, 0, 0, 0.1);
|
| 451 |
+
--shadow-dark: rgba(0, 0, 0, 0.3);
|
| 452 |
+
--gradient-orange: linear-gradient(135deg, #ff6b35 0%, #ff9f40 100%);
|
| 453 |
+
--gradient-orange-subtle: linear-gradient(135deg, rgba(255, 107, 53, 0.1) 0%, rgba(255, 159, 64, 0.1) 100%);
|
| 454 |
+
}
|
| 455 |
+
|
| 456 |
+
/* Dark theme overrides */
|
| 457 |
+
.dark {
|
| 458 |
+
--background: var(--background-dark);
|
| 459 |
+
--surface: var(--surface-dark);
|
| 460 |
+
--text-primary: var(--text-primary-dark);
|
| 461 |
+
--text-secondary: var(--text-secondary-dark);
|
| 462 |
+
--border: var(--border-dark);
|
| 463 |
+
--shadow: var(--shadow-dark);
|
| 464 |
+
}
|
| 465 |
+
|
| 466 |
+
/* Light theme (default) */
|
| 467 |
+
.light, :root {
|
| 468 |
+
--background: var(--background-light);
|
| 469 |
+
--surface: var(--surface-light);
|
| 470 |
+
--text-primary: var(--text-primary-light);
|
| 471 |
+
--text-secondary: var(--text-secondary-light);
|
| 472 |
+
--border: var(--border-light);
|
| 473 |
+
--shadow: var(--shadow-light);
|
| 474 |
+
}
|
| 475 |
+
|
| 476 |
+
/* Global Styles */
|
| 477 |
+
* {
|
| 478 |
+
font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
| 479 |
+
}
|
| 480 |
+
|
| 481 |
+
/* Main Container */
|
| 482 |
+
.gradio-container {
|
| 483 |
+
background: var(--background) !important;
|
| 484 |
+
color: var(--text-primary) !important;
|
| 485 |
+
min-height: 100vh;
|
| 486 |
+
}
|
| 487 |
+
|
| 488 |
+
/* Header Styling */
|
| 489 |
+
.header-container {
|
| 490 |
+
background: var(--gradient-orange) !important;
|
| 491 |
+
padding: 2rem 1rem !important;
|
| 492 |
+
margin: -1rem -1rem 2rem -1rem !important;
|
| 493 |
+
border-radius: 0 0 24px 24px !important;
|
| 494 |
+
box-shadow: 0 8px 32px var(--shadow) !important;
|
| 495 |
+
position: relative;
|
| 496 |
+
overflow: hidden;
|
| 497 |
+
}
|
| 498 |
+
|
| 499 |
+
.header-container::before {
|
| 500 |
+
content: '';
|
| 501 |
+
position: absolute;
|
| 502 |
+
top: 0;
|
| 503 |
+
left: 0;
|
| 504 |
+
right: 0;
|
| 505 |
+
bottom: 0;
|
| 506 |
+
background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.05'%3E%3Ccircle cx='30' cy='30' r='2'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E") !important;
|
| 507 |
+
pointer-events: none;
|
| 508 |
+
}
|
| 509 |
+
|
| 510 |
+
.header-title-center {
|
| 511 |
+
text-align: center !important;
|
| 512 |
+
position: relative;
|
| 513 |
+
z-index: 1;
|
| 514 |
+
}
|
| 515 |
+
|
| 516 |
+
.header-title-center a {
|
| 517 |
+
color: white !important;
|
| 518 |
+
text-decoration: none !important;
|
| 519 |
+
font-weight: 900 !important;
|
| 520 |
+
font-size: 4rem !important;
|
| 521 |
+
text-shadow: 0 4px 8px rgba(0, 0, 0, 0.2) !important;
|
| 522 |
+
letter-spacing: -0.02em !important;
|
| 523 |
+
transition: all 0.3s ease !important;
|
| 524 |
+
}
|
| 525 |
+
|
| 526 |
+
.header-title-center a:hover {
|
| 527 |
+
transform: translateY(-2px) !important;
|
| 528 |
+
text-shadow: 0 6px 16px rgba(0, 0, 0, 0.3) !important;
|
| 529 |
+
}
|
| 530 |
+
|
| 531 |
+
/* Task Container */
|
| 532 |
+
.task-container {
|
| 533 |
+
background: var(--surface) !important;
|
| 534 |
+
border-radius: 16px !important;
|
| 535 |
+
padding: 2rem !important;
|
| 536 |
+
box-shadow: 0 4px 24px var(--shadow) !important;
|
| 537 |
+
border: 1px solid var(--border) !important;
|
| 538 |
+
margin-bottom: 2rem !important;
|
| 539 |
+
}
|
| 540 |
+
|
| 541 |
+
/* Input Components */
|
| 542 |
+
.input-text textarea, .input-text input {
|
| 543 |
+
background: var(--surface) !important;
|
| 544 |
+
border: 2px solid var(--border) !important;
|
| 545 |
+
border-radius: 12px !important;
|
| 546 |
+
padding: 1rem !important;
|
| 547 |
+
color: var(--text-primary) !important;
|
| 548 |
+
font-size: 0.95rem !important;
|
| 549 |
+
line-height: 1.5 !important;
|
| 550 |
+
transition: all 0.3s ease !important;
|
| 551 |
+
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05) !important;
|
| 552 |
+
}
|
| 553 |
+
|
| 554 |
+
.input-text textarea:focus, .input-text input:focus {
|
| 555 |
+
border-color: var(--primary-orange) !important;
|
| 556 |
+
box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.1) !important;
|
| 557 |
+
outline: none !important;
|
| 558 |
+
transform: translateY(-1px) !important;
|
| 559 |
+
}
|
| 560 |
+
|
| 561 |
+
/* Placeholder text styling */
|
| 562 |
+
.input-text textarea::placeholder, .input-text input::placeholder {
|
| 563 |
+
color: var(--text-secondary) !important;
|
| 564 |
+
opacity: 0.7 !important;
|
| 565 |
+
}
|
| 566 |
+
|
| 567 |
+
.input-text textarea::-webkit-input-placeholder, .input-text input::-webkit-input-placeholder {
|
| 568 |
+
color: var(--text-secondary) !important;
|
| 569 |
+
opacity: 0.7 !important;
|
| 570 |
+
}
|
| 571 |
+
|
| 572 |
+
.input-text textarea::-moz-placeholder, .input-text input::-moz-placeholder {
|
| 573 |
+
color: var(--text-secondary) !important;
|
| 574 |
+
opacity: 0.7 !important;
|
| 575 |
+
}
|
| 576 |
+
|
| 577 |
+
.input-text textarea:-ms-input-placeholder, .input-text input:-ms-input-placeholder {
|
| 578 |
+
color: var(--text-secondary) !important;
|
| 579 |
+
opacity: 0.7 !important;
|
| 580 |
+
}
|
| 581 |
+
|
| 582 |
+
/* Dropdown Styling */
|
| 583 |
+
.gr-dropdown {
|
| 584 |
+
background: var(--surface) !important;
|
| 585 |
+
border: 2px solid var(--border) !important;
|
| 586 |
+
border-radius: 12px !important;
|
| 587 |
+
color: var(--text-primary) !important;
|
| 588 |
+
transition: all 0.3s ease !important;
|
| 589 |
+
}
|
| 590 |
+
|
| 591 |
+
.gr-dropdown:focus-within {
|
| 592 |
+
border-color: var(--primary-orange) !important;
|
| 593 |
+
box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.1) !important;
|
| 594 |
+
}
|
| 595 |
+
|
| 596 |
+
/* Button Styling */
|
| 597 |
+
.submit-btn {
|
| 598 |
+
background: var(--gradient-orange) !important;
|
| 599 |
+
border: none !important;
|
| 600 |
+
border-radius: 12px !important;
|
| 601 |
+
padding: 1rem 2rem !important;
|
| 602 |
+
color: white !important;
|
| 603 |
+
font-weight: 600 !important;
|
| 604 |
+
font-size: 1rem !important;
|
| 605 |
+
cursor: pointer !important;
|
| 606 |
+
transition: all 0.3s ease !important;
|
| 607 |
+
box-shadow: 0 4px 16px rgba(255, 107, 53, 0.3) !important;
|
| 608 |
+
text-transform: uppercase !important;
|
| 609 |
+
letter-spacing: 0.5px !important;
|
| 610 |
+
}
|
| 611 |
+
|
| 612 |
+
.submit-btn:hover {
|
| 613 |
+
transform: translateY(-2px) !important;
|
| 614 |
+
box-shadow: 0 6px 24px rgba(255, 107, 53, 0.4) !important;
|
| 615 |
+
background: linear-gradient(135deg, #ff8c5a 0%, #ffb366 100%) !important;
|
| 616 |
+
}
|
| 617 |
+
|
| 618 |
+
.submit-btn:active {
|
| 619 |
+
transform: translateY(0) !important;
|
| 620 |
+
box-shadow: 0 2px 8px rgba(255, 107, 53, 0.3) !important;
|
| 621 |
+
}
|
| 622 |
+
|
| 623 |
+
/* File Upload Styling */
|
| 624 |
+
.file-upload {
|
| 625 |
+
background: var(--gradient-orange-subtle) !important;
|
| 626 |
+
border: 2px dashed var(--primary-orange) !important;
|
| 627 |
+
border-radius: 12px !important;
|
| 628 |
+
padding: 1.5rem !important;
|
| 629 |
+
text-align: center !important;
|
| 630 |
+
transition: all 0.3s ease !important;
|
| 631 |
+
}
|
| 632 |
+
|
| 633 |
+
.file-upload:hover {
|
| 634 |
+
background: rgba(255, 107, 53, 0.15) !important;
|
| 635 |
+
border-color: var(--primary-orange-dark) !important;
|
| 636 |
+
}
|
| 637 |
+
|
| 638 |
+
/* Output Styling */
|
| 639 |
+
.output-html {
|
| 640 |
+
background: var(--surface) !important;
|
| 641 |
+
border: 1px solid var(--border) !important;
|
| 642 |
+
border-radius: 12px !important;
|
| 643 |
+
padding: 1.5rem !important;
|
| 644 |
+
margin-top: 1rem !important;
|
| 645 |
+
box-shadow: 0 2px 12px var(--shadow) !important;
|
| 646 |
+
min-height: 100px !important;
|
| 647 |
+
}
|
| 648 |
+
|
| 649 |
+
.output-html div {
|
| 650 |
+
color: var(--text-primary) !important;
|
| 651 |
+
line-height: 1.6 !important;
|
| 652 |
+
}
|
| 653 |
+
|
| 654 |
+
/* Labels */
|
| 655 |
+
label {
|
| 656 |
+
color: var(--text-primary) !important;
|
| 657 |
+
font-weight: 600 !important;
|
| 658 |
+
font-size: 0.9rem !important;
|
| 659 |
+
margin-bottom: 0.5rem !important;
|
| 660 |
+
text-transform: uppercase !important;
|
| 661 |
+
letter-spacing: 0.5px !important;
|
| 662 |
+
}
|
| 663 |
+
|
| 664 |
+
/* Footer */
|
| 665 |
+
.footer {
|
| 666 |
+
background: var(--surface) !important;
|
| 667 |
+
border-top: 1px solid var(--border) !important;
|
| 668 |
+
padding: 1.5rem !important;
|
| 669 |
+
margin-top: 2rem !important;
|
| 670 |
+
text-align: center !important;
|
| 671 |
+
border-radius: 16px 16px 0 0 !important;
|
| 672 |
+
}
|
| 673 |
+
|
| 674 |
+
.footer a {
|
| 675 |
+
color: var(--primary-orange) !important;
|
| 676 |
+
text-decoration: none !important;
|
| 677 |
+
font-weight: 500 !important;
|
| 678 |
+
transition: color 0.3s ease !important;
|
| 679 |
+
}
|
| 680 |
+
|
| 681 |
+
.footer a:hover {
|
| 682 |
+
color: var(--primary-orange-dark) !important;
|
| 683 |
+
text-decoration: underline !important;
|
| 684 |
+
}
|
| 685 |
+
|
| 686 |
+
/* Responsive Design */
|
| 687 |
+
@media (max-width: 768px) {
|
| 688 |
+
.header-title-center a {
|
| 689 |
+
font-size: 2.5rem !important;
|
| 690 |
+
}
|
| 691 |
+
|
| 692 |
+
.task-container {
|
| 693 |
+
padding: 1.5rem !important;
|
| 694 |
+
margin: 1rem !important;
|
| 695 |
+
}
|
| 696 |
+
|
| 697 |
+
.header-container {
|
| 698 |
+
padding: 1.5rem 1rem !important;
|
| 699 |
+
margin: -1rem -1rem 1rem -1rem !important;
|
| 700 |
+
}
|
| 701 |
+
}
|
| 702 |
+
|
| 703 |
+
/* Enhanced NER Output Styling */
|
| 704 |
+
.output-html span[style*="color: blue"] { color: #3b82f6 !important; }
|
| 705 |
+
.output-html span[style*="color: red"] { color: #ef4444 !important; }
|
| 706 |
+
.output-html span[style*="color: green"] { color: #10b981 !important; }
|
| 707 |
+
.output-html span[style*="color: orange"] { color: var(--primary-orange) !important; }
|
| 708 |
+
.output-html span[style*="color: purple"] { color: #8b5cf6 !important; }
|
| 709 |
+
.output-html span[style*="color: cyan"] { color: #06b6d4 !important; }
|
| 710 |
+
.output-html span[style*="color: magenta"] { color: #ec4899 !important; }
|
| 711 |
+
.output-html span[style*="color: brown"] { color: #92400e !important; }
|
| 712 |
+
.output-html span[style*="color: yellow"] { color: #f59e0b !important; }
|
| 713 |
+
.output-html span[style*="color: pink"] { color: #f472b6 !important; }
|
| 714 |
+
|
| 715 |
+
/* Dark mode specific adjustments */
|
| 716 |
+
@media (prefers-color-scheme: dark) {
|
| 717 |
+
.gradio-container {
|
| 718 |
+
background: var(--background-dark) !important;
|
| 719 |
+
color: var(--text-primary-dark) !important;
|
| 720 |
+
}
|
| 721 |
+
|
| 722 |
+
.task-container, .output-html {
|
| 723 |
+
background: var(--surface-dark) !important;
|
| 724 |
+
border-color: var(--border-dark) !important;
|
| 725 |
+
}
|
| 726 |
+
|
| 727 |
+
.input-text textarea, .input-text input, .gr-dropdown {
|
| 728 |
+
background: var(--surface-dark) !important;
|
| 729 |
+
border-color: var(--border-dark) !important;
|
| 730 |
+
color: var(--text-primary-dark) !important;
|
| 731 |
+
}
|
| 732 |
+
|
| 733 |
+
label {
|
| 734 |
+
color: var(--text-primary-dark) !important;
|
| 735 |
+
}
|
| 736 |
+
}
|
| 737 |
+
|
| 738 |
+
/* Smooth transitions for theme switching */
|
| 739 |
+
* {
|
| 740 |
+
transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease !important;
|
| 741 |
+
}
|
| 742 |
+
"""
|
| 743 |
+
|
| 744 |
+
with gr.Blocks(theme="allenai/gradio-theme", css=custom_css) as demo:
|
| 745 |
with gr.Column():
|
| 746 |
with gr.Row(elem_id="header", elem_classes="header-container"):
|
| 747 |
gr.Markdown("<div class='header-title-center'><a href='https://eventdata.utdallas.edu/conflibert/' style='font-size: 4rem; font-weight: 900;'>ConfliBERT</a></div>")
|
|
|
|
| 875 |
outputs=[output, file_output]
|
| 876 |
)
|
| 877 |
|
| 878 |
+
demo.launch(share=True)
|